1. I have called PCZSceneNode::removeAndDestroyChild(terrainZone2->getEnclosureNode()->getName()) to remove it...
2. And then I tried PCZSceneManager::destroySceneNode(terrainZone2->getEnclosureNode()->getName()) after deleting all children with terrainZone2->getEnclosureNode()->removeAllChildren().
(And I deleted attached Entity too..)
Method 1. wasn't gonna crash.
Method 2. crashed it with new viewport(if I don't recreate viewport it wouldn't crash.)
Both didn't free the ZoneData.
I knew PCZSceneNode::~PCZSceneNode would free the ZoneData and that's why I tried deleting a PCZSceneNode in the first place...
But it seems like it doesn't work? And those two are only good removing methods I know about...
Sorry for asking but can you just give me working example of deleting a Zone?
I've done this:
name = terrainZone1.getEnclosureNode().getName()
root = pczSM.getRootSceneNode()
tSN = root.getChild(name)
It's in python but you get the idea, it's same as doing SceneNode::removeAndDestroyChild(name).
tSN.getCreator().destroySceneNode is correct PCZSceneNode::destroySceneNode(not SceneNode::destroySceneNode) and this function seems like not calling PCZSceneNode::~PCZSceneNode.
So, it wasn't freeing ZoneData, but it wouldn't crash anymore because I did root.removeChild(name) which is omitted from the previous method.
And I think the reason destructor of PCZSceneNode not being called is because PCZSceneNode::destroySceneNode calls SceneManager::destroySceneNode( name ); to delete it.
It gets casted as SceneNode*
typedef std::map<String, SceneNode*> SceneNodeList
void SceneManager::destroySceneNode(const String& name)
SceneNodeList::iterator i = mSceneNodes.find(name);
OGRE_DELETE i->second; // (i->second is SceneNode* not PCZSceneNode*)
yeah so to fix that, void PCZSceneManager::destroySceneNode( const String &name ) in OgrePCZSceneManager.cpp should be modified... unless you have another working method for deleting a zone, I wouldn't mind using that. Thanks...
PS2. Aww mSceneNodes is a protected member.
So, better way of doing it might be calling a PCZSceneNode's destructor directly(should work) or just rename that destructor to another function and call it.
void PCZSceneManager::destroySceneNode( const String &name )
SceneNode * on = ( getSceneNode( name ) );
if ( on != 0 )
// remove references to the node from zones
removeSceneNode( on );
// destroy the node
SceneManager::destroySceneNode( name );
a dirty hack but should work.