PolygonTileMapper
Helper: Compute polygon area using shoelace formula
Helper: Compute polygon area using shoelace formula
Version: v5.0.0
Inherits: RefCounted
Source: polygon_tile_mapper.gd
Parsing: AST-based for maximum accuracy with symbol typing
Constants
MIN_POLY_TILE_OVERLAP_RATIO
Methods
compute_tile_offsets
Signature: static compute_tile_offsets(polygon_node: CollisionPolygon2D, map: TileMapLayer) -> Array
Primary entry point for polygon-to-tile conversion (runtime optimized)
Returns: Array
Static: true
Parameters:
polygon_node: CollisionPolygon2Dmap: TileMapLayer
compute_tile_offsets_with_positioner
Signature: static compute_tile_offsets_with_positioner(polygon_node: CollisionPolygon2D, map: TileMapLayer, positioner: Node2D) -> Array
Uses positioner’s position as coordinate reference instead of polygon’s position
Returns: Array
Static: true
Parameters:
polygon_node: CollisionPolygon2Dmap: TileMapLayerpositioner: Node2D
_compute_tile_offsets_internal
Signature: static _compute_tile_offsets_internal(polygon_node: CollisionPolygon2D, map: TileMapLayer, center_tile: Vector2i) -> Array
Internal implementation shared by both public methods
Returns: Array
Static: true
Parameters:
polygon_node: CollisionPolygon2Dmap: TileMapLayercenter_tile: Vector2i
process_polygon_with_diagnostics
Signature: static process_polygon_with_diagnostics(polygon_node: CollisionPolygon2D, map: TileMapLayer) -> ProcessingResult
Full processing with diagnostic information for testing and debugging
Returns: ProcessingResult
Static: true
Parameters:
polygon_node: CollisionPolygon2Dmap: TileMapLayer
_analyze_offset_pattern
Signature: static _analyze_offset_pattern(offsets: Array[Vector2i]: Variant) -> Dictionary
Helper: Analyze offset pattern for trapezoid detection
Returns: Dictionary
Static: true
Parameters:
offsets: Array[Vector2i]: Variant
_expansion_adds_new_tiles
Signature: static _expansion_adds_new_tiles(original: Array[Vector2i]: Variant, expanded: Array[Vector2i]: Variant) -> bool
Helper: Check if expansion adds new tile coverage
Returns: bool
Static: true
Parameters:
original: Array[Vector2i]: Variantexpanded: Array[Vector2i]: Variant
_determine_area_threshold
Signature: static _determine_area_threshold(is_convex: bool, did_expand: bool, thresholds: AreaThresholds) -> float
Helper: Determine area threshold based on polygon type and processing
Returns: float
Static: true
Parameters:
is_convex: booldid_expand: boolthresholds: AreaThresholds
_compute_tile_rect
Signature: static _compute_tile_rect(abs_tile: Vector2i, map: TileMapLayer, tile_size: Vector2) -> Rect2
Helper: Compute tile rectangle in world space
Returns: Rect2
Static: true
Parameters:
abs_tile: Vector2imap: TileMapLayertile_size: Vector2
_transform_polygon_world
Signature: static _transform_polygon_world(polygon_node: CollisionPolygon2D) -> PackedVector2Array
World polygon conversion - delegates to utility
Returns: PackedVector2Array
Static: true
Parameters:
polygon_node: CollisionPolygon2D
get_polygon_tile_overlap_area
Signature: static get_polygon_tile_overlap_area(polygon: PackedVector2Array, rect: Rect2) -> float
Polygon-tile overlap calculation using Sutherland-Hodgman clipping
Returns: float
Static: true
Parameters:
polygon: PackedVector2Arrayrect: Rect2
_compute_polygon_bounds
Signature: static _compute_polygon_bounds(polygon: PackedVector2Array) -> Rect2
Helper: Compute polygon bounding rectangle
Returns: Rect2
Static: true
Parameters:
polygon: PackedVector2Array
_clip_polygon_to_rect
Signature: static _clip_polygon_to_rect(polygon: PackedVector2Array, rect: Rect2) -> PackedVector2Array
Helper: Clip polygon against rectangle using Sutherland-Hodgman algorithm
Returns: PackedVector2Array
Static: true
Parameters:
polygon: PackedVector2Arrayrect: Rect2
_point_inside_boundary
Signature: static _point_inside_boundary(point: Vector2, boundary: Dictionary) -> bool
Helper: Test if point is inside clipping boundary
Returns: bool
Static: true
Parameters:
point: Vector2boundary: Dictionary
_compute_intersection
Signature: static _compute_intersection(a: Vector2, b: Vector2, boundary: Dictionary) -> Vector2
Helper: Compute line-boundary intersection
Returns: Vector2
Static: true
Parameters:
a: Vector2b: Vector2boundary: Dictionary
_compute_polygon_area
Signature: static _compute_polygon_area(polygon: PackedVector2Array) -> float
Helper: Compute polygon area using shoelace formula
Returns: float
Static: true
Parameters:
polygon: PackedVector2Array