mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-09 21:44:54 +00:00
FIX(rotatecontroller): Account for parent node scale when rotating objects
This commit is contained in:
parent
b1de8ed720
commit
c95c7503a8
@ -40,7 +40,8 @@ namespace MWRender
|
|||||||
|
|
||||||
osg::Quat orient = worldOrient * mRotate * worldOrientInverse * matrix.getRotate();
|
osg::Quat orient = worldOrient * mRotate * worldOrientInverse * matrix.getRotate();
|
||||||
matrix.setRotate(orient);
|
matrix.setRotate(orient);
|
||||||
matrix.setTrans(matrix.getTrans() + worldOrientInverse * mOffset);
|
|
||||||
|
matrix *= osg::Matrix::scale(getParentScale(node));
|
||||||
|
|
||||||
node->setMatrix(matrix);
|
node->setMatrix(matrix);
|
||||||
|
|
||||||
@ -71,4 +72,14 @@ namespace MWRender
|
|||||||
return worldOrient;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ namespace MWRender
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
osg::Quat getWorldOrientation(osg::Node* node);
|
osg::Quat getWorldOrientation(osg::Node* node);
|
||||||
|
osg::Vec3d getParentScale(osg::Node* node);
|
||||||
|
|
||||||
bool mEnabled;
|
bool mEnabled;
|
||||||
osg::Vec3f mOffset;
|
osg::Vec3f mOffset;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user