Fail explicitly when level armatures nest bones

Level animations use global coordinates, but sk_animation uses relative
offsets for child bones. Updating sk_animation to use global coordinates
works, but would break support for model animations (which use relative
offsets).

Although model animation export logic is currently implemented on the
C++ side and would not be immediately affected, eventually it'd be worth
it to move it over to Lua for simplicity and consistency.

So to avoid a future breaking change, and since complex armatures for
level animations are not likely to be needed, I'm leaving the current
behavior as-is until it is proven to be useful/necessary. Levels which
break this rule will now fail to export, to avoid surprises for anyone
who tries.
This commit is contained in:
Matt Penny 2024-02-11 18:41:12 -05:00
parent 3bcf1371e9
commit 79e77030c1

View file

@ -49,6 +49,11 @@ for index, armature in pairs(armatures) do
-- build an index used to attached parts of the scene -- build an index used to attached parts of the scene
-- to animation nodes later -- to animation nodes later
for _, node in pairs(armature.armature.nodes) do for _, node in pairs(armature.armature.nodes) do
local _, parent_index = armature.armature:get_parent_bone(node)
if parent_index then
error("Nested bones are not supported (found in armature '" .. armature.name .. "')")
end
table.insert(bones_as_array, node) table.insert(bones_as_array, node)
local bone_index = #bones_as_array local bone_index = #bones_as_array