]> git.lizzy.rs Git - irrlicht.git/commitdiff
Avoid some broken calculations for IBoneSceneNode positions.
authorcutealien <cutealien@dfc29bdd-3216-0410-991c-e03cc46cb475>
Tue, 11 Oct 2022 22:54:44 +0000 (22:54 +0000)
committersfan5 <sfan5@live.de>
Fri, 24 Mar 2023 16:09:11 +0000 (17:09 +0100)
This is based on bugreport #458 reported by viwrap who also made a nice test-case model.
Note: While solution seems to work and would even be faster, I'm not 100% sure yet if there are no downsides.
The other solution seems to regard last column in matrices - thought I don't think we ever set or use that.
And I also haven't found out yet _why_ the original solution goes wrong.
But animation system uses right-hand quaternions unlike rest of Irrlicht which is obviously a bit dangerous, will have to check the conversions some day.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6438 dfc29bdd-3216-0410-991c-e03cc46cb475

source/Irrlicht/CSkinnedMesh.cpp

index 75e2ca645a9f2b7d5e15c3540d7a36424cdf1675..07e86d6b009c57e8a5e25bee4a559a2cef747e46 100644 (file)
@@ -1347,9 +1347,24 @@ void CSkinnedMesh::recoverJointsFromMesh(core::array<IBoneSceneNode*> &jointChil
        {\r
                IBoneSceneNode* node=jointChildSceneNodes[i];\r
                SJoint *joint=AllJoints[i];\r
-               node->setPosition(joint->LocalAnimatedMatrix.getTranslation());\r
-               node->setRotation(joint->LocalAnimatedMatrix.getRotationDegrees());\r
-               node->setScale(joint->LocalAnimatedMatrix.getScale());\r
+\r
+               if ( joint->UseAnimationFrom )  // Seems to work better (else solution seems to mess up sometimes) and would be faster. Any disadvantage?\r
+               {\r
+                       node->setPosition(joint->Animatedposition);\r
+                       core::quaternion qrot = joint->Animatedrotation;\r
+                       qrot.W *= -1.f; // Animation system uses right-handed rotations? Argh... \r
+                       irr::core::vector3df euler;\r
+                       qrot.toEuler(euler);\r
+                       euler *= core::RADTODEG;\r
+                       node->setRotation(euler);\r
+                       node->setScale(joint->Animatedscale);\r
+               }\r
+               else\r
+               {\r
+                       node->setPosition(joint->LocalAnimatedMatrix.getTranslation());\r
+                       node->setRotation(joint->LocalAnimatedMatrix.getRotationDegrees());\r
+                       node->setScale(joint->LocalAnimatedMatrix.getScale());\r
+               }\r
 \r
                node->positionHint=joint->positionHint;\r
                node->scaleHint=joint->scaleHint;\r