summaryrefslogtreecommitdiffstats
path: root/src/core/nodes
diff options
context:
space:
mode:
authorSvenn-Arne Dragly <svenn-arne.dragly@qt.io>2018-07-05 13:06:24 +0200
committerSvenn-Arne Dragly <svenn-arne.dragly@qt.io>2018-09-03 14:31:52 +0000
commit4a38107bc12f8c3d9d290d4649c8606ea8b1376d (patch)
tree2ca2e0530cca74456b36a105c68d88fe17543a3e /src/core/nodes
parent7f3d98c5326de1a6800f5d91b9f53874b4a71fa7 (diff)
Add private API to access child nodes of QEntity and QFrameGraphNode
This opens up for reduced bookeeping on the backend, and is used by the experimental Dragon render aspect, which is currently being implemented in qt3d-runtime. Change-Id: I4cc2e98e4e0e7e8d456ed11c4fbc48db5c93f2a2 Reviewed-by: Paul Lemire <paul.lemire@kdab.com> (cherry picked from commit 77e418fde850c86e39d9dd8528876599fbe9dc34) Reviewed-by: Mike Krus <mike.krus@kdab.com> Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src/core/nodes')
-rw-r--r--src/core/nodes/qentity.cpp16
-rw-r--r--src/core/nodes/qentity_p.h1
2 files changed, 17 insertions, 0 deletions
diff --git a/src/core/nodes/qentity.cpp b/src/core/nodes/qentity.cpp
index d0ed58efd..64ea65087 100644
--- a/src/core/nodes/qentity.cpp
+++ b/src/core/nodes/qentity.cpp
@@ -52,6 +52,8 @@
#include <Qt3DCore/private/qcomponent_p.h>
#include <Qt3DCore/private/qscene_p.h>
+#include <QQueue>
+
QT_BEGIN_NAMESPACE
namespace Qt3DCore {
@@ -233,6 +235,20 @@ QNodeCreatedChangeBasePtr QEntity::createNodeCreationChange() const
Q_D(const QEntity);
data.parentEntityId = parentEntity() ? parentEntity()->id() : Qt3DCore::QNodeId();
+
+ // Find all child entities
+ QQueue<QNode *> queue;
+ queue.append(childNodes().toList());
+ data.childEntityIds.reserve(queue.size());
+ while (!queue.isEmpty()) {
+ auto *child = queue.dequeue();
+ auto *childEntity = qobject_cast<QEntity *>(child);
+ if (childEntity != nullptr)
+ data.childEntityIds.push_back(childEntity->id());
+ else
+ queue.append(child->childNodes().toList());
+ }
+
data.componentIdsAndTypes.reserve(d->m_components.size());
const QComponentVector &components = d->m_components;
for (QComponent *c : components) {
diff --git a/src/core/nodes/qentity_p.h b/src/core/nodes/qentity_p.h
index ef35d83a1..8fe03cd6b 100644
--- a/src/core/nodes/qentity_p.h
+++ b/src/core/nodes/qentity_p.h
@@ -91,6 +91,7 @@ struct QEntityData
{
Qt3DCore::QNodeId parentEntityId;
QVector<QNodeIdTypePair> componentIdsAndTypes;
+ Qt3DCore::QNodeIdVector childEntityIds;
};
}