mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
Clean up wasn't done properly when deleting a Cell.
This commit is contained in:
parent
faaa08d6d0
commit
c7fb27e801
@ -224,6 +224,7 @@ void ExteriorCellRender::insertMesh(const std::string &mesh)
|
|||||||
{
|
{
|
||||||
sg->addEntity(ent,mInsert->_getDerivedPosition(),mInsert->_getDerivedOrientation(),mInsert->_getDerivedScale());
|
sg->addEntity(ent,mInsert->_getDerivedPosition(),mInsert->_getDerivedOrientation(),mInsert->_getDerivedScale());
|
||||||
sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000));
|
sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000));
|
||||||
|
mScene.getMgr()->destroyEntity(ent);
|
||||||
}
|
}
|
||||||
if (mInsertMesh.empty())
|
if (mInsertMesh.empty())
|
||||||
mInsertMesh = mesh;
|
mInsertMesh = mesh;
|
||||||
@ -363,10 +364,38 @@ void ExteriorCellRender::hide()
|
|||||||
mBase->setVisible(false);
|
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()
|
void ExteriorCellRender::destroy()
|
||||||
{
|
{
|
||||||
if(mBase)
|
if(mBase)
|
||||||
{
|
{
|
||||||
|
destroyAllAttachedMovableObjects(mBase);
|
||||||
mBase->removeAndDestroyAllChildren();
|
mBase->removeAndDestroyAllChildren();
|
||||||
mScene.getMgr()->destroySceneNode(mBase);
|
mScene.getMgr()->destroySceneNode(mBase);
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,8 @@ namespace MWRender
|
|||||||
/// Remove the reference with the given handle permanently from the scene.
|
/// Remove the reference with the given handle permanently from the scene.
|
||||||
virtual void deleteObject (const std::string& handle);
|
virtual void deleteObject (const std::string& handle);
|
||||||
|
|
||||||
|
void destroyAllAttachedMovableObjects(Ogre::SceneNode* i_pSceneNode);
|
||||||
|
|
||||||
static int uniqueID;
|
static int uniqueID;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user