mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Make animation blending and bone overrides interact favorably
This commit is contained in:
parent
455f7a4cae
commit
307ab111d0
2 changed files with 16 additions and 9 deletions
|
@ -181,6 +181,10 @@ void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs)
|
||||||
// anything is rendered so that the transformations of children are up to date
|
// anything is rendered so that the transformations of children are up to date
|
||||||
animateJoints();
|
animateJoints();
|
||||||
|
|
||||||
|
// Copy old transforms *before* bone overrides have been applied.
|
||||||
|
// TODO if there are no bone overrides or no animation blending, this is unnecessary.
|
||||||
|
copyOldTransforms();
|
||||||
|
|
||||||
OnAnimateCallback(timeMs / 1000.0f);
|
OnAnimateCallback(timeMs / 1000.0f);
|
||||||
|
|
||||||
IAnimatedMeshSceneNode::OnAnimate(timeMs);
|
IAnimatedMeshSceneNode::OnAnimate(timeMs);
|
||||||
|
@ -610,21 +614,23 @@ void CAnimatedMeshSceneNode::checkJoints()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAnimatedMeshSceneNode::copyOldTransforms()
|
||||||
|
{
|
||||||
|
for (u32 i = 0; i < PerJoint.SceneNodes.size(); ++i) {
|
||||||
|
if (!PerJoint.SceneNodes[i]->Matrix) {
|
||||||
|
PerJoint.PreTransSaves[i] = PerJoint.SceneNodes[i]->getTransform();
|
||||||
|
} else {
|
||||||
|
PerJoint.PreTransSaves[i] = std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CAnimatedMeshSceneNode::beginTransition()
|
void CAnimatedMeshSceneNode::beginTransition()
|
||||||
{
|
{
|
||||||
if (!JointsUsed)
|
if (!JointsUsed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (TransitionTime != 0) {
|
if (TransitionTime != 0) {
|
||||||
// Copy the transforms of animated joints
|
|
||||||
for (u32 i = 0; i < PerJoint.SceneNodes.size(); ++i) {
|
|
||||||
if (!PerJoint.SceneNodes[i]->Matrix) {
|
|
||||||
PerJoint.PreTransSaves[i] = PerJoint.SceneNodes[i]->getTransform();
|
|
||||||
} else {
|
|
||||||
PerJoint.PreTransSaves[i] = std::nullopt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Transiting = core::reciprocal((f32)TransitionTime);
|
Transiting = core::reciprocal((f32)TransitionTime);
|
||||||
}
|
}
|
||||||
TransitingBlend = 0.f;
|
TransitingBlend = 0.f;
|
||||||
|
|
|
@ -148,6 +148,7 @@ private:
|
||||||
|
|
||||||
void buildFrameNr(u32 timeMs);
|
void buildFrameNr(u32 timeMs);
|
||||||
void checkJoints();
|
void checkJoints();
|
||||||
|
void copyOldTransforms();
|
||||||
void beginTransition();
|
void beginTransition();
|
||||||
|
|
||||||
core::array<video::SMaterial> Materials;
|
core::array<video::SMaterial> Materials;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue