1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-21 02:11:33 +00:00

Remove from MWWorld::World a few functions that already exist in MWWorld::Cells and MWWorld::Scene

This commit is contained in:
Petr Mikheev 2022-11-06 20:06:45 +01:00
parent 2df993004c
commit 7a354d8c78
15 changed files with 74 additions and 132 deletions

View file

@ -242,7 +242,7 @@ bool OMW::Engine::frame(float frametime)
mScriptManager->getGlobalScripts().run(); mScriptManager->getGlobalScripts().run();
} }
mWorld->markCellAsUnchanged(); mWorld->getWorldScene().markCellAsUnchanged();
} }
if (!guiActive) if (!guiActive)

View file

@ -133,17 +133,6 @@ namespace MWBase
virtual void readRecord(ESM::ESMReader& reader, uint32_t type, const std::map<int, int>& contentFileMap) = 0; virtual void readRecord(ESM::ESMReader& reader, uint32_t type, const std::map<int, int>& contentFileMap) = 0;
virtual MWWorld::CellStore* getExterior(int x, int y) = 0;
virtual MWWorld::CellStore* getInterior(std::string_view name) = 0;
virtual MWWorld::CellStore* getCell(const ESM::CellId& id) = 0;
virtual bool isCellActive(MWWorld::CellStore* cell) const = 0;
virtual void testExteriorCells() = 0;
virtual void testInteriorCells() = 0;
virtual void useDeathCamera() = 0; virtual void useDeathCamera() = 0;
virtual void setWaterHeight(const float height) = 0; virtual void setWaterHeight(const float height) = 0;
@ -162,9 +151,6 @@ namespace MWBase
virtual MWWorld::LocalScripts& getLocalScripts() = 0; virtual MWWorld::LocalScripts& getLocalScripts() = 0;
virtual bool hasCellChanged() const = 0;
///< Has the set of active cells changed, since the last frame?
virtual bool isCellExterior() const = 0; virtual bool isCellExterior() const = 0;
virtual bool isCellQuasiExterior() const = 0; virtual bool isCellQuasiExterior() const = 0;
@ -279,8 +265,6 @@ namespace MWBase
virtual const ESM::Cell* getExterior(std::string_view cellName) const = 0; virtual const ESM::Cell* getExterior(std::string_view cellName) const = 0;
///< Return a cell matching the given name or a 0-pointer, if there is no such cell. ///< Return a cell matching the given name or a 0-pointer, if there is no such cell.
virtual void markCellAsUnchanged() = 0;
virtual MWWorld::Ptr getFacedObject() = 0; virtual MWWorld::Ptr getFacedObject() = 0;
///< Return pointer to the object the player is looking at, if it is within activation range ///< Return pointer to the object the player is looking at, if it is within activation range

View file

