diff --git a/code/qcommon/q_math.c b/code/qcommon/q_math.c index f81c121c..d5c102af 100644 --- a/code/qcommon/q_math.c +++ b/code/qcommon/q_math.c @@ -2069,9 +2069,6 @@ void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up angle = angles[ PITCH ] * ( M_PI * 2 / 360 ); sp = sin( angle ); cp = cos( angle ); - angle = angles[ ROLL ] * ( M_PI * 2 / 360 ); - sr = sin( angle ); - cr = cos( angle ); if( forward ) { @@ -2079,18 +2076,25 @@ void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up forward[ 1 ] = cp*sy; forward[ 2 ] = -sp; } - if( right ) - { - right[ 0 ] = ( -1 * sr*sp*cy + -1 * cr*-sy ); - right[ 1 ] = ( -1 * sr*sp*sy + -1 * 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 ( right || up ) + { + angle = angles[ ROLL ] * ( M_PI * 2 / 360 ); + sr = sin( angle ); + cr = cos( angle ); + + if ( right ) + { + right[ 0 ] = ( -1 * sr * sp * cy + -1 * cr * -sy ); + right[ 1 ] = ( -1 * sr * sp * sy + -1 * 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; + } + } } void AngleVectorsLeft( const vec3_t angles, vec3_t forward, vec3_t left, vec3_t up )