Clean up face selection code

pull/1322/head
ruevs 2022-07-09 03:10:05 +03:00 committed by Paul Kahler
parent adb2768154
commit aee47a42c6
3 changed files with 10 additions and 9 deletions

View File

@ -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();

View File

@ -635,11 +635,11 @@ void Group::DrawMesh(DrawMeshAs how, Canvas *canvas) {
std::vector<uint32_t> 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;
}

View File

@ -750,6 +750,7 @@ public:
Selection hover;
bool hoverWasSelectedOnMousedown;
List<Selection> selection;
const unsigned MAX_SELECTABLE_FACES = 3u;
Selection ChooseFromHoverToSelect();
Selection ChooseFromHoverToDrag();