Improve mesh generation
1. All components recombined regardless of color groups 2. Contour main view contribute to x-coord only when width and height is different (Offset greater than radius) 3. Fix generating indicatormaster
parent
f2093bd42a
commit
ee53e3ed4f
|
@ -219,11 +219,18 @@ void ContourToPartConverter::convert()
|
||||||
if (!sideSkeleton.empty()) {
|
if (!sideSkeleton.empty()) {
|
||||||
alignSkeleton(sideSkeleton, mainSkeleton);
|
alignSkeleton(sideSkeleton, mainSkeleton);
|
||||||
float defaultX = mainBoundingBox.center().x() / m_canvasSize.height();
|
float defaultX = mainBoundingBox.center().x() / m_canvasSize.height();
|
||||||
|
float area = mainBoundingBox.width() * mainBoundingBox.height();
|
||||||
|
float mainBoundingBoxWidthHeightOffset = std::abs(mainBoundingBox.width() - mainBoundingBox.height());
|
||||||
|
float rectRadius = std::sqrt(area) * 0.5;
|
||||||
|
bool useCalculatedX = mainBoundingBoxWidthHeightOffset >= rectRadius;
|
||||||
m_nodes.reserve(sideSkeleton.size());
|
m_nodes.reserve(sideSkeleton.size());
|
||||||
for (size_t i = 0; i < sideSkeleton.size(); ++i) {
|
for (size_t i = 0; i < sideSkeleton.size(); ++i) {
|
||||||
const auto &it = sideSkeleton[i];
|
const auto &it = sideSkeleton[i];
|
||||||
size_t j = ((float)i / sideSkeleton.size()) * mainSkeleton.size();
|
float x = defaultX;
|
||||||
float x = j < mainSkeleton.size() ? mainSkeleton[j].first.x() : defaultX;
|
if (useCalculatedX) {
|
||||||
|
size_t j = ((float)i / sideSkeleton.size()) * mainSkeleton.size();
|
||||||
|
x = j < mainSkeleton.size() ? mainSkeleton[j].first.x() : defaultX;
|
||||||
|
}
|
||||||
m_nodes.push_back(std::make_pair(QVector3D(x, it.first.y(), it.first.x()),
|
m_nodes.push_back(std::make_pair(QVector3D(x, it.first.y(), it.first.x()),
|
||||||
it.second));
|
it.second));
|
||||||
}
|
}
|
||||||
|
@ -243,6 +250,7 @@ void ContourToPartConverter::nodesToSnapshot()
|
||||||
snapshotPart["id"] = partIdString;
|
snapshotPart["id"] = partIdString;
|
||||||
snapshotPart["subdived"] = "true";
|
snapshotPart["subdived"] = "true";
|
||||||
snapshotPart["rounded"] = "true";
|
snapshotPart["rounded"] = "true";
|
||||||
|
snapshotPart["base"] = "YZ";
|
||||||
m_snapshot.parts[partIdString] = snapshotPart;
|
m_snapshot.parts[partIdString] = snapshotPart;
|
||||||
|
|
||||||
auto componentId = QUuid::createUuid();
|
auto componentId = QUuid::createUuid();
|
||||||
|
|
|
@ -2037,6 +2037,8 @@ void Document::generateMesh()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit meshGenerating();
|
||||||
|
|
||||||
qDebug() << "Mesh generating..";
|
qDebug() << "Mesh generating..";
|
||||||
|
|
||||||
settleOrigin();
|
settleOrigin();
|
||||||
|
@ -2060,7 +2062,6 @@ void Document::generateMesh()
|
||||||
connect(m_meshGenerator, &MeshGenerator::finished, this, &Document::meshReady);
|
connect(m_meshGenerator, &MeshGenerator::finished, this, &Document::meshReady);
|
||||||
connect(m_meshGenerator, &MeshGenerator::finished, thread, &QThread::quit);
|
connect(m_meshGenerator, &MeshGenerator::finished, thread, &QThread::quit);
|
||||||
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
||||||
emit meshGenerating();
|
|
||||||
thread->start();
|
thread->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2072,6 +2073,7 @@ void Document::generateTexture()
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Texture guide generating..";
|
qDebug() << "Texture guide generating..";
|
||||||
|
emit textureGenerating();
|
||||||
|
|
||||||
m_isTextureObsolete = false;
|
m_isTextureObsolete = false;
|
||||||
|
|
||||||
|
@ -2085,7 +2087,6 @@ void Document::generateTexture()
|
||||||
connect(m_textureGenerator, &TextureGenerator::finished, this, &Document::textureReady);
|
connect(m_textureGenerator, &TextureGenerator::finished, this, &Document::textureReady);
|
||||||
connect(m_textureGenerator, &TextureGenerator::finished, thread, &QThread::quit);
|
connect(m_textureGenerator, &TextureGenerator::finished, thread, &QThread::quit);
|
||||||
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
||||||
emit textureGenerating();
|
|
||||||
thread->start();
|
thread->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2154,6 +2155,7 @@ void Document::postProcess()
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Post processing..";
|
qDebug() << "Post processing..";
|
||||||
|
emit postProcessing();
|
||||||
|
|
||||||
QThread *thread = new QThread;
|
QThread *thread = new QThread;
|
||||||
m_postProcessor = new MeshResultPostProcessor(*m_currentOutcome);
|
m_postProcessor = new MeshResultPostProcessor(*m_currentOutcome);
|
||||||
|
@ -2162,7 +2164,6 @@ void Document::postProcess()
|
||||||
connect(m_postProcessor, &MeshResultPostProcessor::finished, this, &Document::postProcessedMeshResultReady);
|
connect(m_postProcessor, &MeshResultPostProcessor::finished, this, &Document::postProcessedMeshResultReady);
|
||||||
connect(m_postProcessor, &MeshResultPostProcessor::finished, thread, &QThread::quit);
|
connect(m_postProcessor, &MeshResultPostProcessor::finished, thread, &QThread::quit);
|
||||||
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
||||||
emit postProcessing();
|
|
||||||
thread->start();
|
thread->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3782,6 +3783,16 @@ bool Document::isMeshGenerating() const
|
||||||
return nullptr != m_meshGenerator;
|
return nullptr != m_meshGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Document::isPostProcessing() const
|
||||||
|
{
|
||||||
|
return nullptr != m_postProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Document::isTextureGenerating() const
|
||||||
|
{
|
||||||
|
return nullptr != m_textureGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
void Document::copyNodes(std::set<QUuid> nodeIdSet) const
|
void Document::copyNodes(std::set<QUuid> nodeIdSet) const
|
||||||
{
|
{
|
||||||
Snapshot snapshot;
|
Snapshot snapshot;
|
||||||
|
|
|
@ -558,6 +558,8 @@ public:
|
||||||
const Outcome ¤tRiggedOutcome() const;
|
const Outcome ¤tRiggedOutcome() const;
|
||||||
bool currentRigSucceed() const;
|
bool currentRigSucceed() const;
|
||||||
bool isMeshGenerating() const;
|
bool isMeshGenerating() const;
|
||||||
|
bool isPostProcessing() const;
|
||||||
|
bool isTextureGenerating() const;
|
||||||
const QString &script() const;
|
const QString &script() const;
|
||||||
const std::map<QString, std::map<QString, QString>> &variables() const;
|
const std::map<QString, std::map<QString, QString>> &variables() const;
|
||||||
const QString &scriptError() const;
|
const QString &scriptError() const;
|
||||||
|
|
|
@ -238,7 +238,11 @@ DocumentWindow::DocumentWindow() :
|
||||||
regenerateButton->showSpinner(true);
|
regenerateButton->showSpinner(true);
|
||||||
});
|
});
|
||||||
connect(m_document, &Document::resultTextureChanged, this, [=]() {
|
connect(m_document, &Document::resultTextureChanged, this, [=]() {
|
||||||
regenerateButton->showSpinner(false);
|
if (!m_document->isMeshGenerating() &&
|
||||||
|
!m_document->isPostProcessing() &&
|
||||||
|
!m_document->isTextureGenerating()) {
|
||||||
|
regenerateButton->showSpinner(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
connect(regenerateButton->button(), &QPushButton::clicked, m_document, &Document::regenerateMesh);
|
connect(regenerateButton->button(), &QPushButton::clicked, m_document, &Document::regenerateMesh);
|
||||||
|
|
||||||
|
|
|
@ -1010,12 +1010,12 @@ MeshCombiner::Mesh *MeshGenerator::combineComponentMesh(const QString &component
|
||||||
subGroupMeshIdStringList += componentChildGroupIdStringListString;
|
subGroupMeshIdStringList += componentChildGroupIdStringListString;
|
||||||
multipleMeshes.push_back(std::make_tuple(childMesh, CombineMode::Normal, componentChildGroupIdStringListString));
|
multipleMeshes.push_back(std::make_tuple(childMesh, CombineMode::Normal, componentChildGroupIdStringListString));
|
||||||
}
|
}
|
||||||
MeshCombiner::Mesh *subGroupMesh = combineMultipleMeshes(multipleMeshes, foundColorSolubilitySetting);
|
MeshCombiner::Mesh *subGroupMesh = combineMultipleMeshes(multipleMeshes, true/*foundColorSolubilitySetting*/);
|
||||||
if (nullptr == subGroupMesh)
|
if (nullptr == subGroupMesh)
|
||||||
continue;
|
continue;
|
||||||
groupMeshes.push_back(std::make_tuple(subGroupMesh, group.first, subGroupMeshIdStringList.join("&")));
|
groupMeshes.push_back(std::make_tuple(subGroupMesh, group.first, subGroupMeshIdStringList.join("&")));
|
||||||
}
|
}
|
||||||
mesh = combineMultipleMeshes(groupMeshes, false);
|
mesh = combineMultipleMeshes(groupMeshes, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nullptr != mesh)
|
if (nullptr != mesh)
|
||||||
|
|
Loading…
Reference in New Issue