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 |
|---|---|---|
DEFAULT_BRUSH_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. Default per-action cell budget for brush shapes. Designer-facing defaults (PlacementSettings.max_terrain_brush_cells, GridPlacementHost) derive from this constant; MAX_BRUSH_CELLS is the hard runtime ceiling above it. |
MAX_FLOOD_CELLS | Field | 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. 8192 keeps worst-case generation (hex line) under a 4ms budget on the reference machine; measured 3.81ms worst across all shapes at this size. |
DEFAULT_OBJECT_DRAG_PLACEMENTS | Field | Default per-gesture placement budget for OBJECT drags (line, rect fill, rect outline), in whole-tile footprint units. The effective placement cap is this divided by the entry's footprint tile count, so one drag's total instantiated volume stays bounded for 1x1 fences and 7x5 smithies alike. Designer-facing default: PlacementSettings.max_object_drag_placements. |
generate | Method | |
tile_shape | Property | |
is_hex | Property | |
flood_cap | Property | |
estimate_cell_count | Method | |
is_hex | Property | |
ca | Property | |
cb | Property | |
w | Property | |
h | Property | |
ow | Property | |
oh | Property | |
oa | Property | |
ob | Property | |
generate_line | Method | |
generate_rect_fill | Method | |
generate_rect_outline | Method | |
generate_hex_line | Method | |
generate_hex_rect_fill | Method | |
generate_hex_rect_outline | Method | |
generate_flood_fill | Method | |
limit | Property | |
cells | Property | |
bounds | Property | |
start_info | Property | |
queue | Property | |
visited | Property | |
read_index | Property | |
current | Property | |
neighbors | Property | |
can_fill | Property | |
info | Property | |
get_neighbors | Method | |
generate_3d_line | Method | |
limit | Property | |
cells | Property | |
delta | Property | |
steps | Property | |
count | Property | |
t | Property | |
generate_3d_rect_fill | Method | |
limit | Property | |
cells | Property | |
min_x | Property | |
max_x | Property | |
min_y | Property | |
max_y | Property | |
min_z | Property | |
max_z | Property | |
x | Property | |
y | Property | |
z | Property | |
generate_3d_rect_outline | Method | |
limit | Property | |
cells | Property | |
seen | Property | |
min_x | Property | |
max_x | Property | |
min_y | Property | |
max_y | Property | |
min_z | Property | |
max_z | Property | |
x | Property | |
y | Property | |
z | Property | |
cell | Property |