diff options
author | Graham Madarasz <graham@lindenlab.com> | 2013-06-12 08:09:29 -0700 |
---|---|---|
committer | Graham Madarasz <graham@lindenlab.com> | 2013-06-12 08:09:29 -0700 |
commit | 48324a93833cee8aca7559588ee5f2b4afa250fa (patch) | |
tree | 59e37ff8a4b1f93a49304e9f3da57e290debfb8c /indra/llmath/llvector4a.inl | |
parent | 7ad631e6eabaf48f33f4808293ed7ffde8240adb (diff) |
Fix issues with NaNs in tangent data from using normalize3fast on zero-length vectors and other data conditioning; also added assert to normalize3fast to make finding these problems easier in the future
Diffstat (limited to 'indra/llmath/llvector4a.inl')
-rwxr-xr-x | indra/llmath/llvector4a.inl | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl index 7c52ffef21..4589bac9fb 100755 --- a/indra/llmath/llvector4a.inl +++ b/indra/llmath/llvector4a.inl @@ -331,6 +331,9 @@ inline LLSimdScalar LLVector4a::dot4(const LLVector4a& b) const // Note that this does not consider zero length vectors! inline void LLVector4a::normalize3() { + // find out about bad math before it takes two man-days to track down + llassert(isFinite3() && !equals3(getZero())); + // lenSqrd = a dot a LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); // rsqrt = approximate reciprocal square (i.e., { ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2 } @@ -379,6 +382,9 @@ inline void LLVector4a::normalize4() // Note that this does not consider zero length vectors! inline LLSimdScalar LLVector4a::normalize3withLength() { + // find out about bad math before it takes two man-days to track down + llassert(isFinite3() && !equals3(getZero())); + // lenSqrd = a dot a LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); // rsqrt = approximate reciprocal square (i.e., { ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2 } @@ -404,6 +410,9 @@ inline LLSimdScalar LLVector4a::normalize3withLength() // Note that this does not consider zero length vectors! inline void LLVector4a::normalize3fast() { + // find out about bad math before it takes two man-days to track down + llassert(isFinite3() && !equals3(getZero())); + LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); const LLQuad approxRsqrt = _mm_rsqrt_ps(lenSqrd.mQ); mQ = _mm_mul_ps( mQ, approxRsqrt ); |