Fix preference color setting

master
Jeremy Hu 2019-06-08 17:27:13 +09:30
parent 4955e47d76
commit fac78b5e56
3 changed files with 9 additions and 8 deletions

View File

@ -65,13 +65,7 @@ Document::Document() :
void Document::applyPreferencePartColorChange() void Document::applyPreferencePartColorChange()
{ {
for (auto &it: partMap) { regenerateMesh();
if (it.second.hasColor)
continue;
it.second.color = Preferences::instance().partColor();
it.second.dirty = true;
}
emit skeletonChanged();
} }
void Document::applyPreferenceFlatShadingChange() void Document::applyPreferenceFlatShadingChange()
@ -932,7 +926,7 @@ void Document::toSnapshot(Snapshot *snapshot, const std::set<QUuid> &limitNodeId
} }
} }
part["dirty"] = partIt.second.dirty ? "true" : "false"; part["dirty"] = partIt.second.dirty ? "true" : "false";
//if (partIt.second.hasColor) if (partIt.second.hasColor)
part["color"] = partIt.second.color.name(); part["color"] = partIt.second.color.name();
if (partIt.second.colorSolubilityAdjusted()) if (partIt.second.colorSolubilityAdjusted())
part["colorSolubility"] = QString::number(partIt.second.colorSolubility); part["colorSolubility"] = QString::number(partIt.second.colorSolubility);
@ -1576,6 +1570,7 @@ void Document::generateMesh()
toSnapshot(snapshot); toSnapshot(snapshot);
resetDirtyFlags(); resetDirtyFlags();
m_meshGenerator = new MeshGenerator(snapshot); m_meshGenerator = new MeshGenerator(snapshot);
m_meshGenerator->setDefaultPartColor(Preferences::instance().partColor());
m_meshGenerator->setGeneratedCacheContext(&m_generatedCacheContext); m_meshGenerator->setGeneratedCacheContext(&m_generatedCacheContext);
if (!m_smoothNormal) { if (!m_smoothNormal) {
m_meshGenerator->setSmoothShadingThresholdAngleDegrees(0); m_meshGenerator->setSmoothShadingThresholdAngleDegrees(0);

View File

@ -1151,3 +1151,8 @@ void MeshGenerator::generateSmoothTriangleVertexNormals(const std::vector<QVecto
} }
} }
} }
void MeshGenerator::setDefaultPartColor(const QColor &color)
{
m_defaultPartColor = color;
}

View File

@ -62,6 +62,7 @@ public:
void generate(); void generate();
void setGeneratedCacheContext(GeneratedCacheContext *cacheContext); void setGeneratedCacheContext(GeneratedCacheContext *cacheContext);
void setSmoothShadingThresholdAngleDegrees(float degrees); void setSmoothShadingThresholdAngleDegrees(float degrees);
void setDefaultPartColor(const QColor &color);
signals: signals:
void finished(); void finished();
public slots: public slots: