Remove mesh result post processor
parent
69ad5323e9
commit
f8b2004889
|
@ -161,8 +161,6 @@ HEADERS += sources/mesh_generator.h
|
|||
SOURCES += sources/mesh_generator.cc
|
||||
HEADERS += sources/mesh_preview_images_generator.h
|
||||
SOURCES += sources/mesh_preview_images_generator.cc
|
||||
HEADERS += sources/mesh_result_post_processor.h
|
||||
SOURCES += sources/mesh_result_post_processor.cc
|
||||
HEADERS += sources/model_mesh.h
|
||||
SOURCES += sources/model_mesh.cc
|
||||
HEADERS += sources/model_offscreen_render.h
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include "bone_generator.h"
|
||||
#include "image_forever.h"
|
||||
#include "mesh_generator.h"
|
||||
#include "mesh_result_post_processor.h"
|
||||
#include "uv_map_generator.h"
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
|
@ -2167,7 +2166,6 @@ void Document::meshReady()
|
|||
|
||||
qDebug() << "Mesh generation done";
|
||||
|
||||
m_isPostProcessResultObsolete = true;
|
||||
emit resultMeshChanged();
|
||||
|
||||
if (m_isResultMeshObsolete) {
|
||||
|
@ -2175,11 +2173,6 @@ void Document::meshReady()
|
|||
}
|
||||
}
|
||||
|
||||
bool Document::isPostProcessResultObsolete() const
|
||||
{
|
||||
return m_isPostProcessResultObsolete;
|
||||
}
|
||||
|
||||
void Document::batchChangeBegin()
|
||||
{
|
||||
m_batchChangeRefCount++;
|
||||
|
@ -2257,12 +2250,15 @@ void Document::generateTexture()
|
|||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Texture guide generating..";
|
||||
emit textureGenerating();
|
||||
|
||||
m_isTextureObsolete = false;
|
||||
|
||||
auto object = std::make_unique<dust3d::Object>(*m_uvMappedObject);
|
||||
if (nullptr == m_currentObject)
|
||||
return;
|
||||
|
||||
qDebug() << "UV mapping generating..";
|
||||
emit textureGenerating();
|
||||
|
||||
auto object = std::make_unique<dust3d::Object>(*m_currentObject);
|
||||
|
||||
auto snapshot = std::make_unique<dust3d::Snapshot>();
|
||||
toSnapshot(snapshot.get());
|
||||
|
@ -2298,7 +2294,7 @@ void Document::textureReady()
|
|||
delete m_textureGenerator;
|
||||
m_textureGenerator = nullptr;
|
||||
|
||||
qDebug() << "Texture guide generation done";
|
||||
qDebug() << "UV mapping generation done(meshId:" << (nullptr != m_resultTextureMesh ? m_resultTextureMesh->meshId() : 0) << ")";
|
||||
|
||||
emit resultTextureChanged();
|
||||
|
||||
|
@ -2309,47 +2305,9 @@ void Document::textureReady()
|
|||
}
|
||||
}
|
||||
|
||||
void Document::postProcess()
|
||||
quint64 Document::resultTextureImageUpdateVersion()
|
||||
{
|
||||
if (nullptr != m_postProcessor) {
|
||||
m_isPostProcessResultObsolete = true;
|
||||
return;
|
||||
}
|
||||
|
||||
m_isPostProcessResultObsolete = false;
|
||||
|
||||
if (!m_currentObject) {
|
||||
qDebug() << "Model is null";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Post processing..";
|
||||
emit postProcessing();
|
||||
|
||||
QThread* thread = new QThread;
|
||||
m_postProcessor = new MeshResultPostProcessor(*m_currentObject);
|
||||
m_postProcessor->moveToThread(thread);
|
||||
connect(thread, &QThread::started, m_postProcessor, &MeshResultPostProcessor::process);
|
||||
connect(m_postProcessor, &MeshResultPostProcessor::finished, this, &Document::postProcessedMeshResultReady);
|
||||
connect(m_postProcessor, &MeshResultPostProcessor::finished, thread, &QThread::quit);
|
||||
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
||||
thread->start();
|
||||
}
|
||||
|
||||
void Document::postProcessedMeshResultReady()
|
||||
{
|
||||
m_uvMappedObject.reset(m_postProcessor->takePostProcessedObject());
|
||||
|
||||
delete m_postProcessor;
|
||||
m_postProcessor = nullptr;
|
||||
|
||||
qDebug() << "Post process done";
|
||||
|
||||
emit postProcessedResultChanged();
|
||||
|
||||
if (m_isPostProcessResultObsolete) {
|
||||
postProcess();
|
||||
}
|
||||
return m_textureImageUpdateVersion;
|
||||
}
|
||||
|
||||
const dust3d::Object& Document::currentUvMappedObject() const
|
||||
|
@ -2797,10 +2755,10 @@ bool Document::isEdgeEditable(dust3d::Uuid edgeId) const
|
|||
|
||||
bool Document::isExportReady() const
|
||||
{
|
||||
if (m_meshGenerator || m_textureGenerator || m_postProcessor)
|
||||
if (m_meshGenerator || m_textureGenerator || m_boneGenerator)
|
||||
return false;
|
||||
|
||||
if (m_isResultMeshObsolete || m_isTextureObsolete || m_isPostProcessResultObsolete)
|
||||
if (m_isResultMeshObsolete || m_isTextureObsolete || m_isResultBoneObsolete)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -2817,11 +2775,6 @@ bool Document::isMeshGenerating() const
|
|||
return nullptr != m_meshGenerator;
|
||||
}
|
||||
|
||||
bool Document::isPostProcessing() const
|
||||
{
|
||||
return nullptr != m_postProcessor;
|
||||
}
|
||||
|
||||
bool Document::isTextureGenerating() const
|
||||
{
|
||||
return nullptr != m_textureGenerator;
|
||||
|
@ -3065,9 +3018,12 @@ void Document::generateBone()
|
|||
|
||||
m_isResultBoneObsolete = false;
|
||||
|
||||
if (nullptr == m_currentObject)
|
||||
return;
|
||||
|
||||
emit boneGenerating();
|
||||
|
||||
auto object = std::make_unique<dust3d::Object>(*m_uvMappedObject);
|
||||
auto object = std::make_unique<dust3d::Object>(*m_currentObject);
|
||||
|
||||
auto snapshot = std::make_unique<dust3d::Snapshot>();
|
||||
toSnapshot(snapshot.get());
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
class UvMapGenerator;
|
||||
class MeshGenerator;
|
||||
class MeshResultPostProcessor;
|
||||
class BoneGenerator;
|
||||
|
||||
class Document : public QObject {
|
||||
|
@ -230,7 +229,6 @@ signals:
|
|||
void turnaroundChanged();
|
||||
void editModeChanged();
|
||||
void resultTextureChanged();
|
||||
void postProcessedResultChanged();
|
||||
void partSubdivStateChanged(dust3d::Uuid partId);
|
||||
void partXmirrorStateChanged(dust3d::Uuid partId);
|
||||
void partDeformThicknessChanged(dust3d::Uuid partId);
|
||||
|
@ -260,7 +258,6 @@ signals:
|
|||
void checkNode(dust3d::Uuid nodeId);
|
||||
void checkEdge(dust3d::Uuid edgeId);
|
||||
void meshGenerating();
|
||||
void postProcessing();
|
||||
void textureGenerating();
|
||||
void textureChanged();
|
||||
void partAdded(dust3d::Uuid partId);
|
||||
|
@ -361,6 +358,7 @@ public:
|
|||
quint64 resultTextureMeshId();
|
||||
ModelMesh* takeResultBodyBonePreviewMesh();
|
||||
quint64 resultBodyBonePreviewMeshId();
|
||||
quint64 resultTextureImageUpdateVersion();
|
||||
void updateTurnaround(const QImage& image);
|
||||
void clearTurnaround();
|
||||
void updateTextureImage(QImage* image);
|
||||
|
@ -370,9 +368,7 @@ public:
|
|||
void updateTextureAmbientOcclusionImage(QImage* image);
|
||||
const dust3d::Object& currentUvMappedObject() const;
|
||||
bool isExportReady() const;
|
||||
bool isPostProcessResultObsolete() const;
|
||||
bool isMeshGenerating() const;
|
||||
bool isPostProcessing() const;
|
||||
bool isTextureGenerating() const;
|
||||
bool isBoneGenerating() const;
|
||||
void collectCutFaceList(std::vector<QString>& cutFaces) const;
|
||||
|
@ -451,8 +447,6 @@ public slots:
|
|||
void meshReady();
|
||||
void generateTexture();
|
||||
void textureReady();
|
||||
void postProcess();
|
||||
void postProcessedMeshResultReady();
|
||||
void generateBone();
|
||||
void boneReady();
|
||||
void setPartSubdivState(dust3d::Uuid partId, bool subdived);
|
||||
|
@ -571,11 +565,9 @@ private:
|
|||
dust3d::Object* m_currentObject = nullptr;
|
||||
bool m_isTextureObsolete = false;
|
||||
UvMapGenerator* m_textureGenerator = nullptr;
|
||||
bool m_isPostProcessResultObsolete = false;
|
||||
MeshResultPostProcessor* m_postProcessor = nullptr;
|
||||
std::unique_ptr<dust3d::Object> m_uvMappedObject = std::make_unique<dust3d::Object>();
|
||||
ModelMesh* m_resultTextureMesh = nullptr;
|
||||
unsigned long long m_textureImageUpdateVersion = 0;
|
||||
quint64 m_textureImageUpdateVersion = 0;
|
||||
bool m_smoothNormal = false;
|
||||
quint64 m_meshGenerationId = 0;
|
||||
quint64 m_nextMeshGenerationId = 0;
|
||||
|
|
|
@ -205,10 +205,8 @@ DocumentWindow::DocumentWindow()
|
|||
connect(m_document, &Document::resultBodyBonePreviewMeshChanged, this, &DocumentWindow::updateInprogressIndicator);
|
||||
connect(m_document, &Document::resultComponentPreviewMeshesChanged, this, &DocumentWindow::generateComponentPreviewImages);
|
||||
connect(m_document, &Document::textureChanged, this, &DocumentWindow::generateComponentPreviewImages);
|
||||
connect(m_document, &Document::postProcessing, this, &DocumentWindow::updateInprogressIndicator);
|
||||
connect(m_document, &Document::textureGenerating, this, &DocumentWindow::updateInprogressIndicator);
|
||||
connect(m_document, &Document::resultTextureChanged, this, &DocumentWindow::updateInprogressIndicator);
|
||||
connect(m_document, &Document::postProcessedResultChanged, this, &DocumentWindow::updateInprogressIndicator);
|
||||
connect(m_document, &Document::boneGenerating, this, &DocumentWindow::updateInprogressIndicator);
|
||||
connect(m_document, &Document::resultBoneChanged, this, &DocumentWindow::updateInprogressIndicator);
|
||||
connect(m_document, &Document::resultBonePreviewMeshesChanged, this, &DocumentWindow::generateBonePreviewImages);
|
||||
|
@ -634,10 +632,9 @@ DocumentWindow::DocumentWindow()
|
|||
|
||||
connect(m_document, &Document::skeletonChanged, m_document, &Document::generateMesh);
|
||||
connect(m_document, &Document::textureChanged, m_document, &Document::generateTexture);
|
||||
connect(m_document, &Document::resultMeshChanged, m_document, &Document::postProcess);
|
||||
connect(m_document, &Document::postProcessedResultChanged, m_document, &Document::generateTexture);
|
||||
connect(m_document, &Document::resultMeshChanged, m_document, &Document::generateTexture);
|
||||
connect(m_document, &Document::rigChanged, m_document, &Document::generateBone);
|
||||
connect(m_document, &Document::postProcessedResultChanged, m_document, &Document::generateBone);
|
||||
connect(m_document, &Document::resultMeshChanged, m_document, &Document::generateBone);
|
||||
connect(m_document, &Document::resultTextureChanged, this, &DocumentWindow::updateRenderModel);
|
||||
connect(m_document, &Document::resultBodyBonePreviewMeshChanged, this, &DocumentWindow::updateRenderModel);
|
||||
|
||||
|
@ -680,7 +677,7 @@ DocumentWindow::DocumentWindow()
|
|||
|
||||
void DocumentWindow::updateInprogressIndicator()
|
||||
{
|
||||
bool inprogress = m_document->isMeshGenerating() || m_document->isPostProcessing() || m_document->isTextureGenerating() || m_document->isBoneGenerating() || nullptr != m_componentPreviewImagesGenerator || nullptr != m_componentPreviewImagesDecorator;
|
||||
bool inprogress = m_document->isMeshGenerating() || m_document->isTextureGenerating() || m_document->isBoneGenerating() || nullptr != m_componentPreviewImagesGenerator || nullptr != m_componentPreviewImagesDecorator;
|
||||
if (inprogress == m_inprogressIndicator->isSpinning())
|
||||
return;
|
||||
m_inprogressIndicator->showSpinner(inprogress);
|
||||
|
@ -1460,12 +1457,13 @@ void DocumentWindow::forceUpdateRenderModel()
|
|||
mesh = m_document->takeResultBodyBonePreviewMesh();
|
||||
m_currentUpdatedMeshId = m_document->resultBodyBonePreviewMeshId();
|
||||
} else {
|
||||
if (m_document->isMeshGenerating() || m_document->isPostProcessing() || m_document->isTextureGenerating()) {
|
||||
if (m_document->isMeshGenerating() || m_document->isTextureGenerating()) {
|
||||
mesh = m_document->takeResultMesh();
|
||||
m_currentUpdatedMeshId = m_document->resultMeshId();
|
||||
} else {
|
||||
mesh = m_document->takeResultTextureMesh();
|
||||
m_currentUpdatedMeshId = m_document->resultTextureMeshId();
|
||||
m_currentTextureImageUpdateVersion = m_document->resultTextureImageUpdateVersion();
|
||||
}
|
||||
if (m_modelRemoveColor && mesh)
|
||||
mesh->removeColor();
|
||||
|
@ -1476,15 +1474,19 @@ void DocumentWindow::forceUpdateRenderModel()
|
|||
void DocumentWindow::updateRenderModel()
|
||||
{
|
||||
qint64 shouldShowId = 0;
|
||||
if (m_document->isMeshGenerating() || m_document->isPostProcessing() || m_document->isTextureGenerating()) {
|
||||
quint64 shouldShowTextureVersion = m_currentTextureImageUpdateVersion;
|
||||
if (m_document->isMeshGenerating() || m_document->isTextureGenerating()) {
|
||||
shouldShowId = m_document->resultMeshId();
|
||||
} else {
|
||||
shouldShowId = -(qint64)m_document->resultTextureMeshId();
|
||||
shouldShowTextureVersion = m_document->resultTextureImageUpdateVersion();
|
||||
}
|
||||
if (shouldShowId == m_currentUpdatedMeshId)
|
||||
if (shouldShowId == m_currentUpdatedMeshId && shouldShowTextureVersion == m_currentTextureImageUpdateVersion) {
|
||||
return;
|
||||
if (std::abs(shouldShowId) < std::abs(m_currentUpdatedMeshId))
|
||||
}
|
||||
if (std::abs(shouldShowId) < std::abs(m_currentUpdatedMeshId)) {
|
||||
return;
|
||||
}
|
||||
forceUpdateRenderModel();
|
||||
}
|
||||
|
||||
|
|
|
@ -119,6 +119,7 @@ private:
|
|||
bool m_isLastMeshGenerationSucceed = true;
|
||||
qint64 m_currentUpdatedMeshId = 0;
|
||||
quint64 m_currentUpdatedWireframeId = 0;
|
||||
quint64 m_currentTextureImageUpdateVersion = 0;
|
||||
QStringList m_waitingForExportToFilenames;
|
||||
|
||||
QString m_currentFilename;
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
#include "mesh_result_post_processor.h"
|
||||
#include <QGuiApplication>
|
||||
#include <dust3d/mesh/resolve_triangle_tangent.h>
|
||||
|
||||
MeshResultPostProcessor::MeshResultPostProcessor(const dust3d::Object& object)
|
||||
{
|
||||
m_object = new dust3d::Object;
|
||||
*m_object = object;
|
||||
}
|
||||
|
||||
MeshResultPostProcessor::~MeshResultPostProcessor()
|
||||
{
|
||||
delete m_object;
|
||||
}
|
||||
|
||||
dust3d::Object* MeshResultPostProcessor::takePostProcessedObject()
|
||||
{
|
||||
dust3d::Object* object = m_object;
|
||||
m_object = nullptr;
|
||||
return object;
|
||||
}
|
||||
|
||||
void MeshResultPostProcessor::poseProcess()
|
||||
{
|
||||
//if (!m_object->nodes.empty()) {
|
||||
/*
|
||||
{
|
||||
std::vector<std::vector<dust3d::Vector2>> triangleVertexUvs;
|
||||
std::set<int> seamVertices;
|
||||
std::map<dust3d::Uuid, std::vector<dust3d::Rectangle>> partUvRects;
|
||||
dust3d::unwrapUv(*m_object, triangleVertexUvs, seamVertices, partUvRects);
|
||||
m_object->setTriangleVertexUvs(triangleVertexUvs);
|
||||
m_object->setPartUvRects(partUvRects);
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<dust3d::Vector3> triangleTangents;
|
||||
dust3d::resolveTriangleTangent(*m_object, triangleTangents);
|
||||
m_object->setTriangleTangents(triangleTangents);
|
||||
}
|
||||
*/
|
||||
//}
|
||||
}
|
||||
|
||||
void MeshResultPostProcessor::process()
|
||||
{
|
||||
poseProcess();
|
||||
|
||||
emit finished();
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef DUST3D_APPLICATION_MESH_RESULT_POST_PROCESSOR_H_
|
||||
#define DUST3D_APPLICATION_MESH_RESULT_POST_PROCESSOR_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <dust3d/base/object.h>
|
||||
|
||||
class MeshResultPostProcessor : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MeshResultPostProcessor(const dust3d::Object& object);
|
||||
~MeshResultPostProcessor();
|
||||
dust3d::Object* takePostProcessedObject();
|
||||
void poseProcess();
|
||||
signals:
|
||||
void finished();
|
||||
public slots:
|
||||
void process();
|
||||
|
||||
private:
|
||||
dust3d::Object* m_object = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -275,7 +275,7 @@ void BoneGenerator::generateBonePreviews()
|
|||
}
|
||||
}
|
||||
}
|
||||
std::vector<Color> bodyVertexColors(m_vertices.size());
|
||||
std::vector<Color> bodyVertexColors(m_vertices.size(), Color(0.0, 0.0, 0.0, 0.0));
|
||||
for (const auto& it : vertexSkinColors) {
|
||||
Color color;
|
||||
for (const auto& colorIt : it.second)
|
||||
|
|
Loading…
Reference in New Issue