From: cutealien Date: Tue, 11 Oct 2022 22:54:44 +0000 (+0000) Subject: Avoid some broken calculations for IBoneSceneNode positions. X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=edb381bd5050712d1eb8875fe3a405000dd09a3d;p=irrlicht.git Avoid some broken calculations for IBoneSceneNode positions. 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 --- diff --git a/source/Irrlicht/CSkinnedMesh.cpp b/source/Irrlicht/CSkinnedMesh.cpp index 75e2ca6..07e86d6 100644 --- a/source/Irrlicht/CSkinnedMesh.cpp +++ b/source/Irrlicht/CSkinnedMesh.cpp @@ -1347,9 +1347,24 @@ void CSkinnedMesh::recoverJointsFromMesh(core::array &jointChil { IBoneSceneNode* node=jointChildSceneNodes[i]; SJoint *joint=AllJoints[i]; - node->setPosition(joint->LocalAnimatedMatrix.getTranslation()); - node->setRotation(joint->LocalAnimatedMatrix.getRotationDegrees()); - node->setScale(joint->LocalAnimatedMatrix.getScale()); + + if ( joint->UseAnimationFrom ) // Seems to work better (else solution seems to mess up sometimes) and would be faster. Any disadvantage? + { + node->setPosition(joint->Animatedposition); + core::quaternion qrot = joint->Animatedrotation; + qrot.W *= -1.f; // Animation system uses right-handed rotations? Argh... + irr::core::vector3df euler; + qrot.toEuler(euler); + euler *= core::RADTODEG; + node->setRotation(euler); + node->setScale(joint->Animatedscale); + } + else + { + node->setPosition(joint->LocalAnimatedMatrix.getTranslation()); + node->setRotation(joint->LocalAnimatedMatrix.getRotationDegrees()); + node->setScale(joint->LocalAnimatedMatrix.getScale()); + } node->positionHint=joint->positionHint; node->scaleHint=joint->scaleHint;