Skip to content

PolygonIndicatorHeuristics

Polygon Indicator Heuristics Extracted from CollisionMapper for deterministic unit testing of indicator generation logic.

static func is_hollow( offsets: Array[Vector2i], density_factor: float ) -> bool

Detects if a set of tile offsets forms a hollow (concave/void) pattern based on bounding box density. Returns true if (bbox_area > offsets.size() * density_factor)

static func should_expand_trapezoid( polygon_is_convex: bool, offsets: Array[Vector2i], ys: Array[int], xs_by_y: Dictionary, hollow: bool, max_original: int ) -> bool

Returns true if trapezoid expansion (3/5/5 offsets) should be applied. Requirements: - Polygon is convex - Not hollow - Current offsets size <= max_original - Exactly two Y rows present containing -1 and 0 with (0,0) present (pre‑expansion base)

static func generate_trapezoid_offsets( ) -> Array[Vector2i]

Generates canonical 13-tile trapezoid offsets (rows y=-1,0,1 => 3/5/5 pattern).

static func polygon_tile_overlap_area( polygon: PackedVector2Array, rect: Rect2 ) -> float

Computes precise overlap area between polygon world points and a tile rect (duplicate of S-H clip used for deterministic tests).

static func _inside( p: Vector2, boundary: int, left: float, right: float, top: float, bottom: float ) -> bool
static func _intersect( a: Vector2, b: Vector2, boundary: int, left: float, right: float, top: float, bottom: float ) -> Vector2
static func prune_concave_fringe( world_points: PackedVector2Array, offsets: Array[Vector2i], center_tile: Vector2i, tile_size: Vector2, min_area_ratio: float ) -> Array[Vector2i]

Prunes fringe offsets for concave polygons by removing tiles whose overlap area is below min_area_ratio * tile_area. Returns a new array (may be original if no pruning beneficial).

addons/grid_building/placement/manager/components/polygon_indicator_heuristics.gd


This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.