mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Move the deletion of PreloadItem to the worker thread
This commit is contained in:
parent
a1069dce3c
commit
eaeba4138b
@ -9,6 +9,7 @@
|
||||
#include <components/misc/resourcehelpers.hpp>
|
||||
#include <components/nifosg/nifloader.hpp>
|
||||
#include <components/terrain/world.hpp>
|
||||
#include <components/sceneutil/unrefqueue.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
@ -240,7 +241,15 @@ namespace MWWorld
|
||||
|
||||
void CellPreloader::notifyLoaded(CellStore *cell)
|
||||
{
|
||||
mPreloadCells.erase(cell);
|
||||
PreloadMap::iterator found = mPreloadCells.find(cell);
|
||||
if (found != mPreloadCells.end())
|
||||
{
|
||||
// do the deletion in the background thread
|
||||
if (found->second.mWorkItem)
|
||||
mUnrefQueue->push(mPreloadCells[cell].mWorkItem);
|
||||
|
||||
mPreloadCells.erase(found);
|
||||
}
|
||||
}
|
||||
|
||||
void CellPreloader::updateCache(double timestamp)
|
||||
@ -291,4 +300,9 @@ namespace MWWorld
|
||||
mWorkQueue = workQueue;
|
||||
}
|
||||
|
||||
void CellPreloader::setUnrefQueue(SceneUtil::UnrefQueue* unrefQueue)
|
||||
{
|
||||
mUnrefQueue = unrefQueue;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,11 @@ namespace Terrain
|
||||
class World;
|
||||
}
|
||||
|
||||
namespace SceneUtil
|
||||
{
|
||||
class UnrefQueue;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class CellStore;
|
||||
@ -51,11 +56,14 @@ namespace MWWorld
|
||||
|
||||
void setWorkQueue(osg::ref_ptr<SceneUtil::WorkQueue> workQueue);
|
||||
|
||||
void setUnrefQueue(SceneUtil::UnrefQueue* unrefQueue);
|
||||
|
||||
private:
|
||||
Resource::ResourceSystem* mResourceSystem;
|
||||
Resource::BulletShapeManager* mBulletShapeManager;
|
||||
Terrain::World* mTerrain;
|
||||
osg::ref_ptr<SceneUtil::WorkQueue> mWorkQueue;
|
||||
osg::ref_ptr<SceneUtil::UnrefQueue> mUnrefQueue;
|
||||
double mExpiryDelay;
|
||||
unsigned int mMinCacheSize;
|
||||
unsigned int mMaxCacheSize;
|
||||
|
@ -471,6 +471,7 @@ namespace MWWorld
|
||||
mPreloader.reset(new CellPreloader(rendering.getResourceSystem(), physics->getShapeManager(), rendering.getTerrain()));
|
||||
mPreloader->setWorkQueue(mRendering.getWorkQueue());
|
||||
|
||||
mPreloader->setUnrefQueue(rendering.getUnrefQueue());
|
||||
mPhysics->setUnrefQueue(rendering.getUnrefQueue());
|
||||
|
||||
rendering.getResourceSystem()->setExpiryDelay(Settings::Manager::getFloat("cache expiry delay", "Cells"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user