use CellCoordinates instead of a pair of ints for cell coordinates

openmw-37
Marc Zinnschlag 9 years ago
parent 0d35938794
commit b81ee606c8

@ -52,7 +52,7 @@ bool CSVRender::Cell::addObjects (int start, int end)
} }
CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::string& id) CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::string& id)
: mData (data), mId (Misc::StringUtils::lowerCase (id)), mX(0), mY(0) : mData (data), mId (Misc::StringUtils::lowerCase (id))
{ {
mCellNode = new osg::Group; mCellNode = new osg::Group;
rootNode->addChild(mCellNode); rootNode->addChild(mCellNode);
@ -76,8 +76,7 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::st
mTerrain->loadCell(esmLand.mX, mTerrain->loadCell(esmLand.mX,
esmLand.mY); esmLand.mY);
mX = esmLand.mX; mCoordinates = CSMWorld::CellCoordinates (esmLand.mX, esmLand.mY);
mY = esmLand.mY;
} }
} }
} }
@ -245,7 +244,7 @@ void CSVRender::Cell::setCellArrows (int mask)
if (enable!=(mCellArrows[i].get()!=0)) if (enable!=(mCellArrows[i].get()!=0))
{ {
if (enable) if (enable)
mCellArrows[i].reset (new CellArrow (mCellNode, direction, mX, mY)); mCellArrows[i].reset (new CellArrow (mCellNode, direction, mCoordinates));
else else
mCellArrows[i].reset (0); mCellArrows[i].reset (0);
} }
@ -254,5 +253,5 @@ void CSVRender::Cell::setCellArrows (int mask)
CSMWorld::CellCoordinates CSVRender::Cell::getCoordinates() const CSMWorld::CellCoordinates CSVRender::Cell::getCoordinates() const
{ {
return CSMWorld::CellCoordinates (mX, mY); return mCoordinates;
} }

@ -38,8 +38,7 @@ namespace CSVRender
osg::ref_ptr<osg::Group> mCellNode; osg::ref_ptr<osg::Group> mCellNode;
std::map<std::string, Object *> mObjects; std::map<std::string, Object *> mObjects;
std::auto_ptr<Terrain::TerrainGrid> mTerrain; std::auto_ptr<Terrain::TerrainGrid> mTerrain;
int mX; CSMWorld::CellCoordinates mCoordinates;
int mY;
std::auto_ptr<CellArrow> mCellArrows[4]; std::auto_ptr<CellArrow> mCellArrows[4];
/// Ignored if cell does not have an object with the given ID. /// Ignored if cell does not have an object with the given ID.

@ -8,7 +8,6 @@
#include <osg/Shape> #include <osg/Shape>
#include <osg/Geode> #include <osg/Geode>
#include "elements.hpp" #include "elements.hpp"
CSVRender::CellArrowTag::CellArrowTag (CellArrow *arrow) CSVRender::CellArrowTag::CellArrowTag (CellArrow *arrow)
@ -27,8 +26,8 @@ void CSVRender::CellArrow::adjustTransform()
const int cellSize = 8192; const int cellSize = 8192;
const int offset = cellSize / 2 + 400; const int offset = cellSize / 2 + 400;
int x = mXIndex*cellSize + cellSize/2; int x = mCoordinates.getX()*cellSize + cellSize/2;
int y = mYIndex*cellSize + cellSize/2; int y = mCoordinates.getY()*cellSize + cellSize/2;
switch (mDirection) switch (mDirection)
{ {
@ -61,8 +60,8 @@ void CSVRender::CellArrow::buildShape()
} }
CSVRender::CellArrow::CellArrow (osg::Group *cellNode, Direction direction, CSVRender::CellArrow::CellArrow (osg::Group *cellNode, Direction direction,
int xIndex, int yIndex) const CSMWorld::CellCoordinates& coordinates)
: mDirection (direction), mParentNode (cellNode), mXIndex (xIndex), mYIndex (yIndex) : mDirection (direction), mParentNode (cellNode), mCoordinates (coordinates)
{ {
mBaseNode = new osg::PositionAttitudeTransform; mBaseNode = new osg::PositionAttitudeTransform;
@ -82,12 +81,7 @@ CSVRender::CellArrow::~CellArrow()
mParentNode->removeChild (mBaseNode); mParentNode->removeChild (mBaseNode);
} }
int CSVRender::CellArrow::getXIndex() const CSMWorld::CellCoordinates CSVRender::CellArrow::getCoordinates() const
{
return mXIndex;
}
int CSVRender::CellArrow::getYIndex() const
{ {
return mYIndex; return mCoordinates;
} }

@ -5,6 +5,8 @@
#include <osg/ref_ptr> #include <osg/ref_ptr>
#include "../../model/world/cellcoordinates.hpp"
namespace osg namespace osg
{ {
class PositionAttitudeTransform; class PositionAttitudeTransform;
@ -48,8 +50,7 @@ namespace CSVRender
Direction mDirection; Direction mDirection;
osg::Group* mParentNode; osg::Group* mParentNode;
osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode; osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode;
int mXIndex; CSMWorld::CellCoordinates mCoordinates;
int mYIndex;
void adjustTransform(); void adjustTransform();
@ -57,13 +58,12 @@ namespace CSVRender
public: public:
CellArrow (osg::Group *cellNode, Direction direction, int xIndex, int yIndex); CellArrow (osg::Group *cellNode, Direction direction,
const CSMWorld::CellCoordinates& coordinates);
~CellArrow(); ~CellArrow();
int getXIndex() const; CSMWorld::CellCoordinates getCoordinates() const;
int getYIndex() const;
}; };
} }

Loading…
Cancel
Save