mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 21:19:40 +00:00
Clear cached resources
This commit is contained in:
parent
d31ed83b54
commit
742bd00ec6
5 changed files with 24 additions and 0 deletions
|
@ -1244,6 +1244,9 @@ void CSMWorld::Data::assetsChanged()
|
||||||
soundResTable->endReset();
|
soundResTable->endReset();
|
||||||
texTable->endReset();
|
texTable->endReset();
|
||||||
vidTable->endReset();
|
vidTable->endReset();
|
||||||
|
|
||||||
|
// Get rid of potentially old cached assets
|
||||||
|
mResourceSystem->clearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::Data::dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
void CSMWorld::Data::dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
||||||
|
|
|
@ -23,6 +23,11 @@ namespace Resource
|
||||||
mCache->removeExpiredObjectsInCache(referenceTime - mExpiryDelay);
|
mCache->removeExpiredObjectsInCache(referenceTime - mExpiryDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResourceManager::clearCache()
|
||||||
|
{
|
||||||
|
mCache->clear();
|
||||||
|
}
|
||||||
|
|
||||||
void ResourceManager::setExpiryDelay(double expiryDelay)
|
void ResourceManager::setExpiryDelay(double expiryDelay)
|
||||||
{
|
{
|
||||||
mExpiryDelay = expiryDelay;
|
mExpiryDelay = expiryDelay;
|
||||||
|
|
|
@ -28,6 +28,9 @@ namespace Resource
|
||||||
/// Clear cache entries that have not been referenced for longer than expiryDelay.
|
/// Clear cache entries that have not been referenced for longer than expiryDelay.
|
||||||
virtual void updateCache(double referenceTime);
|
virtual void updateCache(double referenceTime);
|
||||||
|
|
||||||
|
/// Clear all cache entries.
|
||||||
|
virtual void clearCache();
|
||||||
|
|
||||||
/// How long to keep objects in cache after no longer being referenced.
|
/// How long to keep objects in cache after no longer being referenced.
|
||||||
void setExpiryDelay (double expiryDelay);
|
void setExpiryDelay (double expiryDelay);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <osgDB/Registry>
|
||||||
|
|
||||||
#include "scenemanager.hpp"
|
#include "scenemanager.hpp"
|
||||||
#include "imagemanager.hpp"
|
#include "imagemanager.hpp"
|
||||||
#include "niffilemanager.hpp"
|
#include "niffilemanager.hpp"
|
||||||
|
@ -68,6 +70,14 @@ namespace Resource
|
||||||
(*it)->updateCache(referenceTime);
|
(*it)->updateCache(referenceTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResourceSystem::clearCache()
|
||||||
|
{
|
||||||
|
for (std::vector<ResourceManager*>::iterator it = mResourceManagers.begin(); it != mResourceManagers.end(); ++it)
|
||||||
|
(*it)->clearCache();
|
||||||
|
|
||||||
|
osgDB::Registry::instance()->clearObjectCache();
|
||||||
|
}
|
||||||
|
|
||||||
void ResourceSystem::addResourceManager(ResourceManager *resourceMgr)
|
void ResourceSystem::addResourceManager(ResourceManager *resourceMgr)
|
||||||
{
|
{
|
||||||
mResourceManagers.push_back(resourceMgr);
|
mResourceManagers.push_back(resourceMgr);
|
||||||
|
|
|
@ -41,6 +41,9 @@ namespace Resource
|
||||||
/// @note May be called from any thread if you do not add or remove resource managers at that point.
|
/// @note May be called from any thread if you do not add or remove resource managers at that point.
|
||||||
void updateCache(double referenceTime);
|
void updateCache(double referenceTime);
|
||||||
|
|
||||||
|
/// Indicates to each resource manager to clear the entire cache.
|
||||||
|
void clearCache();
|
||||||
|
|
||||||
/// Add this ResourceManager to be handled by the ResourceSystem.
|
/// Add this ResourceManager to be handled by the ResourceSystem.
|
||||||
/// @note Does not transfer ownership.
|
/// @note Does not transfer ownership.
|
||||||
void addResourceManager(ResourceManager* resourceMgr);
|
void addResourceManager(ResourceManager* resourceMgr);
|
||||||
|
|
Loading…
Reference in a new issue