Skip to content

Commit

Permalink
engine: use Q_sqrt_fast() in VectorNormalizeFast() and R_TBNtoQtangen…
Browse files Browse the repository at this point in the history
…ts()
  • Loading branch information
illwieckz committed Dec 17, 2024
1 parent a341ce8 commit 80821bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/engine/qcommon/q_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ inline vec_t VectorNormalize( vec3_t v )
// that length != 0, nor does it return length
inline void VectorNormalizeFast( vec3_t v )
{
vec_t ilength = Q_rsqrt( DotProduct( v, v ) );
vec_t ilength = Q_rsqrt_fast( DotProduct( v, v ) );

VectorScale( v, ilength, v );
}
Expand Down
8 changes: 4 additions & 4 deletions src/engine/renderer/tr_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void R_TBNtoQtangents( const vec3_t tangent, const vec3_t binormal,
if ( ( trace = tangent2[ 0 ] + binormal2[ 1 ] + normal2[ 2 ] ) > 0.0f )
{
trace += 1.0f;
scale = 0.5f * Q_rsqrt( trace );
scale = 0.5f * Q_rsqrt_fast( trace );

q[ 3 ] = trace * scale;
q[ 2 ] = ( tangent2 [ 1 ] - binormal2[ 0 ] ) * scale;
Expand All @@ -257,7 +257,7 @@ void R_TBNtoQtangents( const vec3_t tangent, const vec3_t binormal,
else if ( tangent2[ 0 ] > binormal2[ 1 ] && tangent2[ 0 ] > normal2[ 2 ] )
{
trace = tangent2[ 0 ] - binormal2[ 1 ] - normal2[ 2 ] + 1.0f;
scale = 0.5f * Q_rsqrt( trace );
scale = 0.5f * Q_rsqrt_fast( trace );

q[ 0 ] = trace * scale;
q[ 1 ] = ( tangent2 [ 1 ] + binormal2[ 0 ] ) * scale;
Expand All @@ -268,7 +268,7 @@ void R_TBNtoQtangents( const vec3_t tangent, const vec3_t binormal,
else if ( binormal2[ 1 ] > normal2[ 2 ] )
{
trace = -tangent2[ 0 ] + binormal2[ 1 ] - normal2[ 2 ] + 1.0f;
scale = 0.5f * Q_rsqrt( trace );
scale = 0.5f * Q_rsqrt_fast( trace );

q[ 1 ] = trace * scale;
q[ 0 ] = ( tangent2 [ 1 ] + binormal2[ 0 ] ) * scale;
Expand All @@ -279,7 +279,7 @@ void R_TBNtoQtangents( const vec3_t tangent, const vec3_t binormal,
else
{
trace = -tangent2[ 0 ] - binormal2[ 1 ] + normal2[ 2 ] + 1.0f;
scale = 0.5f * Q_rsqrt( trace );
scale = 0.5f * Q_rsqrt_fast( trace );

q[ 2 ] = trace * scale;
q[ 3 ] = ( tangent2 [ 1 ] - binormal2[ 0 ] ) * scale;
Expand Down

0 comments on commit 80821bf

Please sign in to comment.