Persistent Manifold & Contact breaking threshold

Please don't post Bullet support questions here, use the above forums instead.
sir_earl
Posts: 3
Joined: Wed Aug 05, 2015 9:16 pm

Persistent Manifold & Contact breaking threshold

Post by sir_earl »

I'm attempting to switch my 2D physics simulation to using GJK/EPA for collision detection, thus I have implemented a persistent manifold which adds at most one new contact point per step. However I'm running into slight instability due to the contact breaking threshold.

My understanding is that a contact point should be removed once the world space points on both bodies drift apart tangentially by some threshold, but this causes my bodies to pop inside each other on the frame that the contact is removed. A new contact point will then be added on the next frame, but at low time steps, this causes a noticeable pop.

The only thing I can think of to solve this issue is to replace the existing contact point before the threshold is reached, but the GJK algorithm might be returning points for the other contact point if it is deeper (I'm only keeping 2 contact points as this is a 2D engine).

How are others dealing with this issue? Is my understanding flawed?
RandyGaul
Posts: 43
Joined: Mon May 20, 2013 8:01 am
Location: Redmond, WA

Re: Persistent Manifold & Contact breaking threshold

Post by RandyGaul »

I myself haven't implemented EPA, but if it's possible to identify the features that produce a point of contact then the caching of data from one point to another can happen through some book-keeping, like a check for matching contact point IDs. This would avoid any annoying threshold tweaking.

As for the manifold not being very stable the first few frames due to the manifold having only one or two points (edit: well in 2D just one point would be unstable a lot of the time, but in 3D sometimes 4 or 5 points is necessary)... This is just a limitation of the GJK/EPA algorithms.
sir_earl
Posts: 3
Joined: Wed Aug 05, 2015 9:16 pm

Re: Persistent Manifold & Contact breaking threshold

Post by sir_earl »

Yes, I was able to match contact points based on a feature ID when using SAT, but this doesn't seem possible with GJK, MPR, or any algorithms that return a single contact point per step - 1) Multiple runs will return the same point unless you jiggle the bodies and run the algorithm again (which I'd like to avoid for performance reasons) and 2) I'm not convinced that you can rely on any features that GJK could provide.

I'm OK with the fact that GJK takes several frames to build a usable manifold, but oscillating between 1 and 2 points when a box slides down a slope doesn't look great at 30hz - Nor does a settling stack of bodies, so there must be a solution.
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Persistent Manifold & Contact breaking threshold

Post by Dirk Gregorius »

I think what you describe is a natural limitation of the incremental manifold. There will always be a situation where your thresholds break and you end up with one contact point. For many use cases (e.g. debris) this is no problem. Alternatively you can also use GJK and clipping to build the full manifold. Use the separating axis directions and query for the witness features. Just push the side planes out before clipping the reference face to account for the margin. This will even give you some extra stability.
sir_earl
Posts: 3
Joined: Wed Aug 05, 2015 9:16 pm

Re: Persistent Manifold & Contact breaking threshold

Post by sir_earl »

Thanks for that. Looks like GJK + clipping is probably the best way forward.