summaryrefslogtreecommitdiffstats
path: root/src/render/framegraph
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2019-09-17 17:33:28 +0200
committerPaul Lemire <paul.lemire@kdab.com>2019-09-20 14:27:01 +0200
commitc1deb350219fdd1af1226b99de16946f52e099e2 (patch)
tree72dede195116d3a4d87b0dd5abfd52b4f770ad25 /src/render/framegraph
parente695436382f3be9501095eceb202939172ddff22 (diff)
Update QProximityFilter to use direct sync
Change-Id: I2f1ca89bdb6eb34727e2a7a3791c958676e99c2a Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/render/framegraph')
-rw-r--r--src/render/framegraph/proximityfilter.cpp35
-rw-r--r--src/render/framegraph/proximityfilter_p.h4
2 files changed, 16 insertions, 23 deletions
diff --git a/src/render/framegraph/proximityfilter.cpp b/src/render/framegraph/proximityfilter.cpp
index cdfd7e51e..593e541bc 100644
--- a/src/render/framegraph/proximityfilter.cpp
+++ b/src/render/framegraph/proximityfilter.cpp
@@ -53,29 +53,24 @@ ProximityFilter::ProximityFilter()
{
}
-void ProximityFilter::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
+void ProximityFilter::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
- FrameGraphNode::initializeFromPeer(change);
- const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QProximityFilterData>>(change);
- const QProximityFilterData &data = typedChange->data;
- m_entityId = data.entityId;
- m_distanceThreshold = data.distanceThreshold;
-}
+ const QProximityFilter *node = qobject_cast<const QProximityFilter *>(frontEnd);
+ if (!node)
+ return;
-void ProximityFilter::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
-{
- qCDebug(Render::Framegraph) << Q_FUNC_INFO;
- if (e->type() == Qt3DCore::PropertyUpdated) {
- Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (propertyChange->propertyName() == QByteArrayLiteral("entity")) {
- m_entityId = propertyChange->value().value<Qt3DCore::QNodeId>();
- markDirty(AbstractRenderer::FrameGraphDirty);
- } else if (propertyChange->propertyName() == QByteArrayLiteral("distanceThreshold")) {
- m_distanceThreshold = propertyChange->value().toFloat();
- markDirty(AbstractRenderer::FrameGraphDirty);
- }
+ FrameGraphNode::syncFromFrontEnd(frontEnd, firstTime);
+
+ const auto entityId = Qt3DCore::qIdForNode(node->entity());
+ if (entityId != m_entityId) {
+ m_entityId = entityId;
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ }
+
+ if (node->distanceThreshold() != m_distanceThreshold) {
+ m_distanceThreshold = node->distanceThreshold();
+ markDirty(AbstractRenderer::FrameGraphDirty);
}
- FrameGraphNode::sceneChangeEvent(e);
}
} // namespace Render
diff --git a/src/render/framegraph/proximityfilter_p.h b/src/render/framegraph/proximityfilter_p.h
index e57b53dea..5c2f7ad66 100644
--- a/src/render/framegraph/proximityfilter_p.h
+++ b/src/render/framegraph/proximityfilter_p.h
@@ -64,7 +64,7 @@ class Q_AUTOTEST_EXPORT ProximityFilter : public FrameGraphNode
public:
ProximityFilter();
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
float distanceThreshold() const { return m_distanceThreshold; }
Qt3DCore::QNodeId entityId() const { return m_entityId; }
@@ -76,8 +76,6 @@ public:
#endif
private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
-
float m_distanceThreshold;
Qt3DCore::QNodeId m_entityId;
};