1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00

Clean up wasn't done properly when deleting a Cell.

This commit is contained in:
gugus 2011-05-23 20:22:12 +02:00
parent faaa08d6d0
commit c7fb27e801
2 changed files with 31 additions and 0 deletions

View File

@ -224,6 +224,7 @@ void ExteriorCellRender::insertMesh(const std::string &mesh)
{
sg->addEntity(ent,mInsert->_getDerivedPosition(),mInsert->_getDerivedOrientation(),mInsert->_getDerivedScale());
sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000));
mScene.getMgr()->destroyEntity(ent);
}
if (mInsertMesh.empty())
mInsertMesh = mesh;
@ -363,10 +364,38 @@ void ExteriorCellRender::hide()
mBase->setVisible(false);
}
void ExteriorCellRender::destroyAllAttachedMovableObjects(Ogre::SceneNode* i_pSceneNode)
{
if ( !i_pSceneNode )
{
assert( false );
return;
}
// Destroy all the attached objects
SceneNode::ObjectIterator itObject = i_pSceneNode->getAttachedObjectIterator();
while ( itObject.hasMoreElements() )
{
MovableObject* pObject = static_cast<MovableObject*>(itObject.getNext());
i_pSceneNode->getCreator()->destroyMovableObject( pObject );
}
// Recurse to child SceneNodes
SceneNode::ChildNodeIterator itChild = i_pSceneNode->getChildIterator();
while ( itChild.hasMoreElements() )
{
SceneNode* pChildNode = static_cast<SceneNode*>(itChild.getNext());
destroyAllAttachedMovableObjects( pChildNode );
}
}
void ExteriorCellRender::destroy()
{
if(mBase)
{
destroyAllAttachedMovableObjects(mBase);
mBase->removeAndDestroyAllChildren();
mScene.getMgr()->destroySceneNode(mBase);
}

View File

@ -125,6 +125,8 @@ namespace MWRender
/// Remove the reference with the given handle permanently from the scene.
virtual void deleteObject (const std::string& handle);
void destroyAllAttachedMovableObjects(Ogre::SceneNode* i_pSceneNode);
static int uniqueID;
};
}