1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-29 13:20:35 +00:00

FIX(rotatecontroller): Account for parent node scale when rotating objects

This commit is contained in:
Dave Corley 2024-06-29 22:52:48 -05:00
parent b1de8ed720
commit c95c7503a8
2 changed files with 13 additions and 1 deletions

View File

@ -40,7 +40,8 @@ namespace MWRender
osg::Quat orient = worldOrient * mRotate * worldOrientInverse * matrix.getRotate();
matrix.setRotate(orient);
matrix.setTrans(matrix.getTrans() + worldOrientInverse * mOffset);
matrix *= osg::Matrix::scale(getParentScale(node));
node->setMatrix(matrix);
@ -71,4 +72,14 @@ namespace MWRender
return worldOrient;
}
osg::Vec3d RotateController::getParentScale(osg::Node* node)
{
osg::NodePathList nodepaths = node->getParentalNodePaths(mRelativeTo);
if (!nodepaths.empty())
{
return osg::computeLocalToWorld(nodepaths[0]).getScale();
}
return osg::Vec3d(1.0, 1.0, 1.0);
}
}

View File

@ -28,6 +28,7 @@ namespace MWRender
protected:
osg::Quat getWorldOrientation(osg::Node* node);
osg::Vec3d getParentScale(osg::Node* node);
bool mEnabled;
osg::Vec3f mOffset;