summaryrefslogtreecommitdiffstats
path: root/src/render/framegraph/qframegraphnode.cpp
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/render/framegraph/qframegraphnode.cpp
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/render/framegraph/qframegraphnode.cpp')
-rw-r--r--src/render/framegraph/qframegraphnode.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/render/framegraph/qframegraphnode.cpp b/src/render/framegraph/qframegraphnode.cpp
index 0a60edef7..3cf19d0d8 100644
--- a/src/render/framegraph/qframegraphnode.cpp
+++ b/src/render/framegraph/qframegraphnode.cpp
@@ -41,6 +41,12 @@
#include "qframegraphnode_p.h"
#include <Qt3DRender/qframegraphnodecreatedchange.h>
+#include <Qt3DCore/QNode>
+
+#include <QQueue>
+
+using namespace Qt3DCore;
+
QT_BEGIN_NAMESPACE
namespace Qt3DRender {
@@ -190,7 +196,10 @@ QFrameGraphNode::~QFrameGraphNode()
}
/*!
- Returns a pointer to the parent.
+ Returns a pointer to the parent frame graph node.
+
+ If the parent of this node is not a frame graph node,
+ this method will recursively look for a parent node that is a frame graph node.
*/
QFrameGraphNode *QFrameGraphNode::parentFrameGraphNode() const
{
@@ -205,6 +214,31 @@ QFrameGraphNode *QFrameGraphNode::parentFrameGraphNode() const
return parentFGNode;
}
+/*!
+ * Returns a list of the children that are frame graph nodes.
+ * If this function encounters a child node that is not a frame graph node,
+ * it will go through the children of the child node and look for frame graph nodes.
+ * If any of these are not frame graph nodes, they will be further searched as
+ * if they were direct children of this node.
+ */
+QVector<QFrameGraphNode *> QFrameGraphNodePrivate::childFrameGraphNodes() const
+{
+ Q_Q(const QFrameGraphNode);
+ QVector<QFrameGraphNode *> result;
+ QQueue<QNode *> queue;
+ queue.append(q->childNodes().toList());
+ result.reserve(queue.size());
+ while (!queue.isEmpty()) {
+ auto *child = queue.dequeue();
+ auto *childFGNode = qobject_cast<QFrameGraphNode *>(child);
+ if (childFGNode != nullptr)
+ result.push_back(childFGNode);
+ else
+ queue.append(child->childNodes().toList());
+ }
+ return result;
+}
+
/*! \internal */
QFrameGraphNode::QFrameGraphNode(QFrameGraphNodePrivate &dd, QNode *parent)
: QNode(dd, parent)