mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix and clean up skeletal animation (#15722)
* Fix attachments lagging behind their parents (#14818) * Fix animation blending (#14817) * Bring back cool guy as another .x smoke test * Add .x mesh loader unittest * Do bounding box & matrix calculation at proper point in time * Remove obsolete `SAnimatedMesh`
This commit is contained in:
parent
0bb87eb1ff
commit
fde6384a09
40 changed files with 856 additions and 1388 deletions
|
@ -4,9 +4,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "CBoneSceneNode.h"
|
||||
#include "IAnimatedMeshSceneNode.h"
|
||||
#include "IAnimatedMesh.h"
|
||||
|
||||
#include "SkinnedMesh.h"
|
||||
#include "Transform.h"
|
||||
#include "matrix4.h"
|
||||
|
||||
namespace irr
|
||||
|
@ -54,9 +57,11 @@ public:
|
|||
//! returns the current loop mode
|
||||
bool getLoopMode() const override;
|
||||
|
||||
//! Sets a callback interface which will be called if an animation
|
||||
//! playback has ended. Set this to 0 to disable the callback again.
|
||||
void setAnimationEndCallback(IAnimationEndCallBack *callback = 0) override;
|
||||
void setOnAnimateCallback(
|
||||
const std::function<void(f32 dtime)> &cb) override
|
||||
{
|
||||
OnAnimateCallback = cb;
|
||||
}
|
||||
|
||||
//! sets the speed with which the animation is played
|
||||
//! NOTE: setMesh will also change this value and set it to the default speed of the mesh
|
||||
|
@ -117,15 +122,16 @@ public:
|
|||
//! updates the absolute position based on the relative and the parents position
|
||||
void updateAbsolutePosition() override;
|
||||
|
||||
//! Set the joint update mode (0-unused, 1-get joints only, 2-set joints only, 3-move and set)
|
||||
void setJointMode(E_JOINT_UPDATE_ON_RENDER mode) override;
|
||||
|
||||
//! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2)
|
||||
//! Sets the transition time in seconds (note: This needs to enable joints)
|
||||
//! you must call animateJoints(), or the mesh will not animate
|
||||
void setTransitionTime(f32 Time) override;
|
||||
|
||||
void updateJointSceneNodes(const std::vector<SkinnedMesh::SJoint::VariantTransform> &transforms);
|
||||
|
||||
//! updates the joint positions of this mesh
|
||||
void animateJoints(bool CalculateAbsolutePositions = true) override;
|
||||
void animateJoints() override;
|
||||
|
||||
void addJoints();
|
||||
|
||||
//! render mesh ignoring its transformation. Used with ragdolls. (culling is unaffected)
|
||||
void setRenderFromIdentity(bool On) override;
|
||||
|
@ -142,6 +148,7 @@ private:
|
|||
|
||||
void buildFrameNr(u32 timeMs);
|
||||
void checkJoints();
|
||||
void copyOldTransforms();
|
||||
void beginTransition();
|
||||
|
||||
core::array<video::SMaterial> Materials;
|
||||
|
@ -158,19 +165,30 @@ private:
|
|||
f32 Transiting; // is mesh transiting (plus cache of TransitionTime)
|
||||
f32 TransitingBlend; // 0-1, calculated on buildFrameNr
|
||||
|
||||
// 0-unused, 1-get joints only, 2-set joints only, 3-move and set
|
||||
E_JOINT_UPDATE_ON_RENDER JointMode;
|
||||
bool JointsUsed;
|
||||
|
||||
bool Looping;
|
||||
bool ReadOnlyMaterials;
|
||||
bool RenderFromIdentity;
|
||||
|
||||
IAnimationEndCallBack *LoopCallBack;
|
||||
s32 PassCount;
|
||||
std::function<void(f32)> OnAnimateCallback;
|
||||
|
||||
std::vector<IBoneSceneNode *> JointChildSceneNodes;
|
||||
core::array<core::matrix4> PretransitingSave;
|
||||
struct PerJointData {
|
||||
std::vector<CBoneSceneNode *> SceneNodes;
|
||||
std::vector<core::matrix4> GlobalMatrices;
|
||||
std::vector<std::optional<core::Transform>> PreTransSaves;
|
||||
void setN(u16 n) {
|
||||
SceneNodes.clear();
|
||||
SceneNodes.resize(n);
|
||||
GlobalMatrices.clear();
|
||||
GlobalMatrices.resize(n);
|
||||
PreTransSaves.clear();
|
||||
PreTransSaves.resize(n);
|
||||
}
|
||||
};
|
||||
|
||||
PerJointData PerJoint;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue