Repository navigation
Project isometric collision shapes with the map's tile ratio - #1766
Merged
Merged
Conversation
Member
|
another great finding, thanks ! lots of Tiled improvements coming up this 20.11 version, I have a few things also I'm trying to close and also a brand new isometric demo ! |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SeWCkETjW35ZbXDRswV1hx
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
On isometric maps the collision shapes of rectangle, polygon and polyline objects are projected with
toIso(), which is the projection of 2:1 tiles:(x - y, (x + y) / 2). Tiled projects object points with the map's tile size (IsometricRenderer::pixelToScreenCoords),((x - y) * tilewidth / (2 * tileheight), (x + y) / 2), the same wayTMXIsometricRenderer.adjustPositionalready places the objects. On a map whose tiles are not 2:1 the shapes are stretched or squeezed horizontally and stop lining up with the walls they outline.TMXObjectnow keepstilewidth / (2 * tileheight)from the map and scales x by it aftertoIso(). For 2:1 tiles it is 1 and nothing changes. Tile objects are untouched, they aren't projected.I checked it against Tiled: a 4x4 map with 186x108 tiles and a triangle at (108, 108) with points
0,0 216,0 216,108, rendered with Tiled'stmxrasterizer. Its vertices are drawn at (372, 108), (558, 216) and (465, 270), which is what the shape gives after this change. Before it the last two were at (588, 216) and (480, 270).Added tests to
tmxobject.spec.jsfor rectangles, polygons and polylines on 64x32, 128x32, 186x108 and 32x32 tiles, comparing the vertices with Tiled's formula. The non-2:1 ones fail before this change. Changelog entry added under Fixed.Type of change
Checklist
pnpm lintpasses)pnpm testpasses)pnpm build)pnpm test: 8508 passed, 2 failed:text-gradient.spec.js(multi-line ramp) fails onmastertoo on my machine, anddrawmesh_bench.spec.jstimed out after 61 s. eslint and biome pass on the changed files.Related issues
None, found while comparing isometric maps against Tiled.