Skip to content

Commit

Permalink
Call Navigator::setWorldspace once per changing cell
Browse files Browse the repository at this point in the history
  • Loading branch information
elsid committed Sep 6, 2022
1 parent 98ddc31 commit 955db8f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions apps/openmw/mwworld/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,6 @@ namespace MWWorld
const int cellX = cell->getCell()->getGridX();
const int cellY = cell->getCell()->getGridY();

mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace);

if (cell->getCell()->isExterior())
{
osg::ref_ptr<const ESMTerrain::LandObject> land = mRendering.getLandManager()->getLand(cellX, cellY);
Expand Down Expand Up @@ -541,6 +539,7 @@ namespace MWWorld
unloadCell (cell);
}

mNavigator.setWorldspace(mWorld.getExterior(playerCellX, playerCellY)->getCell()->mCellId.mWorldspace);
mNavigator.updateBounds(pos);

mCurrentGridCenter = osg::Vec2i(playerCellX, playerCellY);
Expand Down Expand Up @@ -659,7 +658,10 @@ namespace MWWorld
loadingListener->setLabel("Testing exterior cells ("+std::to_string(i)+"/"+std::to_string(cells.getExtSize())+")...");

CellStore *cell = mWorld.getExterior(it->mData.mX, it->mData.mY);
loadCell(cell, nullptr, false, osg::Vec3f(it->mData.mX + 0.5f, it->mData.mY + 0.5f, 0) * Constants::CellSizeInUnits);
mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace);
const osg::Vec3f position = osg::Vec3f(it->mData.mX + 0.5f, it->mData.mY + 0.5f, 0) * Constants::CellSizeInUnits;
mNavigator.updateBounds(position);
loadCell(cell, nullptr, false, position);

auto iter = mActiveCells.begin();
while (iter != mActiveCells.end())
Expand Down Expand Up @@ -704,8 +706,10 @@ namespace MWWorld
loadingListener->setLabel("Testing interior cells ("+std::to_string(i)+"/"+std::to_string(cells.getIntSize())+")...");

CellStore *cell = mWorld.getInterior(it->mName);
mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace);
ESM::Position position;
mWorld.findInteriorPosition(it->mName, position);
mNavigator.updateBounds(position.asVec3());
loadCell(cell, nullptr, false, position.asVec3());

auto iter = mActiveCells.begin();
Expand Down Expand Up @@ -844,6 +848,7 @@ namespace MWWorld

loadingListener->setProgressRange(cell->count());

mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace);
mNavigator.updateBounds(position.asVec3());

// Load cell.
Expand Down

0 comments on commit 955db8f

Please sign in to comment.