Fix updating of vertex normals for animated meshes (#77)

Updates cached positions and normals of animated vertices
from the mesh. Useful when using meshManipulator to update
the normals.
This commit is contained in:
x2048
2021-11-16 12:30:31 +01:00
committed by GitHub
parent 81bae5b717
commit 39cad3e618
4 changed files with 28 additions and 0 deletions

View File

@ -813,6 +813,21 @@ bool CSkinnedMesh::setHardwareSkinning(bool on)
return HardwareSkinning;
}
void CSkinnedMesh::refreshJointCache()
{
//copy cache from 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;
joint->Weights[j].StaticPos = LocalBuffers[buffer_id]->getVertex(vertex_id)->Pos;
joint->Weights[j].StaticNormal = LocalBuffers[buffer_id]->getVertex(vertex_id)->Normal;
}
}
}
void CSkinnedMesh::calculateGlobalMatrices(SJoint *joint,SJoint *parentJoint)
{