Skip to content

Class

BrushShapeGenerator

Generated GDScript class reference for GridPlacement.BrushShapeGenerator.

Status
Current
Version
v6.1.0
Source updated
2026-09-24
Generated on
2026-09-23

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 RefCounted

Members

NameKindSummary
DEFAULT_BRUSH_CELLSFieldDispatch: 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_CELLSFieldHard safety cap on flood-fill expansion regardless of bounds.
MAX_BRUSH_CELLSFieldHard 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_PLACEMENTSFieldDefault 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.
generateMethod
tile_shapeProperty
is_hexProperty
flood_capProperty
estimate_cell_countMethod
is_hexProperty
caProperty
cbProperty
wProperty
hProperty
owProperty
ohProperty
oaProperty
obProperty
generate_lineMethod
generate_rect_fillMethod
generate_rect_outlineMethod
generate_hex_lineMethod
generate_hex_rect_fillMethod
generate_hex_rect_outlineMethod
generate_flood_fillMethod
limitProperty
cellsProperty
boundsProperty
start_infoProperty
queueProperty
visitedProperty
read_indexProperty
currentProperty
neighborsProperty
can_fillProperty
infoProperty
get_neighborsMethod
generate_3d_lineMethod
limitProperty
cellsProperty
deltaProperty
stepsProperty
countProperty
tProperty
generate_3d_rect_fillMethod
limitProperty
cellsProperty
min_xProperty
max_xProperty
min_yProperty
max_yProperty
min_zProperty
max_zProperty
xProperty
yProperty
zProperty
generate_3d_rect_outlineMethod
limitProperty
cellsProperty
seenProperty
min_xProperty
max_xProperty
min_yProperty
max_yProperty
min_zProperty
max_zProperty
xProperty
yProperty
zProperty
cellProperty