fix(puppet): v0.4.2 — per-channel write_bone conflict (was per-track)

Allow procedural callbacks to write channels that no active anim
writes on the same bone. Example: walk_anim writes leg.scl; procedural
can now write leg.rot without track-conflict error. Previously the
guard was track-level (any anim on the track blocked ALL writes).

Enables hip-anchor-stable + leg-orientation-procedural pattern in
vagrant-skeleton (legs parent=body for body-relative hips, leg.rot
overridden per-frame to walk-direction while walk_fwd_lower drives
leg.scl).

Existing Group 4 track-conflict test still passes: walk_anim writes
leg.rot in keyframes; procedural-write of leg.rot still errors (same
channel). 42/42 assertions GREEN.
This commit is contained in:
Axel Meyer
2026-05-18 21:57:01 +02:00
parent fadaf3b8a3
commit 0b41e8efb7
2 changed files with 25 additions and 5 deletions

View File

@@ -582,13 +582,33 @@ function M.write_bone(handle, bone_id, values)
end end
local track_id = p.rig.bone_to_track[bone_id] local track_id = p.rig.bone_to_track[bone_id]
if track_id ~= nil then if track_id ~= nil then
-- Only check track-conflict if bone is in a track. -- v0.4.2: Per-channel conflict check (was per-track). Allow procedural
-- to write channels that no active anim writes on this bone (e.g.,
-- walk_anim writes leg.scl while procedural writes leg.rot — disjoint).
local writing = {}
if values.rot ~= nil then writing.rot = true end
if values.pos ~= nil then writing.pos = true end
if values.scl ~= nil then writing.scl = true end
for anim_id, _ in pairs(p.playing) do for anim_id, _ in pairs(p.playing) do
local anim = p.animations[anim_id] local anim = p.animations[anim_id]
if anim and anim.track == track_id then if anim and anim.track == track_id then
error("puppet.write_bone: bone '" .. bone_id for _, kf in ipairs(anim.keyframes) do
.. "' is on track '" .. track_id local bkf = kf.bones[bone_id]
.. "' currently active by keyframe '" .. anim_id .. "'") if bkf then
if writing.rot and bkf.rot ~= nil then
error("puppet.write_bone: bone '" .. bone_id
.. "' channel 'rot' conflicts with anim '" .. anim_id .. "'")
end
if writing.pos and bkf.pos ~= nil then
error("puppet.write_bone: bone '" .. bone_id
.. "' channel 'pos' conflicts with anim '" .. anim_id .. "'")
end
if writing.scl and bkf.scl ~= nil then
error("puppet.write_bone: bone '" .. bone_id
.. "' channel 'scl' conflicts with anim '" .. anim_id .. "'")
end
end
end
end end
end end
end end

View File

@@ -1,6 +1,6 @@
{ {
"id": "lib-core.puppet", "id": "lib-core.puppet",
"version": "0.4.1", "version": "0.4.2",
"api_min": "0.1", "api_min": "0.1",
"deps": [] "deps": []
} }