So, I have a scenario in a Box2D project where a sensor "eye" (basically a line) collides with one or more objects, and I want to find the one that's closest to the bottom of the eye. This means that for each fixture colliding with the eye, I'd like to find the point(s) of collision, so that I can choose the closest point.
Right now, my code is structured to store a list of eyes and the things that collide with them in my contact listener's BeginContact
, and to remove the appropriate stuff in EndContact
. I'm planning to loop through this list once a timestep.
My question:
How would one best find points of collision outside of a contact listener? From what I can tell, the b2Contact
s provided in BeginContact
and EndContact
don't persist, so I can't use the contact manifold they provide. Is looping through the eye's contact list my best bet?
Thanks!
Using Kripken's box2djs.