# Representing a concave polygon as a hull "minus" convex cavities

I am implementing 2D collision detection, and trying to tackle the problem of concave polygon vs. shape.

The SAT works only for convex shapes.

I was wondering if the following approach is a viable strategy for concave polygons:

1. Compute the convex hull of the polygon (using the gift wrapping algorithm, for example).

2. The original concave polygon can be represented as the hull, "minus" (set intersection) the carved-out parts - which are also convex.

Then, I apply the SAT for every pair of convex polygons within colliding shapes; a collision between a hole and a "substance" region will nullify any previous collision result.

I hope this approach will be faster to compute than computing SAT between every pair of triangles (assuming the polygons were triangulated).

What do you think?

• How will you distinguish between cases where the collision touches only the "hole" portion of the hull (and should be discarded) versus ones where it touches both the hole and non-hole portions (and is then a true collision)? These two cases give you the same yes/no results for each convex pair involved, so you'd need another ingredient to distinguish them. Commented Apr 7 at 12:07

Your triangulated mesh already represents a convex hull with a cavity, there's no need to perform additional collision checks only to invalidate previous tests. This potentially means additional computation and possible false positives, as @DMGregory pointed out in the comments.

The approach you describe is called the broad phase of collision testing, where the physics engine identifies the potential colliding pairs to investigate further during the subsequent narrow phase.

During the broad phase, the physics engine uses fast collision tests to determine which bodies might intersect. They rely on using simple primitives (such as AABBs or spheres) that fully enclose the original mesh and testing for overlaps in a yes-or-no fashion: if the big, chunky wrapper doesn't collide with anything, then the smaller, higher-detail collision proxy won't either. No need for convex hulls at this time.

Then, during the narrow phase, the engine tests all previous potential pairs and performs the actual collision detection. Now, every game object is tested using its actual collider(s) and, depending on the pair's proxy shapes, the most appropriate collision detection algorithm is used, for example Cube vs. Cube, Sphere vs. Wall, or even AABB vs. Ray. Complex objects may now require the SAT for convex hulls or sub-meshes.

Further readings: Dirk Gregorius's talk Robust Contact Creation for Physics Simulations at GDC 2015 (here's a PDF version of the presentation) gives a solid overview of a physics step collision detection-wise, and may help you figure out an approach that works best for your needs.

• Note that OP is trying to use convex-only collision detection without checking per-triangle of a mesh in the narrow phase. They're also working in 2D, not 3D. Commented Apr 8 at 16:07
• I think you misunderstood the question. I am doing a multithreaded broad phase using spacial partitioning and bounding circles, which are invariant to rotation. My concern is with regards to the narrow phase - and concave vs concave shape in particular. I can create the collision manifold by running the SAT between every pair of triangles from the original polygon, but I wonder if there's a more economical fashion to break up the polygon. Commented Apr 9 at 21:50