Back
· 2 min read
Concave 2D colliders
Splitting a concave polygon into multiple polygons that overlap for better physics results and stability.
- Dragos Balaur
Now, concave polygons are split into multiple polygons that overlap for better physics results and stability.
Cutting a polygon used to leave seams, where small objects could get stuck. Erin Catto's Stuck Inside article explains about overlaps the pieces by hand. This does it automatically.
overlap is configurable, 0.9 by default (it leaves a bit of empty room). At 0 you get the plain cut.

Performance
What the times look like (at build time):
| kind | ns | result |
|---|---|---|
| trimesh | 118 | still inside |
| convex_decomposition, overlap 0 | 187 | still inside |
| convex_decomposition, overlap 0.9 | 367 | out |
- A trimesh is the cheaper static collider when bodies only touch it from outside. This kind is for dynamic bodies.
Also
- Mass comes from the ungrown pieces, so a table weighs what its area says.
- A solids-mode Godot
CollisionPolygon2Dimports as this kind. geometry2d.convex_decompositionhands the pieces to a script.