From ad263ea3752a7ac589876b5379d8f7351da16b83 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Sun, 17 May 2015 00:21:28 +0200 Subject: [PATCH] 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) --- source/src/vertmodel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/src/vertmodel.h b/source/src/vertmodel.h index 4ca38247..6465da1a 100644 --- a/source/src/vertmodel.h +++ b/source/src/vertmodel.h @@ -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) {