mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-20 14:23:53 +00:00
Fix crash when disabling objects in a previously loaded cell, then coming back to that cell and leaving again
This commit is contained in:
parent
c1ec16986b
commit
547f77031d
3 changed files with 23 additions and 16 deletions
|
@ -94,6 +94,9 @@ void Actors::insertActivator (const MWWorld::Ptr& ptr)
|
|||
|
||||
bool Actors::deleteObject (const MWWorld::Ptr& ptr)
|
||||
{
|
||||
if (mAllActors.find(ptr) == mAllActors.end())
|
||||
return false;
|
||||
|
||||
mRendering->removeWaterRippleEmitter (ptr);
|
||||
|
||||
delete mAllActors[ptr];
|
||||
|
@ -139,6 +142,7 @@ void Actors::removeCell(MWWorld::Ptr::CellStore* store)
|
|||
Ogre::SceneNode *base = celliter->second;
|
||||
base->removeAndDestroyAllChildren();
|
||||
mRend.getScene()->destroySceneNode(base);
|
||||
|
||||
mCellSceneNodes.erase(celliter);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ namespace ESM
|
|||
|
||||
namespace MWWorld
|
||||
{
|
||||
/// List all (Ogre-)handles.
|
||||
struct ListHandles
|
||||
/// List all (Ogre-)handles, then reset RefData::mBaseNode to 0.
|
||||
struct ListAndResetHandles
|
||||
{
|
||||
std::vector<Ogre::SceneNode*> mHandles;
|
||||
|
||||
|
@ -23,6 +23,8 @@ namespace MWWorld
|
|||
Ogre::SceneNode* handle = data.getBaseNode();
|
||||
if (handle)
|
||||
mHandles.push_back (handle);
|
||||
|
||||
data.setBaseNode(0);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -76,27 +76,28 @@ namespace MWWorld
|
|||
void Scene::unloadCell (CellStoreCollection::iterator iter)
|
||||
{
|
||||
std::cout << "Unloading cell\n";
|
||||
ListHandles functor;
|
||||
ListAndResetHandles functor;
|
||||
|
||||
(*iter)->forEach<ListHandles>(functor);
|
||||
(*iter)->forEach<ListAndResetHandles>(functor);
|
||||
{
|
||||
// silence annoying g++ warning
|
||||
for (std::vector<Ogre::SceneNode*>::const_iterator iter2 (functor.mHandles.begin());
|
||||
iter2!=functor.mHandles.end(); ++iter2){
|
||||
Ogre::SceneNode* node = *iter2;
|
||||
iter2!=functor.mHandles.end(); ++iter2)
|
||||
{
|
||||
Ogre::SceneNode* node = *iter2;
|
||||
mPhysics->removeObject (node->getName());
|
||||
}
|
||||
}
|
||||
|
||||
if ((*iter)->mCell->isExterior())
|
||||
{
|
||||
ESM::Land* land =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search(
|
||||
(*iter)->mCell->getGridX(),
|
||||
(*iter)->mCell->getGridY()
|
||||
);
|
||||
if (land)
|
||||
mPhysics->removeHeightField( (*iter)->mCell->getGridX(), (*iter)->mCell->getGridY() );
|
||||
}
|
||||
if ((*iter)->mCell->isExterior())
|
||||
{
|
||||
ESM::Land* land =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search(
|
||||
(*iter)->mCell->getGridX(),
|
||||
(*iter)->mCell->getGridY()
|
||||
);
|
||||
if (land)
|
||||
mPhysics->removeHeightField( (*iter)->mCell->getGridX(), (*iter)->mCell->getGridY() );
|
||||
}
|
||||
|
||||
mRendering.removeCell(*iter);
|
||||
|
|
Loading…
Reference in a new issue