schteppe / p2.js

JavaScript 2D physics library
Other
2.64k stars 330 forks source link

Fix to narrowphase.bodiesOverlap() to make sure shapes are passed into collision methods in the right order #256

Closed rejemy closed 8 years ago

rejemy commented 8 years ago

I ran into a crash calling narrowphase.bodiesOverlap() this morning that was due to Narrowphase.prototype.circleConvex being called with the convex being passed in as the circle shape, and the circle shape being passed in as the convex parameters. After looking around in the code, I couldn't figure out what should be preventing this from happening but couldn't find anything. Maybe I'm missing something, but this seems like this bug should happen pretty much half the time mixed collider shapes are tested for overlap. I forked and fixed the issue by checking which order the shapes are expected to be passed into the narrowphase collider function. I'm making a pull request for this in case it's useful to anyone else someday.

schteppe commented 8 years ago

Great, thanks! It's for sure useful!