From aee47a42c6f470d1a295394c7530f86eb0dd6a67 Mon Sep 17 00:00:00 2001 From: ruevs Date: Sat, 9 Jul 2022 03:10:05 +0300 Subject: [PATCH] Clean up face selection code --- src/draw.cpp | 8 ++++---- src/groupmesh.cpp | 10 +++++----- src/ui.h | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/draw.cpp b/src/draw.cpp index 09ee0bc5..831602da 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -185,7 +185,7 @@ void GraphicsWindow::MakeSelected(Selection *stog) { if(stog->entity.v != 0 && SK.GetEntity(stog->entity)->IsFace()) { // In the interest of speed for the triangle drawing code, - // only three faces may be selected at a time. + // only MAX_SELECTABLE_FACES faces may be selected at a time. int c = 0; Selection *s; selection.ClearTags(); @@ -193,9 +193,9 @@ void GraphicsWindow::MakeSelected(Selection *stog) { hEntity he = s->entity; if(he.v != 0 && SK.GetEntity(he)->IsFace()) { c++; - // Modify also Group::DrawMesh "case DrawMeshAs::SELECTED:" - // Magic numers are ugly :-( - if(c >= 3) s->tag = 1; + // See also GraphicsWindow::GroupSelection "if(e->IsFace())" + // and Group::DrawMesh "case DrawMeshAs::SELECTED:" + if(c >= MAX_SELECTABLE_FACES) s->tag = 1; } } selection.RemoveTagged(); diff --git a/src/groupmesh.cpp b/src/groupmesh.cpp index 3c926891..719bf750 100644 --- a/src/groupmesh.cpp +++ b/src/groupmesh.cpp @@ -635,11 +635,11 @@ void Group::DrawMesh(DrawMeshAs how, Canvas *canvas) { std::vector faces; SS.GW.GroupSelection(); auto const &gs = SS.GW.gs; - // Modify also GraphicsWindow::MakeSelected "if(c >= 3) s->tag = 1;" - // Magic numers are ugly :-( - if(gs.faces > 0) faces.push_back(gs.face[0].v); - if(gs.faces > 1) faces.push_back(gs.face[1].v); - if(gs.faces > 2) faces.push_back(gs.face[2].v); + // See also GraphicsWindow::MakeSelected "if(c >= MAX_SELECTABLE_FACES)" + // and GraphicsWindow::GroupSelection "if(e->IsFace())" + for(auto &fc : gs.face) { + faces.push_back(fc.v); + } canvas->DrawFaces(displayMesh, faces, hcf); break; } diff --git a/src/ui.h b/src/ui.h index c4ffff2b..fb777a87 100644 --- a/src/ui.h +++ b/src/ui.h @@ -750,6 +750,7 @@ public: Selection hover; bool hoverWasSelectedOnMousedown; List selection; + const unsigned MAX_SELECTABLE_FACES = 3u; Selection ChooseFromHoverToSelect(); Selection ChooseFromHoverToDrag();