Page 1 of 1

Massive Skeletal animation boost: easy bug fix

Posted: Tue Feb 15, 2022 1:14 am
by omaremad
Hi guys I hope we are all alive and well.
Here is a small fix for my irrlicht family

the skeletal animation code unesscarly computes the pull matrix for every joint and every vertex it affects, it only needs to be done once per joint, results in a MASSIVE boost for high poly meshes

old code
void CSkinnedMesh::skinJoint(SJoint *joint, SJoint *parentJoint)
{

if (joint->Weights.size())
{
//Find this joints pull on vertices...
core::matrix4 jointVertexPull(core::matrix4::EM4CONST_NOTHING);
jointVertexPull.setbyproduct(joint->GlobalAnimatedMatrix, joint->GlobalInversedMatrix); //////<-why is this done so many times per vertex

new code
void CSkinnedMesh::skinJoint(SJoint *joint, SJoint *parentJoint)
{
//Find this joints pull on vertices... moved out of the loop
core::matrix4 jointVertexPull(core::matrix4::EM4CONST_NOTHING);
jointVertexPull.setbyproduct(joint->GlobalAnimatedMatrix, joint->GlobalInversedMatrix);

if (joint->Weights.size())
{

Re: Massive Skeletal animation boost: easy bug fix

Posted: Tue Feb 15, 2022 10:42 am
by CuteAlien
Sorry, I don't understand. The code is not in the loop. It's just behind the if check. So unless I misunderstand your change all do you is add a calculation when nothing has to be calculated.