summaryrefslogtreecommitdiffstats
path: root/core/math/math_funcs.h
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2019-04-01 11:11:02 -0300
committerJuan Linietsky <reduzio@gmail.com>2019-04-01 11:11:02 -0300
commitdee98d3b6d58cbe42fc403d999b278aec9447105 (patch)
treee2d62de5d795629df650c936d94d896022c84055 /core/math/math_funcs.h
parentba1a1686592a3b4b7fef6856174fbb29dd36dae5 (diff)
downloadredot-engine-dee98d3b6d58cbe42fc403d999b278aec9447105.tar.gz
Some improvements to is_equal_approx, restored Quat operator.
Diffstat (limited to 'core/math/math_funcs.h')
-rw-r--r--core/math/math_funcs.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 17112d8940..6ac6839827 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -249,11 +249,11 @@ public:
static float random(float from, float to);
static real_t random(int from, int to) { return (real_t)random((real_t)from, (real_t)to); }
- static _ALWAYS_INLINE_ bool is_equal_approx_ratio(real_t a, real_t b, real_t epsilon = CMP_EPSILON) {
+ static _ALWAYS_INLINE_ bool is_equal_approx_ratio(real_t a, real_t b, real_t epsilon = CMP_EPSILON, real_t min_epsilon = CMP_EPSILON) {
// this is an approximate way to check that numbers are close, as a ratio of their average size
// helps compare approximate numbers that may be very big or very small
real_t diff = abs(a - b);
- if (diff == 0.0) {
+ if (diff == 0.0 || diff < min_epsilon) {
return true;
}
real_t avg_size = (abs(a) + abs(b)) / 2.0;