feat(maps): v0.5.5 — cell_material_slot public getter
Exposes what the v3 vertex/material render path computes internally:
per (layer, x, y), returns {slot, rot, flip} for material cells,
nil for non-material. Override entry wins (normalised via existing
normalize_override_entry); otherwise resolves through
compute_cell_bitmask_v3 + SLOT_LOOKUP.
Primary consumer: debug-overlay tooling (map-editor 0.2.0c.3) that
labels each rendered cell with its blob-14 slot identity for
authoring verification.
This commit is contained in:
26
init.lua
26
init.lua
@@ -1230,6 +1230,32 @@ function M.atlas_tile_size_px(atlas_idx, map_id)
|
||||
return atlas and atlas.tile_size_px or nil
|
||||
end
|
||||
|
||||
-- 0.5.5: public version of what the v3 vertex/material render path
|
||||
-- computes internally. Returns {slot, rot, flip} for a material cell
|
||||
-- (override entry takes precedence, else vertex-bitmask-derived), or
|
||||
-- nil when the cell is non-material / the layer is non-material-bound.
|
||||
-- Primary consumer: debug-overlay tooling that wants to label each
|
||||
-- rendered cell with its blob-14 slot identity.
|
||||
function M.cell_material_slot(layer_name, x, y, map_id)
|
||||
local id = map_id or current_map_id
|
||||
if not id then error("maps.cell_material_slot: no current map") end
|
||||
local m = map_registry[id]
|
||||
if not m.layers or not m.layers[layer_name] then return nil end
|
||||
local layer = m.layers[layer_name]
|
||||
if not layer.material then return nil end
|
||||
if x < 0 or x >= m.size.w or y < 0 or y >= m.size.h then return nil end
|
||||
-- Override wins (sparse force-slot map)
|
||||
local entry = layer.overrides and layer.overrides[x .. ":" .. y]
|
||||
if entry ~= nil then
|
||||
return normalize_override_entry(entry)
|
||||
end
|
||||
-- Vertex-derived bitmask path (only if the layer has a vertex grid)
|
||||
if not layer.vertices then return nil end
|
||||
if not cell_has_material(layer.vertices, m.size.w, m.size.h, x, y) then return nil end
|
||||
local bitmask = compute_cell_bitmask_v3(layer.vertices, m.size.w, m.size.h, x, y)
|
||||
return SLOT_LOOKUP[bitmask]
|
||||
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
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"id":"lib-core.maps","version":"0.5.4","api_min":"0.1"}
|
||||
{"id":"lib-core.maps","version":"0.5.5","api_min":"0.1"}
|
||||
|
||||
Reference in New Issue
Block a user