Fixed mesh animating modifying template skeleton
Former-commit-id: d70bd2ed7c8a38f879641a4b22be4876f6825edb
This commit is contained in:
parent
b652bada13
commit
37d6b71036
|
|
@ -36,6 +36,7 @@ class NAZARA_API NzModel : public NzSceneNode
|
|||
unsigned int GetSkinCount() const;
|
||||
const NzMesh* GetMesh() const;
|
||||
nzSceneNodeType GetSceneNodeType() const override;
|
||||
NzSkeleton* GetSkeleton();
|
||||
const NzSkeleton* GetSkeleton() const;
|
||||
|
||||
bool HasAnimation() const;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class NAZARA_API NzMesh : public NzResource, NzResourceListener
|
|||
bool AddSubMesh(NzSubMesh* subMesh);
|
||||
bool AddSubMesh(const NzString& identifier, NzSubMesh* subMesh);
|
||||
|
||||
void Animate(const NzAnimation* animation, unsigned int frameA, unsigned int frameB, float interpolation) const;
|
||||
void Animate(const NzAnimation* animation, unsigned int frameA, unsigned int frameB, float interpolation, NzSkeleton* skeleton) const;
|
||||
|
||||
bool CreateKeyframe();
|
||||
bool CreateSkeletal(unsigned int jointCount);
|
||||
|
|
|
|||
|
|
@ -112,6 +112,11 @@ nzSceneNodeType NzModel::GetSceneNodeType() const
|
|||
return nzSceneNodeType_Model;
|
||||
}
|
||||
|
||||
NzSkeleton* NzModel::GetSkeleton()
|
||||
{
|
||||
return &m_skeleton;
|
||||
}
|
||||
|
||||
const NzSkeleton* NzModel::GetSkeleton() const
|
||||
{
|
||||
return &m_skeleton;
|
||||
|
|
@ -419,5 +424,5 @@ void NzModel::Update(float elapsedTime)
|
|||
}
|
||||
}
|
||||
|
||||
m_mesh->Animate(m_animation, m_currentFrame, m_nextFrame, m_interpolation);
|
||||
m_mesh->Animate(m_animation, m_currentFrame, m_nextFrame, m_interpolation, &m_skeleton);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ bool NzMesh::AddSubMesh(const NzString& identifier, NzSubMesh* subMesh)
|
|||
return true;
|
||||
}
|
||||
|
||||
void NzMesh::Animate(const NzAnimation* animation, unsigned int frameA, unsigned int frameB, float interpolation) const
|
||||
void NzMesh::Animate(const NzAnimation* animation, unsigned int frameA, unsigned int frameB, float interpolation, NzSkeleton* skeleton) const
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!m_impl)
|
||||
|
|
@ -182,11 +182,19 @@ void NzMesh::Animate(const NzAnimation* animation, unsigned int frameA, unsigned
|
|||
break;
|
||||
|
||||
case nzAnimationType_Skeletal:
|
||||
animation->AnimateSkeleton(&m_impl->skeleton, frameA, frameB, interpolation);
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!skeleton)
|
||||
{
|
||||
NazaraError("Skeleton must be valid for skeletal animation");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
animation->AnimateSkeleton(skeleton, frameA, frameB, interpolation);
|
||||
for (NzSubMesh* subMesh : m_impl->subMeshes)
|
||||
{
|
||||
NzSkeletalMesh* skeletalMesh = static_cast<NzSkeletalMesh*>(subMesh);
|
||||
skeletalMesh->Skin(&m_impl->skeleton);
|
||||
skeletalMesh->Skin(skeleton);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue