Clear terrain cache and reload terrain

pull/280/head
Kyle Cooley 7 years ago
parent d4a722067d
commit 3b9326d238

@ -291,6 +291,13 @@ void CSVRender::Cell::reloadAssets()
iter->second->reloadAssets();
}
if (mTerrain)
{
mTerrain->unloadCell(mCoordinates.getX(), mCoordinates.getY());
mTerrain->clearCache();
mTerrain->loadCell(mCoordinates.getX(), mCoordinates.getY());
}
mCellWater->reloadAssets();
}

@ -231,4 +231,16 @@ namespace Terrain
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.
osg::ref_ptr<osg::Vec2Array> getUVBuffer(unsigned int numVerts);
void clearCache();
// TODO: add releaseGLObjects() for our vertex/element buffer objects
private:

@ -55,6 +55,13 @@ void ChunkManager::reportStats(unsigned int frameNumber, osg::Stats *stats) cons
stats->setAttribute(frameNumber, "Terrain Chunk", mCache->getCacheSize());
}
void ChunkManager::clearCache()
{
ResourceManager::clearCache();
mBufferCache.clearCache();
}
void ChunkManager::setCullingActive(bool active)
{
mCullingActive = active;

@ -34,6 +34,8 @@ namespace Terrain
virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const;
virtual void clearCache();
void setCullingActive(bool active);
private:

@ -70,6 +70,12 @@ float World::getHeightAt(const osg::Vec3f &worldPos)
return mStorage->getHeightAt(worldPos);
}
void World::clearCache()
{
mTextureManager->clearCache();
mChunkManager->clearCache();
}
void World::updateTextureFiltering()
{
mTextureManager->updateTextureFiltering();

@ -67,6 +67,9 @@ 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…
Cancel
Save