This project has moved and is read-only. For the latest updates, please go here.

Abstraction for SAT Polygon Geometries

Topics: Developer Forum
Aug 7, 2009 at 4:49 PM

Hi all,

I've been looking around the new SAT polygon geom creation utilities. They're really looking good, however I've been thinking about an architecture improvement which I think would be extra useful for this functionality. The thing is, you usually want to use SAT for collision detection, but from a game logic point of view you usually don't care about the details of internal SAT partitions.

In principle it would be possible to encapsulate the list of SAT geometries into an abstract Geom instance. This would allow for hooking delegates into the abstract Geom for sensors or collision handling logic events without caring about the internal structure of SAT partitions.

My question is: what could be the problems of encapsulating the list of SAT geoms into a Geom abstraction? This Geom could actually just be a "dummy" from the point of view of the simulator, but could be used for easier integration of collision handling logic and whole geom manipulation.

I believe this would make it easier to replace Polygon geoms for SAT ones, without concern for the details of internal structure.

I hope to have expressed my view clearly enough.

Keep up the excellent work.



Aug 8, 2009 at 2:09 AM

If I understand you correctly, you are talking about the convex decomposition and SAT specific methods in the Vertices class.

While this is a perfectly good idea and I've been thinking about this too and come up with a couple of solutions (implementations will first come in 3.0) there are some things to consider:

1. SAT does not operate on concave (non-convex) geometries and thus you need to use a tool that can split concave geometries into smaller convex geometries. The tools are not reliable and they can sometimes give other problems like increased tunneling and unrealistic collisions.

2. Extra overhead will occur in case you encapsulate everything in an abstract class. The engine does not operate on abstract classes, it only concentrate at a single geometry at the time.

3. Some flexibility will be lost. Since SAT needs all those smaller convex geometries from a single concave one, you can give specific parts more mass for added effect or you can explode geometries into smaller parts (like glass).


I've been thinking about creating a hybrid model where you keep all the convex info (convex decomposition) in the narrow phase, but discard it when you apply impulses. You simply save the geometry from when before it is decomposed and add impulse to the whole geometry instead of each and every geometry that makes up a larger geometry.

All this SAT specific convex decomposition stuff and the like is a tough nut to crack and no one has found a good solution for it yet (not that I'm aware of). It might not be worth the trouble to have a narrow phase collider that only works on convex geometries.