From 74506ce901777b499e67f633e1633b615d237a70 Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Mon, 4 Sep 2023 11:03:39 +0200 Subject: [PATCH] Fix incorrect cast when animating `int` Type was cast to `int` rather than `int64_t` Also corrects `real_t` to `double` (cherry picked from commit 035cf5e2107c492553db876d976536cf0c67c211) --- scene/resources/animation.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 0de80e973b3..b198d357090 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -5579,8 +5579,8 @@ Variant Animation::subtract_variant(const Variant &a, const Variant &b) { Variant Animation::blend_variant(const Variant &a, const Variant &b, float c) { if (a.get_type() != b.get_type()) { if (a.is_num() && b.is_num()) { - real_t va = a; - real_t vb = b; + double va = a; + double vb = b; return va + vb * c; } return a; @@ -5591,7 +5591,7 @@ Variant Animation::blend_variant(const Variant &a, const Variant &b, float c) { return Variant(); } case Variant::INT: { - return int((a.operator int64_t()) + (b.operator int64_t()) * c + 0.5); + return int64_t((a.operator int64_t()) + (b.operator int64_t()) * c + 0.5); } case Variant::FLOAT: { return (a.operator double()) + (b.operator double()) * c; @@ -5664,8 +5664,8 @@ Variant Animation::blend_variant(const Variant &a, const Variant &b, float c) { Variant Animation::interpolate_variant(const Variant &a, const Variant &b, float c) { if (a.get_type() != b.get_type()) { if (a.is_num() && b.is_num()) { - real_t va = a; - real_t vb = b; + double va = a; + double vb = b; return va + (vb - va) * c; } return a; @@ -5677,11 +5677,11 @@ Variant Animation::interpolate_variant(const Variant &a, const Variant &b, float } case Variant::INT: { const int64_t va = a.operator int64_t(); - return int(va + ((b.operator int64_t()) - va) * c); + return int64_t(va + ((b.operator int64_t()) - va) * c); } case Variant::FLOAT: { - const real_t va = a.operator real_t(); - return va + ((b.operator real_t()) - va) * c; + const double va = a.operator double(); + return va + ((b.operator double()) - va) * c; } case Variant::VECTOR2: { return (a.operator Vector2()).lerp(b.operator Vector2(), c); @@ -5783,7 +5783,7 @@ Variant Animation::interpolate_variant(const Variant &a, const Variant &b, float case Variant::PACKED_INT32_ARRAY: { const Vector arr_a = a; const Vector arr_b = b; - int32_t sz = arr_a.size(); + int sz = arr_a.size(); if (sz == 0 || arr_b.size() != sz) { return a; } else { @@ -5795,7 +5795,7 @@ Variant Animation::interpolate_variant(const Variant &a, const Variant &b, float const int32_t *br = arr_b.ptr(); Variant va; - for (int32_t i = 0; i < sz; i++) { + for (int i = 0; i < sz; i++) { va = interpolate_variant(ar[i], br[i], c); vw[i] = va; } @@ -5806,7 +5806,7 @@ Variant Animation::interpolate_variant(const Variant &a, const Variant &b, float case Variant::PACKED_INT64_ARRAY: { const Vector arr_a = a; const Vector arr_b = b; - int64_t sz = arr_a.size(); + int sz = arr_a.size(); if (sz == 0 || arr_b.size() != sz) { return a; } else { @@ -5818,7 +5818,7 @@ Variant Animation::interpolate_variant(const Variant &a, const Variant &b, float const int64_t *br = arr_b.ptr(); Variant va; - for (int64_t i = 0; i < sz; i++) { + for (int i = 0; i < sz; i++) { va = interpolate_variant(ar[i], br[i], c); vw[i] = va; }