mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 09:09:43 +00:00
First step toward fixing terrain selection issues.
This commit is contained in:
parent
373f8636b7
commit
18ea4d8eb2
3 changed files with 92 additions and 8 deletions
|
@ -42,13 +42,84 @@ void CSVRender::TerrainSelection::onlySelect(const std::vector<std::pair<int, in
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::TerrainSelection::addSelect(const std::pair<int, int> &localPos)
|
void CSVRender::TerrainSelection::addSelect(const std::vector<std::pair<int, int>>& localPositions, bool toggleInProgress)
|
||||||
{
|
{
|
||||||
if (std::find(mSelection.begin(), mSelection.end(), localPos) == mSelection.end())
|
if (toggleInProgress)
|
||||||
{
|
{
|
||||||
mSelection.emplace_back(localPos);
|
for (auto const& localPos : localPositions)
|
||||||
update();
|
{
|
||||||
|
auto iterTemp = std::find(mTemporarySelection.begin(), mTemporarySelection.end(), localPos);
|
||||||
|
mDraggedOperationFlag = true;
|
||||||
|
|
||||||
|
if (iterTemp == mTemporarySelection.end())
|
||||||
|
{
|
||||||
|
auto iter = std::find(mSelection.begin(), mSelection.end(), localPos);
|
||||||
|
if (iter == mSelection.end())
|
||||||
|
{
|
||||||
|
mSelection.emplace_back(localPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mTemporarySelection.push_back(localPos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if (mDraggedOperationFlag == false)
|
||||||
|
{
|
||||||
|
for (auto const& localPos : localPositions)
|
||||||
|
{
|
||||||
|
const auto iter = std::find(mSelection.begin(), mSelection.end(), localPos);
|
||||||
|
if (iter == mSelection.end())
|
||||||
|
{
|
||||||
|
mSelection.emplace_back(localPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mDraggedOperationFlag = false;
|
||||||
|
mTemporarySelection.clear();
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::TerrainSelection::removeSelect(const std::vector<std::pair<int, int>>& localPositions, bool toggleInProgress)
|
||||||
|
{
|
||||||
|
if (toggleInProgress)
|
||||||
|
{
|
||||||
|
for (auto const& localPos : localPositions)
|
||||||
|
{
|
||||||
|
auto iterTemp = std::find(mTemporarySelection.begin(), mTemporarySelection.end(), localPos);
|
||||||
|
mDraggedOperationFlag = true;
|
||||||
|
|
||||||
|
if (iterTemp == mTemporarySelection.end())
|
||||||
|
{
|
||||||
|
auto iter = std::find(mSelection.begin(), mSelection.end(), localPos);
|
||||||
|
if (iter != mSelection.end())
|
||||||
|
{
|
||||||
|
mSelection.erase(iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mTemporarySelection.push_back(localPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mDraggedOperationFlag == false)
|
||||||
|
{
|
||||||
|
for (auto const& localPos : localPositions)
|
||||||
|
{
|
||||||
|
const auto iter = std::find(mSelection.begin(), mSelection.end(), localPos);
|
||||||
|
if (iter != mSelection.end())
|
||||||
|
{
|
||||||
|
mSelection.erase(iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mDraggedOperationFlag = false;
|
||||||
|
mTemporarySelection.clear();
|
||||||
|
}
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::TerrainSelection::toggleSelect(const std::vector<std::pair<int, int>> &localPositions, bool toggleInProgress)
|
void CSVRender::TerrainSelection::toggleSelect(const std::vector<std::pair<int, int>> &localPositions, bool toggleInProgress)
|
||||||
|
|
|
@ -36,7 +36,8 @@ namespace CSVRender
|
||||||
~TerrainSelection();
|
~TerrainSelection();
|
||||||
|
|
||||||
void onlySelect(const std::vector<std::pair<int, int>> &localPositions);
|
void onlySelect(const std::vector<std::pair<int, int>> &localPositions);
|
||||||
void addSelect(const std::pair<int, int> &localPos);
|
void addSelect(const std::vector<std::pair<int, int>>& localPositions, bool toggleInProgress);
|
||||||
|
void removeSelect(const std::vector<std::pair<int, int>>& localPositions, bool toggleInProgress);
|
||||||
void toggleSelect(const std::vector<std::pair<int, int>> &localPositions, bool toggleInProgress);
|
void toggleSelect(const std::vector<std::pair<int, int>> &localPositions, bool toggleInProgress);
|
||||||
|
|
||||||
void activate();
|
void activate();
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include "worldspacewidget.hpp"
|
#include "worldspacewidget.hpp"
|
||||||
|
|
||||||
CSVRender::TerrainShapeMode::TerrainShapeMode (WorldspaceWidget *worldspaceWidget, osg::Group* parentNode, QWidget *parent)
|
CSVRender::TerrainShapeMode::TerrainShapeMode (WorldspaceWidget *worldspaceWidget, osg::Group* parentNode, QWidget *parent)
|
||||||
: EditMode (worldspaceWidget, QIcon {":scenetoolbar/editing-terrain-shape"}, Mask_Terrain | Mask_Reference, "Terrain land editing", parent),
|
: EditMode (worldspaceWidget, QIcon {":scenetoolbar/editing-terrain-shape"}, Mask_Terrain, "Terrain land editing", parent),
|
||||||
mParentNode(parentNode)
|
mParentNode(parentNode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1089,9 +1089,21 @@ void CSVRender::TerrainShapeMode::selectTerrainShapes(const std::pair<int, int>&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selectMode == 0) mTerrainShapeSelection->onlySelect(selections);
|
std::string selectAction;
|
||||||
if(selectMode == 1) mTerrainShapeSelection->toggleSelect(selections, dragOperation);
|
|
||||||
|
|
||||||
|
if (selectMode == 0)
|
||||||
|
selectAction = CSMPrefs::get()["3D Scene Editing"]["primary-select-action"].toString();
|
||||||
|
else
|
||||||
|
selectAction = CSMPrefs::get()["3D Scene Editing"]["secondary-select-action"].toString();
|
||||||
|
|
||||||
|
if (selectAction == "Select only")
|
||||||
|
mTerrainShapeSelection->onlySelect(selections);
|
||||||
|
else if (selectAction == "Add to selection")
|
||||||
|
mTerrainShapeSelection->addSelect(selections, dragOperation);
|
||||||
|
else if (selectAction == "Remove from selection")
|
||||||
|
mTerrainShapeSelection->removeSelect(selections, dragOperation);
|
||||||
|
else if (selectAction == "Invert selection")
|
||||||
|
mTerrainShapeSelection->toggleSelect(selections, dragOperation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::TerrainShapeMode::pushEditToCommand(const CSMWorld::LandHeightsColumn::DataType& newLandGrid, CSMDoc::Document& document,
|
void CSVRender::TerrainShapeMode::pushEditToCommand(const CSMWorld::LandHeightsColumn::DataType& newLandGrid, CSMDoc::Document& document,
|
||||||
|
|
Loading…
Reference in a new issue