Why don't engines allow concave shapes?

In a recent topic: Collision Mask Is not Applied for Physics 2.0 - #4 by Silver-Streak

@Silver-Streak said " 2D Game engines in general tend to only allow Convex shapes, all 2D physics libraries exclusively support convex shapes only."

I just would ask why collisions work as that and what would happen if an engine allowed concave shapes?

Short answer: Math

Long answer: Calculating collisions with concave shapes is exponentially more complex in term of mathematical calculations than Convex shapes. This is true in game engines and just physics math in general.

Some of the answers to this thread add further detail. https://www.reddit.com/r/gamedev/comments/64uju9/can_someone_eli5_why_all_the_rigid_body_physics/


I never thought about it but I did a quick Google search and it’s actually a fascinating topic. This was especially enjoyable:


Here is an illustration I happen to have made for a school project on the matter:

Basically, convex shapes have special guarantees under the Hyperplane separation theorem that dictate that if there is a gap between projections of convex shapes then they are not overlapping, and if there is not they must be intersecting.

This projection and gap comparison is mathematically and algorithmically very easy to do, which a computer can do that very easily and efficiently.

On the other hand, concave polygons do not have this property and there is no equivalent easy method. The easiest performant way is to just split it up algorithmically into convex polygons and apply the same algorithm, since any concave polygon can be represented by a set of convex polygons.

But that adds up a lot of extra complexity, it adds processing time when loading up the polygons, in some cases it can add more polygons & edges than necessary making collision checks unnecessarily longer, etc.

So it’s not impossible but for best efficiency, it’s best to let you make convex polygons right off the beginning, since autmatically splitting it up might not be as efficient and not that much extra work


Three replies, three interesting answers and links. Thank you all.