Skip to content

Commit

Permalink
q_math: reuse the first trace in QuatFromMatrix()
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Jan 28, 2025
1 parent 39ce0d8 commit cf5a556
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/engine/qcommon/q_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2866,11 +2866,11 @@ void QuatFromMatrix( quat_t q, const matrix_t m )
*
* https://web.archive.org/web/20100818052330/http://cache-www.intel.com/cd/00/00/29/37/293748_293748.pdf
*/
float t, s;
float t = m[ 0 ] + m[ 5 ] + m[ 10 ] + 1.0f;
float s;

if ( m[ 0 ] + m[ 5 ] + m[ 10 ] + 1.0f > 0.0f )
if ( t > 0.0f )
{
t = m[ 0 ] + m[ 5 ] + m[ 10 ] + 1.0f;
s = ( 1.0f / sqrtf( t ) ) * 0.5f;

q[ 3 ] = s * t;
Expand Down

0 comments on commit cf5a556

Please sign in to comment.