summaryrefslogtreecommitdiff
path: root/src/util/numeric.h
diff options
context:
space:
mode:
authorPaul Ouellette <oue.paul18@gmail.com>2019-02-07 16:26:06 -0500
committerParamat <paramat@users.noreply.github.com>2019-02-07 21:26:06 +0000
commitd5456da69de6d74206a8513fc53db38c7dd4bd22 (patch)
treee0586b970acf83833c54166caaa00a9b8820bc05 /src/util/numeric.h
parentfc566e2e1074e501283d4be70a654d6b79ef07ff (diff)
downloadminetest-d5456da69de6d74206a8513fc53db38c7dd4bd22.tar.gz
minetest-d5456da69de6d74206a8513fc53db38c7dd4bd22.tar.bz2
minetest-d5456da69de6d74206a8513fc53db38c7dd4bd22.zip
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.
Diffstat (limited to 'src/util/numeric.h')
-rw-r--r--src/util/numeric.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util/numeric.h b/src/util/numeric.h
index bfdff84a0..6f82a18c1 100644
--- a/src/util/numeric.h
+++ b/src/util/numeric.h
@@ -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;
+}