Skip to content

Class

BrushShapeGenerator

Generated GDScript class reference for GridPlacement.BrushShapeGenerator.

Status
Current
Version
v6.0
Source updated
Active v6.0 guide line from Grid Placement repo
Generated on
2026-09-01

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
MAX_FLOOD_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. Hard 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.
generateMethod
tile_shapeProperty
is_hexProperty
flood_capProperty
generate_lineMethod
generate_rect_fillMethod
generate_rect_outlineMethod
generate_hex_lineMethod
generate_hex_rect_fillMethod
generate_hex_rect_outlineMethod
generate_flood_fillMethod
cellsProperty
boundsProperty
start_infoProperty
queueProperty
visitedProperty
currentProperty
neighborsProperty
can_fillProperty
infoProperty
get_neighborsMethod