From fac78b5e56265ec862750efa35762fef5aa40248 Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Sat, 8 Jun 2019 17:27:13 +0930 Subject: [PATCH] Fix preference color setting --- src/document.cpp | 11 +++-------- src/meshgenerator.cpp | 5 +++++ src/meshgenerator.h | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/document.cpp b/src/document.cpp index b03df74c..c7f19f16 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -65,13 +65,7 @@ Document::Document() : void Document::applyPreferencePartColorChange() { - for (auto &it: partMap) { - if (it.second.hasColor) - continue; - it.second.color = Preferences::instance().partColor(); - it.second.dirty = true; - } - emit skeletonChanged(); + regenerateMesh(); } void Document::applyPreferenceFlatShadingChange() @@ -932,7 +926,7 @@ void Document::toSnapshot(Snapshot *snapshot, const std::set &limitNodeId } } part["dirty"] = partIt.second.dirty ? "true" : "false"; - //if (partIt.second.hasColor) + if (partIt.second.hasColor) part["color"] = partIt.second.color.name(); if (partIt.second.colorSolubilityAdjusted()) part["colorSolubility"] = QString::number(partIt.second.colorSolubility); @@ -1576,6 +1570,7 @@ void Document::generateMesh() toSnapshot(snapshot); resetDirtyFlags(); m_meshGenerator = new MeshGenerator(snapshot); + m_meshGenerator->setDefaultPartColor(Preferences::instance().partColor()); m_meshGenerator->setGeneratedCacheContext(&m_generatedCacheContext); if (!m_smoothNormal) { m_meshGenerator->setSmoothShadingThresholdAngleDegrees(0); diff --git a/src/meshgenerator.cpp b/src/meshgenerator.cpp index e87b9c8e..d9f50445 100644 --- a/src/meshgenerator.cpp +++ b/src/meshgenerator.cpp @@ -1151,3 +1151,8 @@ void MeshGenerator::generateSmoothTriangleVertexNormals(const std::vector