Removed maximum iteration count as the unilateral root solver might take a large number of iterations to converge.

This commit is contained in:
Irlan 2019-04-23 04:28:36 -03:00
parent 5c90059689
commit d02a1f512e

View File

@ -862,8 +862,8 @@ bool b3GJKShapeCast(b3GJKShapeCastOutput* output,
float32 r2 = proxy2.radius; float32 r2 = proxy2.radius;
float32 radius = r1 + r2; float32 radius = r1 + r2;
float32 d_max = b3Length(translation2); float32 bound = b3Length(translation2);
B3_ASSERT(d_max > 0.0f); B3_ASSERT(bound > 0.0f);
float32 t = 0.0f; float32 t = 0.0f;
@ -894,14 +894,14 @@ bool b3GJKShapeCast(b3GJKShapeCastOutput* output,
return true; return true;
} }
const u32 kMaxIters = 20;
u32 iter = 0; u32 iter = 0;
for (;;) for (;;)
{ {
++iter;
B3_ASSERT(d >= radius); B3_ASSERT(d >= radius);
float32 dt = (d - radius) / d_max; float32 dt = (d - radius) / bound;
t += dt; t += dt;
if (t >= 1.0f) if (t >= 1.0f)
@ -932,14 +932,6 @@ bool b3GJKShapeCast(b3GJKShapeCastOutput* output,
{ {
break; break;
} }
++iter;
if (iter == kMaxIters)
{
output->iterations = iter;
return false;
}
} }
if (d > 0.0f) if (d > 0.0f)