summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJere Tuliniemi <jere.tuliniemi@qt.io>2018-11-28 17:47:44 +0200
committerJere Tuliniemi <jere.tuliniemi@qt.io>2018-11-29 10:02:29 +0000
commit29eeaf92ee83cb5c4711a145be7ce2480fe32bde (patch)
tree1169d1c2bd4df781dc1ed6bcf37d9d23d8d79bcc
parentf2962496f28c138b697e243a71e2056dded452d4 (diff)
Update shader list for all material types
Referenced materials now show the latest shaders if the inspector is open when the shaders are added to the project. Referenced materials also lose the ability to change the material type of the original material. Task-number: QT3DS-2776 Change-Id: I45b86abd5c9b54fd4e4c8c06979032feca6c34b2 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp19
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h3
2 files changed, 14 insertions, 8 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
index 19348fc2..ea6786c7 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
@@ -446,14 +446,19 @@ void InspectorControlModel::duplicateMaterial()
}
}
-void InspectorControlModel::updateMaterialValues(const QStringList &values, int elementIndex)
+void InspectorControlModel::updateMaterialValues(const QStringList &values, int elementIndex,
+ bool updatingShaders)
{
// Find if there are any material items and update the values of those
- for (int row = 0; row < m_groupElements.count(); ++row) {
+ int startIndex = 0;
+ bool isReferenced = !isAnimatableMaterial() && updatingShaders;
+ if (isReferenced && m_groupElements.count() > 0)
+ startIndex = m_groupElements.count() - 1; // Update the last group for referenced materials
+ for (int row = startIndex; row < m_groupElements.count(); ++row) {
const CInspectorGroup *inspectorGroup = m_inspectableBase->GetGroup(row);
const auto group = dynamic_cast<const Qt3DSDMInspectorGroup *>(inspectorGroup);
const auto materialGroup = dynamic_cast<const Qt3DSDMMaterialInspectorGroup *>(group);
- if (materialGroup && materialGroup->isMaterialGroup()) {
+ if (materialGroup && (materialGroup->isMaterialGroup() || isReferenced)) {
if (m_groupElements[row].controlElements.size()) {
auto item = m_groupElements[row].controlElements[elementIndex]
.value<InspectorControlBase *>();
@@ -469,9 +474,9 @@ void InspectorControlModel::updateMaterialValues(const QStringList &values, int
void InspectorControlModel::updateShaderValues()
{
int index = 0;
- if (!isInsideMaterialContainer())
+ if (isAnimatableMaterial() && !isInsideMaterialContainer())
index = 1;
- updateMaterialValues(shaderValues(), index);
+ updateMaterialValues(shaderValues(), index, true);
}
void InspectorControlModel::updateMatDataValues()
@@ -500,7 +505,7 @@ void InspectorControlModel::setMaterials(std::vector<Q3DStudio::CFilePath> &mate
m_materials.push_back({name, relativePath});
}
- if (isAnimatableMaterial())
+ if (!isDefaultMaterial())
updateShaderValues();
}
@@ -1134,7 +1139,7 @@ auto InspectorControlModel::computeGroup(CInspectableBase* inspectable,
if (materialGroup && materialGroup->isMaterialGroup()) {
InspectorControlBase *item = nullptr;
- if (!isInsideMaterialContainer(cdmInspectable)) {
+ if (!isInsideMaterialContainer(cdmInspectable) && !isReference) {
item = createMaterialTypeItem(cdmInspectable, theIndex);
if (item)
result.controlElements.push_back(QVariant::fromValue(item));
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h
index ec928a76..89b3e26a 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h
@@ -206,7 +206,8 @@ private:
bool isAnimatableMaterial(Qt3DSDMInspectable *inspectable) const;
bool isBasicMaterial() const;
bool isBasicMaterial(Qt3DSDMInspectable *inspectable) const;
- void updateMaterialValues(const QStringList &values, int elementIndex);
+ void updateMaterialValues(const QStringList &values, int elementIndex,
+ bool updatingShaders = false);
void updateShaderValues();
void updateMatDataValues();
void updatePropertyValue(InspectorControlBase *element) const;