Generates cell arrays for brush shapes used in terrain painting and object multi-placement. Shape math is abstracted here so both terrain and object paths share the same cell-generation logic. Shapes: SINGLE — the target cell only (pass-through) LINE — Bresenham's line algorithm from start to end (hex: cube-coordinate lerp) RECTANGLE_FILL — all cells in the inclusive rectangle between corners (hex: axial-range parallelogram) RECTANGLE_OUTLINE — perimeter cells of the rectangle (hex: axial-range perimeter) FLOOD_FILL — BFS from target cell, bounded by a predicate AND a region (hex: 6-directional) [enum FloodFillMode] controls the boundary predicate: SAME_TERRAIN — fill connected cells sharing the same terrain EMPTY_CELLS — fill connected empty cells Flood fills are always region-bounded: explicit bounds, else the map's used_rect. An unbounded empty-cell fill would walk the infinite plane (empty matches empty forever) and freeze the game. Hex support: when [param p_tile_shape] is [code]TileSet.TILE_SHAPE_HEXAGON[/code], the generator uses hex-aware algorithms (cube-coordinate lerp for LINE, axial-range iteration for RECTANGLE, 6-directional neighbors for FLOOD_FILL). Godot's default hex layout is pointy-top, odd-row offset.
Source: addons/grid_placement/systems/building/brush_shape_generator.gd
Syntax
class BrushShapeGenerator extends RefCountedMembers
| Name | Kind | Summary |
|---|---|---|
MAX_FLOOD_CELLS | Field | Dispatch: generate the cell array for [param p_shape] between [param p_start] and [param p_end] (end is ignored for SINGLE/FLOOD). [param p_map] must be provided for FLOOD_FILL; used to auto-detect tile_shape when [param p_tile_shape] is not provided. [param p_tile_shape] Optional — set to [code]TileSet.TILE_SHAPE_HEXAGON[/code] to enable hex-aware algorithms. Defaults to SQUARE when omitted and no map is available. Hard safety cap on flood-fill expansion regardless of bounds. |
MAX_BRUSH_CELLS | Field | Hard safety ceiling for all brush shapes (line, rect fill, rect outline, flood). Designer-configurable via PlacementSettings.max_terrain_brush_cells; this is the runtime upper bound to prevent unbounded work from misconfiguration. |
generate | Method | |
tile_shape | Property | |
is_hex | Property | |
generate_line | Method | |
cells | Property | |
x0 | Property | |
y0 | Property | |
x1 | Property | |
y1 | Property | |
dx | Property | |
dy | Property | |
sx | Property | |
sy | Property | |
err | Property | |
e2 | Property | |
generate_rect_fill | Method | |
cells | Property | |
min_x | Property | |
max_x | Property | |
min_y | Property | |
max_y | Property | |
generate_rect_outline | Method | |
cells | Property | |
min_x | Property | |
max_x | Property | |
min_y | Property | |
max_y | Property | |
col | Property | |
row | Property | |
q | Property | |
r | Property | |
s | Property | |
q | Property | |
r | Property | |
col | Property | |
rq | Property | |
rr | Property | |
rs | Property | |
dq | Property | |
dr | Property | |
ds | Property | |
generate_hex_line | Method | |
cells | Property | |
a | Property | |
b | Property | |
dist | Property | |
af | Property | |
bf | Property | |
t | Property | |
p | Property | |
rounded | Property | |
generate_hex_rect_fill | Method | |
cells | Property | |
ca | Property | |
cb | Property | |
min_q | Property | |
max_q | Property | |
min_r | Property | |
max_r | Property | |
generate_hex_rect_outline | Method | |
cells | Property | |
ca | Property | |
cb | Property | |
min_q | Property | |
max_q | Property | |
min_r | Property | |
max_r | Property | |
generate_flood_fill | Method | |
cells | Property | |
bounds | Property | |
start_info | Property | |
queue | Property | |
visited | Property | |
current | Property | |
neighbors | Property | |
can_fill | Property | |
info | Property | |
cube | Property |
Source
addons/grid_placement/systems/building/brush_shape_generator.gd
Plugin docs root:gdscript/plugins/grid_placement_dev/docs