I renamed your topic, because it's not GJK but Convex Cast.
Apart from the Gjk ConvexCastDemo, the convex cast is also used in the Raycaster demo, and it is used for Bullet raycasting, see Bullet/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
Code: Select all
void btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans,
Myagi wrote:
- there is no early out for lamda > 1 (since lambda can only increase), it will actually calculate a hit even if outside the line segment and return fractions > 1
Well spotted, this early out is not necessary for termination but it could improve performance. I'll check it out.
- the returned hit normal is not normalized, and is in A's local space
Indeed, to save a bit of performance it is up to the user to normalize the result. Typically you do a lot of queries, and not all of them are used, so you can just normalize once you know you need the result.
- the average number of iterations is at least around 10 or more in the demo, I thought I read some older post saying the average would be 3-4
GJK itself has typically 3-4 iterations (in many cases, but some cases need more). I never checked how many iterations a typical convex cast takes, that also depends on the shapes involved, and the accuracy (see float epsilon = 0.0001f; ).
- the simplex is reset every time lambda is refined, something I didn't see/understand being done when reading Gino's paper
Indeed, this reset might be redundant for pure linear cast. For the case where rotation is included, this reset is needed, because the minkowski sum changes. This might have to do with some implementation detail inside the voronoi simplex solver. It has been a since I implemented this.
By the way, you might also be interested in FAST library. It includes a similar casting approax, but uses SWIFT SAT instead of GJK:
http://www.continuousphysics.com/Bullet ... .php?t=608
Hope this helps,
Erwin