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.
This commit is contained in:
qonnop 2018-10-06 07:05:17 +02:00
parent f12cb82e0f
commit bbfc6f6985

View file

@ -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;
if (va != vb)
r_dst = int((1.0 - c) * va + vb * c);
else //avoid int casting issues
r_dst = a;
}
return;
case REAL: {