Calculate sr/cr only if right or up is specified

This commit is contained in:
smallmodel 2024-08-29 21:37:05 +02:00
parent 89133bf05d
commit 0147677412
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512

View file

@ -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 ); angle = angles[ PITCH ] * ( M_PI * 2 / 360 );
sp = sin( angle ); sp = sin( angle );
cp = cos( angle ); cp = cos( angle );
angle = angles[ ROLL ] * ( M_PI * 2 / 360 );
sr = sin( angle );
cr = cos( angle );
if( forward ) 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[ 1 ] = cp*sy;
forward[ 2 ] = -sp; forward[ 2 ] = -sp;
} }
if( right ) if ( right || up )
{ {
right[ 0 ] = ( -1 * sr*sp*cy + -1 * cr*-sy ); angle = angles[ ROLL ] * ( M_PI * 2 / 360 );
right[ 1 ] = ( -1 * sr*sp*sy + -1 * cr*cy ); sr = sin( angle );
right[ 2 ] = -1 * sr*cp; cr = cos( angle );
}
if( up ) if ( right )
{ {
up[ 0 ] = ( cr*sp*cy + -sr*-sy ); right[ 0 ] = ( -1 * sr * sp * cy + -1 * cr * -sy );
up[ 1 ] = ( cr*sp*sy + -sr*cy ); right[ 1 ] = ( -1 * sr * sp * sy + -1 * cr * cy );
up[ 2 ] = cr*cp; 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 ) void AngleVectorsLeft( const vec3_t angles, vec3_t forward, vec3_t left, vec3_t up )