]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - mathlib.c
added LoopingFrameNumberFromDouble function to do this operation
[xonotic/darkplaces.git] / mathlib.c
index d6170d28977c27645f71b9987887854670d34916..dae0de50ba070a4f144e6830e47e5fa4da125700 100644 (file)
--- 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;
+}
+