Chris' Tutorials
Docs/Grid Placement

Class

CollisionGeometryCalculator

Generated GDScript class reference for GridPlacement.CollisionGeometryCalculator.

StatusDraft
Versionv6.0
UpdatedDevelopment docs generated from GDScript source

This is unreleased documentation in active development. APIs, class names, and behavior may change before the final release.

Draft — Unreleased:This page is in active development. APIs, class names, and behavior may change before the release is finalized. Use it as a preview of what's coming — not as a stable integration target.

Pure logic class for collision geometry calculations. Contains no state and can be easily tested in isolation. POLYGON CLIPPING ALGORITHM

  • SUTHERLAND-HODGMAN This class implements the Sutherland-Hodgman polygon clipping algorithm for determining polygon-rectangle overlap areas. The algorithm is correct for both convex and concave polygons. Algorithm Overview: 1. The polygon is clipped against each of the 4 rectangle boundaries (left, right, top, bottom) 2. Each clipping operation produces a new polygon that is guaranteed to be inside that boundary 3. The final clipped polygon represents the intersection area between the original polygon and rectangle 4. The area of this clipped polygon determines if the overlap meets the minimum threshold Why Sutherland-Hodgman is Correct:
  • Works for both convex and concave polygons (unlike some simpler algorithms)
  • Produces a valid polygon as output (no self-intersections or invalid geometry)
  • Handles edge cases like polygons completely inside/outside the rectangle
  • Deterministic and numerically stable with proper epsilon handling Default Overlap Thresholds:
  • Edge epsilon: 0.01 (1% tolerance for numerical precision)
  • Minimum overlap ratio: 0.05 (5% of tile area required for detection)
  • Polygons with < 5% tile overlap are considered non-overlapping (prevents spurious micro-overlaps) Key Methods:
  • clip_polygon_to_rect(): Implements the core Sutherland-Hodgman algorithm
  • polygon_overlaps_rect(): Uses clipping to determine if overlap meets threshold
  • polygon_area(): Calculates area using shoelace formula for overlap measurement Testing: All clipping methods are public for comprehensive unit testing validation.

Source: addons/grid_placement/placement/manager/components/collision_geometry_calculator.gd

Syntax

class CollisionGeometryCalculator extends RefCounted

Members

NameKindSummary
debug_polygon_overlapProperty
AREA_REL_EPSField
AREA_ABS_EPSField
calculate_tile_overlapMethod
calculate_tile_overlap_numericMethod
overlapped_tilesProperty
boundsProperty
start_tileProperty
end_tileProperty
tile_posProperty
tile_world_centerProperty
tile_rectProperty
overlapped_tilesProperty
boundsProperty
rangeProperty
start_tileProperty
end_exclusiveProperty
end_tileProperty
tile_posProperty
tile_world_centerProperty
tile_size_vecProperty
tile_rectProperty
overlapped_tilesProperty
boundsProperty
top_left_worldProperty
bottom_right_worldProperty
top_right_worldProperty
bottom_left_worldProperty
corners_tileProperty
min_tile_xProperty
max_tile_xProperty
min_tile_yProperty
max_tile_yProperty
tile_posProperty
tile_world_centerProperty
tile_sizeProperty
half_widthProperty
half_heightProperty
tile_diamondProperty
detect_collisionsMethod
bounds1Property
bounds2Property
min_xProperty
min_yProperty
max_xProperty
max_yProperty
outputProperty
edge_vecProperty
edge_normalProperty
prevProperty
prev_insideProperty
curr_insideProperty
intersectionProperty
intersectionProperty
denominatorProperty
uaProperty
intersectionProperty
polygons_overlapMethod
clippedProperty
edge_startProperty
edge_endProperty
overlap_areaProperty
min_areaProperty
area_epsProperty
adjusted_min_areaProperty
polygon_overlaps_rectMethod
poly_boundsProperty
clippedProperty
areaProperty
rect_areaProperty
min_areaProperty
area_epsProperty
adjusted_min_areaProperty
debug_near_thresholdProperty
debug_conditionProperty
resultProperty
outProperty
nProperty
epsProperty
lastProperty

Source

addons/grid_placement/placement/manager/components/collision_geometry_calculator.gd

Plugin docs root:gdscript/plugins/grid_placement_dev/docs