@ -22,6 +22,7 @@
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwworld/cells.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/cellutils.hpp" #include "../mwworld/cellutils.hpp"
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
@ -586,7 +587,7 @@ namespace MWGui
if (!entry.mMapTexture) if (!entry.mMapTexture)
{ {
if (!mInterior) if (!mInterior)
requestMapRender(MWBase::Environment::get().getWorld()->getExterior(entry.mCellX, entry.mCellY)); requestMapRender(MWBase::Environment::get().getWorldModel()->getExterior(entry.mCellX, entry.mCellY));
osg::ref_ptr<osg::Texture2D> texture = mLocalMapRender->getMapTexture(entry.mCellX, entry.mCellY); osg::ref_ptr<osg::Texture2D> texture = mLocalMapRender->getMapTexture(entry.mCellX, entry.mCellY);
if (texture) if (texture)
@ -624,6 +625,7 @@ namespace MWGui
{ {
std::vector<MWBase::World::DoorMarker> doors; std::vector<MWBase::World::DoorMarker> doors;
MWBase::World* world = MWBase::Environment::get().getWorld(); MWBase::World* world = MWBase::Environment::get().getWorld();
MWWorld::Cells* worldModel = MWBase::Environment::get().getWorldModel();
mDoorMarkersToRecycle.insert( mDoorMarkersToRecycle.insert(
mDoorMarkersToRecycle.end(), mInteriorDoorMarkerWidgets.begin(), mInteriorDoorMarkerWidgets.end()); mDoorMarkersToRecycle.end(), mInteriorDoorMarkerWidgets.begin(), mInteriorDoorMarkerWidgets.end());
@ -634,7 +636,7 @@ namespace MWGui
for (MyGUI::Widget* widget : mExteriorDoorMarkerWidgets) for (MyGUI::Widget* widget : mExteriorDoorMarkerWidgets)
widget->setVisible(false); widget->setVisible(false);
MWWorld::CellStore* cell = world->getInterior(mPrefix); MWWorld::CellStore* cell = worldModel->getInterior(mPrefix);
world->getDoorMarkers(cell, doors); world->getDoorMarkers(cell, doors);
} }
else else
@ -642,7 +644,7 @@ namespace MWGui
for (MapEntry& entry : mMaps) for (MapEntry& entry : mMaps)
{ {
if (!entry.mMapTexture && !widgetCropped(entry.mMapWidget, mLocalMap)) if (!entry.mMapTexture && !widgetCropped(entry.mMapWidget, mLocalMap))
world->getDoorMarkers(world->getExterior(entry.mCellX, entry.mCellY), doors); world->getDoorMarkers(worldModel->getExterior(entry.mCellX, entry.mCellY), doors);
} }
if (doors.empty()) if (doors.empty())
return; return;

View file

@ -13,6 +13,7 @@
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwworld/actionteleport.hpp" #include "../mwworld/actionteleport.hpp"
#include "../mwworld/cells.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/cellutils.hpp" #include "../mwworld/cellutils.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
@ -127,7 +128,7 @@ namespace MWGui
if (cellname.empty()) if (cellname.empty())
{ {
MWWorld::CellStore* cell MWWorld::CellStore* cell
= MWBase::Environment::get().getWorld()->getExterior(cellIndex.x(), cellIndex.y()); = MWBase::Environment::get().getWorldModel()->getExterior(cellIndex.x(), cellIndex.y());
cellname = MWBase::Environment::get().getWorld()->getCellName(cell); cellname = MWBase::Environment::get().getWorld()->getCellName(cell);
interior = false; interior = false;
} }

View file

@ -27,6 +27,7 @@
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/scene.hpp"
#include "debugbindings.hpp" #include "debugbindings.hpp"
#include "luabindings.hpp" #include "luabindings.hpp"
@ -402,7 +403,7 @@ namespace MWLua
{ {
localScripts = createLocalScripts(ptr); localScripts = createLocalScripts(ptr);
localScripts->addAutoStartedScripts(); localScripts->addAutoStartedScripts();
if (ptr.isInCell() && MWBase::Environment::get().getWorld()->isCellActive(ptr.getCell())) if (ptr.isInCell() && MWBase::Environment::get().getWorldScene()->isCellActive(*ptr.getCell()))
mActiveLocalScripts.insert(localScripts); mActiveLocalScripts.insert(localScripts);
} }
localScripts->addCustomScript(scriptId); localScripts->addCustomScript(scriptId);

View file

@ -8,6 +8,7 @@
#include "../mwclass/container.hpp" #include "../mwclass/container.hpp"
#include "../mwworld/cells.hpp"
#include "../mwworld/cellutils.hpp" #include "../mwworld/cellutils.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/timestamp.hpp" #include "../mwworld/timestamp.hpp"
@ -126,31 +127,30 @@ namespace MWLua
// sections. // sections.
MWWorld::CellStore* WorldView::findCell(const std::string& name, osg::Vec3f position) MWWorld::CellStore* WorldView::findCell(const std::string& name, osg::Vec3f position)
{ {
MWBase::World* world = MWBase::Environment::get().getWorld(); MWWorld::Cells* cells = MWBase::Environment::get().getWorldModel();
bool exterior = name.empty() || world->getExterior(name); bool exterior = name.empty() || MWBase::Environment::get().getWorld()->getExterior(name);
if (exterior) if (exterior)
{ {
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(position.x(), position.y()); const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(position.x(), position.y());
return world->getExterior(cellIndex.x(), cellIndex.y()); return cells->getExterior(cellIndex.x(), cellIndex.y());
} }
else else
return world->getInterior(name); return cells->getInterior(name);
} }
MWWorld::CellStore* WorldView::findNamedCell(const std::string& name) MWWorld::CellStore* WorldView::findNamedCell(const std::string& name)
{ {
MWBase::World* world = MWBase::Environment::get().getWorld(); MWWorld::Cells* cells = MWBase::Environment::get().getWorldModel();
const ESM::Cell* esmCell = world->getExterior(name); const ESM::Cell* esmCell = MWBase::Environment::get().getWorld()->getExterior(name);
if (esmCell) if (esmCell)
return world->getExterior(esmCell->getGridX(), esmCell->getGridY()); return cells->getExterior(esmCell->getGridX(), esmCell->getGridY());
else else
return world->getInterior(name); return cells->getInterior(name);
} }
MWWorld::CellStore* WorldView::findExteriorCell(int x, int y) MWWorld::CellStore* WorldView::findExteriorCell(int x, int y)
{ {
MWBase::World* world = MWBase::Environment::get().getWorld(); return MWBase::Environment::get().getWorldModel()->getExterior(x, y);
return world->getExterior(x, y);
} }
} }

