From e3b6e38c5a2a1b94376776d6f5cdb7078bb0d62b Mon Sep 17 00:00:00 2001 From: calic Date: Fri, 29 May 2026 09:56:45 +0200 Subject: [PATCH] =?UTF-8?q?feat(maps):=20v0.5.5=20=E2=80=94=20cell=5Fmater?= =?UTF-8?q?ial=5Fslot=20public=20getter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- init.lua | 26 ++++++++++++++++++++++++++ manifest.lib | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index e9ce8ba..1d06b53 100644 --- a/init.lua +++ b/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 diff --git a/manifest.lib b/manifest.lib index bf04fce..b5f2cfd 100644 --- a/manifest.lib +++ b/manifest.lib @@ -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"}