Open wayfu opened 10 years ago
(ignore the orange lines at the top, those are just the path the player has taken)
You nailed it. There's no vertex overlap, which makes the check fail.
To make the convexConvex narrowphase catch this case, convex polygon clipping must be implemented. One algorithm that could be used is Sutherland-Hodgman. Not sure if it's the most performant choice though.
Until then, you could use circles, or experiment with other Shape types.
I have a feeling that there are more edge cases like this to be caught. All the Narrowphase methods should be looked over and double checked for the cases of large overlaps.
Ah, good to know. I'm using circles now, but I'm going to need that algo for something else, thanks for the link!
There are two more ideas I've had: I don't know how expensive line intersections are, but wouldn't convexConvex collisions happen if any edge of shape A crossed any edge of shape B? You'd just have to use lineLine and looks up code ehhhhhh ;)
Phaser has an implementation of line vs line (Phaser.Line.intersectsPoints), maybe you can crib that from their dev branch?
Or, is it possible to generate a temporary plane from the edge you are testing against, and use that for the collision detection? May even yield CCD...
Wait that's basically what Sutherland-Hodgman does :)
I'm looking at this page here... http://www.altdev.co/2011/05/13/contact-generation-between-3d-convex-meshes/ Not 100% sure how to generate the contact point offsets from the contact points in the general case (especially in the case where there's no vertex inside any of the convexes). But will look more into it.
Here's a screenshot of a physics situation:
http://i.imgur.com/tUKoGZC.png
When I look in the OverlapKeeper, I can see
... and that's it. The collision visually happening between the right rectangle and the right convex does not appear in the OverlapKeeper. I think it may be because despite the overlap, no single vertex is contained in the overlapping shape? I've narrowed the issue down to numContacts being returned as 0 from convexConvex, as far as I can tell.
Any tips on what's going wrong here? Should I move to circular shapes instead of rectangles?