View file

@ -22,6 +22,7 @@
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/scene.hpp"
#include "../mwbase/dialoguemanager.hpp" #include "../mwbase/dialoguemanager.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -1570,7 +1571,8 @@ namespace MWMechanics
} }
else else
{ {
const bool cellChanged = world->hasCellChanged(); MWWorld::Scene* worldScene = MWBase::Environment::get().getWorldScene();
const bool cellChanged = worldScene->hasCellChanged();
const MWWorld::Ptr actorPtr = actor.getPtr(); // make a copy of the map key to avoid it being const MWWorld::Ptr actorPtr = actor.getPtr(); // make a copy of the map key to avoid it being
// invalidated when the player teleports // invalidated when the player teleports
updateActor(actorPtr, duration); updateActor(actorPtr, duration);
@ -1582,7 +1584,7 @@ namespace MWMechanics
// There needs to be a magic effect update in between. // There needs to be a magic effect update in between.
ctrl.updateContinuousVfx(); ctrl.updateContinuousVfx();
if (!cellChanged && world->hasCellChanged()) if (!cellChanged && worldScene->hasCellChanged())
{ {
return; // for now abort update of the old cell when cell changes by teleportation magic effect return; // for now abort update of the old cell when cell changes by teleportation magic effect
// a better solution might be to apply cell changes at the end of the frame // a better solution might be to apply cell changes at the end of the frame

View file

@ -16,6 +16,7 @@
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwworld/actionteleport.hpp" #include "../mwworld/actionteleport.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/scene.hpp"
#include "../mwmechanics/actorutil.hpp" #include "../mwmechanics/actorutil.hpp"
@ -30,7 +31,7 @@ namespace MWScript
public: public:
void execute(Interpreter::Runtime& runtime) override void execute(Interpreter::Runtime& runtime) override
{ {
runtime.push(MWBase::Environment::get().getWorld()->hasCellChanged() ? 1 : 0); runtime.push(MWBase::Environment::get().getWorldScene()->hasCellChanged() ? 1 : 0);
} }
}; };
@ -50,7 +51,7 @@ namespace MWScript
if (wasConsole) if (wasConsole)
MWBase::Environment::get().getWindowManager()->toggleConsole(); MWBase::Environment::get().getWindowManager()->toggleConsole();
MWBase::Environment::get().getWorld()->testExteriorCells(); MWBase::Environment::get().getWorldScene()->testExteriorCells();
if (wasConsole) if (wasConsole)
MWBase::Environment::get().getWindowManager()->toggleConsole(); MWBase::Environment::get().getWindowManager()->toggleConsole();
@ -73,7 +74,7 @@ namespace MWScript
if (wasConsole) if (wasConsole)
MWBase::Environment::get().getWindowManager()->toggleConsole(); MWBase::Environment::get().getWindowManager()->toggleConsole();
MWBase::Environment::get().getWorld()->testInteriorCells(); MWBase::Environment::get().getWorldScene()->testInteriorCells();
if (wasConsole) if (wasConsole)
MWBase::Environment::get().getWindowManager()->toggleConsole(); MWBase::Environment::get().getWindowManager()->toggleConsole();

View file

@ -13,11 +13,13 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwworld/cells.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/cellutils.hpp" #include "../mwworld/cellutils.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/manualref.hpp" #include "../mwworld/manualref.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/scene.hpp"
#include "../mwmechanics/actorutil.hpp" #include "../mwmechanics/actorutil.hpp"
@ -388,6 +390,7 @@ namespace MWScript
bool isPlayer = ptr == MWMechanics::getPlayer(); bool isPlayer = ptr == MWMechanics::getPlayer();
auto world = MWBase::Environment::get().getWorld(); auto world = MWBase::Environment::get().getWorld();
auto worldModel = MWBase::Environment::get().getWorldModel();
if (isPlayer) if (isPlayer)
{ {
world->getPlayer().setTeleported(true); world->getPlayer().setTeleported(true);
@ -396,7 +399,7 @@ namespace MWScript
MWWorld::CellStore* store = nullptr; MWWorld::CellStore* store = nullptr;
try try
{ {
store = world->getInterior(cellID); store = worldModel->getInterior(cellID);
} }
catch (std::exception&) catch (std::exception&)
{ {
@ -415,7 +418,7 @@ namespace MWScript
return; return;
} }
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y); const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y);
store = world->getExterior(cellIndex.x(), cellIndex.y()); store = worldModel->getExterior(cellIndex.x(), cellIndex.y());
} }
if (store) if (store)
{ {
@ -432,7 +435,8 @@ namespace MWScript
rot.z() = osg::DegreesToRadians(zRot); rot.z() = osg::DegreesToRadians(zRot);
world->rotateObject(ptr, rot); world->rotateObject(ptr, rot);
ptr.getClass().adjustPosition(ptr, isPlayer || !world->isCellActive(ptr.getCell())); bool cellActive = MWBase::Environment::get().getWorldScene()->isCellActive(*ptr.getCell());
ptr.getClass().adjustPosition(ptr, isPlayer || !cellActive);
} }
} }
}; };
@ -470,7 +474,7 @@ namespace MWScript
MWWorld::Ptr base = ptr; MWWorld::Ptr base = ptr;
if (isPlayer) if (isPlayer)
{ {
MWWorld::CellStore* cell = world->getExterior(cellIndex.x(), cellIndex.y()); MWWorld::CellStore* cell = MWBase::Environment::get().getWorldModel()->getExterior(cellIndex.x(), cellIndex.y());
ptr = world->moveObject(ptr, cell, osg::Vec3(x, y, z)); ptr = world->moveObject(ptr, cell, osg::Vec3(x, y, z));
} }
else else
@ -487,7 +491,8 @@ namespace MWScript
zRot = zRot / 60.0f; zRot = zRot / 60.0f;
rot.z() = osg::DegreesToRadians(zRot); rot.z() = osg::DegreesToRadians(zRot);
world->rotateObject(ptr, rot); world->rotateObject(ptr, rot);
ptr.getClass().adjustPosition(ptr, isPlayer || !world->isCellActive(ptr.getCell())); bool cellActive = MWBase::Environment::get().getWorldScene()->isCellActive(*ptr.getCell());
ptr.getClass().adjustPosition(ptr, isPlayer || !cellActive);
} }
}; };
@ -513,13 +518,13 @@ namespace MWScript
MWWorld::CellStore* store = nullptr; MWWorld::CellStore* store = nullptr;
try try
{ {
store = MWBase::Environment::get().getWorld()->getInterior(cellID); store = MWBase::Environment::get().getWorldModel()->getInterior(cellID);
} }
catch (std::exception&) catch (std::exception&)
{ {
const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getExterior(cellID); const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getExterior(cellID);
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y); const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y);
store = MWBase::Environment::get().getWorld()->getExterior(cellIndex.x(), cellIndex.y()); store = MWBase::Environment::get().getWorldModel()->getExterior(cellIndex.x(), cellIndex.y());
if (!cell) if (!cell)
{ {
runtime.getContext().report("unknown cell (" + std::string(cellID) + ")"); runtime.getContext().report("unknown cell (" + std::string(cellID) + ")");
@ -569,7 +574,7 @@ namespace MWScript
if (player.getCell()->isExterior()) if (player.getCell()->isExterior())
{ {
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y); const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y);
store = MWBase::Environment::get().getWorld()->getExterior(cellIndex.x(), cellIndex.y()); store = MWBase::Environment::get().getWorldModel()->getExterior(cellIndex.x(), cellIndex.y());
} }
else else
store = player.getCell(); store = player.getCell();

