From 62632dc168ebe5583197a610e86a66da73292aca Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Thu, 25 Oct 2018 23:28:10 +0800 Subject: [PATCH] Fix material widget --- src/materialwidget.cpp | 1 + src/meshgenerator.cpp | 4 ++-- src/meshresultpostprocessor.cpp | 2 +- src/outcome.cpp | 20 ++++---------------- src/outcome.h | 21 ++++++++++----------- src/texturegenerator.cpp | 2 +- 6 files changed, 19 insertions(+), 31 deletions(-) diff --git a/src/materialwidget.cpp b/src/materialwidget.cpp index dab825e0..f77c6221 100644 --- a/src/materialwidget.cpp +++ b/src/materialwidget.cpp @@ -8,6 +8,7 @@ MaterialWidget::MaterialWidget(const Document *document, QUuid materialId) : setObjectName("MaterialFrame"); m_previewWidget = new ModelWidget(this); + m_previewWidget->setAttribute(Qt::WA_TransparentForMouseEvents); m_previewWidget->setFixedSize(Theme::materialPreviewImageSize, Theme::materialPreviewImageSize); m_previewWidget->enableMove(false); m_previewWidget->enableZoom(false); diff --git a/src/meshgenerator.cpp b/src/meshgenerator.cpp index 3817baea..384ab028 100644 --- a/src/meshgenerator.cpp +++ b/src/meshgenerator.cpp @@ -670,11 +670,11 @@ void MeshGenerator::generate() } for (const auto &verticesSourcesIt: m_cacheContext->componentVerticesSources[QUuid().toString()].map()) { - m_outcome->bmeshVertices.push_back(verticesSourcesIt.second); + m_outcome->nodeVertices.push_back(verticesSourcesIt.second); } for (const auto &bmeshNodes: m_cacheContext->partBmeshNodes) { - m_outcome->bmeshNodes.insert(m_outcome->bmeshNodes.end(), + m_outcome->nodes.insert(m_outcome->nodes.end(), bmeshNodes.second.begin(), bmeshNodes.second.end()); } diff --git a/src/meshresultpostprocessor.cpp b/src/meshresultpostprocessor.cpp index e468ad5e..5913d3b7 100644 --- a/src/meshresultpostprocessor.cpp +++ b/src/meshresultpostprocessor.cpp @@ -21,7 +21,7 @@ Outcome *MeshResultPostProcessor::takePostProcessedResultContext() void MeshResultPostProcessor::process() { - if (!m_outcome->bmeshNodes.empty()) { + if (!m_outcome->nodes.empty()) { (void)m_outcome->triangleTangents(); (void)m_outcome->parts(); } diff --git a/src/outcome.cpp b/src/outcome.cpp index 00edb71c..466a56aa 100644 --- a/src/outcome.cpp +++ b/src/outcome.cpp @@ -26,18 +26,6 @@ struct CandidateEdge float length; }; -Outcome::Outcome() : - m_triangleSourceResolved(false), - m_triangleMaterialResolved(false), - m_triangleEdgeSourceMapResolved(false), - m_bmeshNodeMapResolved(false), - m_resultPartsResolved(false), - m_resultTriangleUvsResolved(false), - m_triangleVertexNormalsInterpolated(false), - m_triangleTangentsResolved(false) -{ -} - const std::vector> &Outcome::triangleSourceNodes() { if (!m_triangleSourceResolved) { @@ -90,7 +78,7 @@ void Outcome::calculateTriangleSourceNodes(std::vector> PositionMap> positionMap; std::map, HalfColorEdge> halfColorEdgeMap; std::set brokenTriangleSet; - for (const auto &it: bmeshVertices) { + for (const auto &it: nodeVertices) { positionMap.addPosition(it.position.x(), it.position.y(), it.position.z(), std::make_pair(it.partId, it.nodeId)); } @@ -262,7 +250,7 @@ void Outcome::calculateRemainingVertexSourceNodesAfterTriangleSourceNodesSolved( void Outcome::calculateTriangleMaterials(std::vector &triangleMaterials) { std::map, OutcomeMaterial> nodeMaterialMap; - for (const auto &it: bmeshNodes) { + for (const auto &it: nodes) { nodeMaterialMap[std::make_pair(it.partId, it.nodeId)] = it.material; } const auto sourceNodes = triangleSourceNodes(); @@ -285,8 +273,8 @@ void Outcome::calculateTriangleEdgeSourceMap(std::map, std:: } void Outcome::calculateBmeshNodeMap(std::map, OutcomeNode *> &bmeshNodeMap) { - for (auto i = 0u; i < bmeshNodes.size(); i++) { - OutcomeNode *bmeshNode = &bmeshNodes[i]; + for (auto i = 0u; i < nodes.size(); i++) { + OutcomeNode *bmeshNode = &nodes[i]; bmeshNodeMap[std::make_pair(bmeshNode->partId, bmeshNode->nodeId)] = bmeshNode; } } diff --git a/src/outcome.h b/src/outcome.h index 6910d89a..26b3565a 100644 --- a/src/outcome.h +++ b/src/outcome.h @@ -73,11 +73,10 @@ struct ResultPart class Outcome { public: - std::vector bmeshNodes; - std::vector bmeshVertices; + std::vector nodes; + std::vector nodeVertices; std::vector vertices; std::vector triangles; - Outcome(); public: const std::vector> &triangleSourceNodes(); const std::vector &triangleMaterials(); @@ -89,14 +88,14 @@ public: const std::vector &interpolatedTriangleVertexNormals(); const std::vector &triangleTangents(); private: - bool m_triangleSourceResolved; - bool m_triangleMaterialResolved; - bool m_triangleEdgeSourceMapResolved; - bool m_bmeshNodeMapResolved; - bool m_resultPartsResolved; - bool m_resultTriangleUvsResolved; - bool m_triangleVertexNormalsInterpolated; - bool m_triangleTangentsResolved; + bool m_triangleSourceResolved = false; + bool m_triangleMaterialResolved = false; + bool m_triangleEdgeSourceMapResolved = false; + bool m_bmeshNodeMapResolved = false; + bool m_resultPartsResolved = false; + bool m_resultTriangleUvsResolved = false; + bool m_triangleVertexNormalsInterpolated = false; + bool m_triangleTangentsResolved = false; private: std::vector> m_triangleSourceNodes; std::vector m_triangleMaterials; diff --git a/src/texturegenerator.cpp b/src/texturegenerator.cpp index 7505ff66..403da592 100644 --- a/src/texturegenerator.cpp +++ b/src/texturegenerator.cpp @@ -148,7 +148,7 @@ void TextureGenerator::prepare() QUuid partId = QUuid(partIt.first); updatedMaterialIdMap.insert({partId, materialId}); } - for (const auto &bmeshNode: m_outcome->bmeshNodes) { + for (const auto &bmeshNode: m_outcome->nodes) { for (size_t i = 0; i < (int)TextureType::Count - 1; ++i) { TextureType forWhat = (TextureType)(i + 1); MaterialTextures materialTextures;