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()
{
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<QUuid> &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);

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 setGeneratedCacheContext(GeneratedCacheContext *cacheContext);
void setSmoothShadingThresholdAngleDegrees(float degrees);
void setDefaultPartColor(const QColor &color);
signals:
void finished();
public slots: