Update render model
parent
3685caa92f
commit
ce128bff1e
|
@ -2082,6 +2082,13 @@ ModelMesh* Document::takeResultMesh()
|
||||||
return resultMesh;
|
return resultMesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quint64 Document::resultMeshId()
|
||||||
|
{
|
||||||
|
if (nullptr == m_resultMesh)
|
||||||
|
return 0;
|
||||||
|
return m_resultMesh->meshId();
|
||||||
|
}
|
||||||
|
|
||||||
MonochromeMesh* Document::takeWireframeMesh()
|
MonochromeMesh* Document::takeWireframeMesh()
|
||||||
{
|
{
|
||||||
if (nullptr == m_wireframeMesh)
|
if (nullptr == m_wireframeMesh)
|
||||||
|
@ -2102,6 +2109,13 @@ ModelMesh* Document::takeResultTextureMesh()
|
||||||
return resultTextureMesh;
|
return resultTextureMesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quint64 Document::resultTextureMeshId()
|
||||||
|
{
|
||||||
|
if (nullptr == m_resultTextureMesh)
|
||||||
|
return 0;
|
||||||
|
return m_resultTextureMesh->meshId();
|
||||||
|
}
|
||||||
|
|
||||||
void Document::meshReady()
|
void Document::meshReady()
|
||||||
{
|
{
|
||||||
ModelMesh* resultMesh = m_meshGenerator->takeResultMesh();
|
ModelMesh* resultMesh = m_meshGenerator->takeResultMesh();
|
||||||
|
|
|
@ -352,11 +352,12 @@ public:
|
||||||
};
|
};
|
||||||
void addFromSnapshot(const dust3d::Snapshot& snapshot, enum SnapshotSource source = SnapshotSource::Paste);
|
void addFromSnapshot(const dust3d::Snapshot& snapshot, enum SnapshotSource source = SnapshotSource::Paste);
|
||||||
ModelMesh* takeResultMesh();
|
ModelMesh* takeResultMesh();
|
||||||
|
quint64 resultMeshId();
|
||||||
MonochromeMesh* takeWireframeMesh();
|
MonochromeMesh* takeWireframeMesh();
|
||||||
ModelMesh* takePaintedMesh();
|
ModelMesh* takePaintedMesh();
|
||||||
bool isMeshGenerationSucceed();
|
bool isMeshGenerationSucceed();
|
||||||
ModelMesh* takeResultTextureMesh();
|
ModelMesh* takeResultTextureMesh();
|
||||||
ModelMesh* takeResultRigWeightMesh();
|
quint64 resultTextureMeshId();
|
||||||
void updateTurnaround(const QImage& image);
|
void updateTurnaround(const QImage& image);
|
||||||
void clearTurnaround();
|
void clearTurnaround();
|
||||||
void updateTextureImage(QImage* image);
|
void updateTextureImage(QImage* image);
|
||||||
|
|
|
@ -623,30 +623,10 @@ DocumentWindow::DocumentWindow()
|
||||||
connect(m_document, &Document::postProcessedResultChanged, m_document, &Document::generateTexture);
|
connect(m_document, &Document::postProcessedResultChanged, m_document, &Document::generateTexture);
|
||||||
connect(m_document, &Document::rigChanged, m_document, &Document::generateBone);
|
connect(m_document, &Document::rigChanged, m_document, &Document::generateBone);
|
||||||
connect(m_document, &Document::postProcessedResultChanged, m_document, &Document::generateBone);
|
connect(m_document, &Document::postProcessedResultChanged, m_document, &Document::generateBone);
|
||||||
connect(m_document, &Document::resultTextureChanged, [=]() {
|
connect(m_document, &Document::resultTextureChanged, this, &DocumentWindow::updateRenderModel);
|
||||||
if (m_document->isMeshGenerating())
|
|
||||||
return;
|
|
||||||
auto resultTextureMesh = m_document->takeResultTextureMesh();
|
|
||||||
if (nullptr != resultTextureMesh) {
|
|
||||||
if (resultTextureMesh->meshId() < m_currentUpdatedMeshId) {
|
|
||||||
delete resultTextureMesh;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m_modelRemoveColor && resultTextureMesh)
|
|
||||||
resultTextureMesh->removeColor();
|
|
||||||
m_modelRenderWidget->updateMesh(resultTextureMesh);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(m_document, &Document::resultMeshChanged, [=]() {
|
connect(m_document, &Document::resultMeshChanged, this, &DocumentWindow::updateRenderModel);
|
||||||
auto resultMesh = m_document->takeResultMesh();
|
connect(m_document, &Document::resultMeshChanged, this, &DocumentWindow::updateRenderWireframe);
|
||||||
if (nullptr != resultMesh)
|
|
||||||
m_currentUpdatedMeshId = resultMesh->meshId();
|
|
||||||
if (m_modelRemoveColor && resultMesh)
|
|
||||||
resultMesh->removeColor();
|
|
||||||
m_modelRenderWidget->updateMesh(resultMesh);
|
|
||||||
m_modelRenderWidget->updateWireframeMesh(m_document->takeWireframeMesh());
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::cursorChanged, [=]() {
|
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::cursorChanged, [=]() {
|
||||||
m_modelRenderWidget->setCursor(canvasGraphicsWidget->cursor());
|
m_modelRenderWidget->setCursor(canvasGraphicsWidget->cursor());
|
||||||
|
@ -774,10 +754,18 @@ void DocumentWindow::newDocument()
|
||||||
if (answer != QMessageBox::Yes)
|
if (answer != QMessageBox::Yes)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DocumentWindow::reset()
|
||||||
|
{
|
||||||
m_document->clearHistories();
|
m_document->clearHistories();
|
||||||
m_document->reset();
|
m_document->reset();
|
||||||
m_document->clearTurnaround();
|
m_document->clearTurnaround();
|
||||||
m_document->saveSnapshot();
|
m_document->saveSnapshot();
|
||||||
|
|
||||||
|
m_currentUpdatedMeshId = 0;
|
||||||
|
m_currentUpdatedWireframeId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentWindow::saveAs()
|
void DocumentWindow::saveAs()
|
||||||
|
@ -916,10 +904,7 @@ void DocumentWindow::openPathAs(const QString& path, const QString& asName)
|
||||||
{
|
{
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
|
||||||
m_document->clearHistories();
|
reset();
|
||||||
m_document->reset();
|
|
||||||
m_document->clearTurnaround();
|
|
||||||
m_document->saveSnapshot();
|
|
||||||
|
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
file.open(QFile::ReadOnly);
|
file.open(QFile::ReadOnly);
|
||||||
|
@ -1400,15 +1385,7 @@ bool DocumentWindow::isWorking()
|
||||||
void DocumentWindow::toggleRenderColor()
|
void DocumentWindow::toggleRenderColor()
|
||||||
{
|
{
|
||||||
m_modelRemoveColor = !m_modelRemoveColor;
|
m_modelRemoveColor = !m_modelRemoveColor;
|
||||||
ModelMesh* mesh = nullptr;
|
forceUpdateRenderModel();
|
||||||
if (m_document->isMeshGenerating() || m_document->isPostProcessing() || m_document->isTextureGenerating()) {
|
|
||||||
mesh = m_document->takeResultMesh();
|
|
||||||
} else {
|
|
||||||
mesh = m_document->takeResultTextureMesh();
|
|
||||||
}
|
|
||||||
if (m_modelRemoveColor && mesh)
|
|
||||||
mesh->removeColor();
|
|
||||||
m_modelRenderWidget->updateMesh(mesh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentWindow::generateBonePreviewImages()
|
void DocumentWindow::generateBonePreviewImages()
|
||||||
|
@ -1459,3 +1436,46 @@ void DocumentWindow::bonePreviewImagesReady()
|
||||||
else
|
else
|
||||||
updateInprogressIndicator();
|
updateInprogressIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DocumentWindow::forceUpdateRenderModel()
|
||||||
|
{
|
||||||
|
ModelMesh* mesh = nullptr;
|
||||||
|
if (m_document->isMeshGenerating() || m_document->isPostProcessing() || m_document->isTextureGenerating()) {
|
||||||
|
mesh = m_document->takeResultMesh();
|
||||||
|
m_currentUpdatedMeshId = m_document->resultMeshId();
|
||||||
|
} else {
|
||||||
|
mesh = m_document->takeResultTextureMesh();
|
||||||
|
m_currentUpdatedMeshId = m_document->resultTextureMeshId();
|
||||||
|
}
|
||||||
|
if (m_modelRemoveColor && mesh)
|
||||||
|
mesh->removeColor();
|
||||||
|
m_modelRenderWidget->updateMesh(mesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DocumentWindow::updateRenderModel()
|
||||||
|
{
|
||||||
|
qint64 shouldShowId = 0;
|
||||||
|
if (m_document->isMeshGenerating() || m_document->isPostProcessing() || m_document->isTextureGenerating()) {
|
||||||
|
shouldShowId = m_document->resultMeshId();
|
||||||
|
} else {
|
||||||
|
shouldShowId = -(qint64)m_document->resultTextureMeshId();
|
||||||
|
}
|
||||||
|
if (shouldShowId == m_currentUpdatedMeshId)
|
||||||
|
return;
|
||||||
|
if (std::abs(shouldShowId) < std::abs(m_currentUpdatedMeshId))
|
||||||
|
return;
|
||||||
|
forceUpdateRenderModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DocumentWindow::forceUpdateRenderWireframe()
|
||||||
|
{
|
||||||
|
m_modelRenderWidget->updateWireframeMesh(m_document->takeWireframeMesh());
|
||||||
|
m_currentUpdatedWireframeId = m_document->resultMeshId();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DocumentWindow::updateRenderWireframe()
|
||||||
|
{
|
||||||
|
if (m_document->resultMeshId() == m_currentUpdatedWireframeId)
|
||||||
|
return;
|
||||||
|
forceUpdateRenderWireframe();
|
||||||
|
}
|
||||||
|
|
|
@ -96,6 +96,10 @@ public slots:
|
||||||
void openRecentFile();
|
void openRecentFile();
|
||||||
void updateRecentFileActions();
|
void updateRecentFileActions();
|
||||||
void toggleRenderColor();
|
void toggleRenderColor();
|
||||||
|
void updateRenderModel();
|
||||||
|
void forceUpdateRenderModel();
|
||||||
|
void updateRenderWireframe();
|
||||||
|
void forceUpdateRenderWireframe();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setCurrentFilename(const QString& filename);
|
void setCurrentFilename(const QString& filename);
|
||||||
|
@ -106,13 +110,15 @@ private:
|
||||||
QShortcut* createShortcut(QKeySequence key);
|
QShortcut* createShortcut(QKeySequence key);
|
||||||
QString strippedName(const QString& fullFileName);
|
QString strippedName(const QString& fullFileName);
|
||||||
bool openFiles(const QStringList& pathList);
|
bool openFiles(const QStringList& pathList);
|
||||||
|
void reset();
|
||||||
|
|
||||||
Document* m_document = nullptr;
|
Document* m_document = nullptr;
|
||||||
bool m_firstShow = true;
|
bool m_firstShow = true;
|
||||||
bool m_documentSaved = true;
|
bool m_documentSaved = true;
|
||||||
std::vector<QWidget*> m_dialogs;
|
std::vector<QWidget*> m_dialogs;
|
||||||
bool m_isLastMeshGenerationSucceed = true;
|
bool m_isLastMeshGenerationSucceed = true;
|
||||||
quint64 m_currentUpdatedMeshId = 0;
|
qint64 m_currentUpdatedMeshId = 0;
|
||||||
|
quint64 m_currentUpdatedWireframeId = 0;
|
||||||
QStringList m_waitingForExportToFilenames;
|
QStringList m_waitingForExportToFilenames;
|
||||||
|
|
||||||
QString m_currentFilename;
|
QString m_currentFilename;
|
||||||
|
|
Loading…
Reference in New Issue