fix 'safeNormalize' (probably should remove it)

Fix for Issue 953: cull degenerate triangles
https://github.com/bulletphysics/bullet3/issues/935
Thanks to Oleg Klimov for the report and reproduction case.
This commit is contained in:
erwincoumans
2017-01-30 18:12:09 -08:00
parent 26a34e3cda
commit 72dd8285e8
4 changed files with 70 additions and 54 deletions

View File

@@ -291,14 +291,16 @@ public:
SIMD_FORCE_INLINE btVector3& safeNormalize()
{
btVector3 absVec = this->absolute();
int maxIndex = absVec.maxAxis();
if (absVec[maxIndex]>0)
btScalar l2 = length2();
//triNormal.normalize();
if (l2 >= SIMD_EPSILON*SIMD_EPSILON)
{
*this /= absVec[maxIndex];
return *this /= length();
(*this) /= btSqrt(l2);
}
else
{
setValue(1, 0, 0);
}
setValue(1,0,0);
return *this;
}