diff options
author | Mike Krus <mike.krus@kdab.com> | 2019-09-06 14:18:35 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2019-09-18 19:28:02 +0200 |
commit | dedde9f70664e5d721edb92308d4452a2c9685f5 (patch) | |
tree | 6a7b968a463cd2517360447f6ef531485048834f /src/render/lights | |
parent | 1cdf47f02e2b32da4ac82561f625716642d2933a (diff) |
Update QEnvironmentLight to use direct sync
Change-Id: I4f89fa7609ef84a9e2795dc81e8232c895177e9f
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/render/lights')
-rw-r--r-- | src/render/lights/environmentlight.cpp | 14 | ||||
-rw-r--r-- | src/render/lights/environmentlight_p.h | 3 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/render/lights/environmentlight.cpp b/src/render/lights/environmentlight.cpp index d4245fb6e..20364fdfa 100644 --- a/src/render/lights/environmentlight.cpp +++ b/src/render/lights/environmentlight.cpp @@ -53,11 +53,17 @@ QNodeId EnvironmentLight::shaderData() const return m_shaderDataId; } -void EnvironmentLight::initializeFromPeer(const QNodeCreatedChangeBasePtr &change) +void EnvironmentLight::syncFromFrontEnd(const QNode *frontEnd, bool firstTime) { - const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QEnvironmentLightData>>(change); - const auto &data = typedChange->data; - m_shaderDataId = data.shaderDataId; + BackendNode::syncFromFrontEnd(frontEnd, firstTime); + const QEnvironmentLight *node = qobject_cast<const QEnvironmentLight *>(frontEnd); + if (!node) + return; + + if (firstTime) { + QEnvironmentLightPrivate *d = static_cast<QEnvironmentLightPrivate *>(QEnvironmentLightPrivate::get(const_cast<Qt3DCore::QNode *>(frontEnd))); + m_shaderDataId = d->m_shaderData ? d->m_shaderData->id() : QNodeId{}; + } } } // namespace Render diff --git a/src/render/lights/environmentlight_p.h b/src/render/lights/environmentlight_p.h index 00d49d298..92f6ce100 100644 --- a/src/render/lights/environmentlight_p.h +++ b/src/render/lights/environmentlight_p.h @@ -63,10 +63,9 @@ class Q_AUTOTEST_EXPORT EnvironmentLight : public BackendNode { public: Qt3DCore::QNodeId shaderData() const; + void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override; private: - void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final; - Qt3DCore::QNodeId m_shaderDataId; }; |