Skip to content

PolygonTileOverlap

Utility functions for polygon-tile overlap calculations.

Provides static methods for geometric calculations used by both CollisionMapper and PolygonTileMapper to avoid code duplication.

static func compute_overlap_area

(

polygon:

PackedVector2Array

,

rect:

Rect2

)

->

float

Compute precise overlap area (world units^2) between a polygon and a rectangular tile using Sutherland–Hodgman clipping followed by the shoelace formula. Parameters: • polygon: PackedVector2Array – world points. • rect: Rect2 – tile rect in world. Returns: float – overlap area (>= 0).

static func _compute_polygon_bounds

(

polygon:

PackedVector2Array

)

->

Rect2

Helper: Compute polygon bounding rectangle
static func _clip_polygon_to_rect

(

polygon:

PackedVector2Array

,

rect:

Rect2

)

->

PackedVector2Array

Helper: Clip polygon against rectangle using Sutherland-Hodgman algorithm

static func _point_inside_boundary

(

point:

Vector2

,

boundary:

Dictionary

)

->

bool

Helper: Test if point is inside clipping boundary
static func _compute_intersection

(

a:

Vector2

,

b:

Vector2

,

boundary:

Dictionary

)

->

Vector2

Helper: Compute line-boundary intersection
static func _compute_polygon_area

(

polygon:

PackedVector2Array

)

->

float

Helper: Compute polygon area using shoelace formula

addons/grid_building/placement/manager/components/mapper/polygon_tile_overlap.gd


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