TileMap
Fix rendering odd-sized tiles
#74814
Merged
+14
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Each
TileMapQuadrant
was storing local positions within themap_to_local
/local_to_map
maps cached for rendering asVector2i
s instead ofVector2
s. This is incorrect, local positions can be non-int. Using float vectors for keys is fine in here, as what's being used for these are the results ofTileMap::map_to_local(cell_map_coords)
calls which are per-cell unique and always the same for each cell.Cells are rendered relative to the per quadrant CanvasItem(s) (
ci
below;E_cell.key - tile_position
being the relative position):godot/scene/2d/tile_map.cpp
Lines 1284 to 1285 in 550a779
and quadrant's own position can also be non-int: it's calculated as the position of its first cell's position (its center and hence can be non-int), possibly offsetted according to the Y-sorting:
godot/scene/2d/tile_map.cpp
Lines 1241 to 1246 in 550a779
Meaning the relative cell-in-quadrant position (
E_cell.key - tile_position
) can be non-int, hence this PR changesdraw_tile
to take inVector2
instead ofVector2i
to avoid truncating such passed relative positions to ints.On top of the above fixes the in-editor plugin rendering as in some places
Rect2i::get_center()
was used which returns a center truncated to ints (aVector2i
) instead of an actual center which is needed. This resulted in another possible misalignment by half unit.Fixes #62911.
Supersedes #74773. Thanks @Portponky for pointing at the cause