From 083e4516a60252d842fb264ac995ca9b92cc71ba Mon Sep 17 00:00:00 2001 From: Janne Kangas Date: Tue, 10 Mar 2020 13:02:36 +0200 Subject: Implement delayed shader compilation success update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the results of shader compilation in Editor panels with a small delay, after an effect or a material file has been changed. This is a simpler alternative to implementing a dedicated signaling channel from GL backend to Editor, just for the purpose of indicating that a compilation result is ready. Task-id: QT3DS-4065 Change-Id: I3d77d789196906954cdd0ff3d5e9e5b06772d5fb Reviewed-by: Tomi Korpipää Reviewed-by: Antti Määttä Reviewed-by: Miikka Heikkinen --- .../Palettes/Inspector/InspectorControlModel.cpp | 6 ++++-- .../Qt3DStudio/Palettes/Inspector/InspectorControlModel.h | 2 +- .../Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp | 14 ++++++++++++++ .../Qt3DStudio/Palettes/Inspector/InspectorControlView.h | 1 + .../Qt3DStudio/Palettes/Project/ProjectFileSystemModel.cpp | 12 ++++++++---- .../Qt3DStudio/Palettes/Project/ProjectFileSystemModel.h | 1 + 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp index 3d774108..09f7f5e0 100644 --- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp +++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp @@ -1202,8 +1202,10 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c return; propertySystem->GetInstancePropertyValue(instance, element->m_property, value); - if (value.getType() == qt3dsdm::DataModelDataType::None) + if (value.getType() == qt3dsdm::DataModelDataType::None) { + updateValidState(element); // Shader property has type none, still need to update valid return; + } const auto metaDataProvider = doc->GetStudioSystem()->GetActionMetaData(); info = metaDataProvider->GetMetaDataPropertyInfo( @@ -1508,7 +1510,7 @@ void InspectorControlModel::refresh() for (int p = 0; p < group.controlElements.count(); ++p) { QVariant& element = group.controlElements[p]; InspectorControlBase *property = element.value(); - if (property->m_property.Valid()) { + if (property->m_property.Valid() || property->m_title == tr("Shader")) { updatePropertyValue(property); updateControlledToggleState(property); } diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.h b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.h index 454d4645..bcd4ce22 100644 --- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.h +++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.h @@ -143,7 +143,6 @@ public: bool controlled); void notifyPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance, qt3dsdm::Qt3DSDMPropertyHandle inProperty); - void updateValidState(InspectorControlBase *inItem) const; Q_INVOKABLE void setMaterialTypeValue(long instance, int handle, const QVariant &value); Q_INVOKABLE void setShaderValue(long instance, int handle, const QVariant &value); @@ -215,6 +214,7 @@ private: void refreshTree(); void updateAnimateToggleState(InspectorControlBase *inItem); void updateControlledToggleState(InspectorControlBase *inItem) const; + void updateValidState(InspectorControlBase *inItem) const; QStringList materialTypeValues() const; QStringList shaderValues() const; diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp index f956021e..f991f467 100644 --- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp +++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp @@ -88,6 +88,13 @@ InspectorControlView::InspectorControlView(const QSize &preferredSize, QWidget * dispatch->AddPresentationChangeListener(this); dispatch->AddDataModelListener(this); + m_shaderStatusUpdateTimer.setSingleShot(true); + m_shaderStatusUpdateTimer.setInterval(3000); + + connect(&m_shaderStatusUpdateTimer, &QTimer::timeout, [&](){ + m_inspectorControlModel->refresh(); + }); + connect(m_meshChooserView, &MeshChooserView::meshSelected, this, [this] (int handle, int instance, const QString &name) { if (name.startsWith(QLatin1Char('#'))) { @@ -170,6 +177,9 @@ void InspectorControlView::onFilesChanged( L"material", L"shader", L"materialdef", nullptr }; + static const wchar_t *effectExtensions[] = { + L"effect", nullptr + }; static const wchar_t *fontExtensions[] = { L"ttf", L"otf", nullptr @@ -189,6 +199,8 @@ void InspectorControlView::onFilesChanged( qt3dsdm::binary_sort_insert_unique(m_fileList, relativePath); else if (record.m_ModificationType == Q3DStudio::FileModificationType::Destroyed) qt3dsdm::binary_sort_erase(m_fileList, relativePath); + else + m_shaderStatusUpdateTimer.start(); } else if (isInList(fontExtensions, record.m_File.GetExtension())) { if (record.m_ModificationType == Q3DStudio::FileModificationType::Created || record.m_ModificationType == Q3DStudio::FileModificationType::Destroyed) { @@ -200,6 +212,8 @@ void InspectorControlView::onFilesChanged( g_StudioApp.GetCore()->getProjectFile().loadSubpresentationsAndDatainputs( g_StudioApp.m_subpresentations, g_StudioApp.m_dataInputDialogItems); m_inspectorControlModel->refreshRenderables(); + } else if (isInList(effectExtensions, record.m_File.GetExtension())) { + m_shaderStatusUpdateTimer.start(); } } } diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.h b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.h index ff969c03..6bc7d6fb 100644 --- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.h +++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.h @@ -133,6 +133,7 @@ private: std::vector> m_connections; QColor m_backgroundColor; + QTimer m_shaderStatusUpdateTimer; VariantsGroupModel *m_variantsGroupModel = nullptr; InspectorControlModel *m_inspectorControlModel = nullptr; CInspectableBase *m_inspectableBase = nullptr; diff --git a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.cpp b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.cpp index 2287f294..77a2a24a 100644 --- a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.cpp +++ b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.cpp @@ -66,8 +66,15 @@ ProjectFileSystemModel::ProjectFileSystemModel(QObject *parent) : QAbstractListM m_projectReferencesUpdateTimer.setSingleShot(true); m_projectReferencesUpdateTimer.setInterval(0); + m_shaderCheckTimer.setSingleShot(true); + m_shaderCheckTimer.setInterval(3000); + connect(&m_projectReferencesUpdateTimer, &QTimer::timeout, this, &ProjectFileSystemModel::updateProjectReferences); + connect(&m_shaderCheckTimer, &QTimer::timeout, [&](){ + checkShaders(); + updateRoles({IsProjectReferencedRole, HasWarningRole, ExtraIconRole}); + }); } QHash ProjectFileSystemModel::roleNames() const @@ -222,9 +229,6 @@ void ProjectFileSystemModel::updateReferences() std::for_each(renderableList.begin(), renderableList.end(), addReferencesRenderable); m_references.insert(projectPath); - - checkShaders(); - updateRoles({IsReferencedRole, Qt::DecorationRole, HasWarningRole, ExtraIconRole}); } @@ -416,7 +420,6 @@ void ProjectFileSystemModel::updateProjectReferences() } m_projectReferencesUpdateMap.clear(); - checkShaders(); updateRoles({IsProjectReferencedRole, HasWarningRole, ExtraIconRole}); } @@ -1352,6 +1355,7 @@ void ProjectFileSystemModel::onFilesChanged( m_projectReferencesUpdateMap.insert(filePath, false); } m_projectReferencesUpdateTimer.start(); + m_shaderCheckTimer.start(); } } } diff --git a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.h b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.h index 56cd56b5..8fb63805 100644 --- a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.h +++ b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.h @@ -165,6 +165,7 @@ private: // Value: if true, uip was modified or created. If false, it was removed. QHash m_projectReferencesUpdateMap; QTimer m_projectReferencesUpdateTimer; + QTimer m_shaderCheckTimer; std::shared_ptr m_directoryConnection; QString m_selectFile; // file to be selected on next layout change }; -- cgit v1.2.3