diff options
author | Jim Albamont <jim.albamont@kdab.com> | 2019-03-31 21:57:36 -0500 |
---|---|---|
committer | Jim Albamont <jim.albamont@kdab.com> | 2019-04-16 14:13:11 +0000 |
commit | 993db3e119ed552843aac0d99e1c302eeb8c8582 (patch) | |
tree | 9c2c3923921092fad52f64a7e9b0a961e1c92e53 /src/render/framegraph/qframegraphnode.cpp | |
parent | 1fcdee0f313845f4e06b294cf520ab477191774b (diff) |
Fix FrameGraph node parenting
Framegraph suffers from the same problem as Entities. When they are created
they pass their parent FrameGraph node, and not their parent QNode. When
reparenting them we need to make sure the same thing happens otherwise
you get backend FrameGraph nodes parented to non-framegraph nodes and
they are just dropped from backend.
Change-Id: I1b9cab2c9e869c690c4c43208e62a1044b3359a4
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/framegraph/qframegraphnode.cpp')
-rw-r--r-- | src/render/framegraph/qframegraphnode.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/render/framegraph/qframegraphnode.cpp b/src/render/framegraph/qframegraphnode.cpp index 9acfd1209..d52b728a8 100644 --- a/src/render/framegraph/qframegraphnode.cpp +++ b/src/render/framegraph/qframegraphnode.cpp @@ -40,6 +40,7 @@ #include "qframegraphnode.h" #include "qframegraphnode_p.h" #include <Qt3DRender/qframegraphnodecreatedchange.h> +#include <Qt3DCore/qpropertyupdatedchange.h> #include <Qt3DCore/QNode> @@ -248,9 +249,24 @@ QFrameGraphNode::QFrameGraphNode(QFrameGraphNodePrivate &dd, QNode *parent) Qt3DCore::QNodeCreatedChangeBasePtr QFrameGraphNode::createNodeCreationChange() const { + // connect to the parentChanged signal here rather than constructor because + // until now there's no backend node to notify when parent changes + connect(this, &QNode::parentChanged, this, &QFrameGraphNode::onParentChanged); + return QFrameGraphNodeCreatedChangeBasePtr::create(this); } +void QFrameGraphNode::onParentChanged(QObject *) +{ + const auto parentID = parentFrameGraphNode() ? parentFrameGraphNode()->id() : Qt3DCore::QNodeId(); + auto parentChange = Qt3DCore::QPropertyUpdatedChangePtr::create(id()); + parentChange->setPropertyName("parentFrameGraphUpdated"); + parentChange->setValue(QVariant::fromValue(parentID)); + const bool blocked = blockNotifications(false); + notifyObservers(parentChange); + blockNotifications(blocked); +} + } // namespace Qt3DRender QT_END_NAMESPACE |