Large polygon shape vs triangulated/decomposited shape

Hy. I almost finished my algorithm for decompositing concave shapes(still needs minor fixes but it works), now for fine tunning for jbox2d 2.1.2 i need to know what better/faster works:
- smaller shapes(triangles), but larger number of shapes per body
- bigger concave polygons, but smaller number of shapes per body
I mean by smaller/larger shapes(smaller/larger number of vertexes)

Anyone? 🙄
Nice work!

Unless I'm gravely mistaken, collisions are checked for by first comparing the bounding boxes of two fixtures, and if they overlap then the fixtures themselves are checked, in this case for polygons a separating axis is looked for.
So I guess you would want to:
- keep the number of fixtures down
- keep bounding boxes to an efficient size
- keep the overall number of edges down
Any way you look at it, chopping everything up into triangles ain't gonna help at all. The bounding boxes are AABBs so keeping them efficient means avoiding long skinny shapes where possible.

However having said all this, I really doubt you would see much difference in a typical game situation either way 🙂
I was looking at the source of jbox library and all fixtures are put into dynamic tree which gives something like O(log n) where is n number of fixtures for searching AABB, but the SAT algorithm has complexity O(Na(Ha + Hb) + Nb(Ha + Hb) + EaEb(Ha + Hb)) (Nx - normal number, Hx - time to search intervals, Ex - number of edges) (sory for bad formatting) which is worst than O(log n).
So my theory is better to have more fixtures with smaller(less edges) per body than body with less fixtures and bigger(more edges) shapes per body, but in balanced ratio.
As you say, lots of triangle polygons per body would probably kill performance...searching the tree would probably take more time than SAT.

Decomposition algorithm would probably put out best if using some kind of heuristic estimate of fixtures count vs edge per fixture count.

Anyway...

Quote:
The bounding boxes are AABBs so keeping them efficient means avoiding long skinny shapes where possible.


Yeah i noticed that with pain, my tank was keep jumping thru very long wall even at very low velocities. ...now about splitting long skinny in smaller peaces...
I was thinking of finding Minimum bounding box / Axis oriented bounding box for convex shape.
And if height vs width ratio was over some threshold the shape would be split/cut along narrowest direction. This would be repeated until shapes are not under threshold ratio...

have anyone better idea?

I am not sure if i know anymore how to compose statements, so forgive me for bad English.
If you want to take a look at an implementation of this, check out the Farseer library (it's a c# physics engine that uses a port of box2d)

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