1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 03:59:56 +00:00

Fix RotateController not updating skeleton

This commit is contained in:
Sam Hellawell 2024-04-04 00:11:15 +01:00
parent 2288a691d2
commit ceabeab0fd

View file

@ -1,6 +1,7 @@
#include "rotatecontroller.hpp"
#include <osg/MatrixTransform>
#include <osgAnimation/Bone>
namespace MWRender
{
@ -40,9 +41,19 @@ namespace MWRender
osg::Quat orient = worldOrient * mRotate * worldOrientInverse * matrix.getRotate();
matrix.setRotate(orient);
matrix.setTrans(matrix.getTrans() + worldOrientInverse * mOffset);
node->setMatrix(matrix);
// If we are linked to a bone we must call setMatrixInSkeletonSpace
osgAnimation::Bone* b = dynamic_cast<osgAnimation::Bone*>(node);
if (b)
{
osgAnimation::Bone* parent = b->getBoneParent();
if (parent)
b->setMatrixInSkeletonSpace(matrix * parent->getMatrixInSkeletonSpace());
else
b->setMatrixInSkeletonSpace(matrix);
}
traverse(node, nv);
}