QmlDesigner: Show 3D scene with multiple objects

A View3D can have multiple root nodes, which are
automatically aggregated in a single root node.

Change-Id: I3ad11eff5a8beadbd53f0fc8cdcaecd78772768b
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Thomas Hartmann
2019-10-15 13:59:25 +02:00
parent db3dc34a12
commit 18ff97581a
2 changed files with 19 additions and 9 deletions

View File

@@ -147,6 +147,22 @@ bool Qt5InformationNodeInstanceServer::isDirtyRecursiveForParentInstances(QQuick
return false; return false;
} }
QObject *Qt5InformationNodeInstanceServer::findRootNodeOf3DViewport(
const QList<ServerNodeInstance> &instanceList) const
{
for (const ServerNodeInstance &instance : instanceList) {
if (instance.isSubclassOf("QQuick3DViewport")) {
for (const ServerNodeInstance &child : instanceList) { /* Look for scene node */
/* The QQuick3DViewport always creates a root node.
* This root node contains the complete scene. */
if (child.isSubclassOf("QQuick3DNode") && child.parent() == instance)
return child.internalObject()->property("parent").value<QObject *>();
}
}
}
return nullptr;
}
void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeInstance> &instanceList) void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeInstance> &instanceList)
{ {
ServerNodeInstance root = rootNodeInstance(); ServerNodeInstance root = rootNodeInstance();
@@ -157,15 +173,8 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeIns
if (root.isSubclassOf("QQuick3DNode")) { if (root.isSubclassOf("QQuick3DNode")) {
node = root.internalObject(); node = root.internalObject();
showCustomLight = true; // Pure node scene we should add a custom light showCustomLight = true; // Pure node scene we should add a custom light
} else { // Look for QQuick3DView } else {
for (const ServerNodeInstance &instance : instanceList) { node = findRootNodeOf3DViewport(instanceList);
if (instance.isSubclassOf("QQuick3DViewport")) {
for (const ServerNodeInstance &child : instanceList) { /* Look for scene node */
if (child.isSubclassOf("QQuick3DNode") && child.parent() == instance)
node = child.internalObject();
}
}
}
} }
if (node) { // If we found a scene we create the edit view if (node) { // If we found a scene we create the edit view

View File

@@ -52,6 +52,7 @@ protected:
private: private:
void setup3DEditView(const QList<ServerNodeInstance> &instanceList); void setup3DEditView(const QList<ServerNodeInstance> &instanceList);
QObject *findRootNodeOf3DViewport(const QList<ServerNodeInstance> &instanceList) const;
QSet<ServerNodeInstance> m_parentChangedSet; QSet<ServerNodeInstance> m_parentChangedSet;
QList<ServerNodeInstance> m_completedComponentList; QList<ServerNodeInstance> m_completedComponentList;