summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJere Tuliniemi <jere.tuliniemi@qt.io>2019-10-08 10:34:51 +0300
committerJere Tuliniemi <jere.tuliniemi@qt.io>2019-10-14 09:06:19 +0300
commit9c36497bccbe3f84b521820e308050cabd7862ef (patch)
treed828a796829df7dcfc50274e8a0ffd6eb6588253
parent04f6edf7fa056ed3070456cabee3ab05e96d2c60 (diff)
Fix duplicated material references
If a material that is referenced by another is duplicated, the material and all the referenced materials are now changed to basic material that refer to the new duplicated file. Task-number: QT3DS-3977 Change-Id: Ia7cd19401b407138fe9b72a6a60394cdee01ed52 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
index ee6e09c0..f0ca73ee 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
@@ -358,13 +358,29 @@ void InspectorControlModel::duplicateMaterial()
Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, tr("Set Material Type")));
doc->SelectDataModelObject(duplicate);
+ // Change all material that reference this material to basic materials too
+ Q3DStudio::CString relPathCString = Q3DStudio::CString::fromQString(relPath);
+ Q3DStudio::CString duplicateName = getBridge()->GetName(duplicate, true);
+ auto nameProperty = getBridge()->GetNameProperty();
+ QVector<qt3dsdm::Qt3DSDMInstanceHandle> refMats;
+ doc->getSceneReferencedMaterials(doc->GetSceneInstance(), refMats);
+ for (auto &refMat : qAsConst(refMats)) {
+ if (getBridge()->getMaterialReference(refMat) == instance) {
+ scopedEditor->setMaterialReferenceByPath(refMat, absPath);
+ scopedEditor->setMaterialSourcePath(refMat, relPathCString);
+ scopedEditor->SetName(refMat, duplicateName);
+ doc->GetStudioSystem()->GetFullSystemSignalSender()->SendInstancePropertyValue(
+ refMat, nameProperty);
+ }
+ }
+
if (type != OBJTYPE_REFERENCEDMATERIAL)
sceneEditor->SetMaterialType(instance, QStringLiteral("Referenced Material"));
scopedEditor->setMaterialReferenceByPath(instance, absPath);
- scopedEditor->setMaterialSourcePath(instance, Q3DStudio::CString::fromQString(relPath));
- scopedEditor->SetName(instance, getBridge()->GetName(duplicate, true));
+ scopedEditor->setMaterialSourcePath(instance, relPathCString);
+ scopedEditor->SetName(instance, duplicateName);
doc->GetStudioSystem()->GetFullSystemSignalSender()->SendInstancePropertyValue(
- instance, getBridge()->GetNameProperty());
+ instance, nameProperty);
}
}