From c00427add34f505cff275ea33423f1053423d646 Mon Sep 17 00:00:00 2001 From: Giacom Date: Sun, 7 Apr 2019 22:40:56 +0100 Subject: Added move_toward functions for float, Vector2 and Vector3 --- core/math/math_funcs.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'core/math/math_funcs.h') 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; } -- cgit v1.2.3