4
votes

Concave shapes seem to not be supported in box2d but I have not found any explanation about why they are not supported and the fact that you have to create multiple convex shapes in order to achieve the wanted shape. Wouldn't it be easier to just support concave shapes so that you only would have to create one single shape?

So could someone smart please try to explain why concave shapes are not supported in box2d, like the technical part etc.? And doesn't it take up more memory to have multiple shapes instead of one?

This could really make the world make more sense to me!

1
Would it be reasonable and useful to add the game-physics tag to this question? I think the answer to why not concave shapes has to do with performance for which game-physics tag might get the broader exposure needed to get some experienced answers.Louis Langholtz

1 Answers

1
votes

Box2D is written/developed by Erin Catto and "Box2D is not open contribution". As such, for the answer to why Box2D doesn't support concave shapes, we have to look to him.

Fortunately, Box2D has a web forum with the question (from 2010 in its General Discussion section): Why do shapes have to be convex?

Erin's first response is:

I think this explains it well enough: http://en.wikipedia.org/wiki/Separating_axis_theorem

There are techniques for handling concave shapes. They typically require a lot of memory and setup. For example, I've seen some papers that use signed distance maps. But they are often very light on details.

Later in the discussion, Erin adds what I think is an insightful gem:

AFAIK there are no high quality, high performance algorithms for concave narrow-phase collision. As it stands, there is little written about how to compute contact points and normals for convex shapes, let alone concave shapes.

This leads us to a relevant StackOverflow question (from 2013) of: Algorithms for collision detection between concave polygons. To date there's only been one answer to that question and it references a paper from 2003. This seems to substantiate Erin's position and claim.