]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Tomaz optimized AngleVectors for the roll == 0 case
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 15 May 2004 23:24:11 +0000 (23:24 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 15 May 2004 23:24:11 +0000 (23:24 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4173 d7cf8633-e32d-0410-b094-e92efae38249

mathlib.c

index 22112734e2fa59565c8c14459e3a5110677ee689..28f7eddae8e43df35e11a48c5cec4a16c2f1bc89 100644 (file)
--- a/mathlib.c
+++ b/mathlib.c
@@ -418,20 +418,38 @@ void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
        }
        if (right || up)
        {
-               angle = angles[ROLL] * (M_PI*2 / 360);
-               sr = sin(angle);
-               cr = cos(angle);
-               if (right)
+               if (angles[ROLL])
                {
-                       right[0] = -1*(sr*sp*cy+cr*-sy);
-                       right[1] = -1*(sr*sp*sy+cr*cy);
-                       right[2] = -1*(sr*cp);
+                       angle = angles[ROLL] * (M_PI*2 / 360);
+                       sr = sin(angle);
+                       cr = cos(angle);
+                       if (right)
+                       {
+                               right[0] = -1*(sr*sp*cy+cr*-sy);
+                               right[1] = -1*(sr*sp*sy+cr*cy);
+                               right[2] = -1*(sr*cp);
+                       }
+                       if (up)
+                       {
+                               up[0] = (cr*sp*cy+-sr*-sy);
+                               up[1] = (cr*sp*sy+-sr*cy);
+                               up[2] = cr*cp;
+                       }
                }
-               if (up)
+               else
                {
-                       up[0] = (cr*sp*cy+-sr*-sy);
-                       up[1] = (cr*sp*sy+-sr*cy);
-                       up[2] = cr*cp;
+                       if (right)
+                       {
+                               right[0] = sy;
+                               right[1] = -cy;
+                               right[2] = 0;
+                       }
+                       if (up)
+                       {
+                               up[0] = (sp*cy);
+                               up[1] = (sp*sy);
+                               up[2] = cp;
+                       }
                }
        }
 }