mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 15:09:39 +00:00
Clear terrain cache and reload terrain
This commit is contained in:
parent
d4a722067d
commit
3b9326d238
7 changed files with 39 additions and 0 deletions
|
@ -291,6 +291,13 @@ void CSVRender::Cell::reloadAssets()
|
||||||
iter->second->reloadAssets();
|
iter->second->reloadAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mTerrain)
|
||||||
|
{
|
||||||
|
mTerrain->unloadCell(mCoordinates.getX(), mCoordinates.getY());
|
||||||
|
mTerrain->clearCache();
|
||||||
|
mTerrain->loadCell(mCoordinates.getX(), mCoordinates.getY());
|
||||||
|
}
|
||||||
|
|
||||||
mCellWater->reloadAssets();
|
mCellWater->reloadAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,4 +231,16 @@ namespace Terrain
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BufferCache::clearCache()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mIndexBufferMutex);
|
||||||
|
mIndexBufferMap.clear();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mUvBufferMutex);
|
||||||
|
mUvBufferMap.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ namespace Terrain
|
||||||
/// @note Thread safe.
|
/// @note Thread safe.
|
||||||
osg::ref_ptr<osg::Vec2Array> getUVBuffer(unsigned int numVerts);
|
osg::ref_ptr<osg::Vec2Array> getUVBuffer(unsigned int numVerts);
|
||||||
|
|
||||||
|
void clearCache();
|
||||||
|
|
||||||
// TODO: add releaseGLObjects() for our vertex/element buffer objects
|
// TODO: add releaseGLObjects() for our vertex/element buffer objects
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -55,6 +55,13 @@ void ChunkManager::reportStats(unsigned int frameNumber, osg::Stats *stats) cons
|
||||||
stats->setAttribute(frameNumber, "Terrain Chunk", mCache->getCacheSize());
|
stats->setAttribute(frameNumber, "Terrain Chunk", mCache->getCacheSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChunkManager::clearCache()
|
||||||
|
{
|
||||||
|
ResourceManager::clearCache();
|
||||||
|
|
||||||
|
mBufferCache.clearCache();
|
||||||
|
}
|
||||||
|
|
||||||
void ChunkManager::setCullingActive(bool active)
|
void ChunkManager::setCullingActive(bool active)
|
||||||
{
|
{
|
||||||
mCullingActive = active;
|
mCullingActive = active;
|
||||||
|
|
|
@ -34,6 +34,8 @@ namespace Terrain
|
||||||
|
|
||||||
virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const;
|
virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const;
|
||||||
|
|
||||||
|
virtual void clearCache();
|
||||||
|
|
||||||
void setCullingActive(bool active);
|
void setCullingActive(bool active);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -70,6 +70,12 @@ float World::getHeightAt(const osg::Vec3f &worldPos)
|
||||||
return mStorage->getHeightAt(worldPos);
|
return mStorage->getHeightAt(worldPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::clearCache()
|
||||||
|
{
|
||||||
|
mTextureManager->clearCache();
|
||||||
|
mChunkManager->clearCache();
|
||||||
|
}
|
||||||
|
|
||||||
void World::updateTextureFiltering()
|
void World::updateTextureFiltering()
|
||||||
{
|
{
|
||||||
mTextureManager->updateTextureFiltering();
|
mTextureManager->updateTextureFiltering();
|
||||||
|
|
|
@ -67,6 +67,9 @@ namespace Terrain
|
||||||
/// @note Thread safe.
|
/// @note Thread safe.
|
||||||
virtual void cacheCell(View* view, int x, int y) {}
|
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.
|
/// Load the cell into the scene graph.
|
||||||
/// @note Not thread safe.
|
/// @note Not thread safe.
|
||||||
/// @note May be ignored by derived implementations that don't organize the terrain into cells.
|
/// @note May be ignored by derived implementations that don't organize the terrain into cells.
|
||||||
|
|
Loading…
Reference in a new issue