Destroying bodies

wraith

19-07-2009 05:14:29

I'm just wondering if there's a "correct" way to dispose of bodies? I'm a little concerned about destroying them at the wrong time and causing errors. Right now I'm just using the RenderSystem to destroy them when I'm done.

OGRE3DRenderSystem::destroyBody(OGRE3DBody);

I've read in the Nx documentation that deleting bodies inside the contact report is inadvisable, so when should it be done? Is there something else that should be done instead?

betajaen

19-07-2009 12:32:43

You can destroy all RigidBodies (apart from StaticGeometries) when the scene isn't simulating; this includes any callbacks as a result of it. If you need to destroy a body during a callback (i.e. a missile hitting a building) then just make a note of the pointer somewhere and destroy it after PhysX is done with that particular frame.