summaryrefslogtreecommitdiff
path: root/core/math/math_funcs.h
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-06-01 12:05:18 +0200
committerGitHub <noreply@github.com>2019-06-01 12:05:18 +0200
commit3c4fab295b96c9bd852601531bf35c1ade56b54c (patch)
tree9adcec083a49ca4935ff70e1257bd492ca88df62 /core/math/math_funcs.h
parent64a88e8ef35d692f31d6114793468623c6756785 (diff)
parentc00427add34f505cff275ea33423f1053423d646 (diff)
Merge pull request #27789 from Giacom/move_towards
Added move_toward functions for float, Vector2 and Vector3
Diffstat (limited to 'core/math/math_funcs.h')
-rw-r--r--core/math/math_funcs.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 82b5b56c01..0e3bd8a318 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -224,6 +224,8 @@ public:
float x = CLAMP((p_weight - p_from) / (p_to - p_from), 0.0f, 1.0f);
return x * x * (3.0f - 2.0f * x);
}
+ static _ALWAYS_INLINE_ double move_toward(double p_from, double p_to, double p_delta) { return abs(p_to - p_from) <= p_delta ? p_to : p_from + SGN(p_to - p_from) * p_delta; }
+ static _ALWAYS_INLINE_ float move_toward(float p_from, float p_to, float p_delta) { return abs(p_to - p_from) <= p_delta ? p_to : p_from + SGN(p_to - p_from) * p_delta; }
static _ALWAYS_INLINE_ double linear2db(double p_linear) { return Math::log(p_linear) * 8.6858896380650365530225783783321; }
static _ALWAYS_INLINE_ float linear2db(float p_linear) { return Math::log(p_linear) * 8.6858896380650365530225783783321; }