Editor?

Erin Catto wrote:
I plan to support edge soups for static level geometry. These will be placed in an AABB tree for fast processing.

Convex decomposition wouldn't be hard for closed polygons. In the worst case I could just triangulate the polygon.

Both the convex hull code and the convex decomposition code could be contributions because they are external utilities.


I've found that "naive" edge-soup (i.e just representing static geometry as individual linesegs) doesn't work all that well -- when an object penetrates into a vertex, you get a different response depending on which of the two edges (which share the vert) are processed first. Additionally, neither of the two responses will be correct. This same problem happens with convex decomposition -- the multiple convex/local solutions don't necessarily combine to arrive at the correct concave/global solution.

Then again, triangle-soup is very popular.. I just have never had good results without relying on some sort of special handling of shared features (planes shared by convex-decomposed chunks should never be considered a seperating axis, verts shared by edges in edge-soup should be handled differently, etc).

I'd love to hear how other people are doing this though.
Yes, handling collision with a triangle mesh robustly is quite tricky. A good place to start is by looking at the article in Game Programming Gems 4 on contact reduction.

I recommend analyzing the topology and adjusting your collision code accordingly. Also, some clustering and contact reduction can help quit a bit.

I'll always remember the problem where you have a box sitting on the edge of a cliff and the box shoots out into the abyss because the box thinks it's deeply penetrated into the face of the cliff. Quite annoying.

I expect edge soups to be no less annoying. 🙂
Yeah, that cliff example is exactly the sort of problem I've encountered.

I've read the GPG4 article a few times times over the past couple years, however I still don't really see how it would be useful beyond reducing the number of constraints to solve. Would it help in your cliff case, or were you referring to just mesh-vs-mesh?
So the GPG4 paper just gets the ball rolling. You have to work more details out on your own.

For the box on the cliff problem, you should use the lower box face as the contact normal. I never used cross(box edge, triangle edge) as the contact normal because a thin box wedged between two horizontal triangles would only get horizontal contact normals and no vertical support, leading to the box falling out of the world.

It's rules like these you have to come up with to make the system work. It's do-able, but tricky and it requires a lot of testing.
I've had a pretty frustrating time with trying to fix collision problems by adding logic -- it seems like each rule ends up solving one problem case only to create 2 new ones 🙂

Currently I've got a decent mesh-vs-mesh method working, but it's hellishly slow for convex shapes (since convex shapes are treated as meshes.. so, 4x vert and 4x edge for each box). My problem is that any attempt to implement an optimized convex-vs-mesh method inevitably has all sorts of "box pops out the wrong face" issues..

Original thread: https://box2d.org/forum/viewtopic.php?t=11