mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 09:23:53 +00:00
Changes to land creation, add ability to specifically clear terrain cache
This commit is contained in:
parent
ab607f3028
commit
2eacc2f093
5 changed files with 46 additions and 4 deletions
|
@ -77,27 +77,55 @@ bool CSVRender::Cell::addObjects (int start, int end)
|
||||||
|
|
||||||
void CSVRender::Cell::createLand()
|
void CSVRender::Cell::createLand()
|
||||||
{
|
{
|
||||||
|
// Cell is deleted
|
||||||
if (mDeleted)
|
if (mDeleted)
|
||||||
{
|
{
|
||||||
mTerrain.reset();
|
unloadLand();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setup land if available
|
||||||
const CSMWorld::IdCollection<CSMWorld::Land>& land = mData.getLand();
|
const CSMWorld::IdCollection<CSMWorld::Land>& land = mData.getLand();
|
||||||
int landIndex = land.searchId(mId);
|
int landIndex = land.searchId(mId);
|
||||||
if (landIndex != -1)
|
if (landIndex != -1 && !land.getRecord(mId).isDeleted())
|
||||||
{
|
{
|
||||||
const ESM::Land& esmLand = land.getRecord(mId).get();
|
const ESM::Land& esmLand = land.getRecord(mId).get();
|
||||||
|
|
||||||
if (esmLand.getLandData (ESM::Land::DATA_VHGT))
|
if (esmLand.getLandData (ESM::Land::DATA_VHGT))
|
||||||
{
|
{
|
||||||
mTerrain.reset(new Terrain::TerrainGrid(mCellNode, mCellNode, mData.getResourceSystem().get(), new TerrainStorage(mData), Mask_Terrain));
|
if (mTerrain)
|
||||||
|
{
|
||||||
|
mTerrain->unloadCell(mCoordinates.getX(), mCoordinates.getY());
|
||||||
|
mTerrain->clearAssociatedCaches();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mTerrain.reset(new Terrain::TerrainGrid(mCellNode, mCellNode,
|
||||||
|
mData.getResourceSystem().get(), new TerrainStorage(mData), Mask_Terrain));
|
||||||
|
}
|
||||||
|
|
||||||
mTerrain->loadCell(esmLand.mX, esmLand.mY);
|
mTerrain->loadCell(esmLand.mX, esmLand.mY);
|
||||||
|
|
||||||
mCellBorder.reset(new CellBorder(mCellNode, mCoordinates));
|
if (!mCellBorder)
|
||||||
|
mCellBorder.reset(new CellBorder(mCellNode, mCoordinates));
|
||||||
|
|
||||||
mCellBorder->buildShape(esmLand);
|
mCellBorder->buildShape(esmLand);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No land data
|
||||||
|
unloadLand();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::Cell::unloadLand()
|
||||||
|
{
|
||||||
|
if (mTerrain)
|
||||||
|
mTerrain->unloadCell(mCoordinates.getX(), mCoordinates.getY());
|
||||||
|
|
||||||
|
if (mCellBorder)
|
||||||
|
mCellBorder.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::string& id,
|
CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::string& id,
|
||||||
|
|
|
@ -73,6 +73,7 @@ namespace CSVRender
|
||||||
bool addObjects (int start, int end);
|
bool addObjects (int start, int end);
|
||||||
|
|
||||||
void createLand();
|
void createLand();
|
||||||
|
void unloadLand();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -400,18 +400,21 @@ void CSVRender::PagedWorldspaceWidget::landTextureDataChanged (const QModelIndex
|
||||||
{
|
{
|
||||||
for (auto cellIt : mCells)
|
for (auto cellIt : mCells)
|
||||||
cellIt.second->landTextureChanged(topLeft, bottomRight);
|
cellIt.second->landTextureChanged(topLeft, bottomRight);
|
||||||
|
flagAsModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::PagedWorldspaceWidget::landTextureAboutToBeRemoved (const QModelIndex& parent, int start, int end)
|
void CSVRender::PagedWorldspaceWidget::landTextureAboutToBeRemoved (const QModelIndex& parent, int start, int end)
|
||||||
{
|
{
|
||||||
for (auto cellIt : mCells)
|
for (auto cellIt : mCells)
|
||||||
cellIt.second->landTextureAboutToBeRemoved(parent, start, end);
|
cellIt.second->landTextureAboutToBeRemoved(parent, start, end);
|
||||||
|
flagAsModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::PagedWorldspaceWidget::landTextureAdded (const QModelIndex& parent, int start, int end)
|
void CSVRender::PagedWorldspaceWidget::landTextureAdded (const QModelIndex& parent, int start, int end)
|
||||||
{
|
{
|
||||||
for (auto cellIt : mCells)
|
for (auto cellIt : mCells)
|
||||||
cellIt.second->landTextureAdded(parent, start, end);
|
cellIt.second->landTextureAdded(parent, start, end);
|
||||||
|
flagAsModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -75,4 +75,10 @@ void World::updateTextureFiltering()
|
||||||
mTextureManager->updateTextureFiltering();
|
mTextureManager->updateTextureFiltering();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::clearAssociatedCaches()
|
||||||
|
{
|
||||||
|
mTextureManager->clearCache();
|
||||||
|
mChunkManager->clearCache();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,10 @@ namespace Terrain
|
||||||
|
|
||||||
float getHeightAt (const osg::Vec3f& worldPos);
|
float getHeightAt (const osg::Vec3f& worldPos);
|
||||||
|
|
||||||
|
/// Clears the cached land and landtexture data.
|
||||||
|
/// @note Thread safe.
|
||||||
|
virtual void clearAssociatedCaches();
|
||||||
|
|
||||||
/// Load a terrain cell at maximum LOD and store it in the View for later use.
|
/// Load a terrain cell at maximum LOD and store it in the View for later use.
|
||||||
/// @note Thread safe.
|
/// @note Thread safe.
|
||||||
virtual void cacheCell(View* view, int x, int y) {}
|
virtual void cacheCell(View* view, int x, int y) {}
|
||||||
|
|
Loading…
Reference in a new issue