diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index d841bd992..955e97e3e 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -1,10 +1,14 @@ #include "cell.hpp" +#include +#include +#include #include #include #include #include +#include #include "../../model/world/idtable.hpp" #include "../../model/world/columns.hpp" @@ -77,6 +81,16 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::st mCellNode = new osg::Group; rootNode->addChild(mCellNode); + osg::ref_ptr pathgridTransform = new osg::PositionAttitudeTransform(); + pathgridTransform->setPosition(osg::Vec3f(mCoordinates.getX() * ESM::Land::REAL_SIZE, + mCoordinates.getY() * ESM::Land::REAL_SIZE, 0)); + mCellNode->addChild(pathgridTransform); + + mPathgridGeode = new osg::Geode(); + pathgridTransform->addChild(mPathgridGeode); + + mPathgridGeometry = 0; + setCellMarker(); if (!mDeleted) @@ -104,6 +118,15 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::st mCellBorder->buildShape(esmLand); } } + + const CSMWorld::SubCellCollection& pathgrids = mData.getPathgrids(); + int pathgridIndex = pathgrids.searchId(mId); + if (pathgridIndex != -1) + { + mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create( + pathgrids.getRecord(pathgridIndex).get()); + mPathgridGeode->addDrawable(mPathgridGeometry); + } } } @@ -256,22 +279,53 @@ bool CSVRender::Cell::referenceAdded (const QModelIndex& parent, int start, int void CSVRender::Cell::pathgridAdded(const CSMWorld::Pathgrid& pathgrid) { + mPathgridGeode->removeDrawable(mPathgridGeometry); + mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create(pathgrid); + mPathgridGeode->addDrawable(mPathgridGeometry); } void CSVRender::Cell::pathgridRemoved() { + mPathgridGeode->removeDrawable(mPathgridGeometry); } void CSVRender::Cell::pathgridDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight) { + const CSMWorld::SubCellCollection& pathgrids = mData.getPathgrids(); + int pathgridIndex = pathgrids.searchId(mId); + if (pathgridIndex != -1) + { + mPathgridGeode->removeDrawable(mPathgridGeometry); + mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create( + pathgrids.getRecord(pathgridIndex).get()); + mPathgridGeode->addDrawable(mPathgridGeometry); + } } void CSVRender::Cell::pathgridRowRemoved(const QModelIndex& parent, int start, int end) { + const CSMWorld::SubCellCollection& pathgrids = mData.getPathgrids(); + int pathgridIndex = pathgrids.searchId(mId); + if (pathgridIndex != -1) + { + mPathgridGeode->removeDrawable(mPathgridGeometry); + mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create( + pathgrids.getRecord(pathgridIndex).get()); + mPathgridGeode->addDrawable(mPathgridGeometry); + } } void CSVRender::Cell::pathgridRowAdded(const QModelIndex& parent, int start, int end) { + const CSMWorld::SubCellCollection& pathgrids = mData.getPathgrids(); + int pathgridIndex = pathgrids.searchId(mId); + if (pathgridIndex != -1) + { + mPathgridGeode->removeDrawable(mPathgridGeometry); + mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create( + pathgrids.getRecord(pathgridIndex).get()); + mPathgridGeode->addDrawable(mPathgridGeometry); + } } void CSVRender::Cell::setSelection (int elementMask, Selection mode) diff --git a/apps/opencs/view/render/cell.hpp b/apps/opencs/view/render/cell.hpp index 4758a95c3..0efb8757c 100644 --- a/apps/opencs/view/render/cell.hpp +++ b/apps/opencs/view/render/cell.hpp @@ -23,6 +23,8 @@ class QModelIndex; namespace osg { class Group; + class Geometry; + class Geode; } namespace CSMWorld @@ -41,6 +43,8 @@ namespace CSVRender CSMWorld::Data& mData; std::string mId; osg::ref_ptr mCellNode; + osg::ref_ptr mPathgridGeode; + osg::ref_ptr mPathgridGeometry; std::map mObjects; std::auto_ptr mTerrain; CSMWorld::CellCoordinates mCoordinates;