Detecting mouse cursor collisions without moving bodies

Topics: Developer Forum, User Forum
May 10, 2013 at 9:30 AM
I'm working on a game engine, and I'm currently trying to figure out how to make an editor that switches seamlessly between gameplay and editing.

Currently I freeze the world (for editing) by stopping calls to World.Update(). The problem I'm having is that this prevents Farseer from detecting collisions between the bodies of the world and the cursor's sensor body.

I currently detect collisions with the cursor by doing
cursor.body.OnCollision += new OnCollisionEventHandler(worldSensor_OnCollision);
Where I then find the body with fixtureB.Body.BodyId.

How can I select bodies by their collision mesh without moving the world?
May 10, 2013 at 6:30 PM
That's a tough one. I'm thinking the easiest way to do it would to be to just detect the collisions manually. If you don't need too much precision, you can just loop through the bodies in the world, get their bounding rectangle (I think it's called AABB or some such) and manually check Rect.Intersects with your mouse cursor body.

Hope that helps,
Mike.
May 12, 2013 at 6:27 PM
I thought I was just being dense, but I guess this isn't a supported thing. So I followed your advice.
I use Fixture.TestPoint() on all fixtures of all bodies and it works great.
Guess I can tolerate the performance inefficiency since it's only for the editor...

Thanks!