summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahmoud Badri <mahmoud.badri@qt.io>2019-03-20 14:23:50 +0200
committerMahmoud Badri <mahmoud.badri@qt.io>2019-03-20 13:20:30 +0000
commita7a0ffa97db530ea572cc38d2ee573f131f48791 (patch)
treebeae84ac9f9d95e0124af757f0e610c1d592388b
parent7887d152278c97a597674231a3ab79d2e8dca394 (diff)
Improve timeline playback/scrubbing performance
Inspector model was being refreshed on every time change. Removed this unnecessary model refresh and corrected an issue so that inspector is updated on every property change. This greatly improved playback performance. Also removed few other unneeded code and some cleanups along the way. Task-number: QT3DS-3184 Change-Id: I77606b52239c8bfbcf235ebfd1189ba45acc2abb Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp48
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h16
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp53
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h4
4 files changed, 35 insertions, 86 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
index 8b993c75..feca12b5 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
@@ -25,15 +25,10 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <QFileInfo>
-#include <QtCore/qurl.h>
-
-#include <functional>
#include "InspectorControlModel.h"
#include "Core.h"
#include "Doc.h"
-#include "ControlGraphIterators.h"
#include "InspectorGroup.h"
#include "Qt3DSDMInspectorGroup.h"
#include "Qt3DSDMInspectorRow.h"
@@ -42,8 +37,6 @@
#include "Qt3DSDMDataCore.h"
#include "StudioApp.h"
#include "IDocumentEditor.h"
-#include "Control.h"
-#include "ControlData.h"
#include "Qt3DSDMMetaData.h"
#include "Qt3DSDMSignals.h"
#include "CmdDataModelDeanimate.h"
@@ -64,6 +57,8 @@
#include "Dispatch.h"
#include "VariantsGroupModel.h"
+#include <QtCore/qfileinfo.h>
+
static QStringList renderableItems()
{
QStringList renderables;
@@ -125,21 +120,6 @@ void InspectorControlModel::setInspectable(CInspectableBase *inInspectable)
m_modifiedProperty.second = 0;
m_previouslyCommittedValue = {};
- const auto signalProvider
- = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetFullSystemSignalProvider();
-
- if (m_notifier.get() == nullptr) {
- m_notifier = signalProvider->ConnectInstancePropertyValue(
- std::bind(&InspectorControlModel::onPropertyChanged,
- this, std::placeholders::_1, std::placeholders::_2));
- }
- if (m_slideNotifier.get() == nullptr) {
- m_slideNotifier = signalProvider->ConnectSlideRearranged(
- std::bind(&InspectorControlModel::onSlideRearranged, this,
- std::placeholders::_1, std::placeholders::_2,
- std::placeholders::_3));
- }
-
if (m_inspectableBase != inInspectable) {
m_inspectableBase = inInspectable;
rebuildTree();
@@ -173,19 +153,16 @@ CInspectableBase *getReferenceMaterialInspectable(CInspectableBase *inspectBase)
return nullptr;
}
-void InspectorControlModel::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
- qt3dsdm::Qt3DSDMPropertyHandle inProperty)
+void InspectorControlModel::notifyPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
+ qt3dsdm::Qt3DSDMPropertyHandle inProperty)
{
auto doc = g_StudioApp.GetCore()->GetDoc();
const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
if (!bridge->IsSceneGraphInstance(inInstance))
return;
- if (inProperty == bridge->GetLayer().m_variants) {
- // only update the variants model if its property changes
- m_variantsModel->refresh();
+ if (inProperty == bridge->GetLayer().m_variants) // variants model is updated upon edit
return;
- }
bool changed = false;
for (int row = 0; row < m_groupElements.count(); ++row) {
@@ -689,7 +666,6 @@ void InspectorControlModel::updateFontValues(InspectorControlBase *element) cons
}
}
-
QStringList InspectorControlModel::materialTypeValues() const
{
QStringList values;
@@ -876,7 +852,7 @@ InspectorControlBase* InspectorControlModel::createItem(Qt3DSDMInspectable *insp
item->m_tooltip = Q3DStudio::CString(metaProperty.m_Description.c_str()).toQString();
// \n is parsed as \\n from the material and effect files. Replace them to fix multi-line
// tooltips
- item->m_tooltip.replace(QStringLiteral("\\n"), QStringLiteral("\n"));
+ item->m_tooltip.replace(QLatin1String("\\n"), QLatin1String("\n"));
item->m_animatable = metaProperty.m_Animatable &&
studio->GetAnimationSystem()->IsPropertyAnimatable(item->m_instance,
@@ -1570,8 +1546,7 @@ void InspectorControlModel::saveIfMaterial(qt3dsdm::Qt3DSDMInstanceHandle instan
}
}
- sceneEditor->writeMaterialFile(material, materialName,
- sourcePath.isEmpty(), sourcePath);
+ sceneEditor->writeMaterialFile(material, materialName, sourcePath.isEmpty(), sourcePath);
}
}
@@ -2035,15 +2010,6 @@ void InspectorControlModel::setPropertyAnimated(long instance, int handle, bool
g_StudioApp.GetCore()->ExecuteCommand(cmd);
}
-void InspectorControlModel::onSlideRearranged(const qt3dsdm::Qt3DSDMSlideHandle &inMaster,
- int inOldIndex, int inNewIndex)
-{
- Q_UNUSED(inMaster);
- Q_UNUSED(inOldIndex);
- Q_UNUSED(inNewIndex);
- rebuildTree();
-}
-
QVariant InspectorControlModel::data(const QModelIndex &index, int role) const
{
if (!hasIndex(index.row(), index.column(),index.parent()))
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h
index 5e7b92c2..85c9c391 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h
@@ -29,16 +29,15 @@
#ifndef INSPECTORCONTROLMODEL_H
#define INSPECTORCONTROLMODEL_H
-#include <QtCore/qabstractitemmodel.h>
-#include <QtCore/qvector.h>
-
#include "Qt3DSDMValue.h"
#include "Qt3DSDMMetaDataValue.h"
#include "Qt3DSDMMetaDataTypes.h"
#include "Qt3DSFileTools.h"
-
#include "IDocumentEditor.h"
+#include <QtCore/qabstractitemmodel.h>
+#include <QtCore/qvector.h>
+
class CInspectableBase;
class Qt3DSDMInspectable;
class SGuideInspectableImpl;
@@ -109,7 +108,7 @@ class InspectorControlModel : public QAbstractListModel
Q_OBJECT
public:
explicit InspectorControlModel(VariantsGroupModel *variantsModel, QObject *parent);
- ~InspectorControlModel() = default;
+ ~InspectorControlModel() override = default;
enum Roles {
GroupValuesRole = Qt::UserRole + 1,
@@ -138,6 +137,8 @@ public:
void setPropertyControllerInstance(long instance,int handle,
Q3DStudio::CString controllerInstance,
bool controlled);
+ void notifyPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
+ qt3dsdm::Qt3DSDMPropertyHandle inProperty);
Q_INVOKABLE void setMaterialTypeValue(long instance, int handle, const QVariant &value);
Q_INVOKABLE void setShaderValue(long instance, int handle, const QVariant &value);
@@ -220,14 +221,9 @@ private:
void updatePropertyValue(InspectorControlBase *element) const;
void rebuildTree();
void refreshTree();
- void onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
- qt3dsdm::Qt3DSDMPropertyHandle inProperty);
void updateAnimateToggleState(InspectorControlBase *inItem);
void updateControlledToggleState(InspectorControlBase *inItem) const;
- std::shared_ptr<qt3dsdm::ISignalConnection> m_notifier;
- std::shared_ptr<qt3dsdm::ISignalConnection> m_slideNotifier;
-
QStringList materialTypeValues() const;
QStringList shaderValues() const;
QStringList matDataValues() const;
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
index 6ba75709..ddcec94c 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
@@ -143,10 +143,8 @@ void InspectorControlView::OnNewPresentation()
g_StudioApp.GetCore()->getProjectFile().getProjectPath(),
std::bind(&InspectorControlView::onFilesChanged, this, std::placeholders::_1)));
m_connections.push_back(sp->ConnectInstancePropertyValue(
- std::bind(&InspectorControlView::onInstancePropertyValueChanged, this,
+ std::bind(&InspectorControlView::onPropertyChanged, this, std::placeholders::_1,
std::placeholders::_2)));
- m_connections.push_back(sp->ConnectComponentSeconds(
- std::bind(&InspectorControlView::OnTimeChanged, this)));
m_connections.push_back(assetGraph->ConnectChildAdded(
std::bind(&InspectorControlView::onChildAdded, this, std::placeholders::_2)));
m_connections.push_back(assetGraph->ConnectChildRemoved(
@@ -163,11 +161,6 @@ void InspectorControlView::OnClosingPresentation()
m_connections.clear();
}
-void InspectorControlView::OnTimeChanged()
-{
- m_inspectorControlModel->refresh();
-}
-
void InspectorControlView::onFilesChanged(
const Q3DStudio::TFileModificationList &inFileModificationList)
{
@@ -295,14 +288,14 @@ bool InspectorControlView::canLinkProperty(int instance, int handle) const
{
CDoc *doc = g_StudioApp.GetCore()->GetDoc();
const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
+
if (bridge->isInsideMaterialContainer(instance))
return false;
- EStudioObjectType type = bridge->GetObjectType(instance);
- if (!qt3dsdm::Qt3DSDMPropertyHandle(handle).Valid()
- && (type & (OBJTYPE_CUSTOMMATERIAL | OBJTYPE_MATERIAL | OBJTYPE_REFERENCEDMATERIAL))) {
+
+ if (bridge->IsMaterialBaseInstance(instance)) // all material types are unlinkable
return false;
- }
- if (doc->GetStudioSystem()->GetPropertySystem()->GetName(handle) == L"eyeball")
+
+ if (handle == bridge->GetSceneAsset().m_Eyeball.m_Property) // eyeball is unlinkable
return false;
return doc->GetDocumentReader().CanPropertyBeLinked(instance, handle);
@@ -331,15 +324,17 @@ void InspectorControlView::openInInspector()
doc->SelectDataModelObject(instance);
}
-void InspectorControlView::onInstancePropertyValueChanged(
- qt3dsdm::Qt3DSDMPropertyHandle propertyHandle)
+void InspectorControlView::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
+ qt3dsdm::Qt3DSDMPropertyHandle inProperty)
{
+ m_inspectorControlModel->notifyPropertyChanged(inInstance, inProperty);
+
auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge();
// titleChanged implies icon change too, but that will only occur if inspectable type changes,
// which will invalidate the inspectable anyway, so in reality we are only interested in name
// property here
- if (propertyHandle == bridge->GetNameProperty()
- && m_inspectableBase && m_inspectableBase->IsValid()) {
+ if (inProperty == bridge->GetNameProperty() && m_inspectableBase
+ && m_inspectableBase->IsValid()) {
Q_EMIT titleChanged();
}
}
@@ -435,28 +430,20 @@ void InspectorControlView::showContextMenu(int x, int y, int handle, int instanc
auto doc = g_StudioApp.GetCore()->GetDoc();
if (canOpenInInspector(instance, handle)) {
- auto action = theContextMenu.addAction(QObject::tr("Open in Inspector"));
+ auto action = theContextMenu.addAction(tr("Open in Inspector"));
connect(action, &QAction::triggered, this, &InspectorControlView::openInInspector);
}
- bool canBeLinkedFlag = canLinkProperty(instance, handle);
- if (canBeLinkedFlag) {
- const bool isLinkedFlag = doc->GetDocumentReader().IsPropertyLinked(instance, handle);
-
- if (isLinkedFlag) {
- auto action = theContextMenu.addAction(QObject::tr("Unlink Property from Master Slide"));
- action->setEnabled(canBeLinkedFlag);
- connect(action, &QAction::triggered, this, &InspectorControlView::toggleMasterLink);
- } else {
- auto action = theContextMenu.addAction(QObject::tr("Link Property from Master Slide"));
- action->setEnabled(canBeLinkedFlag);
- connect(action, &QAction::triggered, this, &InspectorControlView::toggleMasterLink);
- }
-
+ if (canLinkProperty(instance, handle)) {
+ bool isLinked = doc->GetDocumentReader().IsPropertyLinked(instance, handle);
+ auto action = theContextMenu.addAction(isLinked ? tr("Unlink Property from Master Slide")
+ : tr("Link Property from Master Slide"));
+ connect(action, &QAction::triggered, this, &InspectorControlView::toggleMasterLink);
} else {
- auto action = theContextMenu.addAction(QObject::tr("Unable to link from Master Slide"));
+ auto action = theContextMenu.addAction(tr("Unable to link from Master Slide"));
action->setEnabled(false);
}
+
theContextMenu.exec(mapToGlobal({x, y}));
m_instance = 0;
m_handle = 0;
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h
index ace070b6..cb852824 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h
@@ -119,14 +119,14 @@ private:
void onFilesChanged(const Q3DStudio::TFileModificationList &inFileModificationList);
void OnNewPresentation() override;
void OnClosingPresentation() override;
- void OnTimeChanged();
void filterMaterials(std::vector<Q3DStudio::CFilePath> &materials);
void filterMatDatas(std::vector<Q3DStudio::CFilePath> &matDatas);
void setPropertyValueFromFilename(long instance, int handle, const QString &name);
bool canLinkProperty(int instance, int handle) const;
bool canOpenInInspector(int instance, int handle) const;
void openInInspector();
- void onInstancePropertyValueChanged(qt3dsdm::Qt3DSDMPropertyHandle propertyHandle);
+ void onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
+ qt3dsdm::Qt3DSDMPropertyHandle inProperty);
void onChildAdded(int inChild);
void onChildRemoved();