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)
: mData (data), mId (Misc::StringUtils::lowerCase (id)), mX(0), mY(0)
: mData (data), mId (Misc::StringUtils::lowerCase (id))
{
mCellNode = new osg::Group;
rootNode->addChild(mCellNode);
@ -76,8 +76,7 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::st
mTerrain->loadCell(esmLand.mX,
esmLand.mY);
mX = esmLand.mX;
mY = esmLand.mY;
mCoordinates = CSMWorld::CellCoordinates (esmLand.mX, esmLand.mY);
}
}
}
@ -245,7 +244,7 @@ void CSVRender::Cell::setCellArrows (int mask)
if (enable!=(mCellArrows[i].get()!=0))
{
if (enable)
mCellArrows[i].reset (new CellArrow (mCellNode, direction, mX, mY));
mCellArrows[i].reset (new CellArrow (mCellNode, direction, mCoordinates));
else
mCellArrows[i].reset (0);
}
@ -254,5 +253,5 @@ void CSVRender::Cell::setCellArrows (int mask)
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;
std::map<std::string, Object *> mObjects;
std::auto_ptr<Terrain::TerrainGrid> mTerrain;
int mX;
int mY;
CSMWorld::CellCoordinates mCoordinates;
std::auto_ptr<CellArrow> mCellArrows[4];
/// Ignored if cell does not have an object with the given ID.

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

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

Loading…
Cancel
Save