moved mwworld/cellutils.hpp -> esm/util.hpp

simplify_debugging
florent.teppe 2 years ago
parent f261f59809
commit 1cf0cd5628

@ -17,7 +17,6 @@
#include "../mwworld/actionteleport.hpp"
#include "../mwworld/actiontrap.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/cellutils.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/customdata.hpp"
#include "../mwworld/esmstore.hpp"

@ -23,7 +23,6 @@
#include "../mwbase/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/cellutils.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/worldmodel.hpp"
@ -277,7 +276,7 @@ namespace MWGui
if (!mInterior)
{
cellIndex = MWWorld::positionToCellIndex(worldX, worldY);
cellIndex = ESM::positionToCellIndex(worldX, worldY);
nX = (worldX - cellSize * cellIndex.x()) / cellSize;
// Image space is -Y up, cells are Y up
nY = 1 - (worldY - cellSize * cellIndex.y()) / cellSize;

@ -15,7 +15,6 @@
#include "../mwworld/actionteleport.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/cellutils.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
@ -126,8 +125,7 @@ namespace MWGui
{
std::string_view cellname = transport[i].mCellName;
bool interior = true;
const osg::Vec2i cellIndex
= MWWorld::positionToCellIndex(transport[i].mPos.pos[0], transport[i].mPos.pos[1]);
const osg::Vec2i cellIndex = ESM::positionToCellIndex(transport[i].mPos.pos[0], transport[i].mPos.pos[1]);
if (cellname.empty())
{
MWWorld::CellStore& cell = MWBase::Environment::get().getWorldModel()->getExterior(
@ -194,7 +192,7 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode();
MWBase::Environment::get().getWindowManager()->fadeScreenOut(1);
osg::Vec2i posCell = MWWorld::positionToCellIndex(pos.pos[0], pos.pos[1]);
osg::Vec2i posCell = ESM::positionToCellIndex(pos.pos[0], pos.pos[1]);
ESM::RefId cellId = ESM::Cell::generateIdForCell(!interior, cellname, posCell.x(), posCell.y());
// Teleports any followers, too.

@ -10,7 +10,6 @@
#include "../mwclass/container.hpp"
#include "../mwworld/cellutils.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/timestamp.hpp"
#include "../mwworld/worldmodel.hpp"

@ -14,7 +14,6 @@
#include "../mwbase/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/cellutils.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/manualref.hpp"
#include "../mwworld/player.hpp"
@ -401,7 +400,7 @@ namespace MWScript
store = &worldModel->getCell(cellID);
if (store->isExterior())
{
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y);
const osg::Vec2i cellIndex = ESM::positionToCellIndex(x, y);
store = &worldModel->getExterior(
ESM::ExteriorCellIndex(cellIndex.x(), cellIndex.y(), store->getCell()->getWorldSpace()));
}
@ -417,7 +416,7 @@ namespace MWScript
Log(Debug::Warning) << error;
if (!isPlayer)
return;
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y);
const osg::Vec2i cellIndex = ESM::positionToCellIndex(x, y);
store = &worldModel->getExterior(
ESM::ExteriorCellIndex(cellIndex.x(), cellIndex.y(), store->getCell()->getWorldSpace()));
}
@ -468,7 +467,7 @@ namespace MWScript
{
world->getPlayer().setTeleported(true);
}
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y);
const osg::Vec2i cellIndex = ESM::positionToCellIndex(x, y);
// another morrowind oddity: player will be moved to the exterior cell at this location,
// non-player actors will move within the cell they are in.
@ -569,7 +568,7 @@ namespace MWScript
MWWorld::CellStore* store = nullptr;
if (player.getCell()->isExterior())
{
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y);
const osg::Vec2i cellIndex = ESM::positionToCellIndex(x, y);
store = &MWBase::Environment::get().getWorldModel()->getExterior(ESM::ExteriorCellIndex(
cellIndex.x(), cellIndex.y(), player.getCell()->getCell()->getWorldSpace()));
}

@ -11,7 +11,6 @@
#include "../mwmechanics/creaturestats.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/cellutils.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/worldmodel.hpp"

@ -10,7 +10,6 @@
#include <apps/openmw/mwbase/environment.hpp>
#include <apps/openmw/mwbase/world.hpp>
#include <apps/openmw/mwworld/cellutils.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
namespace MWWorld
@ -89,7 +88,7 @@ namespace MWWorld
}
else
{
const osg::Vec2i index = positionToCellIndex(ref.mDoorDest.pos[0], ref.mDoorDest.pos[1]);
const osg::Vec2i index = ESM::positionToCellIndex(ref.mDoorDest.pos[0], ref.mDoorDest.pos[1]);
return ESM::RefId::esm3ExteriorCell(index.x(), index.y());
}
};

