1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-21 09:39:56 +00:00

Move getNorthVector out of MWWorld::World (used only in one place)

This commit is contained in:
Petr Mikheev 2022-12-24 13:45:18 +01:00
parent 310acaeee9
commit 103908ffc7
4 changed files with 14 additions and 20 deletions

View File

@ -156,9 +156,6 @@ namespace MWBase
virtual bool isCellQuasiExterior() const = 0;
virtual osg::Vec2f getNorthVector(const MWWorld::CellStore* cell) = 0;
///< get north vector for given interior cell
virtual void getDoorMarkers(MWWorld::CellStore* cell, std::vector<DoorMarker>& out) = 0;
///< get a list of teleport door markers for a given cell, to be displayed on the local map

View File

@ -281,6 +281,19 @@ namespace MWRender
}
}
static osg::Vec2f getNorthVector(const MWWorld::CellStore* cell)
{
MWWorld::ConstPtr northmarker = cell->searchConst(ESM::RefId::stringRefId("northmarker"));
if (northmarker.isEmpty())
return osg::Vec2f(0, 1);
osg::Quat orient(-northmarker.getRefData().getPosition().rot[2], osg::Vec3f(0, 0, 1));
osg::Vec3f dir = orient * osg::Vec3f(0, 1, 0);
osg::Vec2f d(dir.x(), dir.y());
return d;
}
void LocalMap::requestInteriorMap(const MWWorld::CellStore* cell)
{
osg::ComputeBoundsVisitor computeBoundsVisitor;
@ -299,7 +312,7 @@ namespace MWRender
mBounds = bounds;
// Get the cell's NorthMarker rotation. This is used to rotate the entire map.
osg::Vec2f north = MWBase::Environment::get().getWorld()->getNorthVector(cell);
osg::Vec2f north = getNorthVector(cell);
mAngle = std::atan2(north.x(), north.y());

View File

@ -2022,19 +2022,6 @@ namespace MWWorld
mWeatherManager->modRegion(regionid, chances);
}
osg::Vec2f World::getNorthVector(const CellStore* cell)
{
MWWorld::ConstPtr northmarker = cell->searchConst(ESM::RefId::stringRefId("northmarker"));
if (northmarker.isEmpty())
return osg::Vec2f(0, 1);
osg::Quat orient(-northmarker.getRefData().getPosition().rot[2], osg::Vec3f(0, 0, 1));
osg::Vec3f dir = orient * osg::Vec3f(0, 1, 0);
osg::Vec2f d(dir.x(), dir.y());
return d;
}
struct GetDoorMarkerVisitor
{
std::vector<World::DoorMarker>& mOut;

View File

@ -246,9 +246,6 @@ namespace MWWorld
bool isCellQuasiExterior() const override;
osg::Vec2f getNorthVector(const CellStore* cell) override;
///< get north vector for given interior cell
void getDoorMarkers(MWWorld::CellStore* cell, std::vector<DoorMarker>& out) override;
///< get a list of teleport door markers for a given cell, to be displayed on the local map