Deleting the scene manager

psychosmurf

21-09-2006 23:34:17

Hey guys I have been working on fliping out to the menu screen from a pause menu but it seems when I try to re-enter a state i have already been in it is crashing because that state already exsists and it is trying to recreate it. So in my exit function I am trying to destroy the scene manager but one of my team memebers in class said you can't do that because it will always crash out the game. Now we have tried two tings

here we try to destroy the scene manager:
mRoot->destroySceneManager(mSceneMgr);

and here we try to distroy the world
mWorld->destroyScene("Main");

neither of these work. Any suggestions?

DaCracker

22-09-2006 06:32:31

Just delete the mWorld pointer and it will
clean up all enteties and sceneManagers
for you :wink:

betajaen

22-09-2006 09:14:52

But then the PhysX SDK is re-launched, if you want to go through that route do it via a cleaner and safer way:

mWorld->reset();

As for the crashing I've fixed that problem (it was do with the scene vector) I can post the fix if you like.

psychosmurf

22-09-2006 14:22:45

a fix would be soooo sweet =p lol. you going to but a link up here or on the nxogre website? And thx for the responses guys.

betajaen

22-09-2006 15:13:26

Here. A CVS update right now would cause a lot of anger and hate (with a lot of a new file changes):

This is the manual scene deletion functionin world.cpp, In theory it should be different from yours:

bool world::destroyScene(Ogre::String _name) {

if (mScene.size() > 0) {
for(std::vector< nxOgre::scene* >::iterator i = mScene.begin();i != mScene.end();++i) {

if ((*i)->getName() == _name) {
delete (*i);
mScene.erase(i);
return true;
}

}
}


return false;
}

psychosmurf

22-09-2006 16:45:50

alright i put the code you posted into the nxogre_world.cpp and then recompiled. I moved the .dll over to the release folder. I am still getting the same error when i try to go back into the same world.

-----------------------------------
Details:
-----------------------------------
Error #: 6
Function: SceneManagerEnumerator::createSceneManager
Description: SceneManager instance called 'UrbanCityLevel' already exists.
File: \OgreDev\Dagon\OgreMain\src\OgreSceneManagerEnumerator.cpp
Line: 194
Stack unwinding: <<beginning of stack>>


now i tried using just the mWorld->reset(); and then the mWorld->destroyScene("Main")

tried even using both lol ... they both cause the same error when i try to reenter the world.

betajaen

22-09-2006 19:18:08

Thats an Ogre issue, your creating a SceneManager that already exists.

Reset only destroys the scenes not the SceneManagers. You should destroy the SceneManager after the reset.

psychosmurf

23-09-2006 18:08:33

hey, I have tried to use

this->mWorld->destroyScene();
mWorld->reset();
mRoot->destroySceneManager(mSceneMgr);

and they all crash out the program =( /cry

betajaen

23-09-2006 18:42:56

Where is it crashing though?

Use std::cout << "a" << std::endl; between the lines of code to check.

psychosmurf

23-09-2006 19:50:08

it is crashing when i try to call

mRoot->destroySceneManager(mSceneMgr);

:(

betajaen

23-09-2006 20:11:55

That's Ogre then, most likely it's in use or you have a pointer using it.

psychosmurf

23-09-2006 20:21:24

humm it is the last thing called in the exit method... what should i be doing here then? lol