1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Use true pitch/yaw/roll rotations without loss of precision by pgimeno (#8019)

Store the rotation in the node as a 4x4 transformation matrix internally (through IDummyTransformationSceneNode), which allows more manipulations without losing precision or having gimbal lock issues.

Network rotation is still transmitted as Eulers, though, not as matrix. But it will stay this way in 5.0.
This commit is contained in:
Paul Ouellette 2019-02-07 16:26:06 -05:00 committed by Paramat
parent fc566e2e10
commit d5456da69d
8 changed files with 251 additions and 49 deletions

View file

@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irr_v2d.h"
#include "irr_v3d.h"
#include "irr_aabb3d.h"
#include <matrix4.h>
#define rangelim(d, min, max) ((d) < (min) ? (min) : ((d) > (max) ? (max) : (d)))
#define myfloor(x) ((x) < 0.0 ? (int)(x) - 1 : (int)(x))
@ -417,3 +418,17 @@ inline void wrappedApproachShortest(T &current, const T target, const T stepsize
current = target;
}
}
void setPitchYawRollRad(core::matrix4 &m, const v3f &rot);
inline void setPitchYawRoll(core::matrix4 &m, const v3f &rot)
{
setPitchYawRollRad(m, rot * core::DEGTORAD64);
}
v3f getPitchYawRollRad(const core::matrix4 &m);
inline v3f getPitchYawRoll(const core::matrix4 &m)
{
return getPitchYawRollRad(m) * core::RADTODEG64;
}