GJK Convex Cast (subsimplex) stuff

Myagi
Posts: 5
Joined: Fri Jul 22, 2005 7:57 pm

GJK Convex Cast (subsimplex) stuff

Post by Myagi »

Having looked a bit of time with the SubSimplexConvexCast GJK cast, trying to incorperate it, to compare/verify to my own hack job (based on Gino's jgt04 paper and whatever info I could find), I made a few observations I was wondering about. I've used the latest version.

These may or may not be features, bugs or just things I'm wondering about, I'm just interested in some clarification to keep my sanity


- 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

- the returned hit normal is not normalized, and is in A's local space

- 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

- the simplex is reset every time lambda is refined, something I didn't see/understand being done when reading Gino's paper


(I "verified" some of these things with the convexcast demo and modifying it, but since I don't really know what the heck I'm doing I thought I'd better ask ;) )
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: GJK Convex Cast (subsimplex) stuff

Post by Erwin Coumans »

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