diff options
| author | Juan Linietsky | 2017-01-03 23:20:20 -0300 |
|---|---|---|
| committer | GitHub | 2017-01-03 23:20:20 -0300 |
| commit | 3a0c19d3f6ddb26359c95d84c376a8e6b1afd04d (patch) | |
| tree | 8e313066ce55a3366cd6b972ff429372583cda28 /core/math/math_funcs.h | |
| parent | f2e99826c0b1e8227644bfab0795d858c504d279 (diff) | |
| parent | bd7ba0b664fa98381db9ef8edb69ba211213d595 (diff) | |
| download | godot-3a0c19d3f6ddb26359c95d84c376a8e6b1afd04d.tar.gz godot-3a0c19d3f6ddb26359c95d84c376a8e6b1afd04d.tar.zst godot-3a0c19d3f6ddb26359c95d84c376a8e6b1afd04d.zip | |
Diffstat (limited to 'core/math/math_funcs.h')
| -rw-r--r-- | core/math/math_funcs.h | 9 |
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) { |
