collision_shape_processor
AUTO-GENERATED FILE — DO NOT EDIT MANUALLY
Source: placement/manager/components/mapper/collision_shape_processor.gd
Version: 5.0
class_name: (none)
extends: RefCounted
Signals
(none)
Exports
(none)
Methods
_init()- Initializes the processor with required dependencies.
[b]Parameters:[/b][br]
- [code]cache_manager[/code]: GeometryCacheManager for polygon bounds caching[br]
get_tile_offsets_for_collision_object()- Computes tile offsets for all collision shapes in a collision object.
This is the main entry point for collision-to-tile mapping. It processes all shapes attached to the collision object and returns their combined tile coverage as offsets relative to a calculated center tile.
[b]Tile Shape Detection:[/b][br] Automatically reads tile shape from [code]map.tile_set.tile_shape[/code] to ensure single source of truth. Supports TileSet.TILE_SHAPE_SQUARE and TileSet.TILE_SHAPE_ISOMETRIC.[br][br]
[b]Returns:[/b] Dictionary[Vector2i, Array] mapping tile offsets to collision objects
_initialize_collision_mapping()- Validates that required dependencies are available for collision mapping.
_process_shape_offsets()- Processes shape offsets for a single collision test setup.
Iterates through all shapes in the test setup and calculates which tiles they overlap with based on the tile shape defined in the map’s TileSet.
[param rect_test_setup]: Shape and collision test configuration @param test_data: Overall test setup containing epsilon values @param map: TileMapLayer providing tile configuration via its TileSet @param center_tile: Reference tile position for offset calculations @param tile_size: Size of each tile in world coordinates @param shape_epsilon: Minimum overlap threshold for shape-tile intersection @param col_obj: Collision object being processed @returns Dictionary[Vector2i, Array] mapping tile offsets to collision objects for this shape setup
_calculate_tile_range()- Calculates the tile range that needs to be checked for a shape.
Determines the bounding box of tiles that might intersect with the shape. Uses actual polygon vertices (which already have rotation/scale/skew applied) instead of AABB to avoid over-expansion under rotation.
@param shape: Shape2D to calculate range for @param bounds: AABB of the shape (fallback for optimization hints) @param map: TileMapLayer providing tile configuration via its TileSet @param tile_size: Size of each tile in world coordinates @param shape_transform: Transform of the shape in world space @param start_tile: Output parameter for the starting tile coordinate @param end_exclusive: Output parameter for the ending tile coordinate (exclusive) @param shape_polygon: Transformed polygon vertices (rotation/scale/skew already applied)
_compute_shape_tile_offsets()- Computes which tiles a shape overlaps with, returning offset positions.
For each tile in the specified range, calculates the intersection area between the shape and tile using the tile geometry defined in the map’s TileSet. Returns tile positions relative to the center tile.
@param shape: Shape2D to compute overlaps for @param shape_transform: Transform of the shape in world space @param map: TileMapLayer providing tile configuration via its TileSet @param tile_size: Size of each tile in world coordinates @param shape_epsilon: Minimum overlap threshold for inclusion @param start_tile: Starting tile coordinate for range @param end_exclusive: Ending tile coordinate for range (exclusive) @param center_tile: Reference tile for calculating relative offsets @param shape_polygon: Polygon representation of the shape @returns Array of Vector2i offsets relative to center_tile
_enforce_horizontal_symmetry()- Enforces horizontal symmetry for circular and capsule shapes.
For shapes that should be symmetrical (circles and capsules), ensures that if a tile offset exists on one side, the corresponding mirror offset also exists. This prevents asymmetrical collision detection for symmetric shapes.
@param shape_offsets: Array of tile offsets to make symmetric (modified in-place)
_merge_offsets_into_positions()- Merges shape offsets into the collision positions dictionary.
Adds each calculated tile offset to the collision positions dictionary, ensuring each collision object is properly tracked for its affected tiles.
@param shape_offsets: Array of tile offsets to merge @param collision_positions: Dictionary mapping tile positions to collision objects @param col_obj: Collision object being processed
_merge_collision_positions()- Merges two collision position dictionaries.
Combines the contents of source_positions into target_positions, ensuring each collision object is properly tracked for its affected tiles.
@param target_positions: Dictionary to merge into (modified in-place) @param source_positions: Dictionary to merge from