]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - mathlib.c
don't accumulate time reports for the first 10 seconds of a match so things can settle
[xonotic/darkplaces.git] / mathlib.c
index d6170d28977c27645f71b9987887854670d34916..ed0a43c60d3869c735dad47f6495f50afa47928d 100644 (file)
--- a/mathlib.c
+++ b/mathlib.c
@@ -203,11 +203,16 @@ void VectorVectors(const vec3_t forward, vec3_t right, vec3_t up)
        right[0] = forward[2];
        right[1] = -forward[0];
        right[2] = forward[1];
+       // BUG!
+       //   assume forward = {sqrt(1/3), sqrt(1/3), -sqrt(1/3)}
+       //   then right will be {-sqrt(1/3), -sqrt(1/3), sqrt(1/3)}
+       //   PROBLEM?
 
        d = DotProduct(forward, right);
        VectorMA(right, -d, forward, right);
        VectorNormalize(right);
        CrossProduct(right, forward, up);
+       VectorNormalize(up); // CrossProduct in this case returns 'up thats length is not 1
 }
 
 void VectorVectorsDouble(const double *forward, double *right, double *up)
@@ -756,3 +761,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;
+}
+