Handles polygon-to-tile-offset conversion with testable, separated concerns. This class extracts the complex polygon processing logic from CollisionMapper2D to enable better testing and separation of responsibilities. Coordinate semantics
- Tile addressing is center-based. For 16×16 tiles, the center is at +8,+8 from the tile origin.
- Tests and runtime share "bottom-inclusive, top-exclusive" behavior on axis-aligned boundaries to avoid fencepost rows when a polygon edge lies exactly on a tile boundary. Pipeline stages: 1. Transform polygon to world space and compute initial tile coverage 2. Apply trapezoid expansion heuristics for convex polygons when beneficial 3. Prune concave polygon fringes to remove unwanted overhangs 4. Filter tiles by minimum area overlap to remove slivers (with concave center-point check)
Source: addons/grid_placement/placement/manager/components/mapper/polygon_tile_mapper.gd
Syntax
class PolygonTileMapperMembers
| Name | Kind | Summary |
|---|---|---|
MIN_POLY_TILE_OVERLAP_RATIO | Field | |
default_ratio | Property | Configuration for area-based filtering thresholds |
convex_ratio | Property | |
expanded_trapezoid_ratio | Property | |
expansion_candidate_ratio | Property | |
compute_tile_offsets_with_positioner | Method | |
eps | Property | |
xs | Property | |
ys | Property | |
found_x | Property | |
found_y | Property | |
bounds | Property | |
height_tiles | Property | |
max_y | Property | |
adjusted | Property | |
get_polygon_tile_overlap_area | Method |
Tutorials built on Grid Placement
- Godot multiplayer grid placement: one host, four sessions
- Godot 2D grid building system: paint, place, save
- Godot 3D grid building system: the runtime loop
- Godot 4 grid-building plugins: build mode vs editor tools
- 3D room placement in Godot: build rooms and stack storeys
- 3D grid placement in Godot 4: full setup tutorial
- Snap to a TileMap in Godot: 2D grid placement
- How to make a farming system in Godot
- How to snap objects to a 3D grid in Godot