@ -1,19 +0,0 @@
#ifndef OPENMW_MWWORLD_CELLUTILS_H
#define OPENMW_MWWORLD_CELLUTILS_H
#include <components/misc/constants.hpp>
#include <osg/Vec2i>
#include <cmath>
namespace MWWorld
{
inline osg::Vec2i positionToCellIndex(float x, float y, bool esm4Ext = false)
{
const float cellSize = esm4Ext ? Constants::ESM4CellSizeInUnits : Constants::CellSizeInUnits;
return { static_cast<int>(std::floor(x / cellSize)), static_cast<int>(std::floor(y / cellSize)) };
}
}
#endif

@ -40,7 +40,6 @@
#include "cellpreloader.hpp"
#include "cellstore.hpp"
#include "cellutils.hpp"
#include "cellvisitors.hpp"
#include "class.hpp"
#include "esmstore.hpp"
@ -525,7 +524,7 @@ namespace MWWorld
if (distance <= maxDistance)
return *currentGridCenter;
}
return positionToCellIndex(pos.x(), pos.y(), isEsm4Ext);
return ESM::positionToCellIndex(pos.x(), pos.y(), isEsm4Ext);
}
void Scene::playerMoved(const osg::Vec3f& pos)
@ -1293,7 +1292,7 @@ namespace MWWorld
else
{
osg::Vec3f pos = dest.mPos.asVec3();
const osg::Vec2i cellIndex = positionToCellIndex(pos.x(), pos.y());
const osg::Vec2i cellIndex = ESM::positionToCellIndex(pos.x(), pos.y());
preloadCell(mWorld.getWorldModel().getExterior(
ESM::ExteriorCellIndex(cellIndex.x(), cellIndex.y(), extWorldspace)),
true);

@ -95,7 +95,6 @@
#include "projectilemanager.hpp"
#include "weather.hpp"
#include "cellutils.hpp"
#include "contentloader.hpp"
#include "esmloader.hpp"
@ -380,7 +379,7 @@ namespace MWWorld
pos.rot[1] = 0;
pos.rot[2] = 0;
osg::Vec2i exteriorCellPos = positionToCellIndex(pos.pos[0], pos.pos[1]);
osg::Vec2i exteriorCellPos = ESM::positionToCellIndex(pos.pos[0], pos.pos[1]);
ESM::RefId cellId = ESM::RefId::esm3ExteriorCell(exteriorCellPos.x(), exteriorCellPos.y());
mWorldScene->changeToExteriorCell(cellId, pos, true);
}
@ -1245,7 +1244,7 @@ namespace MWWorld
MWWorld::Ptr World::moveObject(const Ptr& ptr, const osg::Vec3f& position, bool movePhysics, bool moveToActive)
{
const osg::Vec2i index = positionToCellIndex(position.x(), position.y());
const osg::Vec2i index = ESM::positionToCellIndex(position.x(), position.y());
CellStore* cell = ptr.getCell();
ESM::RefId worldspaceId
@ -2064,7 +2063,7 @@ namespace MWWorld
throw std::runtime_error("copyObjectToCell(): cannot copy object to null cell");
if (cell->isExterior())
{
const osg::Vec2i index = positionToCellIndex(pos.pos[0], pos.pos[1]);
const osg::Vec2i index = ESM::positionToCellIndex(pos.pos[0], pos.pos[1]);
cell = &mWorldModel.getExterior(
ESM::ExteriorCellIndex(index.x(), index.y(), cell->getCell()->getWorldSpace()));
}

@ -16,7 +16,6 @@
#include "../mwbase/world.hpp"
#include "cellstore.hpp"
#include "cellutils.hpp"
#include "esmstore.hpp"
namespace
@ -333,7 +332,7 @@ MWWorld::CellStore& MWWorld::WorldModel::getCellByPosition(
{
if (cellInSameWorldSpace && !cellInSameWorldSpace->isExterior())
return *cellInSameWorldSpace;
const osg::Vec2i cellIndex = positionToCellIndex(pos.x(), pos.y());
const osg::Vec2i cellIndex = ESM::positionToCellIndex(pos.x(), pos.y());
ESM::RefId exteriorWorldspace
= cellInSameWorldSpace ? cellInSameWorldSpace->getCell()->getWorldSpace() : ESM::Cell::sDefaultWorldspaceId;
return getExterior(ESM::ExteriorCellIndex(cellIndex.x(), cellIndex.y(), exteriorWorldspace));

@ -1,7 +1,10 @@
#ifndef OPENMW_ESM_UTIL_H
#define OPENMW_ESM_UTIL_H
#include <cmath>
#include <osg/Quat>
#include <osg/Vec2>
#include <osg/Vec2i>
#include <osg/Vec3f>
#include <components/esm/refid.hpp>
@ -80,6 +83,13 @@ namespace ESM
{
return isESM4Ext ? Constants::ESM4CellSizeInUnits : Constants::CellSizeInUnits;
}
inline osg::Vec2i positionToCellIndex(float x, float y, bool esm4Ext = false)
{
const float cellSize = esm4Ext ? Constants::ESM4CellSizeInUnits : Constants::CellSizeInUnits;
return { static_cast<int>(std::floor(x / cellSize)), static_cast<int>(std::floor(y / cellSize)) };
}
}
namespace std

Loading…
Cancel
Save