@@ -214,7 +214,7 @@ class SuperSkinningTMPStruct
214214 uint32_t redir;
215215};
216216
217- core::matrix4x3 getGlobalMatrix_evil (asset::ICPUSkinnedMesh::SJoint* joint)
217+ core::matrix3x4SIMD getGlobalMatrix_evil (asset::ICPUSkinnedMesh::SJoint* joint)
218218{
219219 // if (joint->GlobalInversedMatrix.isIdentity())
220220 // return joint->GlobalInversedMatrix;
@@ -338,47 +338,33 @@ bool CXMeshFileLoader::load(SContext& _ctx, io::IReadFile* file)
338338 }
339339 if (mesh->AttachedJointID !=-1 )
340340 {
341- bool correctBindMatrix = _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix .isIdentity ();
342- core::matrix4x3 globalMat,globalMatInvTransp;
341+ bool correctBindMatrix = _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix ==core::matrix3x4SIMD ();
342+ core::matrix3x4SIMD globalMat;
343+ core::matrix4SIMD globalMatInvTransp;
343344 if (correctBindMatrix)
344345 {
345346 globalMat = getGlobalMatrix_evil (_ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]);
346- //
347- globalMatInvTransp (0 ,0 ) = globalMat (0 ,0 );
348- globalMatInvTransp (1 ,0 ) = globalMat (0 ,1 );
349- globalMatInvTransp (2 ,0 ) = globalMat (0 ,2 );
350- globalMatInvTransp (0 ,1 ) = globalMat (1 ,0 );
351- globalMatInvTransp (1 ,1 ) = globalMat (1 ,1 );
352- globalMatInvTransp (2 ,1 ) = globalMat (1 ,2 );
353- globalMatInvTransp (0 ,2 ) = globalMat (2 ,0 );
354- globalMatInvTransp (1 ,2 ) = globalMat (2 ,1 );
355- globalMatInvTransp (2 ,2 ) = globalMat (2 ,2 );
356- globalMatInvTransp (0 ,3 ) = globalMat (3 ,0 );
357- globalMatInvTransp (1 ,3 ) = globalMat (3 ,1 );
358- globalMatInvTransp (2 ,3 ) = globalMat (3 ,2 );
359- globalMatInvTransp.makeInverse ();
347+ core::matrix3x4SIMD tmp;
348+ globalMat.getInverse (tmp);
349+ globalMatInvTransp = core::matrix4SIMD (tmp);
360350 }
361351 else
362352 {
363- _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix .getInverse (globalMat);
364- globalMatInvTransp (0 ,0 ) = _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix (0 ,0 );
365- globalMatInvTransp (1 ,0 ) = _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix (0 ,1 );
366- globalMatInvTransp (2 ,0 ) = _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix (0 ,2 );
367- globalMatInvTransp (0 ,1 ) = _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix (1 ,0 );
368- globalMatInvTransp (1 ,1 ) = _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix (1 ,1 );
369- globalMatInvTransp (2 ,1 ) = _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix (1 ,2 );
370- globalMatInvTransp (0 ,2 ) = _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix (2 ,0 );
371- globalMatInvTransp (1 ,2 ) = _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix (2 ,1 );
372- globalMatInvTransp (2 ,2 ) = _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix (2 ,2 );
373- globalMatInvTransp (0 ,3 ) = _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix (3 ,0 );
374- globalMatInvTransp (1 ,3 ) = _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix (3 ,1 );
375- globalMatInvTransp (2 ,3 ) = _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix (3 ,2 );
353+ _ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix .getInverse (globalMat);
354+ globalMatInvTransp = core::matrix4SIMD (_ctx.AnimatedMesh ->getAllJoints ()[mesh->AttachedJointID ]->GlobalInversedMatrix );
376355 }
356+ globalMatInvTransp = core::transpose (globalMatInvTransp);
377357
378358 for (size_t j=0 ; j<mesh->Vertices .size (); j++)
379359 {
380- globalMat.transformVect (&mesh->Vertices [j].Pos .X );
381- globalMatInvTransp.mulSub3x3With3x1 (&mesh->Vertices [j].Normal .X );
360+ core::vectorSIMDf tmp;
361+ tmp.set (mesh->Vertices [j].Pos );
362+ tmp[3 ] = 1 .f ;
363+ globalMat.transformVect (tmp);
364+ mesh->Vertices [j].Pos = tmp.getAsVector3df ();
365+
366+ tmp.set (mesh->Vertices [j].Normal );
367+ mesh->Vertices [j].Normal = globalMatInvTransp.sub3x3TransformVect (tmp).getAsVector3df ();
382368
383369 reinterpret_cast <SkinnedVertexFinalData*>(vSkinningDataBuf->getPointer ())[j].boneWeights = 0x000003ffu ;
384370 reinterpret_cast <SkinnedVertexFinalData*>(vSkinningDataBuf->getPointer ())[j].boneIDs [0 ] = mesh->AttachedJointID ;
@@ -886,10 +872,6 @@ bool CXMeshFileLoader::parseDataObjectFrame(SContext& _ctx, asset::ICPUSkinnedMe
886872 {
887873 if (!parseDataObjectTransformationMatrix (_ctx, joint->LocalMatrix ))
888874 return false ;
889-
890- // joint->LocalAnimatedMatrix
891- // joint->LocalAnimatedMatrix.makeInverse();
892- // joint->LocalMatrix=tmp*joint->LocalAnimatedMatrix;
893875 }
894876 else
895877 if (objectName == " Mesh" )
@@ -920,7 +902,7 @@ bool CXMeshFileLoader::parseDataObjectFrame(SContext& _ctx, asset::ICPUSkinnedMe
920902}
921903
922904
923- bool CXMeshFileLoader::parseDataObjectTransformationMatrix (SContext& _ctx, core::matrix4x3 &mat)
905+ bool CXMeshFileLoader::parseDataObjectTransformationMatrix (SContext& _ctx, core::matrix3x4SIMD &mat)
924906{
925907#ifdef _XREADER_DEBUG
926908 os::Printer::log (" CXFileReader: Reading Transformation Matrix" , ELL_DEBUG);
@@ -2090,9 +2072,8 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(SContext& _ctx, asset::ICPUSk
20902072 }
20912073
20922074 // read matrix
2093- core::matrix4x3 mat4x3;
2094- readMatrix (_ctx, mat4x3);
2095- // mat=joint->LocalMatrix*mat;
2075+ core::matrix3x4SIMD mat;
2076+ readMatrix (_ctx, mat);
20962077
20972078 if (!checkForOneFollowingSemicolons (_ctx))
20982079 {
@@ -2105,14 +2086,14 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(SContext& _ctx, asset::ICPUSk
21052086 asset::ICPUSkinnedMesh::SRotationKey *keyR=joint->addRotationKey ();
21062087 keyR->frame =time;
21072088
2108- keyR->rotation = core::quaternion (mat4x3 );
2089+ keyR->rotation = core::quaternion (mat );
21092090
21102091 asset::ICPUSkinnedMesh::SPositionKey *keyP=joint->addPositionKey ();
21112092 keyP->frame =time;
2112- keyP->position =mat4x3 .getTranslation ();
2093+ keyP->position = mat .getTranslation (). getAsVector3df ();
21132094
21142095
2115- core::vector3df scale=mat4x3 .getScale ();
2096+ core::vector3df scale = mat .getScale (). getAsVector3df ();
21162097
21172098 if (scale.X ==0 )
21182099 scale.X =1 ;
@@ -2612,7 +2593,7 @@ bool CXMeshFileLoader::readRGBA(SContext& _ctx, video::SColor& color)
26122593
26132594
26142595// read matrix from list of floats
2615- bool CXMeshFileLoader::readMatrix (SContext& _ctx, core::matrix4x3 & mat)
2596+ bool CXMeshFileLoader::readMatrix (SContext& _ctx, core::matrix3x4SIMD & mat)
26162597{
26172598 for (uint32_t j=0u ; j<4u ; j++)
26182599 {
0 commit comments