]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix the mathlib corner case vectoangles2('0 0 -1', '...')
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 4 Sep 2008 09:28:23 +0000 (09:28 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 4 Sep 2008 09:28:23 +0000 (09:28 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8491 d7cf8633-e32d-0410-b094-e92efae38249

mathlib.c

index cbd57db1d5d68458324733e17218a62cd512b8e4..d6170d28977c27645f71b9987887854670d34916 100644 (file)
--- a/mathlib.c
+++ b/mathlib.c
@@ -523,8 +523,16 @@ void AnglesFromVectors (vec3_t angles, const vec3_t forward, const vec3_t up, qb
 {
        if (forward[0] == 0 && forward[1] == 0)
        {
-               angles[PITCH] = forward[2] > 0 ? -M_PI * 0.5 : M_PI * 0.5;
-               angles[YAW] = up ? atan2(-up[1], -up[0]) : 0;
+               if(forward[2] > 0)
+               {
+                       angles[PITCH] = -M_PI * 0.5;
+                       angles[YAW] = up ? atan2(-up[1], -up[0]) : 0;
+               }
+               else
+               {
+                       angles[PITCH] = M_PI * 0.5;
+                       angles[YAW] = up ? atan2(up[1], up[0]) : 0;
+               }
                angles[ROLL] = 0;
        }
        else