1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-30 07:45:39 +00:00

Normalize forward and up vectors

To avoid having any of their components to be out of the range [-1, 1].
This commit is contained in:
elsid 2024-07-21 01:26:29 +02:00
parent ad428bd23b
commit 041b3b233a
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625

View file

@ -35,7 +35,9 @@ namespace Misc
inline osg::Vec3f toEulerAnglesXZ(const osg::Quat& quat)
{
return toEulerAnglesXZ(quat * osg::Vec3f(0, 1, 0));
osg::Vec3f forward = quat * osg::Vec3f(0, 1, 0);
forward.normalize();
return toEulerAnglesXZ(forward);
}
inline osg::Vec3f toEulerAnglesXZ(const osg::Matrixf& m)
@ -56,7 +58,11 @@ namespace Misc
inline osg::Vec3f toEulerAnglesZYX(const osg::Quat& quat)
{
return toEulerAnglesZYX(quat * osg::Vec3f(0, 1, 0), quat * osg::Vec3f(0, 0, 1));
osg::Vec3f forward = quat * osg::Vec3f(0, 1, 0);
forward.normalize();
osg::Vec3f up = quat * osg::Vec3f(0, 0, 1);
up.normalize();
return toEulerAnglesZYX(forward, up);
}
inline osg::Vec3f toEulerAnglesZYX(const osg::Matrixf& m)