1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-31 18:31:04 +00:00

Make bone interpolation work again

This commit is contained in:
Lars Mueller 2025-08-20 18:49:02 +02:00 committed by sfan5
parent ce8e8f6bf4
commit 550b042076
2 changed files with 25 additions and 2 deletions

View file

@ -85,6 +85,28 @@ core.register_entity("testentities:sam", {
},
on_activate = function(self)
self.object:set_animation({x = 0, y = 219}, 30, 0, true)
self._timer = 0
self._grow_head = true
self:_animate_head()
end,
_head_anim_duration = 2,
_animate_head = function(self)
local s = self._grow_head and 2 or 1
self.object:set_bone_override("Head", {
scale = {
vec = vector.new(s, s, s),
absolute = true,
interpolation = self._head_anim_duration,
},
})
end,
on_step = function(self, dtime)
self._timer = self._timer + dtime
if self._timer >= self._head_anim_duration then
self._timer = 0
self._grow_head = not self._grow_head
self:_animate_head()
end
end,
})

View file

@ -171,7 +171,8 @@ void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs)
}
// set CurrentFrameNr
buildFrameNr(timeMs - LastTimeMs);
const u32 dtimeMs = timeMs - LastTimeMs;
buildFrameNr(dtimeMs);
LastTimeMs = timeMs;
// This needs to be done on animate, which is called recursively *before*
@ -183,7 +184,7 @@ void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs)
copyOldTransforms();
if (OnAnimateCallback)
OnAnimateCallback(timeMs / 1000.0f);
OnAnimateCallback(dtimeMs / 1000.0f);
IAnimatedMeshSceneNode::OnAnimate(timeMs);