X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=mathlib.c;h=dae0de50ba070a4f144e6830e47e5fa4da125700;hb=7b26a1146198a553b373ac59406be611e34c50d6;hp=d6170d28977c27645f71b9987887854670d34916;hpb=fde75b49095458f8c405fef8c5550675f7e65761;p=xonotic%2Fdarkplaces.git diff --git a/mathlib.c b/mathlib.c index d6170d28..dae0de50 100644 --- a/mathlib.c +++ b/mathlib.c @@ -756,3 +756,12 @@ void BoxFromPoints(vec3_t mins, vec3_t maxs, int numpoints, vec_t *point3f) } } +// LordHavoc: this has to be done right or you get severe precision breakdown +int LoopingFrameNumberFromDouble(double t, int loopframes) +{ + if (loopframes) + return (int)(t - floor(t/loopframes)*loopframes); + else + return (int)t; +} +