PolygonTileMapper

AUTO-GENERATED FILE – DO NOT EDIT MANUALLY

Handles polygon-to-tile-offset conversion with testable, separated concerns.

Source File: addons/grid_building/placement/manager/components/mapper/polygon_tile_mapper.gd

Constants

  • Constant: MIN_POLY_TILE_OVERLAP_RATIO := 0.12

Public Methods

compute_tile_offsets

1
2
3
4
compute_tile_offsets(
    polygon_node: CollisionPolygon2D,
    map: TileMapLayer
) -> Array[Vector2i]

Flags: static

Primary entry point for polygon-to-tile conversion (runtime optimized)


compute_tile_offsets_with_positioner

1
2
3
4
5
compute_tile_offsets_with_positioner(
    polygon_node: CollisionPolygon2D,
    map: TileMapLayer,
    positioner: Node2D
) -> Array[Vector2i]

Flags: static

Primary entry point with positioner reference for consistent positioning Uses positioner’s position as coordinate reference instead of polygon’s position


process_polygon_with_diagnostics

1
2
3
4
process_polygon_with_diagnostics(
    polygon_node: CollisionPolygon2D,
    map: TileMapLayer
) -> ProcessingResult

Flags: static

Full processing with diagnostic information for testing and debugging


get_polygon_tile_overlap_area

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

Flags: static

Polygon-tile overlap calculation using Sutherland-Hodgman clipping


Private Methods

_compute_tile_offsets_internal

1
2
3
4
5
_compute_tile_offsets_internal(
    polygon_node: CollisionPolygon2D,
    map: TileMapLayer,
    center_tile: Vector2i
) -> Array[Vector2i]

Flags: static, private

Internal implementation shared by both public methods


_analyze_offset_pattern

1
_analyze_offset_pattern(offsets: Array[Vector2i]) -> Dictionary

Flags: static, private

Helper: Analyze offset pattern for trapezoid detection


_expansion_adds_new_tiles

1
2
3
4
_expansion_adds_new_tiles(
    original: Array[Vector2i],
    expanded: Array[Vector2i]
) -> bool

Flags: static, private

Helper: Check if expansion adds new tile coverage


_determine_area_threshold

1
2
3
4
5
_determine_area_threshold(
    is_convex: bool,
    did_expand: bool,
    thresholds: AreaThresholds
) -> float

Flags: static, private

Helper: Determine area threshold based on polygon type and processing


_compute_tile_rect

1
2
3
4
5
_compute_tile_rect(
    abs_tile: Vector2i,
    map: TileMapLayer,
    tile_size: Vector2
) -> Rect2

Flags: static, private

Helper: Compute tile rectangle in world space


_transform_polygon_world

1
_transform_polygon_world(polygon_node: CollisionPolygon2D) -> PackedVector2Array

Flags: static, private

World polygon conversion - delegates to utility


_compute_polygon_bounds

1
_compute_polygon_bounds(polygon: PackedVector2Array) -> Rect2

Flags: static, private

Helper: Compute polygon bounding rectangle


_clip_polygon_to_rect

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

Flags: static, private

Helper: Clip polygon against rectangle using Sutherland-Hodgman algorithm


_point_inside_boundary

1
2
3
4
_point_inside_boundary(
    point: Vector2,
    boundary: Dictionary
) -> bool

Flags: static, private

Helper: Test if point is inside clipping boundary


_compute_intersection

1
2
3
4
5
_compute_intersection(
    a: Vector2,
    b: Vector2,
    boundary: Dictionary
) -> Vector2

Flags: static, private

Helper: Compute line-boundary intersection


_compute_polygon_area

1
_compute_polygon_area(polygon: PackedVector2Array) -> float

Flags: static, private

Helper: Compute polygon area using shoelace formula