Skip to content

Commit

Permalink
q_shared: avoid rsqrt_fast(0) in VectorNormalizeFast() when trapping …
Browse files Browse the repository at this point in the history
…float exceptions
  • Loading branch information
illwieckz committed Dec 20, 2024
1 parent f755ae2 commit 191f4c1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/engine/qcommon/q_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,15 @@ 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_fast( DotProduct( v, v ) );
vec_t length = DotProduct( v, v );

VectorScale( v, ilength, v );
#if DAEMON_USE_FLOAT_EXCEPTIONS
if ( length )
#endif
{
vec_t ilength = Q_rsqrt_fast( length );
VectorScale( v, ilength, v );
}
}

inline vec_t VectorNormalize2( const vec3_t v, vec3_t out )
Expand Down

0 comments on commit 191f4c1

Please sign in to comment.