diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-07-26 17:12:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-26 17:12:13 +0200 |
commit | 33d423e240fbfa0b28bfa40fd0be746e88e95a31 (patch) | |
tree | 939fc51c1797482ef66a2c0924150a42ed0ad36f /core | |
parent | c75f4c06f0c422309414ca8d44437dd1b78d9af9 (diff) | |
parent | 7f9bfee0ac4707f2586bd25c04c3883c9eb1be9e (diff) |
Merge pull request #39898 from Meriipu/master_gdscript
GDScript: Clarified/fixed inaccuracies in the built-in function docs.
Diffstat (limited to 'core')
-rw-r--r-- | core/math/math_funcs.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 7a9fd60e23..9f8d4da5b3 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -231,19 +231,19 @@ public: static _ALWAYS_INLINE_ double range_lerp(double p_value, double p_istart, double p_istop, double p_ostart, double p_ostop) { return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value)); } static _ALWAYS_INLINE_ float range_lerp(float p_value, float p_istart, float p_istop, float p_ostart, float p_ostop) { return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value)); } - static _ALWAYS_INLINE_ double smoothstep(double p_from, double p_to, double p_weight) { + static _ALWAYS_INLINE_ double smoothstep(double p_from, double p_to, double p_s) { if (is_equal_approx(p_from, p_to)) { return p_from; } - double x = CLAMP((p_weight - p_from) / (p_to - p_from), 0.0, 1.0); - return x * x * (3.0 - 2.0 * x); + double s = CLAMP((p_s - p_from) / (p_to - p_from), 0.0, 1.0); + return s * s * (3.0 - 2.0 * s); } - static _ALWAYS_INLINE_ float smoothstep(float p_from, float p_to, float p_weight) { + static _ALWAYS_INLINE_ float smoothstep(float p_from, float p_to, float p_s) { if (is_equal_approx(p_from, p_to)) { return p_from; } - float x = CLAMP((p_weight - p_from) / (p_to - p_from), 0.0f, 1.0f); - return x * x * (3.0f - 2.0f * x); + float s = CLAMP((p_s - p_from) / (p_to - p_from), 0.0f, 1.0f); + return s * s * (3.0f - 2.0f * s); } 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; } |