diff --git a/src/meshgenerator.cpp b/src/meshgenerator.cpp index 6ce4294f..9faf1cef 100644 --- a/src/meshgenerator.cpp +++ b/src/meshgenerator.cpp @@ -333,6 +333,7 @@ nodemesh::Combiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdSt bool subdived = isTrueValueString(valueOfKeyInMapOrEmpty(part, "subdived")); bool rounded = isTrueValueString(valueOfKeyInMapOrEmpty(part, "rounded")); bool chamfered = isTrueValueString(valueOfKeyInMapOrEmpty(part, "chamfered")); + bool countershaded = isTrueValueString(valueOfKeyInMapOrEmpty(part, "countershaded")); QString colorString = valueOfKeyInMapOrEmpty(part, "color"); QColor partColor = colorString.isEmpty() ? m_defaultPartColor : QColor(colorString); float deformThickness = 1.0; @@ -521,6 +522,7 @@ nodemesh::Combiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdSt outcomeNode.radius = nodeInfo.radius; outcomeNode.color = partColor; outcomeNode.materialId = materialId; + outcomeNode.countershaded = countershaded; outcomeNode.colorSolubility = colorSolubility; outcomeNode.boneMark = nodeInfo.boneMark; outcomeNode.mirroredByPartId = mirroredPartIdString; diff --git a/src/outcome.h b/src/outcome.h index ec302af1..062ac8d7 100644 --- a/src/outcome.h +++ b/src/outcome.h @@ -20,6 +20,7 @@ struct OutcomeNode QColor color; float colorSolubility = 0; QUuid materialId; + bool countershaded = false; QUuid mirrorFromPartId; QUuid mirroredByPartId; BoneMark boneMark; diff --git a/src/texturegenerator.cpp b/src/texturegenerator.cpp index fb690d01..1da7c723 100644 --- a/src/texturegenerator.cpp +++ b/src/texturegenerator.cpp @@ -164,6 +164,7 @@ void TextureGenerator::prepare() return; std::map updatedMaterialIdMap; + std::map updatedCountershadedMap; for (const auto &partIt: m_snapshot->parts) { QUuid materialId; auto materialIdIt = partIt.second.find("materialId"); @@ -171,10 +172,19 @@ void TextureGenerator::prepare() materialId = QUuid(materialIdIt->second); QUuid partId = QUuid(partIt.first); updatedMaterialIdMap.insert({partId, materialId}); - if (isTrueValueString(valueOfKeyInMapOrEmpty(partIt.second, "countershaded"))) - m_countershadedPartIds.insert(partId); + auto countershadedIt = partIt.second.find("countershaded"); + if (countershadedIt != partIt.second.end()) + updatedCountershadedMap.insert({partId, isTrueValueString(countershadedIt->second)}); } for (const auto &bmeshNode: m_outcome->nodes) { + + bool countershaded = bmeshNode.countershaded; + auto findUpdatedCountershadedMap = updatedCountershadedMap.find(bmeshNode.mirrorFromPartId.isNull() ? bmeshNode.partId : bmeshNode.mirrorFromPartId); + if (findUpdatedCountershadedMap != updatedCountershadedMap.end()) + countershaded = findUpdatedCountershadedMap->second; + if (countershaded) + m_countershadedPartIds.insert(bmeshNode.partId); + for (size_t i = 0; i < (int)TextureType::Count - 1; ++i) { TextureType forWhat = (TextureType)(i + 1); MaterialTextures materialTextures;