Utility/Node: Massively improve skeletal animations performance by allowing to invalidate the whole skeleton only once
Thanks to @SirMishaa for pointing that out
This commit is contained in:
@@ -3,86 +3,14 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/Joint.hpp>
|
||||
#include <Nazara/Utility/Skeleton.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
Joint::Joint(Skeleton* skeleton) :
|
||||
m_skeleton(skeleton),
|
||||
m_skinningMatrixUpdated(false)
|
||||
void Joint::InvalidateNode(Invalidation invalidation)
|
||||
{
|
||||
}
|
||||
|
||||
Joint::Joint(const Joint& joint) :
|
||||
Node(joint),
|
||||
m_inverseBindMatrix(joint.m_inverseBindMatrix),
|
||||
m_name(joint.m_name),
|
||||
m_skeleton(joint.m_skeleton),
|
||||
m_skinningMatrixUpdated(false)
|
||||
{
|
||||
}
|
||||
|
||||
void Joint::EnsureSkinningMatrixUpdate() const
|
||||
{
|
||||
if (!m_skinningMatrixUpdated)
|
||||
UpdateSkinningMatrix();
|
||||
}
|
||||
|
||||
const Matrix4f& Joint::GetInverseBindMatrix() const
|
||||
{
|
||||
return m_inverseBindMatrix;
|
||||
}
|
||||
|
||||
const std::string& Joint::GetName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
Skeleton* Joint::GetSkeleton()
|
||||
{
|
||||
return m_skeleton;
|
||||
}
|
||||
|
||||
const Skeleton* Joint::GetSkeleton() const
|
||||
{
|
||||
return m_skeleton;
|
||||
}
|
||||
|
||||
const Matrix4f& Joint::GetSkinningMatrix() const
|
||||
{
|
||||
if (!m_skinningMatrixUpdated)
|
||||
UpdateSkinningMatrix();
|
||||
|
||||
return m_skinningMatrix;
|
||||
}
|
||||
|
||||
void Joint::SetInverseBindMatrix(const Matrix4f& matrix)
|
||||
{
|
||||
m_inverseBindMatrix = matrix;
|
||||
m_skinningMatrixUpdated = false;
|
||||
}
|
||||
|
||||
void Joint::SetName(std::string name)
|
||||
{
|
||||
m_name = std::move(name);
|
||||
|
||||
m_skeleton->InvalidateJointMap();
|
||||
}
|
||||
|
||||
void Joint::InvalidateNode()
|
||||
{
|
||||
Node::InvalidateNode();
|
||||
Node::InvalidateNode(invalidation);
|
||||
|
||||
m_skinningMatrixUpdated = false;
|
||||
}
|
||||
|
||||
void Joint::UpdateSkinningMatrix() const
|
||||
{
|
||||
if (!m_transformMatrixUpdated)
|
||||
UpdateTransformMatrix();
|
||||
|
||||
m_skinningMatrix = Matrix4f::ConcatenateTransform(m_inverseBindMatrix, m_transformMatrix);
|
||||
m_skinningMatrixUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user