Destroying Objects in BloodyMess

FietsPomp

06-05-2009 13:23:32

I created a object.
mBody = mRenderSystem->createBody(new NxOgre::Box(1, 1, 1), NxOgre::Real3(position.x, position.y, position.z), "Blob_blue.mesh");
I like the object, its fine, it animates and stuff. But now i want to delete it.

So i look insize OGRE3DRenderSystem.h and see it has no removeBody() function.
So i thought.. maybe i need to delete it fromt the object itself.
So i look inside OGRE3DBody.h and see this:
/** \internal. Use OGRE3DRenderSystem::destroyBody
*/
~OGRE3DBody(void);


DestroyBody dosnt exist.
Do i have an old file here or is this just not yet implemented?

Btw betajean thanks for making this wrapper. Its pretty nice!

betajaen

06-05-2009 13:39:42

I noticed this a few weeks back too, It will be in the new release.

FietsPomp

06-05-2009 13:41:30

Im gonna throw them into infinity and recycle them but it would be nice if you could quick post the function?

Thanks for the quick reply.

betajaen

06-05-2009 19:52:52

void OGRE3DRenderSystem::destroyBody(OGRE3DBody* body)
{
if (body == 0 || body->getClassType() != _OGRE3DBody)
return;

mBodies.remove(body);

NxOgre_Delete(body);
}

FietsPomp

27-05-2009 12:25:23

To return on this.

This gives a problem. VS gives me a error because their are possible two getClassType() functions the body can pick...
(this could also be the way i implemented this code)

The other problem is that the body class does not remove itself from the Ogre scenes.
For people who also have this problem.
From:

OGRE3DBody::~OGRE3DBody()
{
// In here, we would clean up any rendering stuff.
// We leave the physics stuff to the Actors destructor.
}


to:

OGRE3DBody::~OGRE3DBody()
{
mSceneManager->destroySceneNode(mNode);
mSceneManager->destroyEntity(mEntity);
}

betajaen

27-05-2009 14:28:50

I introduced a lot of Ogre functions into the OGRERenderSystem in the next release of Mess. The new OGRE3DBody constructor is a bit more elaborate.

// Remove all attachments.
if (mNode->numAttachedObjects())
mNode->detachAllObjects();

// Destroy all child scenenodes.
if (mNode->numChildren())
mNode->removeAndDestroyAllChildren();

// Destroy this Scene node.
mNode->getParentSceneNode()->removeAndDestroyChild(mNode->getName());
mNode = 0;