mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-19 13:41:32 +00:00
Second step toward fixing terrain selection issues.
This commit is contained in:
parent
18ea4d8eb2
commit
008bf64dd9
5 changed files with 60 additions and 5 deletions
|
@ -19,9 +19,12 @@ const int CSVRender::CellBorder::VertexCount = (ESM::Land::LAND_SIZE * 4) - 3;
|
||||||
CSVRender::CellBorder::CellBorder(osg::Group* cellNode, const CSMWorld::CellCoordinates& coords)
|
CSVRender::CellBorder::CellBorder(osg::Group* cellNode, const CSMWorld::CellCoordinates& coords)
|
||||||
: mParentNode(cellNode)
|
: mParentNode(cellNode)
|
||||||
{
|
{
|
||||||
|
mBorderGeode = new osg::Geode();
|
||||||
|
|
||||||
mBaseNode = new osg::PositionAttitudeTransform();
|
mBaseNode = new osg::PositionAttitudeTransform();
|
||||||
mBaseNode->setNodeMask(Mask_CellBorder);
|
mBaseNode->setNodeMask(Mask_CellBorder);
|
||||||
mBaseNode->setPosition(osg::Vec3f(coords.getX() * CellSize, coords.getY() * CellSize, 10));
|
mBaseNode->setPosition(osg::Vec3f(coords.getX() * CellSize, coords.getY() * CellSize, 10));
|
||||||
|
mBaseNode->addChild(mBorderGeode);
|
||||||
|
|
||||||
mParentNode->addChild(mBaseNode);
|
mParentNode->addChild(mBaseNode);
|
||||||
}
|
}
|
||||||
|
@ -79,10 +82,8 @@ void CSVRender::CellBorder::buildShape(const ESM::Land& esmLand)
|
||||||
geometry->addPrimitiveSet(primitives);
|
geometry->addPrimitiveSet(primitives);
|
||||||
geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||||
|
|
||||||
|
mBorderGeode->removeDrawables(0);
|
||||||
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
|
mBorderGeode->addDrawable(geometry);
|
||||||
geode->addDrawable(geometry);
|
|
||||||
mBaseNode->addChild(geode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CSVRender::CellBorder::landIndex(int x, int y)
|
size_t CSVRender::CellBorder::landIndex(int x, int y)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
namespace osg
|
namespace osg
|
||||||
{
|
{
|
||||||
|
class Geode;
|
||||||
class Group;
|
class Group;
|
||||||
class PositionAttitudeTransform;
|
class PositionAttitudeTransform;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +48,7 @@ namespace CSVRender
|
||||||
|
|
||||||
osg::Group* mParentNode;
|
osg::Group* mParentNode;
|
||||||
osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode;
|
osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode;
|
||||||
|
osg::ref_ptr<osg::Geode> mBorderGeode;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
20
apps/opencs/view/render/commands.cpp
Normal file
20
apps/opencs/view/render/commands.cpp
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#include "commands.hpp"
|
||||||
|
|
||||||
|
#include <components/esm/loadland.hpp>
|
||||||
|
|
||||||
|
#include "cell.hpp"
|
||||||
|
#include "terrainselection.hpp"
|
||||||
|
|
||||||
|
CSVRender::DrawTerrainSelectionCommand::DrawTerrainSelectionCommand(TerrainSelection& terrainSelection, QUndoCommand* parent)
|
||||||
|
: mTerrainSelection(terrainSelection)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void CSVRender::DrawTerrainSelectionCommand::redo()
|
||||||
|
{
|
||||||
|
mTerrainSelection.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::DrawTerrainSelectionCommand::undo()
|
||||||
|
{
|
||||||
|
mTerrainSelection.update();
|
||||||
|
}
|
30
apps/opencs/view/render/commands.hpp
Normal file
30
apps/opencs/view/render/commands.hpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef CSV_RENDER_COMMANDS_HPP
|
||||||
|
#define CSV_RENDER_COMMANDS_HPP
|
||||||
|
|
||||||
|
#include <QUndoCommand>
|
||||||
|
|
||||||
|
namespace ESM
|
||||||
|
{
|
||||||
|
struct Land;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSVRender
|
||||||
|
{
|
||||||
|
class Cell;
|
||||||
|
class TerrainSelection;
|
||||||
|
|
||||||
|
|
||||||
|
class DrawTerrainSelectionCommand : public QUndoCommand
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
TerrainSelection& mTerrainSelection;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DrawTerrainSelectionCommand(TerrainSelection& terrainSelection, QUndoCommand* parent = nullptr);
|
||||||
|
|
||||||
|
void redo() override;
|
||||||
|
void undo() override;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -34,6 +34,7 @@
|
||||||
#include "../../model/world/universalid.hpp"
|
#include "../../model/world/universalid.hpp"
|
||||||
|
|
||||||
#include "brushdraw.hpp"
|
#include "brushdraw.hpp"
|
||||||
|
#include "commands.hpp"
|
||||||
#include "editmode.hpp"
|
#include "editmode.hpp"
|
||||||
#include "pagedworldspacewidget.hpp"
|
#include "pagedworldspacewidget.hpp"
|
||||||
#include "mask.hpp"
|
#include "mask.hpp"
|
||||||
|
@ -284,6 +285,7 @@ void CSVRender::TerrainShapeMode::applyTerrainEditChanges()
|
||||||
sortAndLimitAlteredCells();
|
sortAndLimitAlteredCells();
|
||||||
|
|
||||||
undoStack.beginMacro ("Edit shape and normal records");
|
undoStack.beginMacro ("Edit shape and normal records");
|
||||||
|
undoStack.push(new DrawTerrainSelectionCommand(*mTerrainShapeSelection));
|
||||||
|
|
||||||
for(CSMWorld::CellCoordinates cellCoordinates: mAlteredCells)
|
for(CSMWorld::CellCoordinates cellCoordinates: mAlteredCells)
|
||||||
{
|
{
|
||||||
|
@ -353,6 +355,7 @@ void CSVRender::TerrainShapeMode::applyTerrainEditChanges()
|
||||||
}
|
}
|
||||||
pushNormalsEditToCommand(landNormalsNew, document, landTable, cellId);
|
pushNormalsEditToCommand(landNormalsNew, document, landTable, cellId);
|
||||||
}
|
}
|
||||||
|
undoStack.push(new DrawTerrainSelectionCommand(*mTerrainShapeSelection));
|
||||||
undoStack.endMacro();
|
undoStack.endMacro();
|
||||||
clearTransientEdits();
|
clearTransientEdits();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue