try to catch error/ freezing reported on OSX

This commit is contained in:
Erwin Coumans
2006-06-15 13:39:05 +00:00
parent a31829fe20
commit 986f999671

View File

@@ -21,8 +21,11 @@ subject to the following restrictions:
static const SimdScalar rel_error = SimdScalar(1.0e-5);
SimdScalar rel_error2 = rel_error * rel_error;
float maxdist2 = 1.e30f;
#include <stdio.h>
int gGjkMaxIter=1000;
bool gIrregularCatch = true;
GjkPairDetector::GjkPairDetector(ConvexShape* objectA,ConvexShape* objectB,SimplexSolverInterface* simplexSolver,ConvexPenetrationDepthSolver* penetrationDepthSolver)
:m_cachedSeparatingAxis(0.f,0.f,1.f),
@@ -50,6 +53,8 @@ void GjkPairDetector::GetClosestPoints(const ClosestPointInput& input,Result& ou
marginB = 0.f;
}
int curIter = 0;
bool isValid = false;
bool checkSimplex = false;
bool checkPenetration = true;
@@ -66,6 +71,7 @@ void GjkPairDetector::GetClosestPoints(const ClosestPointInput& input,Result& ou
while (true)
{
SimdVector3 seperatingAxisInA = (-m_cachedSeparatingAxis)* input.m_transformA.getBasis();
SimdVector3 seperatingAxisInB = m_cachedSeparatingAxis* input.m_transformB.getBasis();
@@ -120,7 +126,7 @@ void GjkPairDetector::GetClosestPoints(const ClosestPointInput& input,Result& ou
break;
}
bool check = (!m_simplexSolver->fullSimplex());
//&& squaredDistance > SIMD_EPSILON * m_simplexSolver->maxVertex());
//bool check = (!m_simplexSolver->fullSimplex() && squaredDistance > SIMD_EPSILON * m_simplexSolver->maxVertex());
if (!check)
{
@@ -128,6 +134,39 @@ void GjkPairDetector::GetClosestPoints(const ClosestPointInput& input,Result& ou
m_simplexSolver->backup_closest(m_cachedSeparatingAxis);
break;
}
//rare failure case, perhaps deferate shapes?
if (curIter++ > gGjkMaxIter)
{
#define CATCH_ME 1
#ifdef CATCH_ME
//this should not happen, we need to catch it
//#if defined(DEBUG) || defined (_DEBUG)
if (gIrregularCatch)
{
gIrregularCatch = false;
printf("GjkPairDetector maxIter exceeded:%i\n",curIter);
printf("sepAxis=(%f,%f,%f), squaredDistance = %f, shapeTypeA=%i,shapeTypeB=%i\n",
m_cachedSeparatingAxis.getX(),
m_cachedSeparatingAxis.getY(),
m_cachedSeparatingAxis.getZ(),
squaredDistance,
m_minkowskiA->GetShapeType(),
m_minkowskiB->GetShapeType());
printf("If you can reproduce this, please email bugs@continuousphysics.com\n");
printf("Please include above information, your Platform, version of OS.\n");
printf("Thanks.\n");
}
//#endif
#endif //CATCH_ME
break;
}
}
if (checkSimplex)