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