jmc wrote:
Q1) I've been studying up on barycentric coordinates of a triangle, and from what I've read it's only defined if the point P lies in the plane of the triangle. I can't seem to find where in the code you project the origin onto the plane of the triangle.
The projection of the origin into the triangle plane happens here:
http://www.continuousphysics.com/Bullet ... ource.htmlCode:
00405 // P inside face region. Compute Q through its barycentric coordinates (u,v,w)
00406 float denom = 1.0f / (va + vb + vc);
00407 float v = vb * denom;
00408 float w = vc * denom;
00410 result.m_closestPointOnSimplex = a + ab * v + ac * w;
00414 result.SetBarycentricCoordinates(1-v-w,v,w);
jmc wrote:
Q2) When you have a full simplex, and you can't reduce it down to a smaller one, you just give up. Don't some uses of the gjk algorithm require you to calculate the lambda values even if you end up with a full simplex? An example that comes to mind is closest points on objects.
There are two cases in which the simplex solver will terminate the Bullet GJK implementation:
1) No reduction is done, because the origin is inside the tetrahedron. This means means the two convex objects are penetrating. The GJK outerloop will break.
2) Degenerate simplex, 3 or more points that are co-linear. This will also terminate the GJK loop. Degeneracy can also be caused by cancellation, as Gino stated before, this can be a problem in cases with large difference in feature sizes. If this is really a problem, some improvements can be made by re-ordering calculations to remove this cancellation effect.
In both cases either the current seperating distance is within the chosen collision-margins there will be a closest point result (penetration) reported, or a seperate user-provided penetration depth algorithm will be used.
Erwin