Add pathgrid to navmesh as off mesh connection
parent
095a45c714
commit
c4cd3b2c4f
@ -1,44 +0,0 @@
|
||||
#include "coordinateconverter.hpp"
|
||||
|
||||
#include <components/esm/loadcell.hpp>
|
||||
#include <components/esm/loadland.hpp>
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
CoordinateConverter::CoordinateConverter(const ESM::Cell* cell)
|
||||
: mCellX(0), mCellY(0)
|
||||
{
|
||||
if (cell->isExterior())
|
||||
{
|
||||
mCellX = cell->mData.mX * ESM::Land::REAL_SIZE;
|
||||
mCellY = cell->mData.mY * ESM::Land::REAL_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
void CoordinateConverter::toWorld(ESM::Pathgrid::Point& point)
|
||||
{
|
||||
point.mX += mCellX;
|
||||
point.mY += mCellY;
|
||||
}
|
||||
|
||||
void CoordinateConverter::toWorld(osg::Vec3f& point)
|
||||
{
|
||||
point.x() += static_cast<float>(mCellX);
|
||||
point.y() += static_cast<float>(mCellY);
|
||||
}
|
||||
|
||||
void CoordinateConverter::toLocal(osg::Vec3f& point)
|
||||
{
|
||||
point.x() -= static_cast<float>(mCellX);
|
||||
point.y() -= static_cast<float>(mCellY);
|
||||
}
|
||||
|
||||
osg::Vec3f CoordinateConverter::toLocalVec3(const osg::Vec3f& point)
|
||||
{
|
||||
return osg::Vec3f(
|
||||
point.x() - static_cast<float>(mCellX),
|
||||
point.y() - static_cast<float>(mCellY),
|
||||
point.z()
|
||||
);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
#ifndef GAME_MWMECHANICS_COORDINATECONVERTER_H
|
||||
#define GAME_MWMECHANICS_COORDINATECONVERTER_H
|
||||
|
||||
#include <components/esm/defs.hpp>
|
||||
#include <components/esm/loadpgrd.hpp>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
struct Cell;
|
||||
}
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
/// \brief convert coordinates between world and local cell
|
||||
class CoordinateConverter
|
||||
{
|
||||
public:
|
||||
CoordinateConverter(const ESM::Cell* cell);
|
||||
|
||||
/// in-place conversion from local to world
|
||||
void toWorld(ESM::Pathgrid::Point& point);
|
||||
|
||||
/// in-place conversion from local to world
|
||||
void toWorld(osg::Vec3f& point);
|
||||
|
||||
/// in-place conversion from world to local
|
||||
void toLocal(osg::Vec3f& point);
|
||||
|
||||
osg::Vec3f toLocalVec3(const osg::Vec3f& point);
|
||||
|
||||
private:
|
||||
int mCellX;
|
||||
int mCellY;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,68 @@
|
||||
#ifndef OPENMW_COMPONENTS_MISC_COORDINATECONVERTER_H
|
||||
#define OPENMW_COMPONENTS_MISC_COORDINATECONVERTER_H
|
||||
|
||||
#include <components/esm/defs.hpp>
|
||||
#include <components/esm/loadcell.hpp>
|
||||
#include <components/esm/loadland.hpp>
|
||||
#include <components/esm/loadpgrd.hpp>
|
||||
|
||||
namespace Misc
|
||||
{
|
||||
/// \brief convert coordinates between world and local cell
|
||||
class CoordinateConverter
|
||||
{
|
||||
public:
|
||||
CoordinateConverter(bool exterior, int cellX, int cellY)
|
||||
: mCellX(exterior ? cellX * ESM::Land::REAL_SIZE : 0),
|
||||
mCellY(exterior ? cellY * ESM::Land::REAL_SIZE : 0)
|
||||
{
|
||||
}
|
||||
|
||||
explicit CoordinateConverter(const ESM::Cell* cell)
|
||||
: CoordinateConverter(cell->isExterior(), cell->mData.mX, cell->mData.mY)
|
||||
{
|
||||
}
|
||||
|
||||
/// in-place conversion from local to world
|
||||
void toWorld(ESM::Pathgrid::Point& point) const
|
||||
{
|
||||
point.mX += mCellX;
|
||||
point.mY += mCellY;
|
||||
}
|
||||
|
||||
ESM::Pathgrid::Point toWorldPoint(ESM::Pathgrid::Point point) const
|
||||
{
|
||||
toWorld(point);
|
||||
return point;
|
||||
}
|
||||
|
||||
/// in-place conversion from local to world
|
||||
void toWorld(osg::Vec3f& point) const
|
||||
{
|
||||
point.x() += static_cast<float>(mCellX);
|
||||
point.y() += static_cast<float>(mCellY);
|
||||
}
|
||||
|
||||
/// in-place conversion from world to local
|
||||
void toLocal(osg::Vec3f& point) const
|
||||
{
|
||||
point.x() -= static_cast<float>(mCellX);
|
||||
point.y() -= static_cast<float>(mCellY);
|
||||
}
|
||||
|
||||
osg::Vec3f toLocalVec3(const osg::Vec3f& point) const
|
||||
{
|
||||
return osg::Vec3f(
|
||||
point.x() - static_cast<float>(mCellX),
|
||||
point.y() - static_cast<float>(mCellY),
|
||||
point.z()
|
||||
);
|
||||
}
|
||||
|
||||
private:
|
||||
int mCellX;
|
||||
int mCellY;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue