aboutsummaryrefslogtreecommitdiff
path: root/core/math/math_funcs.h
diff options
context:
space:
mode:
authorJuan Linietsky2017-01-04 01:17:41 -0300
committerJuan Linietsky2017-01-04 01:17:41 -0300
commit76c2e8583e70e8c976a306e77a40e8e7226aa249 (patch)
treefe260ef3c0d00996d537f2fe3b8c78abfb92aa60 /core/math/math_funcs.h
parentb085c40edfac45ec1c8b866c789f6e9bab7e5e08 (diff)
parent3a0c19d3f6ddb26359c95d84c376a8e6b1afd04d (diff)
downloadgodot-76c2e8583e70e8c976a306e77a40e8e7226aa249.tar.gz
godot-76c2e8583e70e8c976a306e77a40e8e7226aa249.tar.zst
godot-76c2e8583e70e8c976a306e77a40e8e7226aa249.zip
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 ec0ed3947..24081528f 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) {