X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=mathlib.c;h=6758445a20e4ed50e568f1e5c9627cb6b0913673;hb=783c61300adf71a38a5c9edb323d6f5ff90ac51d;hp=8fb29b21840368c5142bd418be6171c15e67896c;hpb=fb70c042c37a9778e1ef2b8cc96b3807c3c994bb;p=xonotic%2Fdarkplaces.git diff --git a/mathlib.c b/mathlib.c index 8fb29b21..6758445a 100644 --- 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; + } } } } @@ -454,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; + } } } } @@ -591,7 +627,7 @@ void Mathlib_Init(void) #include "matrixlib.h" -void Matrix4x4_Print (const matrix4x4_t *in) +void Matrix4x4_Print(const matrix4x4_t *in) { Con_Printf("%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n" , in->m[0][0], in->m[0][1], in->m[0][2], in->m[0][3]