summaryrefslogtreecommitdiffstats
path: root/core/math/math_funcs.h
diff options
context:
space:
mode:
authorFerenc Arn <tagcup@yahoo.com>2016-10-18 15:50:21 -0500
committerFerenc Arn <tagcup@yahoo.com>2017-01-03 17:41:04 -0600
commitbd7ba0b664fa98381db9ef8edb69ba211213d595 (patch)
tree8e313066ce55a3366cd6b972ff429372583cda28 /core/math/math_funcs.h
parentf2e99826c0b1e8227644bfab0795d858c504d279 (diff)
downloadredot-engine-bd7ba0b664fa98381db9ef8edb69ba211213d595.tar.gz
Use right handed coordinate system for rotation matrices and quaternions. Also fixes Euler angles (XYZ convention, which is used as default by Blender).
Furthermore, functions which expect a rotation matrix will now give an error simply, rather than trying to orthonormalize such matrices. The documentation for such functions has be updated accordingly. This commit breaks code using 3D rotations, and is a part of the breaking changes in 2.1 -> 3.0 transition. The code affected within Godot code base is fixed in this commit.
Diffstat (limited to 'core/math/math_funcs.h')
-rw-r--r--core/math/math_funcs.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index ec0ed39471..24081528f0 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -96,6 +96,15 @@ public:
static double random(double from, double to);
+ static _FORCE_INLINE_ bool isequal_approx(real_t a, real_t b) {
+ // TODO: Comparing floats for approximate-equality is non-trivial.
+ // Using epsilon should cover the typical cases in Godot (where a == b is used to compare two reals), such as matrix and vector comparison operators.
+ // A proper implementation in terms of ULPs should eventually replace the contents of this function.
+ // See https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ for details.
+
+ return abs(a-b) < CMP_EPSILON;
+ }
+
static _FORCE_INLINE_ real_t abs(real_t g) {