1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00

Second step toward fixing terrain selection issues.

This commit is contained in:
Atahualpa 2021-05-10 14:20:53 +02:00
parent 18ea4d8eb2
commit 008bf64dd9
5 changed files with 60 additions and 5 deletions

View File

@ -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)
: mParentNode(cellNode)
{
mBorderGeode = new osg::Geode();
mBaseNode = new osg::PositionAttitudeTransform();
mBaseNode->setNodeMask(Mask_CellBorder);
mBaseNode->setPosition(osg::Vec3f(coords.getX() * CellSize, coords.getY() * CellSize, 10));
mBaseNode->addChild(mBorderGeode);
mParentNode->addChild(mBaseNode);
}
@ -79,10 +82,8 @@ void CSVRender::CellBorder::buildShape(const ESM::Land& esmLand)
geometry->addPrimitiveSet(primitives);
geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
geode->addDrawable(geometry);
mBaseNode->addChild(geode);
mBorderGeode->removeDrawables(0);
mBorderGeode->addDrawable(geometry);
}
size_t CSVRender::CellBorder::landIndex(int x, int y)

View File

@ -7,6 +7,7 @@
namespace osg
{
class Geode;
class Group;
class PositionAttitudeTransform;
}
@ -47,7 +48,7 @@ namespace CSVRender
osg::Group* mParentNode;
osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode;
osg::ref_ptr<osg::Geode> mBorderGeode;
};
}

View 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();
}

View 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

View File

@ -34,6 +34,7 @@
#include "../../model/world/universalid.hpp"
#include "brushdraw.hpp"
#include "commands.hpp"
#include "editmode.hpp"
#include "pagedworldspacewidget.hpp"
#include "mask.hpp"
@ -284,6 +285,7 @@ void CSVRender::TerrainShapeMode::applyTerrainEditChanges()
sortAndLimitAlteredCells();
undoStack.beginMacro ("Edit shape and normal records");
undoStack.push(new DrawTerrainSelectionCommand(*mTerrainShapeSelection));
for(CSMWorld::CellCoordinates cellCoordinates: mAlteredCells)
{
@ -353,6 +355,7 @@ void CSVRender::TerrainShapeMode::applyTerrainEditChanges()
}
pushNormalsEditToCommand(landNormalsNew, document, landTable, cellId);
}
undoStack.push(new DrawTerrainSelectionCommand(*mTerrainShapeSelection));
undoStack.endMacro();
clearTransientEdits();
}