From 2f734d9cfa15a4fe8df65e656fab9dad82cadac7 Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Wed, 27 Jan 2016 14:19:40 +0600 Subject: [PATCH] When explicitly regenerating groups, only generate until active group. Before this change, groups and their meshes were generated even past the active group, which, in cause the mesh was broken, caused red marks to appear for no apparent reason. Furthermore, it unnecessarily slows down regeneration. --- src/dsc.h | 16 ++++++++++++++++ src/generate.cpp | 6 ++++++ src/graphicswin.cpp | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/dsc.h b/src/dsc.h index 61b3782c..c2c29414 100644 --- a/src/dsc.h +++ b/src/dsc.h @@ -304,6 +304,22 @@ public: return t; } + int IndexOf(H h) { + int first = 0, last = n-1; + while(first <= last) { + int mid = (first + last)/2; + H hm = elem[mid].h; + if(hm.v > h.v) { + last = mid-1; // and first stays the same + } else if(hm.v < h.v) { + first = mid+1; // and last stays the same + } else { + return mid; + } + } + return -1; + } + T *FindByIdNoOops(H h) { int first = 0, last = n-1; while(first <= last) { diff --git a/src/generate.cpp b/src/generate.cpp index 048ce693..d4e45f00 100644 --- a/src/generate.cpp +++ b/src/generate.cpp @@ -168,6 +168,12 @@ void SolveSpaceUI::GenerateAll(void) { void SolveSpaceUI::GenerateAll(int first, int last, bool andFindFree) { int i, j; + // generate until active group + if(last == -2) { + last = SK.group.IndexOf(SS.GW.activeGroup); + if(last == -1) last = INT_MAX; + } + // Remove any requests or constraints that refer to a nonexistent // group; can check those immediately, since we know what the list // of groups should be. diff --git a/src/graphicswin.cpp b/src/graphicswin.cpp index 5bce93fc..909da945 100644 --- a/src/graphicswin.cpp +++ b/src/graphicswin.cpp @@ -886,7 +886,7 @@ void GraphicsWindow::MenuEdit(int id) { case MNU_REGEN_ALL: SS.ReloadAllImported(); - SS.GenerateAll(0, INT_MAX); + SS.GenerateAll(0, -2); SS.ScheduleShowTW(); break;