From 58da7fd104d3f7b185564f8afb96452f2cba9f12 Mon Sep 17 00:00:00 2001 From: Axel Meyer Date: Fri, 22 May 2026 00:34:30 +0200 Subject: [PATCH] Write atlas_uv onto bones_by_id, not rig.bones The render loop iterates bones_z_sorted, which contains references to the bones_by_id objects build_rig constructs. rig.bones is the original rig_table.bones source array, which is a separate set of bone objects. load_textures was writing atlas_uv onto rig.bones entries, so render never saw it and every textured bone fell through to the colored-rect phase-1 fallback. Vagrant-skeleton's puppet rendered as bare rotated rects instead of subterrain sprites. Co-Authored-By: Claude Opus 4.7 (1M context) --- init.lua | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/init.lua b/init.lua index b6fa992..043c2b9 100644 --- a/init.lua +++ b/init.lua @@ -1187,18 +1187,23 @@ function M.load_textures(rig, asset_aliases) -- Bind each bone to its uv-rect; resolve anchor (uv.w/2, uv.h/2 default). -- Anchor is a rig-author concern: bone-level b.anchor (set in rig table) -- takes precedence; tile UV center is the fallback. - for _, b in ipairs(rig.bones) do - if b.texture then - local tile = by_name[b.texture] + -- + -- The render loop reads from bones_by_id (via bones_z_sorted), not from + -- rig.bones (which keeps the original rig_table.bones reference). We + -- must write atlas_uv onto the bones_by_id objects so render sees it. + for _, b_src in ipairs(rig.bones) do + if b_src.texture then + local tile = by_name[b_src.texture] if tile == nil then error("puppet.load_textures: atlas '" .. rig.asset_pack - .. "' has no tile '" .. b.texture .. "'") + .. "' has no tile '" .. b_src.texture .. "'") end - b.atlas_uv = tile.uv + local target = rig.bones_by_id[b_src.id] + target.atlas_uv = tile.uv -- sprite_reach for locomotion: tile height minus anchor.y - b.texture_height = tile.uv.h - if b.anchor == nil then - b.anchor = { tile.uv.w / 2, tile.uv.h / 2 } + target.texture_height = tile.uv.h + if target.anchor == nil then + target.anchor = { tile.uv.w / 2, tile.uv.h / 2 } end end end