this should not be necessary, but it happened. todo: why doesn't gjk terminate. there are 2 rare cases, one with 'nan'/undefined separating axis/distance, and another with rather big distances.
This commit is contained in:
@@ -23,6 +23,7 @@ SimdScalar rel_error2 = rel_error * rel_error;
|
|||||||
float maxdist2 = 1.e30f;
|
float maxdist2 = 1.e30f;
|
||||||
|
|
||||||
|
|
||||||
|
int maxIter=1000;
|
||||||
|
|
||||||
GjkPairDetector::GjkPairDetector(ConvexShape* objectA,ConvexShape* objectB,SimplexSolverInterface* simplexSolver,ConvexPenetrationDepthSolver* penetrationDepthSolver)
|
GjkPairDetector::GjkPairDetector(ConvexShape* objectA,ConvexShape* objectB,SimplexSolverInterface* simplexSolver,ConvexPenetrationDepthSolver* penetrationDepthSolver)
|
||||||
:m_cachedSeparatingAxis(0.f,0.f,1.f),
|
:m_cachedSeparatingAxis(0.f,0.f,1.f),
|
||||||
@@ -50,6 +51,8 @@ void GjkPairDetector::GetClosestPoints(const ClosestPointInput& input,Result& ou
|
|||||||
marginB = 0.f;
|
marginB = 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int curIter = 0;
|
||||||
|
|
||||||
bool isValid = false;
|
bool isValid = false;
|
||||||
bool checkSimplex = false;
|
bool checkSimplex = false;
|
||||||
bool checkPenetration = true;
|
bool checkPenetration = true;
|
||||||
@@ -66,6 +69,21 @@ void GjkPairDetector::GetClosestPoints(const ClosestPointInput& input,Result& ou
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
if (curIter++ > maxIter)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
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());
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
SimdVector3 seperatingAxisInA = (-m_cachedSeparatingAxis)* input.m_transformA.getBasis();
|
SimdVector3 seperatingAxisInA = (-m_cachedSeparatingAxis)* input.m_transformA.getBasis();
|
||||||
SimdVector3 seperatingAxisInB = m_cachedSeparatingAxis* input.m_transformB.getBasis();
|
SimdVector3 seperatingAxisInB = m_cachedSeparatingAxis* input.m_transformB.getBasis();
|
||||||
|
|||||||
Reference in New Issue
Block a user