Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect cast when animating int #81296

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions scene/resources/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -5783,7 +5783,7 @@ Variant Animation::interpolate_variant(const Variant &a, const Variant &b, float
case Variant::PACKED_INT32_ARRAY: {
const Vector<int32_t> arr_a = a;
const Vector<int32_t> arr_b = b;
int32_t sz = arr_a.size();
int sz = arr_a.size();
if (sz == 0 || arr_b.size() != sz) {
return a;
} else {
Expand All @@ -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;
}
Expand All @@ -5806,7 +5806,7 @@ Variant Animation::interpolate_variant(const Variant &a, const Variant &b, float
case Variant::PACKED_INT64_ARRAY: {
const Vector<int64_t> arr_a = a;
const Vector<int64_t> arr_b = b;
int64_t sz = arr_a.size();
int sz = arr_a.size();
if (sz == 0 || arr_b.size() != sz) {
return a;
} else {
Expand All @@ -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;
}
Expand Down
Loading