fix(maps): v0.5.3 — refresh atlas_by_alias after load_textures

build_map_v3 caches an alias->atlas dict (atlas_by_alias) at map-load
time, pointing at the resolved stubs from load_tilemap. load_textures
later REPLACES m.atlases[i] in-place with the populated record
(diffuse_texture_handle + per-tile UVs from the lib-asset's
tiles.atlas.json) but never updated atlas_by_alias.

Effect: the v3 vertex/material render path resolves
m.atlas_by_alias[layer.material] to the PRE-load stub, finds no
diffuse handle, and short-circuits to the MISSING_ASSET_COLOR
fallback — every material-bound cell renders solid yellow regardless
of the bitmask/slot computation.

Fix: after each m.atlases[atlas_idx] = ... write in load_textures,
also overwrite m.atlas_by_alias[atlas_alias] with the new record.
Guarded on `if m.atlas_by_alias` so v2 maps (no autotile path) are
unaffected.

Found by the editor's freshly-bound work map after 0.2.0b.1 — vagrant
was unaffected by the bug because its hand-authored map was loaded
fine on the very first frame, masking the issue.
This commit is contained in:
calic
2026-05-29 01:27:49 +02:00
parent 714ec57010
commit 9bd4e5a415
2 changed files with 8 additions and 1 deletions

View File

@@ -1680,6 +1680,13 @@ function M.load_textures(asset_aliases)
diffuse_texture_handle = ok_d and diffuse_h or nil,
height_texture_handle = ok_h and height_h or nil,
}
-- v0.5.3: keep atlas_by_alias in sync with the replaced atlas
-- record. Built at load time off the pre-load stub; without this
-- refresh the v3 vertex/material render path resolves through
-- atlas_by_alias to the stub and falls back to MISSING_ASSET_COLOR.
if m.atlas_by_alias then
m.atlas_by_alias[atlas_alias] = m.atlases[atlas_idx]
end
end
-- Update m.tile_size from first atlas only when the atlas declares a uniform