View file

@ -30,9 +30,11 @@
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwworld/cells.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwworld/scene.hpp"
#include "../mwmechanics/actorutil.hpp" #include "../mwmechanics/actorutil.hpp"
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
@ -554,7 +556,7 @@ void MWState::StateManager::loadGame(const Character* character, const std::file
{ {
// Cell no longer exists (i.e. changed game files), choose a default cell // Cell no longer exists (i.e. changed game files), choose a default cell
Log(Debug::Warning) << "Warning: Player character's cell no longer exists, changing to the default cell"; Log(Debug::Warning) << "Warning: Player character's cell no longer exists, changing to the default cell";
MWWorld::CellStore* cell = MWBase::Environment::get().getWorld()->getExterior(0, 0); MWWorld::CellStore* cell = MWBase::Environment::get().getWorldModel()->getExterior(0, 0);
float x, y; float x, y;
MWBase::Environment::get().getWorld()->indexToPosition(0, 0, x, y, false); MWBase::Environment::get().getWorld()->indexToPosition(0, 0, x, y, false);
ESM::Position pos; ESM::Position pos;
@ -575,7 +577,7 @@ void MWState::StateManager::loadGame(const Character* character, const std::file
// Since we passed "changeEvent=false" to changeCell, we shouldn't have triggered the cell change flag. // Since we passed "changeEvent=false" to changeCell, we shouldn't have triggered the cell change flag.
// But make sure the flag is cleared anyway in case it was set from an earlier game. // But make sure the flag is cleared anyway in case it was set from an earlier game.
MWBase::Environment::get().getWorld()->markCellAsUnchanged(); MWBase::Environment::get().getWorldScene()->markCellAsUnchanged();
MWBase::Environment::get().getLuaManager()->gameLoaded(); MWBase::Environment::get().getLuaManager()->gameLoaded();
} }

View file

@ -8,6 +8,7 @@
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"
#include "../mwworld/cells.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/cellutils.hpp" #include "../mwworld/cellutils.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
@ -42,6 +43,7 @@ namespace MWWorld
void ActionTeleport::teleport(const Ptr& actor) void ActionTeleport::teleport(const Ptr& actor)
{ {
MWBase::World* world = MWBase::Environment::get().getWorld(); MWBase::World* world = MWBase::Environment::get().getWorld();
MWWorld::Cells* worldModel = MWBase::Environment::get().getWorldModel();
actor.getClass().getCreatureStats(actor).land(actor == world->getPlayerPtr()); actor.getClass().getCreatureStats(actor).land(actor == world->getPlayerPtr());
if (actor == world->getPlayerPtr()) if (actor == world->getPlayerPtr())
{ {
@ -58,10 +60,10 @@ namespace MWWorld
else if (mCellName.empty()) else if (mCellName.empty())
{ {
const osg::Vec2i index = positionToCellIndex(mPosition.pos[0], mPosition.pos[1]); const osg::Vec2i index = positionToCellIndex(mPosition.pos[0], mPosition.pos[1]);
world->moveObject(actor, world->getExterior(index.x(), index.y()), mPosition.asVec3(), true, true); world->moveObject(actor, worldModel->getExterior(index.x(), index.y()), mPosition.asVec3(), true, true);
} }
else else
world->moveObject(actor, world->getInterior(mCellName), mPosition.asVec3(), true, true); world->moveObject(actor, worldModel->getInterior(mCellName), mPosition.asVec3(), true, true);
} }
} }

View file

@ -13,6 +13,7 @@
#include <components/fallback/fallback.hpp> #include <components/fallback/fallback.hpp>
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwworld/cells.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/magiceffects.hpp" #include "../mwworld/magiceffects.hpp"
@ -430,7 +431,7 @@ namespace MWWorld
try try
{ {
mCellStore = world.getCell(player.mCellId); mCellStore = MWBase::Environment::get().getWorldModel()->getCell(player.mCellId);
} }
catch (...) catch (...)
{ {
@ -467,7 +468,7 @@ namespace MWWorld
if (player.mHasMark) if (player.mHasMark)
{ {
mMarkedPosition = player.mMarkedPosition; mMarkedPosition = player.mMarkedPosition;
mMarkedCell = world.getCell(player.mMarkedCell); mMarkedCell = MWBase::Environment::get().getWorldModel()->getCell(player.mMarkedCell);
} }
else else
{ {

View file

@ -543,7 +543,7 @@ namespace MWWorld
} }
mNavigator.setWorldspace( mNavigator.setWorldspace(
mWorld.getExterior(playerCellX, playerCellY)->getCell()->mCellId.mWorldspace, navigatorUpdateGuard.get()); mWorld.getWorldModel().getExterior(playerCellX, playerCellY)->getCell()->mCellId.mWorldspace, navigatorUpdateGuard.get());
mNavigator.updateBounds(pos, navigatorUpdateGuard.get()); mNavigator.updateBounds(pos, navigatorUpdateGuard.get());
mCurrentGridCenter = osg::Vec2i(playerCellX, playerCellY); mCurrentGridCenter = osg::Vec2i(playerCellX, playerCellY);
@ -566,7 +566,7 @@ namespace MWWorld
{ {
if (!isCellInCollection(x, y, collection)) if (!isCellInCollection(x, y, collection))
{ {
refsToLoad += mWorld.getExterior(x, y)->count(); refsToLoad += mWorld.getWorldModel().getExterior(x, y)->count();
cellsPositionsToLoad.emplace_back(x, y); cellsPositionsToLoad.emplace_back(x, y);
} }
} }
@ -601,7 +601,7 @@ namespace MWWorld
{ {
if (!isCellInCollection(x, y, mActiveCells)) if (!isCellInCollection(x, y, mActiveCells))
{ {
CellStore* cell = mWorld.getExterior(x, y); CellStore* cell = mWorld.getWorldModel().getExterior(x, y);
loadCell(cell, loadingListener, changeEvent, pos, navigatorUpdateGuard.get()); loadCell(cell, loadingListener, changeEvent, pos, navigatorUpdateGuard.get());
} }
} }
@ -610,7 +610,7 @@ namespace MWWorld
navigatorUpdateGuard.reset(); navigatorUpdateGuard.reset();
CellStore* current = mWorld.getExterior(playerCellX, playerCellY); CellStore* current = mWorld.getWorldModel().getExterior(playerCellX, playerCellY);
MWBase::Environment::get().getWindowManager()->changeCell(current); MWBase::Environment::get().getWindowManager()->changeCell(current);
if (changeEvent) if (changeEvent)
@ -663,7 +663,7 @@ namespace MWWorld
loadingListener->setLabel( loadingListener->setLabel(
"Testing exterior cells (" + std::to_string(i) + "/" + std::to_string(cells.getExtSize()) + ")..."); "Testing exterior cells (" + std::to_string(i) + "/" + std::to_string(cells.getExtSize()) + ")...");
CellStore* cell = mWorld.getExterior(it->mData.mX, it->mData.mY); CellStore* cell = mWorld.getWorldModel().getExterior(it->mData.mX, it->mData.mY);
mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace, navigatorUpdateGuard.get()); mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace, navigatorUpdateGuard.get());
const osg::Vec3f position const osg::Vec3f position
= osg::Vec3f(it->mData.mX + 0.5f, it->mData.mY + 0.5f, 0) * Constants::CellSizeInUnits; = osg::Vec3f(it->mData.mX + 0.5f, it->mData.mY + 0.5f, 0) * Constants::CellSizeInUnits;
@ -720,7 +720,7 @@ namespace MWWorld
loadingListener->setLabel( loadingListener->setLabel(
"Testing interior cells (" + std::to_string(i) + "/" + std::to_string(cells.getIntSize()) + ")..."); "Testing interior cells (" + std::to_string(i) + "/" + std::to_string(cells.getIntSize()) + ")...");
CellStore* cell = mWorld.getInterior(it->mName); CellStore* cell = mWorld.getWorldModel().getInterior(it->mName);
mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace, navigatorUpdateGuard.get()); mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace, navigatorUpdateGuard.get());
ESM::Position position; ESM::Position position;
mWorld.findInteriorPosition(it->mName, position); mWorld.findInteriorPosition(it->mName, position);
@ -842,7 +842,7 @@ namespace MWWorld
void Scene::changeToInteriorCell( void Scene::changeToInteriorCell(
const std::string& cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent) const std::string& cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent)
{ {
CellStore* cell = mWorld.getInterior(cellName); CellStore* cell = mWorld.getWorldModel().getInterior(cellName);
bool useFading = (mCurrentCell != nullptr); bool useFading = (mCurrentCell != nullptr);
if (useFading) if (useFading)
MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.5); MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.5);
@ -917,7 +917,7 @@ namespace MWWorld
changeCellGrid(position.asVec3(), cellIndex.x(), cellIndex.y(), changeEvent); changeCellGrid(position.asVec3(), cellIndex.x(), cellIndex.y(), changeEvent);
CellStore* current = mWorld.getExterior(cellIndex.x(), cellIndex.y()); CellStore* current = mWorld.getWorldModel().getExterior(cellIndex.x(), cellIndex.y());
changePlayerCell(current, position, adjustPlayerPos); changePlayerCell(current, position, adjustPlayerPos);
if (changeEvent) if (changeEvent)
@ -1116,12 +1116,12 @@ namespace MWWorld
try try
{ {
if (!door.getCellRef().getDestCell().empty()) if (!door.getCellRef().getDestCell().empty())
preloadCell(mWorld.getInterior(door.getCellRef().getDestCell())); preloadCell(mWorld.getWorldModel().getInterior(door.getCellRef().getDestCell()));
else else
{ {
osg::Vec3f pos = door.getCellRef().getDoorDest().asVec3(); osg::Vec3f pos = door.getCellRef().getDoorDest().asVec3();
const osg::Vec2i cellIndex = positionToCellIndex(pos.x(), pos.y()); const osg::Vec2i cellIndex = positionToCellIndex(pos.x(), pos.y());
preloadCell(mWorld.getExterior(cellIndex.x(), cellIndex.y()), true); preloadCell(mWorld.getWorldModel().getExterior(cellIndex.x(), cellIndex.y()), true);
exteriorPositions.emplace_back(pos, gridCenterToBounds(getNewGridCenter(pos))); exteriorPositions.emplace_back(pos, gridCenterToBounds(getNewGridCenter(pos)));
} }
} }
@ -1167,7 +1167,7 @@ namespace MWWorld
+ mPreloadDistance; + mPreloadDistance;
if (dist < loadDist) if (dist < loadDist)
preloadCell(mWorld.getExterior(cellX + dx, cellY + dy)); preloadCell(mWorld.getWorldModel().getExterior(cellX + dx, cellY + dy));
} }
} }
} }
@ -1183,7 +1183,7 @@ namespace MWWorld
{ {
for (int dy = -mHalfGridSize; dy <= mHalfGridSize; ++dy) for (int dy = -mHalfGridSize; dy <= mHalfGridSize; ++dy)
{ {
mPreloader->preload(mWorld.getExterior(x + dx, y + dy), mRendering.getReferenceTime()); mPreloader->preload(mWorld.getWorldModel().getExterior(x + dx, y + dy), mRendering.getReferenceTime());
if (++numpreloaded >= mPreloader->getMaxCacheSize()) if (++numpreloaded >= mPreloader->getMaxCacheSize())
break; break;
} }
@ -1263,12 +1263,12 @@ namespace MWWorld
for (ESM::Transport::Dest& dest : listVisitor.mList) for (ESM::Transport::Dest& dest : listVisitor.mList)
{ {
if (!dest.mCellName.empty()) if (!dest.mCellName.empty())
preloadCell(mWorld.getInterior(dest.mCellName)); preloadCell(mWorld.getWorldModel().getInterior(dest.mCellName));
else else
{ {
osg::Vec3f pos = dest.mPos.asVec3(); osg::Vec3f pos = dest.mPos.asVec3();
const osg::Vec2i cellIndex = positionToCellIndex(pos.x(), pos.y()); const osg::Vec2i cellIndex = positionToCellIndex(pos.x(), pos.y());
preloadCell(mWorld.getExterior(cellIndex.x(), cellIndex.y()), true); preloadCell(mWorld.getWorldModel().getExterior(cellIndex.x(), cellIndex.y()), true);
exteriorPositions.emplace_back(pos, gridCenterToBounds(getNewGridCenter(pos))); exteriorPositions.emplace_back(pos, gridCenterToBounds(getNewGridCenter(pos)));
} }
} }

View file

@ -592,39 +592,6 @@ namespace MWWorld
return nullptr; return nullptr;
} }
CellStore* World::getExterior(int x, int y)
{
return mCells.getExterior(x, y);
}
CellStore* World::getInterior(std::string_view name)
{
return mCells.getInterior(name);
}
CellStore* World::getCell(const ESM::CellId& id)
{
if (id.mPaged)
return getExterior(id.mIndex.mX, id.mIndex.mY);
else
return getInterior(id.mWorldspace);
}
bool World::isCellActive(CellStore* cell) const
{
return mWorldScene->getActiveCells().count(cell) > 0;
}
void World::testExteriorCells()
{
mWorldScene->testExteriorCells();
}
void World::testInteriorCells()
{
mWorldScene->testInteriorCells();
}
void World::useDeathCamera() void World::useDeathCamera()
{ {
mRendering->getCamera()->setMode(MWRender::Camera::Mode::ThirdPerson); mRendering->getCamera()->setMode(MWRender::Camera::Mode::ThirdPerson);
@ -650,11 +617,6 @@ namespace MWWorld
return mLocalScripts; return mLocalScripts;
} }
bool World::hasCellChanged() const
{
return mWorldScene->hasCellChanged();
}
void World::setGlobalInt(std::string_view name, int value) void World::setGlobalInt(std::string_view name, int value)
{ {
bool dateUpdated = mCurrentDate->updateGlobalInt(name, value); bool dateUpdated = mCurrentDate->updateGlobalInt(name, value);
@ -1045,11 +1007,6 @@ namespace MWWorld
mCurrentDate->setup(mGlobalVariables); mCurrentDate->setup(mGlobalVariables);
} }
void World::markCellAsUnchanged()
{
return mWorldScene->markCellAsUnchanged();
}
float World::getMaxActivationDistance() const float World::getMaxActivationDistance() const
{ {
if (mActivationDistanceOverride >= 0) if (mActivationDistanceOverride >= 0)
@ -1305,7 +1262,7 @@ namespace MWWorld
const osg::Vec2i index = positionToCellIndex(position.x(), position.y()); const osg::Vec2i index = positionToCellIndex(position.x(), position.y());
CellStore* cell = ptr.getCell(); CellStore* cell = ptr.getCell();
CellStore* newCell = getExterior(index.x(), index.y()); CellStore* newCell = mCells.getExterior(index.x(), index.y());
bool isCellActive = getPlayerPtr().isInCell() && getPlayerPtr().getCell()->isExterior() bool isCellActive = getPlayerPtr().isInCell() && getPlayerPtr().getCell()->isExterior()
&& mWorldScene->isCellActive(*newCell); && mWorldScene->isCellActive(*newCell);
@ -2850,7 +2807,7 @@ namespace MWWorld
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
pos.pos[0] = pos.pos[1] = pos.pos[2] = 0; pos.pos[0] = pos.pos[1] = pos.pos[2] = 0;
MWWorld::CellStore* cellStore = getInterior(name); MWWorld::CellStore* cellStore = mCells.getInterior(name);
if (!cellStore) if (!cellStore)
return false; return false;
@ -2881,12 +2838,12 @@ namespace MWWorld
{ {
ESM::Position doorDest = door->getDoorDest(); ESM::Position doorDest = door->getDoorDest();
const osg::Vec2i index = positionToCellIndex(doorDest.pos[0], doorDest.pos[1]); const osg::Vec2i index = positionToCellIndex(doorDest.pos[0], doorDest.pos[1]);
source = getExterior(index.x(), index.y()); source = mCells.getExterior(index.x(), index.y());
} }
// door to interior // door to interior
else else
{ {
source = getInterior(door->getDestCell()); source = mCells.getInterior(door->getDestCell());
} }
if (source) if (source)
{ {
@ -2933,7 +2890,7 @@ namespace MWWorld
if (xResult.ec == std::errc::result_out_of_range || yResult.ec == std::errc::result_out_of_range) if (xResult.ec == std::errc::result_out_of_range || yResult.ec == std::errc::result_out_of_range)
throw std::runtime_error("Cell coordinates out of range."); throw std::runtime_error("Cell coordinates out of range.");
else if (xResult.ec == std::errc{} && yResult.ec == std::errc{}) else if (xResult.ec == std::errc{} && yResult.ec == std::errc{})
ext = getExterior(x, y)->getCell(); ext = mCells.getExterior(x, y)->getCell();
// ignore std::errc::invalid_argument, as this means that name probably refers to a interior cell // ignore std::errc::invalid_argument, as this means that name probably refers to a interior cell
// instead of comma separated coordinates // instead of comma separated coordinates
} }
@ -3352,7 +3309,7 @@ namespace MWWorld
nextCells.clear(); nextCells.clear();
for (const std::string& currentCell : currentCells) for (const std::string& currentCell : currentCells)
{ {
MWWorld::CellStore* next = getInterior(currentCell); MWWorld::CellStore* next = mCells.getInterior(currentCell);
if (!next) if (!next)
continue; continue;
@ -3406,7 +3363,7 @@ namespace MWWorld
nextCells.clear(); nextCells.clear();
for (const std::string& cell : currentCells) for (const std::string& cell : currentCells)
{ {
MWWorld::CellStore* next = getInterior(cell); MWWorld::CellStore* next = mCells.getInterior(cell);
checkedCells.insert(cell); checkedCells.insert(cell);
if (!next) if (!next)
continue; continue;
@ -3704,7 +3661,7 @@ namespace MWWorld
Log(Debug::Warning) << "Failed to confiscate items: prison marker not linked to prison interior"; Log(Debug::Warning) << "Failed to confiscate items: prison marker not linked to prison interior";
return; return;
} }
MWWorld::CellStore* prison = getInterior(prisonName); MWWorld::CellStore* prison = mCells.getInterior(prisonName);
if (!prison) if (!prison)
{ {
Log(Debug::Warning) << "Failed to confiscate items: failed to load cell " << prisonName; Log(Debug::Warning) << "Failed to confiscate items: failed to load cell " << prisonName;

View file

@ -219,17 +219,6 @@ namespace MWWorld
void readRecord(ESM::ESMReader& reader, uint32_t type, const std::map<int, int>& contentFileMap) override; void readRecord(ESM::ESMReader& reader, uint32_t type, const std::map<int, int>& contentFileMap) override;
CellStore* getExterior(int x, int y) override;
CellStore* getInterior(std::string_view name) override;
CellStore* getCell(const ESM::CellId& id) override;
bool isCellActive(CellStore* cell) const override;
void testExteriorCells() override;
void testInteriorCells() override;
// switch to POV before showing player's death animation // switch to POV before showing player's death animation
void useDeathCamera() override; void useDeathCamera() override;
@ -253,9 +242,6 @@ namespace MWWorld
LocalScripts& getLocalScripts() override; LocalScripts& getLocalScripts() override;
bool hasCellChanged() const override;
///< Has the set of active cells changed, since the last frame?
bool isCellExterior() const override; bool isCellExterior() const override;
bool isCellQuasiExterior() const override; bool isCellQuasiExterior() const override;
@ -375,8 +361,6 @@ namespace MWWorld
const ESM::Cell* getExterior(std::string_view cellName) const override; const ESM::Cell* getExterior(std::string_view cellName) const override;
///< Return a cell matching the given name or a 0-pointer, if there is no such cell. ///< Return a cell matching the given name or a 0-pointer, if there is no such cell.
void markCellAsUnchanged() override;
MWWorld::Ptr getFacedObject() override; MWWorld::Ptr getFacedObject() override;
///< Return pointer to the object the player is looking at, if it is within activation range ///< Return pointer to the object the player is looking at, if it is within activation range