Only iterate through temporary selection when using toggle

pull/3178/head
unelsson 3 years ago
parent 46960825ef
commit 55456a19fc

@ -64,7 +64,6 @@ void CSVRender::TerrainSelection::toggleSelect(const std::vector<std::pair<int,
void CSVRender::TerrainSelection::clearTemporarySelection()
{
mTemporarySelection.clear();
update();
}
void CSVRender::TerrainSelection::activate()
@ -211,45 +210,50 @@ void CSVRender::TerrainSelection::handleSelection(const std::vector<std::pair<in
{
for (auto const& localPos : localPositions)
{
auto iterTemp = std::find(mTemporarySelection.begin(), mTemporarySelection.end(), localPos);
const auto iter = std::find(mSelection.begin(), mSelection.end(), localPos);
if (iterTemp == mTemporarySelection.end())
switch (selectionMethod)
{
const auto iter = std::find(mSelection.begin(), mSelection.end(), localPos);
case SelectionMethod::OnlySelect:
break;
switch (selectionMethod)
{
case SelectionMethod::AddSelect:
if (iter == mSelection.end())
{
mSelection.emplace_back(localPos);
}
break;
case SelectionMethod::RemoveSelect:
if (iter != mSelection.end())
{
mSelection.erase(iter);
}
break;
case SelectionMethod::ToggleSelect:
if (iter == mSelection.end())
{
mSelection.emplace_back(localPos);
}
else
{
const auto iterTemp = std::find(mTemporarySelection.begin(), mTemporarySelection.end(), localPos);
if (iterTemp == mTemporarySelection.end())
{
mSelection.erase(iter);
if (iter == mSelection.end())
{
mSelection.emplace_back(localPos);
}
else
{
mSelection.erase(iter);
}
}
mTemporarySelection.emplace_back(localPos);
break;
default: break;
}
}
mTemporarySelection.emplace_back(localPos);
default:
break;
}
}
update();
}

@ -115,6 +115,7 @@ void CSVRender::TerrainShapeMode::primarySelectPressed(const WorldspaceHitResult
if(hit.hit && hit.tag == nullptr)
{
selectTerrainShapes(CSMWorld::CellCoordinates::toVertexCoords(hit.worldPos), 0);
mTerrainShapeSelection->clearTemporarySelection();
}
}
@ -123,6 +124,7 @@ void CSVRender::TerrainShapeMode::secondarySelectPressed(const WorldspaceHitResu
if(hit.hit && hit.tag == nullptr)
{
selectTerrainShapes(CSMWorld::CellCoordinates::toVertexCoords(hit.worldPos), 1);
mTerrainShapeSelection->clearTemporarySelection();
}
}

@ -130,6 +130,7 @@ void CSVRender::TerrainTextureMode::primarySelectPressed(const WorldspaceHitResu
if(hit.hit && hit.tag == nullptr)
{
selectTerrainTextures(CSMWorld::CellCoordinates::toTextureCoords(hit.worldPos), 0);
mTerrainTextureSelection->clearTemporarySelection();
}
}
@ -138,6 +139,7 @@ void CSVRender::TerrainTextureMode::secondarySelectPressed(const WorldspaceHitRe
if(hit.hit && hit.tag == nullptr)
{
selectTerrainTextures(CSMWorld::CellCoordinates::toTextureCoords(hit.worldPos), 1);
mTerrainTextureSelection->clearTemporarySelection();
}
}

Loading…
Cancel
Save