replit/kaboom

Circle Shape Collider

peratik opened this issue · 2 comments

Hi,

How to add a circle shape collider?

I know area has a property for setting shape

But it seems circle colliders is not supported.

Yes, I have the same problem. https://kaboomjs.com/#AreaCompOpt - the documentation says that "currently only Rect and Polygon is supported".

Circle is not supported, but given that polygon is supported, I think you can just make the polygon in the shape of a circle.

The problem is that the SAT collision code only knows how to work with polygons. If this is fixed, circle areas can stay circle areas.
To fix it, you need to add code to find the polygon point (not vertex, point) closest to the circle and take the orthogonal to the line connecting that point and the circle center as projection axis. To find the point quickly, you need Voronoi partitioning of the polygon.