mirror of
https://github.com/bulletphysics/bullet3
synced 2025-01-18 21:10:05 +00:00
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:
parent
1035e21422
commit
2529aebc79
@ -23,6 +23,7 @@ SimdScalar rel_error2 = rel_error * rel_error;
|
||||
float maxdist2 = 1.e30f;
|
||||
|
||||
|
||||
int maxIter=1000;
|
||||
|
||||
GjkPairDetector::GjkPairDetector(ConvexShape* objectA,ConvexShape* objectB,SimplexSolverInterface* simplexSolver,ConvexPenetrationDepthSolver* penetrationDepthSolver)
|
||||
:m_cachedSeparatingAxis(0.f,0.f,1.f),
|
||||
@ -50,6 +51,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 +69,21 @@ void GjkPairDetector::GetClosestPoints(const ClosestPointInput& input,Result& ou
|
||||
|
||||
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 seperatingAxisInB = m_cachedSeparatingAxis* input.m_transformB.getBasis();
|
||||
|
Loading…
Reference in New Issue
Block a user