From c63b2619288f50022e6ac76512f5e371635f3c5c Mon Sep 17 00:00:00 2001 From: ousnius Date: Wed, 6 Jan 2016 23:49:44 +0100 Subject: [PATCH] Always update the shape source when brush stroke ends --- OutfitProject.cpp | 23 --------- OutfitProject.h | 9 ---- OutfitStudio.cpp | 127 +++++----------------------------------------- OutfitStudio.h | 5 -- 4 files changed, 13 insertions(+), 151 deletions(-) diff --git a/OutfitProject.cpp b/OutfitProject.cpp index ab0eb5bf..9dbf23ec 100644 --- a/OutfitProject.cpp +++ b/OutfitProject.cpp @@ -256,22 +256,6 @@ string OutfitProject::OutfitName() { return outfitName; } -bool OutfitProject::IsDirty() { - return (shapeDirty.size() > 0); -} - -void OutfitProject::Clean(const string& specificShape) { - shapeDirty.erase(specificShape); -} - -void OutfitProject::SetDirty(const string& specificShape) { - shapeDirty[specificShape] = true; -} - -bool OutfitProject::IsDirty(const string& specificShape) { - return (shapeDirty.find(specificShape) != shapeDirty.end()); -} - bool OutfitProject::ValidSlider(int index) { if (index >= 0 && index < activeSet.size()) return true; @@ -1045,7 +1029,6 @@ void OutfitProject::UpdateShapeFromMesh(const string& shapeName, const mesh* m) liveVerts.emplace_back(move(Vector3(m->verts[i].x * -10, m->verts[i].z * 10, m->verts[i].y * 10))); workNif.SetVertsForShape(shapeName, liveVerts); - Clean(shapeName); } void OutfitProject::UpdateMorphResult(const string& shapeName, const string& sliderName, unordered_map& vertUpdates) { @@ -1916,12 +1899,6 @@ void OutfitProject::RenameShape(const string& shapeName, const string& newShapeN morpher.RenameShape(shapeName, newShapeName); activeSet.RenameShape(shapeName, newShapeName); - - if (shapeDirty.find(shapeName) != shapeDirty.end()) { - shapeDirty.erase(shapeName); - shapeDirty[newShapeName] = true; - } - wxLogMessage("Renamed shape '%s' to '%s'.", shapeName, newShapeName); } diff --git a/OutfitProject.h b/OutfitProject.h index e69f597d..022abae1 100644 --- a/OutfitProject.h +++ b/OutfitProject.h @@ -48,7 +48,6 @@ class OutfitProject { map> boneScaleVerts; map> workWeights; - map shapeDirty; unordered_map shapeTextures; // inOwner is meant to provide access to OutfitStudio for the purposes of reporting process status only. @@ -86,14 +85,6 @@ class OutfitProject { string SliderSetFileName(); string OutfitName(); - bool IsDirty(); - void Clean() { - shapeDirty.clear(); - } - void Clean(const string& specificShape); - void SetDirty(const string& specificShape); - bool IsDirty(const string& specificShape); - bool ValidSlider(int index); bool ValidSlider(const string& sliderName); bool AllSlidersZero(); diff --git a/OutfitStudio.cpp b/OutfitStudio.cpp index 2b78ef46..48a519a6 100644 --- a/OutfitStudio.cpp +++ b/OutfitStudio.cpp @@ -633,8 +633,6 @@ void OutfitStudio::ActiveShapeUpdated(TweakStroke* refStroke, bool bIsUndo, bool project->workWeights.clear(); } } - else - project->SetDirty(activeItem->shapeName); } } @@ -642,37 +640,7 @@ string OutfitStudio::GetActiveBone() { return activeBone; } -bool OutfitStudio::IsDirty() { - return project->IsDirty(); -} - -bool OutfitStudio::IsDirty(const string& shapeName) { - return project->IsDirty(shapeName); -} - -void OutfitStudio::SetClean(const string& shapeName) { - project->Clean(shapeName); -} - void OutfitStudio::EnterSliderEdit(const string& sliderName) { - if (IsDirty(activeItem->shapeName)) { - int response = wxMessageBox("You have unsaved changes to the base mesh shape, do you wish to apply the changes? If you select NO, the changes will be lost.", wxMessageBoxCaptionStr, wxYES_NO | wxCANCEL, this); - if (response == wxCANCEL) - return; - - if (response == wxYES) { - vector shapes; - project->GetShapes(shapes); - - for (auto &s : shapes) { - UpdateShapeSource(s); - project->RefreshMorphShape(s); - } - } - if (response == wxNO) - project->Clean(); - } - bEditSlider = true; activeSlider = sliderName; SliderDisplay* d = sliderDisplays[activeSlider]; @@ -1294,19 +1262,9 @@ void OutfitStudio::OnSaveSliderSet(wxCommandEvent& event) { vector shapeMeshes; vector shapes; project->GetShapes(shapes); - for (auto &s : shapes){ - if (project->IsBaseShape(s)) { - if (IsDirty(s)) - UpdateShapeSource(s); - } - else { - if (IsDirty(s)) { - UpdateShapeSource(s); - project->RefreshMorphShape(s); - } + for (auto &s : shapes) + if (!project->IsBaseShape(s)) shapeMeshes.push_back(glView->GetMesh(s)); - } - } bool updateNormals = GetMenuBar()->IsChecked(XRCID("btnAutoNormals")); @@ -1467,19 +1425,9 @@ void OutfitStudio::OnSaveSliderSetAs(wxCommandEvent& WXUNUSED(event)) { vector shapeMeshes; vector shapes; project->GetShapes(shapes); - for (auto &s : shapes){ - if (project->IsBaseShape(s)) { - if (IsDirty(s)) - UpdateShapeSource(s); - } - else { - if (IsDirty(s)) { - UpdateShapeSource(s); - project->RefreshMorphShape(s); - } + for (auto &s : shapes) + if (!project->IsBaseShape(s)) shapeMeshes.push_back(glView->GetMesh(s)); - } - } bool updateNormals = GetMenuBar()->IsChecked(XRCID("btnAutoNormals")); @@ -2285,43 +2233,7 @@ void OutfitStudio::ZeroSliders() { } } -int OutfitStudio::PromptUpdateBase() { - int response; - response = wxMessageBox("You have unsaved changes to the base mesh shape, do you wish to apply the changes? If you select NO, the changes will be lost.", wxMessageBoxCaptionStr, wxYES_NO | wxCANCEL, this); - - if (response == wxCANCEL) - return response; - - if (response == wxYES) { - vector shapes; - project->GetShapes(shapes); - - for (auto &s : shapes) { - UpdateShapeSource(s); - project->RefreshMorphShape(s); - } - - //OnSliderConform(wxCommandEvent()); - //glView->GetStrokeManager()->InvalidateHistoricalBVH(); - glView->GetStrokeManager()->Clear(); - } - - if (response == wxNO) { - project->Clean(); - //glView->GetStrokeManager()->InvalidateHistoricalBVH(); - glView->GetStrokeManager()->Clear(); - } - return response; -} - void OutfitStudio::OnSlider(wxScrollEvent& event) { - int type = event.GetEventType(); - static bool sentinel = false; - - if (type == wxEVT_SCROLL_CHANGED) - if (sentinel) - return; - wxSlider* s = ((wxSlider*)event.GetEventObject()); if (!s) return; @@ -2336,13 +2248,6 @@ void OutfitStudio::OnSlider(wxScrollEvent& event) { boneScale->SetValue(0); } - if (IsDirty() && !bEditSlider) { - sentinel = true; - if (PromptUpdateBase() == wxCANCEL) - return; - sentinel = false; - } - if (outfitBones && sliderName == "boneScale") { wxArrayTreeItemIds selItems; outfitBones->GetSelections(selItems); @@ -2373,10 +2278,6 @@ void OutfitStudio::OnLoadPreset(wxCommandEvent& WXUNUSED(event)) { string choice; bool hi = true; - if (IsDirty()) - if (PromptUpdateBase() == wxCANCEL) - return; - presets.LoadPresets("SliderPresets", choice, names, true); presets.GetPresetNames(names); @@ -2961,10 +2862,6 @@ void OutfitStudio::OnSliderConform(wxCommandEvent& WXUNUSED(event)) { UpdateProgress(1, "Initializing data..."); project->InitConform(); - if (IsDirty(i->shapeName)) { - UpdateShapeSource(i->shapeName); - project->RefreshMorphShape(i->shapeName); - } UpdateProgress(50, "Conforming: " + i->shapeName); project->morpher.CopyMeshMask(glView->GetMesh(i->shapeName), i->shapeName); @@ -4165,12 +4062,6 @@ bool wxGLPanel::StartBrushStroke(const wxPoint& screenPos) { activeBrush = &smoothBrush; } - if (activeBrush->Type() == TBT_WEIGHT && os->IsDirty()) { - os->PromptUpdateBase(); - activeBrush = savedBrush; - return false; - } - activeStroke = strokeManager->CreateStroke(gls.GetActiveMesh(), activeBrush); activeBrush->setConnected(bConnectedEdit); activeBrush->setMirror(bXMirror); @@ -4256,9 +4147,17 @@ void wxGLPanel::EndBrushStroke() { } } - if (activeStroke->BrushType() != TBT_MASK) + if (activeStroke->BrushType() != TBT_MASK) { os->ActiveShapeUpdated(strokeManager->GetCurStateStroke()); + vector shapes; + os->project->GetShapes(shapes); + for (auto &s : shapes) { + os->UpdateShapeSource(s); + os->project->RefreshMorphShape(s); + } + } + activeStroke = nullptr; activeBrush = savedBrush; } diff --git a/OutfitStudio.h b/OutfitStudio.h index a4607a44..9f92b1d3 100644 --- a/OutfitStudio.h +++ b/OutfitStudio.h @@ -492,7 +492,6 @@ class OutfitStudio : public wxFrame { vector GetShapeList(); void UpdateShapeSource(const string& shapeName); - int PromptUpdateBase(); void ActiveShapeUpdated(TweakStroke* refStroke, bool bIsUndo = false, bool setWeights = true); void UpdateActiveShapeUI(); @@ -503,10 +502,6 @@ class OutfitStudio : public wxFrame { bool NotifyStrokeStarting(); - bool IsDirty(); - bool IsDirty(const string& shapeName); - void SetClean(const string& shapeName); - void EnterSliderEdit(const string& sliderName); void ExitSliderEdit(); void MenuEnterSliderEdit();