forked from Mirrorlandia_minetest/irrlicht
Reset mesh animation state before recalculating normals (#90)
This commit is contained in:
parent
52e03a8485
commit
2fec5e5dd3
@ -82,6 +82,9 @@ namespace scene
|
||||
//! Refreshes vertex data cached in joints such as positions and normals
|
||||
virtual void refreshJointCache() = 0;
|
||||
|
||||
//! Moves the mesh into static position.
|
||||
virtual void resetAnimation() = 0;
|
||||
|
||||
//! A vertex weight
|
||||
struct SWeight
|
||||
{
|
||||
|
@ -147,6 +147,12 @@ void CMeshManipulator::recalculateNormals(scene::IMesh* mesh, bool smooth, bool
|
||||
if (!mesh)
|
||||
return;
|
||||
|
||||
if (mesh->getMeshType() == EAMT_SKINNED)
|
||||
{
|
||||
ISkinnedMesh *smesh = (ISkinnedMesh *) mesh;
|
||||
smesh->resetAnimation();
|
||||
}
|
||||
|
||||
const u32 bcount = mesh->getMeshBufferCount();
|
||||
for ( u32 b=0; b<bcount; ++b)
|
||||
recalculateNormals(mesh->getMeshBuffer(b), smooth, angleWeighted);
|
||||
|
@ -829,6 +829,24 @@ void CSkinnedMesh::refreshJointCache()
|
||||
}
|
||||
}
|
||||
|
||||
void CSkinnedMesh::resetAnimation()
|
||||
{
|
||||
//copy from the cache to the mesh...
|
||||
for (u32 i=0; i<AllJoints.size(); ++i)
|
||||
{
|
||||
SJoint *joint=AllJoints[i];
|
||||
for (u32 j=0; j<joint->Weights.size(); ++j)
|
||||
{
|
||||
const u16 buffer_id=joint->Weights[j].buffer_id;
|
||||
const u32 vertex_id=joint->Weights[j].vertex_id;
|
||||
LocalBuffers[buffer_id]->getVertex(vertex_id)->Pos = joint->Weights[j].StaticPos;
|
||||
LocalBuffers[buffer_id]->getVertex(vertex_id)->Normal = joint->Weights[j].StaticNormal;
|
||||
}
|
||||
}
|
||||
SkinnedLastFrame = false;
|
||||
LastAnimatedFrame = -1;
|
||||
}
|
||||
|
||||
void CSkinnedMesh::calculateGlobalMatrices(SJoint *joint,SJoint *parentJoint)
|
||||
{
|
||||
if (!joint && parentJoint) // bit of protection from endless loops
|
||||
|
@ -116,6 +116,9 @@ namespace scene
|
||||
//! Refreshes vertex data cached in joints such as positions and normals
|
||||
virtual void refreshJointCache() _IRR_OVERRIDE_;
|
||||
|
||||
//! Moves the mesh into static position.
|
||||
virtual void resetAnimation() _IRR_OVERRIDE_;
|
||||
|
||||
//Interface for the mesh loaders (finalize should lock these functions, and they should have some prefix like loader_
|
||||
//these functions will use the needed arrays, set values, etc to help the loaders
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user