mistigrii33
27-11-2011 21:55:11
Hi,
I'm using the latest Critter release with BuggySwires
I wanted to delete a Critter::Body, and i got the folowing problem : the body is being deleted in PhysX, but not in Ogre ! The Ogre mesh still being visible in the world.
After taking a look at Critter, i found the problem come from the Critter::Node destructor ;
Because the destroyNode is only called when mNodeBehaviour == Enums::SceneNodeDestructorBehaviour_Destroy and because mNodeBehaviour is never initialize anywhere, the destroyNode will never be called.
If you want to reproduce the bug, here is a simple code :
To make the Node destruction works, i initialize this mNodeBehaviour variable in both constructors:
What's the aim of this NodeBehaviour ? Is it for futur release ?
I'm using the latest Critter release with BuggySwires
I wanted to delete a Critter::Body, and i got the folowing problem : the body is being deleted in PhysX, but not in Ogre ! The Ogre mesh still being visible in the world.
After taking a look at Critter, i found the problem come from the Critter::Node destructor ;
Node::~Node()
{
if (mNodeBehaviour == Enums::SceneNodeDestructorBehaviour_Destroy)
{
destroyNode(mNode);
}mNode = 0;
}
Because the destroyNode is only called when mNodeBehaviour == Enums::SceneNodeDestructorBehaviour_Destroy and because mNodeBehaviour is never initialize anywhere, the destroyNode will never be called.
If you want to reproduce the bug, here is a simple code :
Critter::BodyDescription bodyDesc;
bodyDesc.mMass = 10.0f;
bodyDesc.mGroup = Objects;
NxOgre::BoxDescription boxDesc;
boxDesc.mSize.set(10,10,10);
Critter::Body* b = mRenderSystem->createBody(boxDesc, NxOgre::Vec3(0, 100, 0), "ogrehead.mesh", bodyDesc);
mRenderSystem->destroyBody(b);
// from here you still have the ogrehead in Ogre ! (The SceneNode created by Critter isn't destroyed)
To make the Node destruction works, i initialize this mNodeBehaviour variable in both constructors:
Node::Node(Ogre::SceneManager* scene_mgr, RenderSystem* renderSys)
: mSceneMgr(scene_mgr), mRenderSystem(renderSys)
{
mNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
mNodeBehaviour = Enums::SceneNodeDestructorBehaviour_Destroy;
}
Node::Node(Ogre::SceneManager* scene_mgr, Ogre::SceneNode* parent, RenderSystem* renderSys)
: mSceneMgr(scene_mgr), mRenderSystem(renderSys)
{
mNode = parent->createChildSceneNode();
mNodeBehaviour = Enums::SceneNodeDestructorBehaviour_Destroy;
}
What's the aim of this NodeBehaviour ? Is it for futur release ?