Tomaz optimized AngleVectorsFLU for the roll == 0 case
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 16 May 2004 00:19:10 +0000 (00:19 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 16 May 2004 00:19:10 +0000 (00:19 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4175 d7cf8633-e32d-0410-b094-e92efae38249

mathlib.c

index 28f7edd..6758445 100644 (file)
--- a/mathlib.c
+++ b/mathlib.c
@@ -472,20 +472,38 @@ void AngleVectorsFLU (const vec3_t angles, vec3_t forward, vec3_t left, vec3_t u
        }
        if (left || up)
        {
-               angle = angles[ROLL] * (M_PI*2 / 360);
-               sr = sin(angle);
-               cr = cos(angle);
-               if (left)
+               if (angles[ROLL])
                {
-                       left[0] = sr*sp*cy+cr*-sy;
-                       left[1] = sr*sp*sy+cr*cy;
-                       left[2] = sr*cp;
+                       angle = angles[ROLL] * (M_PI*2 / 360);
+                       sr = sin(angle);
+                       cr = cos(angle);
+                       if (left)
+                       {
+                               left[0] = sr*sp*cy+cr*-sy;
+                               left[1] = sr*sp*sy+cr*cy;
+                               left[2] = 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 (left)
+                       {
+                               left[0] = -sy;
+                               left[1] = cy;
+                               left[2] = 0;
+                       }
+                       if (up)
+                       {
+                               up[0] = sp*cy;
+                               up[1] = sp*sy;
+                               up[2] = cp;
+                       }
                }
        }
 }