mirror of
https://github.com/minetest/irrlicht.git
synced 2024-12-27 08:27:30 +01:00
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
|
//! Refreshes vertex data cached in joints such as positions and normals
|
||||||
virtual void refreshJointCache() = 0;
|
virtual void refreshJointCache() = 0;
|
||||||
|
|
||||||
|
//! Moves the mesh into static position.
|
||||||
|
virtual void resetAnimation() = 0;
|
||||||
|
|
||||||
//! A vertex weight
|
//! A vertex weight
|
||||||
struct SWeight
|
struct SWeight
|
||||||
{
|
{
|
||||||
|
@ -147,6 +147,12 @@ void CMeshManipulator::recalculateNormals(scene::IMesh* mesh, bool smooth, bool
|
|||||||
if (!mesh)
|
if (!mesh)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (mesh->getMeshType() == EAMT_SKINNED)
|
||||||
|
{
|
||||||
|
ISkinnedMesh *smesh = (ISkinnedMesh *) mesh;
|
||||||
|
smesh->resetAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
const u32 bcount = mesh->getMeshBufferCount();
|
const u32 bcount = mesh->getMeshBufferCount();
|
||||||
for ( u32 b=0; b<bcount; ++b)
|
for ( u32 b=0; b<bcount; ++b)
|
||||||
recalculateNormals(mesh->getMeshBuffer(b), smooth, angleWeighted);
|
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)
|
void CSkinnedMesh::calculateGlobalMatrices(SJoint *joint,SJoint *parentJoint)
|
||||||
{
|
{
|
||||||
if (!joint && parentJoint) // bit of protection from endless loops
|
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
|
//! Refreshes vertex data cached in joints such as positions and normals
|
||||||
virtual void refreshJointCache() _IRR_OVERRIDE_;
|
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_
|
//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
|
//these functions will use the needed arrays, set values, etc to help the loaders
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user