mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 09:15:38 +00:00
Fix issues on terrain change
terrain Preloader now preloads the right terrain
This commit is contained in:
parent
427b6ea39a
commit
7bc4fc6bf9
5 changed files with 43 additions and 23 deletions
|
@ -745,6 +745,7 @@ namespace MWRender
|
|||
|
||||
if (store->getCell()->isExterior())
|
||||
{
|
||||
enableTerrain(true, store->getCell()->getWorldSpace());
|
||||
mTerrain->loadCell(store->getCell()->getGridX(), store->getCell()->getGridY());
|
||||
}
|
||||
}
|
||||
|
@ -756,7 +757,8 @@ namespace MWRender
|
|||
|
||||
if (store->getCell()->isExterior())
|
||||
{
|
||||
mTerrain->unloadCell(store->getCell()->getGridX(), store->getCell()->getGridY());
|
||||
getWorldspaceTerrain(store->getCell()->getWorldSpace())
|
||||
->unloadCell(store->getCell()->getGridX(), store->getCell()->getGridY());
|
||||
}
|
||||
|
||||
mWater->removeCell(store);
|
||||
|
|
|
@ -238,26 +238,7 @@ namespace MWWorld
|
|||
|
||||
CellPreloader::~CellPreloader()
|
||||
{
|
||||
if (mTerrainPreloadItem)
|
||||
{
|
||||
mTerrainPreloadItem->abort();
|
||||
mTerrainPreloadItem->waitTillDone();
|
||||
mTerrainPreloadItem = nullptr;
|
||||
}
|
||||
|
||||
if (mUpdateCacheItem)
|
||||
{
|
||||
mUpdateCacheItem->waitTillDone();
|
||||
mUpdateCacheItem = nullptr;
|
||||
}
|
||||
|
||||
for (PreloadMap::iterator it = mPreloadCells.begin(); it != mPreloadCells.end(); ++it)
|
||||
it->second.mWorkItem->abort();
|
||||
|
||||
for (PreloadMap::iterator it = mPreloadCells.begin(); it != mPreloadCells.end(); ++it)
|
||||
it->second.mWorkItem->waitTillDone();
|
||||
|
||||
mPreloadCells.clear();
|
||||
clearAllTasks();
|
||||
}
|
||||
|
||||
void CellPreloader::preload(CellStore& cell, double timestamp)
|
||||
|
@ -458,4 +439,37 @@ namespace MWWorld
|
|||
&& contains(mLoadedTerrainPositions, std::array{ position }, ESM::Land::REAL_SIZE);
|
||||
}
|
||||
|
||||
void CellPreloader::setTerrain(Terrain::World* terrain)
|
||||
{
|
||||
if (terrain != mTerrain)
|
||||
{
|
||||
clearAllTasks();
|
||||
mTerrain = terrain;
|
||||
}
|
||||
}
|
||||
|
||||
void CellPreloader::clearAllTasks()
|
||||
{
|
||||
if (mTerrainPreloadItem)
|
||||
{
|
||||
mTerrainPreloadItem->abort();
|
||||
mTerrainPreloadItem->waitTillDone();
|
||||
mTerrainPreloadItem = nullptr;
|
||||
}
|
||||
|
||||
if (mUpdateCacheItem)
|
||||
{
|
||||
mUpdateCacheItem->waitTillDone();
|
||||
mUpdateCacheItem = nullptr;
|
||||
}
|
||||
|
||||
for (PreloadMap::iterator it = mPreloadCells.begin(); it != mPreloadCells.end(); ++it)
|
||||
it->second.mWorkItem->abort();
|
||||
|
||||
for (PreloadMap::iterator it = mPreloadCells.begin(); it != mPreloadCells.end(); ++it)
|
||||
it->second.mWorkItem->waitTillDone();
|
||||
|
||||
mPreloadCells.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,8 +74,11 @@ namespace MWWorld
|
|||
void syncTerrainLoad(Loading::Listener& listener);
|
||||
void abortTerrainPreloadExcept(const PositionCellGrid* exceptPos);
|
||||
bool isTerrainLoaded(const CellPreloader::PositionCellGrid& position, double referenceTime) const;
|
||||
void setTerrain(Terrain::World* terrain);
|
||||
|
||||
private:
|
||||
void clearAllTasks();
|
||||
|
||||
Resource::ResourceSystem* mResourceSystem;
|
||||
Resource::BulletShapeManager* mBulletShapeManager;
|
||||
Terrain::World* mTerrain;
|
||||
|
|
|
@ -571,7 +571,8 @@ namespace MWWorld
|
|||
mCurrentGridCenter = osg::Vec2i(playerCellX, playerCellY);
|
||||
osg::Vec4i newGrid = gridCenterToBounds(mCurrentGridCenter);
|
||||
mRendering.setActiveGrid(newGrid);
|
||||
|
||||
mRendering.enableTerrain(true, playerCellIndex.mWorldspace);
|
||||
mPreloader->setTerrain(mRendering.getTerrain());
|
||||
if (mRendering.pagingUnlockCache())
|
||||
mPreloader->abortTerrainPreloadExcept(nullptr);
|
||||
if (!mPreloader->isTerrainLoaded(std::make_pair(pos, newGrid), mRendering.getReferenceTime()))
|
||||
|
|
|
@ -284,7 +284,7 @@ namespace Terrain
|
|||
, mLodFactor(lodFactor)
|
||||
, mVertexLodMod(vertexLodMod)
|
||||
, mViewDistance(std::numeric_limits<float>::max())
|
||||
, mMinSize(1 / 8.f)
|
||||
, mMinSize(ESM::isEsm4Ext(worldspace) ? 1 / 4.f : 1 / 8.f)
|
||||
, mDebugTerrainChunks(debugChunks)
|
||||
{
|
||||
mChunkManager->setCompositeMapSize(compMapResolution);
|
||||
|
|
Loading…
Reference in a new issue