This project has moved and is read-only. For the latest updates, please go here.

Body/Geometry Removal

Topics: Developer Forum, Project Management Forum, User Forum
Apr 1, 2008 at 6:31 AM
Edited Apr 1, 2008 at 6:32 AM
Hi everyone. First of all I must say this is a great engine.

I am having some problems with removing a body and its geometry from the physics simulator. I have tried a LOT of ways to remove it. I am running this on the XBOX 360, so I don't know if it is exclusive to that (I'll try it on the PC tomorrow). I'm using newest version of Farseer.

So basically what is happening is that I have a "switch" object, and when the player is intersecting it and the press the button, it is supposed to delete some body and geometry. When I enabled the debug view, it looks like there are 2 instances of the body and geometry in the physics simulator. When I press the switch, the thickness of the square decreases, but still exists, so I think there are multiple copies of it. I searched on the forums for similar threads, and found one. It suggested that I use a different BroadPhaseCollision type such as brute force or selective sweep and prune, I tried all and they still do the same thing. Here is my code to get rid of them geometry and body:

bodyList0.Enabled = false;

I looked through my code to see where I am adding objects to the physics simulator and there are no duplicates of adding the same object. I looked at all the other code in my project, and compared they ways I create the geometries and bodies, and they are the same format. I'm really stumped about this....

Anyone have an idea for a solution?

edit : Those 0 links are the square brackets with 0's in them
Apr 1, 2008 at 12:36 PM
Hmm, strange.

Are bodyList and geomList your objects?

You should be able to do this with a single call body.Dispose() This should dispose the body internally in the engine, which in turn will dispose any attached geoms, and finally the engine should automatically remove it from ths list.

I have found some issues with a the broad phase collider where they were holding on to a geom and keeping it from being removed somehow.. I haven't investigated that yet. The BruteForce collider should not have this issue.

Do you have a demo you could post, preferably with code.
Apr 1, 2008 at 1:18 PM
Hey crashlander.

I figured out the problem. I had an extra LoadContent() call in my code, and that is where all the geometry and bodies were created. Now it works perfectly.