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

Problem with removing connected body

Sep 2, 2012 at 12:24 PM


I'm using this code to remove body from world:;;


But if that body is connected to another body with revolute joint, after iterating through first world.step this exception is thrown:

System.NullReferenceException was unhandled
       at FarseerPhysics.Dynamics.Fixture.get_ShapeType()
       at FarseerPhysics.Dynamics.Contacts.Contact.Create(Fixture fixtureA, Int32 indexA, Fixture fixtureB, Int32 indexB)
       at FarseerPhysics.Dynamics.ContactManager.AddPair(FixtureProxy& proxyA, FixtureProxy& proxyB)
       at FarseerPhysics.Collision.DynamicTreeBroadPhase.UpdatePairs(BroadphaseDelegate callback)
       at FarseerPhysics.Dynamics.ContactManager.FindNewContacts()
       at FarseerPhysics.Dynamics.World.Step(Single dt)
       at PhysicsSandbox.GameStateManagement.GameplayScreen.Update(GameTime gameTime, Boolean otherScreenHasFocus, Boolean coveredByOtherScreen)


Not sure what's wrong. As far I know removebody from world may remove all fixtures and joints associated with that body. But it look like there is still an reference to it.



Sep 2, 2012 at 4:31 PM

If I call Step after removing of body (not 0 step)

Than exception will not be shown...

Still not sure what is good way to have ability to edit world, adding new bodies and removing while not performing steps..

Sep 10, 2012 at 12:02 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.