From 705a0ab6770459d89474b3495b05214315a49c94 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 25 Jun 2013 11:16:27 -0700 Subject: NORSPEC-288 WIP fixes the issue with normal gen, but may be a bigger perf hit than we want --- indra/llmath/llvector4a.inl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'indra/llmath/llvector4a.inl') diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl index 7c52ffef21..558fe09323 100755 --- a/indra/llmath/llvector4a.inl +++ b/indra/llmath/llvector4a.inl @@ -409,6 +409,26 @@ inline void LLVector4a::normalize3fast() mQ = _mm_mul_ps( mQ, approxRsqrt ); } +inline void LLVector4a::normalize3fast_checked(LLVector4a* d) +{ + if (!isFinite3()) + { + *this = d ? *d : LLVector4a(0,1,0,1); + return; + } + + LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); + + if (lenSqrd.getF32ptr()[0] <= FLT_EPSILON) + { + *this = d ? *d : LLVector4a(0,1,0,1); + return; + } + + const LLQuad approxRsqrt = _mm_rsqrt_ps(lenSqrd.mQ); + mQ = _mm_mul_ps( mQ, approxRsqrt ); +} + // Return true if this vector is normalized with respect to x,y,z up to tolerance inline LLBool32 LLVector4a::isNormalized3( F32 tolerance ) const { -- cgit v1.2.3