PolygonIndicatorHeuristics

AUTO-GENERATED FILE – DO NOT EDIT MANUALLY

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

Source File: addons/grid_building/placement/manager/components/polygon_indicator_heuristics.gd

Extends: RefCounted

Public Methods

is_hollow

1
2
3
4
is_hollow(
    offsets: Array[Vector2i],
    density_factor: float = 1.5
) -> bool

Flags: static

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)


should_expand_trapezoid

1
2
3
4
5
6
7
8
should_expand_trapezoid(
    polygon_is_convex: bool,
    offsets: Array[Vector2i],
    ys: Array[int],
    xs_by_y: Dictionary,
    hollow: bool,
    max_original: int = 10
) -> bool

Flags: static

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)

generate_trapezoid_offsets

1
generate_trapezoid_offsets() -> Array[Vector2i]

Flags: static

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


polygon_tile_overlap_area

1
2
3
4
polygon_tile_overlap_area(
    polygon: PackedVector2Array,
    rect: Rect2
) -> float

Flags: static

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


prune_concave_fringe

1
2
3
4
5
6
7
prune_concave_fringe(
    world_points: PackedVector2Array,
    offsets: Array[Vector2i],
    center_tile: Vector2i,
    tile_size: Vector2,
    min_area_ratio: float = 0.12
) -> Array[Vector2i]

Flags: static

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).


Private Methods

_inside

1
2
3
4
5
6
7
8
_inside(
    p: Vector2,
    boundary: int,
    left: float,
    right: float,
    top: float,
    bottom: float
) -> bool

Flags: static, private


_intersect

1
2
3
4
5
6
7
8
9
_intersect(
    a: Vector2,
    b: Vector2,
    boundary: int,
    left: float,
    right: float,
    top: float,
    bottom: float
) -> Vector2

Flags: static, private