mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 10:36: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:
parent
ad428bd23b
commit
041b3b233a
1 changed files with 8 additions and 2 deletions
|
@ -35,7 +35,9 @@ namespace Misc
|
||||||
|
|
||||||
inline osg::Vec3f toEulerAnglesXZ(const osg::Quat& quat)
|
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)
|
inline osg::Vec3f toEulerAnglesXZ(const osg::Matrixf& m)
|
||||||
|
@ -56,7 +58,11 @@ namespace Misc
|
||||||
|
|
||||||
inline osg::Vec3f toEulerAnglesZYX(const osg::Quat& quat)
|
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)
|
inline osg::Vec3f toEulerAnglesZYX(const osg::Matrixf& m)
|
||||||
|
|
Loading…
Reference in a new issue