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 );
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 )