Prozi / detect-collisions

Detect collisions between different shapes such as Points, Lines, Boxes, Polygons (including concave), Ellipses, and Circles. Features include RayCasting and support for offsets, rotation, scaling, bounding box padding, with options for static and trigger bodies (non-colliding).
https://prozi.github.io/detect-collisions/
MIT License
202 stars 21 forks source link

Simple aInB for polygons #34

Closed Codezilluh closed 2 years ago

Codezilluh commented 2 years ago

I don't know if I went about this in the right way, but I might've :)

Uses AABB for aInB for polygons. Polygon aInB used to always return true, so this is "better than nothing." It does have it's flaws (specifically for concave polygons) but gets the job done.

This just treats both elements as boxes:

image

Codezilluh commented 2 years ago

Something I did just consider is that we should probably check !a.isConvex and !b.isConvex so we don't override convex Polygon on Circle aInB. However, I don't think Polygon on Polygon has an aInB. So maybe something else needs to be done.