From bf6182daa8b4d7cea79310547f71d7a3155e17b0 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 29 Mar 2013 07:50:08 -0700 Subject: Update Mac and Windows breakpad builds to latest --- indra/llmath/llvector4a.inl | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 indra/llmath/llvector4a.inl (limited to 'indra/llmath/llvector4a.inl') diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl old mode 100644 new mode 100755 -- cgit v1.2.3 From 48324a93833cee8aca7559588ee5f2b4afa250fa Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 12 Jun 2013 08:09:29 -0700 Subject: 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 --- indra/llmath/llvector4a.inl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/llmath/llvector4a.inl') 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 ); -- cgit v1.2.3 From d2b253f1f6072beead770519849ad3b18a1a4359 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 12 Jun 2013 09:16:19 -0700 Subject: Changes to protect against use of normalize3fast on degenerate vectors --- indra/llmath/llvector4a.inl | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'indra/llmath/llvector4a.inl') diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl index 4589bac9fb..6860252a75 100755 --- a/indra/llmath/llvector4a.inl +++ b/indra/llmath/llvector4a.inl @@ -410,8 +410,26 @@ 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 ); +} + +// Normalize this vector with respect to the x, y, and z components only. Accurate only to 10-12 bits of precision. W component is destroyed +// Note that this does not consider zero length vectors! +inline void LLVector4a::normalize3fast_checked(LLVector4a* default) +{ + // handle bogus inputs before NaNs are generated below + // + if (!isFinite3() || (dot3(*this).getF32() < F_APPROXIMATELY_ZERO)) + { + if (default) + *this = *default; + else + set(0,1,0,1); + + return; + } LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); const LLQuad approxRsqrt = _mm_rsqrt_ps(lenSqrd.mQ); -- cgit v1.2.3 From 9726f3774d58e5d9d78648bb5185f694a9f70954 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 12 Jun 2013 10:26:06 -0700 Subject: Backout tangent assert experiment --- indra/llmath/llvector4a.inl | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'indra/llmath/llvector4a.inl') diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl index 6860252a75..7c52ffef21 100755 --- a/indra/llmath/llvector4a.inl +++ b/indra/llmath/llvector4a.inl @@ -331,9 +331,6 @@ 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 } @@ -382,9 +379,6 @@ 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 } @@ -415,27 +409,6 @@ inline void LLVector4a::normalize3fast() mQ = _mm_mul_ps( mQ, approxRsqrt ); } -// Normalize this vector with respect to the x, y, and z components only. Accurate only to 10-12 bits of precision. W component is destroyed -// Note that this does not consider zero length vectors! -inline void LLVector4a::normalize3fast_checked(LLVector4a* default) -{ - // handle bogus inputs before NaNs are generated below - // - if (!isFinite3() || (dot3(*this).getF32() < F_APPROXIMATELY_ZERO)) - { - if (default) - *this = *default; - else - set(0,1,0,1); - - return; - } - - LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); - 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