From bbfc6f698511dfdfa44e61aa88bd5678dda06bd8 Mon Sep 17 00:00:00 2001 From: qonnop Date: Sat, 6 Oct 2018 07:05:17 +0200 Subject: [PATCH] Fixed int interpolation issue, closes #22763 When interpolating between two equal int values a and b, floating point calculation imprecisions can result in different values depending on the interpolation factor. --- core/variant_op.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 9afc31a772e..7389b7a71a1 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -3542,7 +3542,10 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & case INT: { int64_t va = a._data._int; int64_t vb = b._data._int; - r_dst = int((1.0 - c) * va + vb * c); + if (va != vb) + r_dst = int((1.0 - c) * va + vb * c); + else //avoid int casting issues + r_dst = a; } return; case REAL: {