Skip to content

Commit 80821bf

Browse files
committed
engine: use Q_sqrt_fast() in VectorNormalizeFast() and R_TBNtoQtangents()
1 parent a341ce8 commit 80821bf

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/engine/qcommon/q_shared.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ inline vec_t VectorNormalize( vec3_t v )
693693
// that length != 0, nor does it return length
694694
inline void VectorNormalizeFast( vec3_t v )
695695
{
696-
vec_t ilength = Q_rsqrt( DotProduct( v, v ) );
696+
vec_t ilength = Q_rsqrt_fast( DotProduct( v, v ) );
697697

698698
VectorScale( v, ilength, v );
699699
}

src/engine/renderer/tr_main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void R_TBNtoQtangents( const vec3_t tangent, const vec3_t binormal,
246246
if ( ( trace = tangent2[ 0 ] + binormal2[ 1 ] + normal2[ 2 ] ) > 0.0f )
247247
{
248248
trace += 1.0f;
249-
scale = 0.5f * Q_rsqrt( trace );
249+
scale = 0.5f * Q_rsqrt_fast( trace );
250250

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

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

273273
q[ 1 ] = trace * scale;
274274
q[ 0 ] = ( tangent2 [ 1 ] + binormal2[ 0 ] ) * scale;
@@ -279,7 +279,7 @@ void R_TBNtoQtangents( const vec3_t tangent, const vec3_t binormal,
279279
else
280280
{
281281
trace = -tangent2[ 0 ] - binormal2[ 1 ] + normal2[ 2 ] + 1.0f;
282-
scale = 0.5f * Q_rsqrt( trace );
282+
scale = 0.5f * Q_rsqrt_fast( trace );
283283

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

0 commit comments

Comments
 (0)