From 369b0a378cbc7dd58fa1f5485c4c3eadca434764 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 18 Nov 2016 15:26:01 +0000 Subject: [PATCH] Optimize toggling visibility of normals, points, edges, outlines. Before this commit, any visibility toggle would cause a regeneration. After this commit, toggling visibility of normals and points never causes a regeneration, and toggling visibility of edges and outlines only causes a regeneration when they weren't already generated. --- src/graphicswin.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/graphicswin.cpp b/src/graphicswin.cpp index 1a552c2..33cb806 100644 --- a/src/graphicswin.cpp +++ b/src/graphicswin.cpp @@ -1081,13 +1081,14 @@ void GraphicsWindow::ToggleBool(bool *v) { // so not meaningful to show them and hide the shaded. if(!showShaded) showFaces = false; - // We might need to regenerate the mesh and edge list, since the edges - // wouldn't have been generated if they were previously hidden. - if(showEdges || showOutlines) { - SK.GetGroup(activeGroup)->displayDirty = true; + // If the mesh or edges were previously hidden, they haven't been generated, + // and if we are going to show them, we need to generate them first. + Group *g = SK.GetGroup(SS.GW.activeGroup); + if(*v && (g->displayOutlines.l.n == 0 && (v == &showEdges || v == &showOutlines))) { + SS.GenerateAll(SolveSpaceUI::Generate::UNTIL_ACTIVE); } - SS.GenerateAll(); + SS.GW.persistentDirty = true; InvalidateGraphics(); SS.ScheduleShowTW(); }