diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-11-24 18:54:30 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-11-24 18:54:30 +0100 |
commit | 0d202cb5f16bdd4aeb9f9a761359f42b1760ca01 (patch) | |
tree | 4a3fbd7a804c2c7c1a378ee0f902b0c726a1236b /core/math/vector4.cpp | |
parent | 06bdc91afd1579cfe8fd5e13781c717c2cd9f2a1 (diff) | |
parent | b217c41d360bdd4eeab94a2064c1eb5ab6bd93d5 (diff) |
Merge pull request #69111 from TokageItLab/put-together-interpolations
Refactor interpolating functions in some classes to use `Math` class
Diffstat (limited to 'core/math/vector4.cpp')
-rw-r--r-- | core/math/vector4.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/core/math/vector4.cpp b/core/math/vector4.cpp index 3b189f7ed4..5ddf2bb6f6 100644 --- a/core/math/vector4.cpp +++ b/core/math/vector4.cpp @@ -130,11 +130,12 @@ Vector4 Vector4::round() const { } Vector4 Vector4::lerp(const Vector4 &p_to, const real_t p_weight) const { - return Vector4( - x + (p_weight * (p_to.x - x)), - y + (p_weight * (p_to.y - y)), - z + (p_weight * (p_to.z - z)), - w + (p_weight * (p_to.w - w))); + Vector4 res = *this; + res.x = Math::lerp(res.x, p_to.x, p_weight); + res.y = Math::lerp(res.y, p_to.y, p_weight); + res.z = Math::lerp(res.z, p_to.z, p_weight); + res.w = Math::lerp(res.w, p_to.w, p_weight); + return res; } Vector4 Vector4::cubic_interpolate(const Vector4 &p_b, const Vector4 &p_pre_a, const Vector4 &p_post_b, const real_t p_weight) const { |