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:
parent
f12cb82e0f
commit
bbfc6f6985
1 changed files with 4 additions and 1 deletions
|
@ -3542,7 +3542,10 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
|
||||||
case INT: {
|
case INT: {
|
||||||
int64_t va = a._data._int;
|
int64_t va = a._data._int;
|
||||||
int64_t vb = b._data._int;
|
int64_t vb = b._data._int;
|
||||||
|
if (va != vb)
|
||||||
r_dst = int((1.0 - c) * va + vb * c);
|
r_dst = int((1.0 - c) * va + vb * c);
|
||||||
|
else //avoid int casting issues
|
||||||
|
r_dst = a;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case REAL: {
|
case REAL: {
|
||||||
|
|
Loading…
Reference in a new issue