mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 15:23:48 +01:00
Improve b3d:get_animated_bone_properties
This commit is contained in:
parent
b974113fa9
commit
aef7ad5e6e
24
b3d.lua
24
b3d.lua
@ -346,13 +346,25 @@ function get_animated_bone_properties(self, keyframe, interpolate)
|
|||||||
local bone_properties = {}
|
local bone_properties = {}
|
||||||
local function get_props(node, parent_bone_name)
|
local function get_props(node, parent_bone_name)
|
||||||
local properties = {parent_bone_name = 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
|
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
|
end
|
||||||
properties.rotation = modlib.quaternion.compose(node.rotation, properties.rotation)
|
|
||||||
|
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
|
if node.bone then
|
||||||
properties.bone_name = node.name
|
properties.bone_name = node.name
|
||||||
table.insert(bone_properties, properties)
|
table.insert(bone_properties, properties)
|
||||||
@ -366,4 +378,4 @@ function get_animated_bone_properties(self, keyframe, interpolate)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Export environment
|
-- Export environment
|
||||||
return _ENV
|
return _ENV
|
||||||
|
Loading…
Reference in New Issue
Block a user