mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-25 16:53:46 +01:00
Improve b3d:get_animated_bone_properties
This commit is contained in:
parent
b974113fa9
commit
aef7ad5e6e
20
b3d.lua
20
b3d.lua
@ -346,13 +346,25 @@ function get_animated_bone_properties(self, keyframe, interpolate)
|
||||
local bone_properties = {}
|
||||
local function get_props(node, parent_bone_name)
|
||||
local properties = {parent_bone_name = parent_bone_name}
|
||||
if node.keys and next(node.keys) ~= nil then
|
||||
properties = modlib.table.add_all(properties, get_frame_values(node.keys))
|
||||
|
||||
if keyframe > 0 and node.keys and next(node.keys) ~= nil then
|
||||
modlib.table.add_all(properties, get_frame_values(node.keys))
|
||||
end
|
||||
for _, property in pairs{"position", "rotation", "scale"} do
|
||||
properties[property] = properties[property] or modlib.table.copy(node[property])
|
||||
|
||||
if not properties.position then -- animation not present, fall back to node position
|
||||
properties.position = modlib.table.copy(node.position)
|
||||
end
|
||||
|
||||
if properties.rotation then -- animation is relative to node rotation
|
||||
properties.rotation = modlib.quaternion.compose(node.rotation, properties.rotation)
|
||||
else
|
||||
properties.rotation = modlib.table.copy(node.rotation)
|
||||
end
|
||||
|
||||
if not properties.scale then -- animation not present, fall back to node scale
|
||||
properties.scale = modlib.table.copy(node.scale)
|
||||
end
|
||||
|
||||
if node.bone then
|
||||
properties.bone_name = node.name
|
||||
table.insert(bone_properties, properties)
|
||||
|
Loading…
Reference in New Issue
Block a user