mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-27 05:37:25 +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:
parent
ad428bd23b
commit
041b3b233a
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user