From dd7a2f22d1d792c52cf3356a60a2ce1add7bbf1a Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Sat, 9 Dec 2023 11:53:18 -0600 Subject: [PATCH] Cleanup(CSVRender::Cell:updateLand): Early exit when landscape should not be loaded --- apps/opencs/view/render/cell.cpp | 49 ++++++++++++++++---------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index 574b88f5c9..ec8fcc7e2b 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -133,32 +133,33 @@ void CSVRender::Cell::updateLand() // Setup land if available const CSMWorld::IdCollection& land = mData.getLand(); int landIndex = land.searchId(mId); - if (landIndex != -1 && !land.getRecord(mId).isDeleted()) + + if (landIndex == -1 || land.getRecord(mId).isDeleted()) + return; + + const ESM::Land& esmLand = land.getRecord(mId).get(); + + if (!esmLand.getLandData(ESM::Land::DATA_VHGT)) + mTerrainStorage->resetHeights(); + + if (mTerrain) { - const ESM::Land& esmLand = land.getRecord(mId).get(); - - if (!esmLand.getLandData(ESM::Land::DATA_VHGT)) - mTerrainStorage->resetHeights(); - - if (mTerrain) - { - mTerrain->unloadCell(mCoordinates.getX(), mCoordinates.getY()); - mTerrain->clearAssociatedCaches(); - } - else - { - constexpr double expiryDelay = 0; - mTerrain = std::make_unique(mCellNode, mCellNode, mData.getResourceSystem().get(), - mTerrainStorage, Mask_Terrain, ESM::Cell::sDefaultWorldspaceId, expiryDelay); - } - - mTerrain->loadCell(esmLand.mX, esmLand.mY); - - if (!mCellBorder) - mCellBorder = std::make_unique(mCellNode, mCoordinates); - - mCellBorder->buildShape(esmLand); + mTerrain->unloadCell(mCoordinates.getX(), mCoordinates.getY()); + mTerrain->clearAssociatedCaches(); } + else + { + constexpr double expiryDelay = 0; + mTerrain = std::make_unique(mCellNode, mCellNode, mData.getResourceSystem().get(), + mTerrainStorage, Mask_Terrain, ESM::Cell::sDefaultWorldspaceId, expiryDelay); + } + + mTerrain->loadCell(esmLand.mX, esmLand.mY); + + if (!mCellBorder) + mCellBorder = std::make_unique(mCellNode, mCoordinates); + + mCellBorder->buildShape(esmLand); } void CSVRender::Cell::unloadLand()