Deleting more than one body [solved]

alienskull

09-11-2007 21:44:22

I'm not sure how to delete more than one body that is created from the same mesh.

Calling destroyBody requires a 'const NxString& name' and I'm not sure what to pass it. If I give it "myModel.mesh" then i can delete the first one but not any after that. So I thought I might have to pass it this:nxBody->getName() or thisnxBody->getNxActor()->getName()
but I'm still getting errors. Please help.

I'm not doing anything with batches.. this is for things that I have called createBody for multiple times using the same .mesh file such as:
mPhysicsScene->createBody( meshFileName, new NxOgre::ConvexShape( meshFileName ), Ogre::Vector3::ZERO, ap);

betajaen

09-11-2007 21:54:43

If you don't give a name for the body, then it automatically generates one based of the mesh name.

mScene->destroyActor(nxBody->getName());

See if that works, over destroyBody (although technically they are the same function). If that doesn't work make sure the "nxBody" pointer isn't zero or random, and it was passed onto when it was created.

alienskull

10-11-2007 17:11:41

Turns out it was my sloppy (first time) implementation of a singleton object that was causing it to pass nxBody as an invalid pointer so:mPhysicsScene->destroyBody( nxBody->getName() );
works perfectly.