feat(maps): v0.5.4 — atlas_diffuse_handle + atlas_tile_size_px + atlas_tile_uv

Public accessors for palette-like consumers (map-editor 0.2.0c.2)
that need to render real tile thumbnails. All three return nil when
the atlas-idx is out of range, the slot has no tile in the atlas,
or the texture failed to load (headless test env).

atlas_tile_uv resolves the slot via the same `slot_NN_` regex used
internally by the v3 vertex/material render path, so callers see
the same slot -> tile_id mapping the renderer uses.
This commit is contained in:
calic
2026-05-29 01:37:38 +02:00
parent 9bd4e5a415
commit be6d419061
2 changed files with 33 additions and 1 deletions

View File

@@ -1210,6 +1210,38 @@ function M.atlas_id_at(idx, map_id)
or m.atlases[idx + 1] and m.atlases[idx + 1].id
end
-- 0.5.4: Public accessors for palette-like consumers (map-editor) that
-- need to render real tile thumbnails. All three return nil when the
-- atlas-idx is out of range, the slot has no tile in the atlas, or the
-- texture failed to load (headless test env).
function M.atlas_diffuse_handle(atlas_idx, map_id)
local id = map_id or current_map_id
if not id then error("maps.atlas_diffuse_handle: no current map") end
local m = map_registry[id]
local atlas = m.atlases and m.atlases[atlas_idx + 1]
return atlas and atlas.diffuse_texture_handle or nil
end
function M.atlas_tile_size_px(atlas_idx, map_id)
local id = map_id or current_map_id
if not id then error("maps.atlas_tile_size_px: no current map") end
local m = map_registry[id]
local atlas = m.atlases and m.atlases[atlas_idx + 1]
return atlas and atlas.tile_size_px or nil
end
function M.atlas_tile_uv(atlas_idx, slot, map_id)
local id = map_id or current_map_id
if not id then error("maps.atlas_tile_uv: no current map") end
local m = map_registry[id]
local atlas = m.atlases and m.atlases[atlas_idx + 1]
if not atlas or not atlas.tiles then return nil end
local slot_idx = atlas_slot_index(atlas)
local tile_id = slot_idx[slot]
local tile = tile_id and atlas.tiles[tile_id]
return tile and tile.uv or nil
end
function M.has_layer(layer_name, map_id)
local id = map_id or current_map_id
if not id then error("maps.has_layer: no current map") end