avoid triggering ASSERT due to insufficient floating point precision

For bigger lastmillis and zero basetime in combination with odd values for
as.speed, t can become negative due to rounding errors.

(time: 3404565, as.speed: 43,47826 -> t: -0,00575)
This commit is contained in:
ac-stef
2015-05-17 00:21:28 +02:00
parent 65c2e0f83a
commit ad263ea375
+2 -2
View File
@@ -27,8 +27,8 @@ struct vertmodel : model
void setframes(const animstate &as)
{
int time = lastmillis-as.basetime;
fr1 = (int)(time/as.speed); // round to full frames
t = (time-fr1*as.speed)/as.speed; // progress of the frame, value from 0.0f to 1.0f
fr1 = (int)(double(time)/as.speed); // round to full frames
t = (time-double(fr1)*as.speed)/as.speed; // progress of the frame, value from 0.0f to 1.0f
ASSERT(t >= 0.0f);
if(as.anim&ANIM_LOOP)
{