panzhiyi3
12-04-2010 09:56:19
mCurrStage=new OgreMaxScene(); //I'm using OgreMax
// Create a new OgreNewt physics world and set some basic configuration options, initialise debugger
mWorld=new World();
mWorld->setWorldSize(Ogre::Vector3(-500, -500, -500), Ogre::Vector3(500, 500, 500));
mWorld->setSolverModel(1);
mWorld->setThreadCount(1);
mWorld->getDebugger().init(mSceneMgr);Then I creat some bodies.When I press a key,the whole scene will be destroyed so that I can load a new scene.
if (mInputDevice->isKeyDown(KC_A))
{
if(mGame)
{
mRoot->removeFrameListener(mGame);
delete mGame; //Code:delete mCurrStage; mWorld->getDebugger().deInit(); delete mWorld;
mGame=0;
//mSceneMgr->clearScene(); //We can't destroy scene nodes
Ogre::SceneManager::MovableObjectIterator it=mSceneMgr->getMovableObjectIterator("Entity");
while(it.hasMoreElements())
{
MovableObject *obj=it.getNext();
mSceneMgr->destroySceneNode(obj->getParentSceneNode()); //this causes the problem!
mSceneMgr->destroyMovableObject(obj);
}
mSceneMgr->destroyAllLights();
mSceneMgr->destroyAllEntities();
mSceneMgr->destroyAllManualObjects();
}
}When I try to destroy my scene nodes,the program will crash,where is the problem?