mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Code cleanup and more cache clearing
This commit is contained in:
parent
679a284735
commit
979b0d7211
11 changed files with 40 additions and 29 deletions
|
@ -1220,29 +1220,31 @@ void CSMWorld::Data::assetsChanged()
|
|||
{
|
||||
mVFS->rebuildIndex();
|
||||
|
||||
ResourceTable* meshTable = static_cast<ResourceTable*>(getTableModel(UniversalId::Type_Meshes));
|
||||
ResourceTable* iconTable = static_cast<ResourceTable*>(getTableModel(UniversalId::Type_Icons));
|
||||
ResourceTable* musicTable = static_cast<ResourceTable*>(getTableModel(UniversalId::Type_Musics));
|
||||
ResourceTable* soundResTable = static_cast<ResourceTable*>(getTableModel(UniversalId::Type_SoundsRes));
|
||||
ResourceTable* texTable = static_cast<ResourceTable*>(getTableModel(UniversalId::Type_Textures));
|
||||
ResourceTable* vidTable = static_cast<ResourceTable*>(getTableModel(UniversalId::Type_Videos));
|
||||
const UniversalId assetTableIds[] = {
|
||||
UniversalId::Type_Meshes,
|
||||
UniversalId::Type_Icons,
|
||||
UniversalId::Type_Musics,
|
||||
UniversalId::Type_SoundsRes,
|
||||
UniversalId::Type_Textures,
|
||||
UniversalId::Type_Videos
|
||||
};
|
||||
|
||||
meshTable->beginReset();
|
||||
iconTable->beginReset();
|
||||
musicTable->beginReset();
|
||||
soundResTable->beginReset();
|
||||
texTable->beginReset();
|
||||
vidTable->beginReset();
|
||||
size_t numAssetTables = sizeof(assetTableIds) / sizeof(UniversalId);
|
||||
|
||||
for (size_t i = 0; i < numAssetTables; ++i)
|
||||
{
|
||||
ResourceTable* table = static_cast<ResourceTable*>(getTableModel(assetTableIds[i]));
|
||||
table->beginReset();
|
||||
}
|
||||
|
||||
// Trigger recreation
|
||||
mResourcesManager.recreateResources();
|
||||
|
||||
meshTable->endReset();
|
||||
iconTable->endReset();
|
||||
musicTable->endReset();
|
||||
soundResTable->endReset();
|
||||
texTable->endReset();
|
||||
vidTable->endReset();
|
||||
for (size_t i = 0; i < numAssetTables; ++i)
|
||||
{
|
||||
ResourceTable* table = static_cast<ResourceTable*>(getTableModel(assetTableIds[i]));
|
||||
table->endReset();
|
||||
}
|
||||
|
||||
// Get rid of potentially old cached assets
|
||||
mResourceSystem->clearCache();
|
||||
|
|
|
@ -896,7 +896,6 @@ void CSVDoc::View::addMetaDataSubView()
|
|||
addSubView (CSMWorld::UniversalId (CSMWorld::UniversalId::Type_MetaData, "sys::meta"));
|
||||
}
|
||||
|
||||
|
||||
void CSVDoc::View::abortOperation (int type)
|
||||
{
|
||||
mDocument->abortOperation (type);
|
||||
|
|
|
@ -294,7 +294,6 @@ void CSVRender::Cell::reloadAssets()
|
|||
if (mTerrain)
|
||||
{
|
||||
mTerrain->unloadCell(mCoordinates.getX(), mCoordinates.getY());
|
||||
mTerrain->clearCache();
|
||||
mTerrain->loadCell(mCoordinates.getX(), mCoordinates.getY());
|
||||
}
|
||||
|
||||
|
|
|
@ -190,6 +190,13 @@ void BulletShapeManager::updateCache(double referenceTime)
|
|||
mInstanceCache->removeUnreferencedObjectsInCache();
|
||||
}
|
||||
|
||||
void BulletShapeManager::clearCache()
|
||||
{
|
||||
ResourceManager::clearCache();
|
||||
|
||||
mInstanceCache->clear();
|
||||
}
|
||||
|
||||
void BulletShapeManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const
|
||||
{
|
||||
stats->setAttribute(frameNumber, "Shape", mCache->getCacheSize());
|
||||
|
|
|
@ -42,6 +42,8 @@ namespace Resource
|
|||
/// @see ResourceManager::updateCache
|
||||
virtual void updateCache(double referenceTime);
|
||||
|
||||
virtual void clearCache();
|
||||
|
||||
void reportStats(unsigned int frameNumber, osg::Stats *stats) const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -43,6 +43,12 @@ namespace Resource
|
|||
objectsToRemove.clear();
|
||||
}
|
||||
|
||||
void MultiObjectCache::clear()
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
||||
_objectCache.clear();
|
||||
}
|
||||
|
||||
void MultiObjectCache::addEntryToObjectCache(const std::string &filename, osg::Object *object)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
||||
|
|
|
@ -25,6 +25,9 @@ namespace Resource
|
|||
|
||||
void removeUnreferencedObjectsInCache();
|
||||
|
||||
/** Remove all objects from the cache. */
|
||||
void clear();
|
||||
|
||||
void addEntryToObjectCache(const std::string& filename, osg::Object* object);
|
||||
|
||||
/** Take an Object from cache. Return NULL if no object found. */
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace Resource
|
|||
void updateCache(double referenceTime);
|
||||
|
||||
/// Indicates to each resource manager to clear the entire cache.
|
||||
/// @note May be called from any thread if you do not add or remove resource managers at that point.
|
||||
void clearCache();
|
||||
|
||||
/// Add this ResourceManager to be handled by the ResourceSystem.
|
||||
|
|
|
@ -723,6 +723,7 @@ namespace Resource
|
|||
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mSharedStateMutex);
|
||||
mSharedStateManager->clearCache();
|
||||
mInstanceCache->clear();
|
||||
}
|
||||
|
||||
void SceneManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const
|
||||
|
|
|
@ -70,12 +70,6 @@ float World::getHeightAt(const osg::Vec3f &worldPos)
|
|||
return mStorage->getHeightAt(worldPos);
|
||||
}
|
||||
|
||||
void World::clearCache()
|
||||
{
|
||||
mTextureManager->clearCache();
|
||||
mChunkManager->clearCache();
|
||||
}
|
||||
|
||||
void World::updateTextureFiltering()
|
||||
{
|
||||
mTextureManager->updateTextureFiltering();
|
||||
|
|
|
@ -67,9 +67,6 @@ namespace Terrain
|
|||
/// @note Thread safe.
|
||||
virtual void cacheCell(View* view, int x, int y) {}
|
||||
|
||||
/// Clears cached texture and chunk data.
|
||||
virtual void clearCache();
|
||||
|
||||
/// Load the cell into the scene graph.
|
||||
/// @note Not thread safe.
|
||||
/// @note May be ignored by derived implementations that don't organize the terrain into cells.
|
||||
|
|
Loading…
Reference in a new issue