Skip to content

Tilemap rects without a texture path use the mesh texture - #144

Open
WaruGameDev wants to merge 2 commits into
doriaxengine:mainfrom
WaruGameDev:fix/tilemap-default-submesh
Open

WaruGameDev wants to merge 2 commits into
doriaxengine:mainfrom
WaruGameDev:fix/tilemap-default-submesh

Conversation

@WaruGameDev

Copy link
Copy Markdown

Problem

Tilemap::addRect only creates a submesh when it gets a texture path. If the texture is set with Mesh::setTexture (a path or TextureData) and the rects are added without a path, numSubmeshes stays 0, so createTilemap drops every tile and logs nothing:

Tilemap tilemap(&scene);
tilemap.setTexture("tiles", TextureData(w, h, size, ColorFormat::RGBA, 4, pixels));
tilemap.addRect(0, "a", Rect(0, 0, 0.5, 0.5));
tilemap.addTile(0, "t0", 0, Vector2(0, 0), 16, 16);
tilemap.createTilemap(); // no indices, nothing drawn

Fix

A rect without its own texture path already uses submesh 0, where Mesh::setTexture puts the texture. createTilemap now counts that submesh when the tilemap has rects and no submesh yet. Rects added with a path keep creating their own submeshes as before.

Testing

The snippet above (two tiles), reading the MeshComponent after createTilemap():

  • on main: numSubmeshes == 0, 0 indices
  • with this change: numSubmeshes == 1, 12 indices

The engine library builds with MSVC (VS 2022, Debug).

🤖 Generated with Claude Code

WaruGameDev and others added 2 commits November 23, 2026 10:33
Tilemap::addRect only creates a submesh when it gets a texture path. With
the texture set by Mesh::setTexture (a path or TextureData) and rects added
without one, numSubmeshes stayed 0 and createTilemap skipped every tile,
with no error. createTilemap now counts submesh 0, where setTexture puts
the texture, when the tilemap has rects and no submesh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bmesh

createTilemap waits for a tile's texture to know its size before it
normalizes pixel rects, but it skipped the rects without a submesh of their
own (submeshId -1), the ones drawn with submesh 0. A scene loaded from file
then built the mesh before the texture size arrived, kept the pixel rects
and drew the whole texture in every tile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant