Fix material widget
parent
438c488f5a
commit
62632dc168
|
@ -8,6 +8,7 @@ MaterialWidget::MaterialWidget(const Document *document, QUuid materialId) :
|
||||||
setObjectName("MaterialFrame");
|
setObjectName("MaterialFrame");
|
||||||
|
|
||||||
m_previewWidget = new ModelWidget(this);
|
m_previewWidget = new ModelWidget(this);
|
||||||
|
m_previewWidget->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
m_previewWidget->setFixedSize(Theme::materialPreviewImageSize, Theme::materialPreviewImageSize);
|
m_previewWidget->setFixedSize(Theme::materialPreviewImageSize, Theme::materialPreviewImageSize);
|
||||||
m_previewWidget->enableMove(false);
|
m_previewWidget->enableMove(false);
|
||||||
m_previewWidget->enableZoom(false);
|
m_previewWidget->enableZoom(false);
|
||||||
|
|
|
@ -670,11 +670,11 @@ void MeshGenerator::generate()
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &verticesSourcesIt: m_cacheContext->componentVerticesSources[QUuid().toString()].map()) {
|
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) {
|
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());
|
bmeshNodes.second.begin(), bmeshNodes.second.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ Outcome *MeshResultPostProcessor::takePostProcessedResultContext()
|
||||||
|
|
||||||
void MeshResultPostProcessor::process()
|
void MeshResultPostProcessor::process()
|
||||||
{
|
{
|
||||||
if (!m_outcome->bmeshNodes.empty()) {
|
if (!m_outcome->nodes.empty()) {
|
||||||
(void)m_outcome->triangleTangents();
|
(void)m_outcome->triangleTangents();
|
||||||
(void)m_outcome->parts();
|
(void)m_outcome->parts();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,18 +26,6 @@ struct CandidateEdge
|
||||||
float length;
|
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<std::pair<QUuid, QUuid>> &Outcome::triangleSourceNodes()
|
const std::vector<std::pair<QUuid, QUuid>> &Outcome::triangleSourceNodes()
|
||||||
{
|
{
|
||||||
if (!m_triangleSourceResolved) {
|
if (!m_triangleSourceResolved) {
|
||||||
|
@ -90,7 +78,7 @@ void Outcome::calculateTriangleSourceNodes(std::vector<std::pair<QUuid, QUuid>>
|
||||||
PositionMap<std::pair<QUuid, QUuid>> positionMap;
|
PositionMap<std::pair<QUuid, QUuid>> positionMap;
|
||||||
std::map<std::pair<int, int>, HalfColorEdge> halfColorEdgeMap;
|
std::map<std::pair<int, int>, HalfColorEdge> halfColorEdgeMap;
|
||||||
std::set<int> brokenTriangleSet;
|
std::set<int> brokenTriangleSet;
|
||||||
for (const auto &it: bmeshVertices) {
|
for (const auto &it: nodeVertices) {
|
||||||
positionMap.addPosition(it.position.x(), it.position.y(), it.position.z(),
|
positionMap.addPosition(it.position.x(), it.position.y(), it.position.z(),
|
||||||
std::make_pair(it.partId, it.nodeId));
|
std::make_pair(it.partId, it.nodeId));
|
||||||
}
|
}
|
||||||
|
@ -262,7 +250,7 @@ void Outcome::calculateRemainingVertexSourceNodesAfterTriangleSourceNodesSolved(
|
||||||
void Outcome::calculateTriangleMaterials(std::vector<OutcomeMaterial> &triangleMaterials)
|
void Outcome::calculateTriangleMaterials(std::vector<OutcomeMaterial> &triangleMaterials)
|
||||||
{
|
{
|
||||||
std::map<std::pair<QUuid, QUuid>, OutcomeMaterial> nodeMaterialMap;
|
std::map<std::pair<QUuid, QUuid>, OutcomeMaterial> nodeMaterialMap;
|
||||||
for (const auto &it: bmeshNodes) {
|
for (const auto &it: nodes) {
|
||||||
nodeMaterialMap[std::make_pair(it.partId, it.nodeId)] = it.material;
|
nodeMaterialMap[std::make_pair(it.partId, it.nodeId)] = it.material;
|
||||||
}
|
}
|
||||||
const auto sourceNodes = triangleSourceNodes();
|
const auto sourceNodes = triangleSourceNodes();
|
||||||
|
@ -285,8 +273,8 @@ void Outcome::calculateTriangleEdgeSourceMap(std::map<std::pair<int, int>, std::
|
||||||
}
|
}
|
||||||
|
|
||||||
void Outcome::calculateBmeshNodeMap(std::map<std::pair<QUuid, QUuid>, OutcomeNode *> &bmeshNodeMap) {
|
void Outcome::calculateBmeshNodeMap(std::map<std::pair<QUuid, QUuid>, OutcomeNode *> &bmeshNodeMap) {
|
||||||
for (auto i = 0u; i < bmeshNodes.size(); i++) {
|
for (auto i = 0u; i < nodes.size(); i++) {
|
||||||
OutcomeNode *bmeshNode = &bmeshNodes[i];
|
OutcomeNode *bmeshNode = &nodes[i];
|
||||||
bmeshNodeMap[std::make_pair(bmeshNode->partId, bmeshNode->nodeId)] = bmeshNode;
|
bmeshNodeMap[std::make_pair(bmeshNode->partId, bmeshNode->nodeId)] = bmeshNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,11 +73,10 @@ struct ResultPart
|
||||||
class Outcome
|
class Outcome
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::vector<OutcomeNode> bmeshNodes;
|
std::vector<OutcomeNode> nodes;
|
||||||
std::vector<OutcomeNodeVertex> bmeshVertices;
|
std::vector<OutcomeNodeVertex> nodeVertices;
|
||||||
std::vector<OutcomeVertex> vertices;
|
std::vector<OutcomeVertex> vertices;
|
||||||
std::vector<OutcomeTriangle> triangles;
|
std::vector<OutcomeTriangle> triangles;
|
||||||
Outcome();
|
|
||||||
public:
|
public:
|
||||||
const std::vector<std::pair<QUuid, QUuid>> &triangleSourceNodes();
|
const std::vector<std::pair<QUuid, QUuid>> &triangleSourceNodes();
|
||||||
const std::vector<OutcomeMaterial> &triangleMaterials();
|
const std::vector<OutcomeMaterial> &triangleMaterials();
|
||||||
|
@ -89,14 +88,14 @@ public:
|
||||||
const std::vector<QVector3D> &interpolatedTriangleVertexNormals();
|
const std::vector<QVector3D> &interpolatedTriangleVertexNormals();
|
||||||
const std::vector<QVector3D> &triangleTangents();
|
const std::vector<QVector3D> &triangleTangents();
|
||||||
private:
|
private:
|
||||||
bool m_triangleSourceResolved;
|
bool m_triangleSourceResolved = false;
|
||||||
bool m_triangleMaterialResolved;
|
bool m_triangleMaterialResolved = false;
|
||||||
bool m_triangleEdgeSourceMapResolved;
|
bool m_triangleEdgeSourceMapResolved = false;
|
||||||
bool m_bmeshNodeMapResolved;
|
bool m_bmeshNodeMapResolved = false;
|
||||||
bool m_resultPartsResolved;
|
bool m_resultPartsResolved = false;
|
||||||
bool m_resultTriangleUvsResolved;
|
bool m_resultTriangleUvsResolved = false;
|
||||||
bool m_triangleVertexNormalsInterpolated;
|
bool m_triangleVertexNormalsInterpolated = false;
|
||||||
bool m_triangleTangentsResolved;
|
bool m_triangleTangentsResolved = false;
|
||||||
private:
|
private:
|
||||||
std::vector<std::pair<QUuid, QUuid>> m_triangleSourceNodes;
|
std::vector<std::pair<QUuid, QUuid>> m_triangleSourceNodes;
|
||||||
std::vector<OutcomeMaterial> m_triangleMaterials;
|
std::vector<OutcomeMaterial> m_triangleMaterials;
|
||||||
|
|
|
@ -148,7 +148,7 @@ void TextureGenerator::prepare()
|
||||||
QUuid partId = QUuid(partIt.first);
|
QUuid partId = QUuid(partIt.first);
|
||||||
updatedMaterialIdMap.insert({partId, materialId});
|
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) {
|
for (size_t i = 0; i < (int)TextureType::Count - 1; ++i) {
|
||||||
TextureType forWhat = (TextureType)(i + 1);
|
TextureType forWhat = (TextureType)(i + 1);
|
||||||
MaterialTextures materialTextures;
|
MaterialTextures materialTextures;
|
||||||
|
|
Loading…
Reference in New Issue