summaryrefslogtreecommitdiffstats
path: root/src/render/lights
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/lights')
-rw-r--r--src/render/lights/light.cpp16
-rw-r--r--src/render/lights/light_p.h4
2 files changed, 12 insertions, 8 deletions
diff --git a/src/render/lights/light.cpp b/src/render/lights/light.cpp
index e8474b728..30d71082b 100644
--- a/src/render/lights/light.cpp
+++ b/src/render/lights/light.cpp
@@ -58,14 +58,18 @@ QNodeId Light::shaderData() const
return m_shaderDataId;
}
-void Light::initializeFromPeer(const QNodeCreatedChangeBasePtr &change)
+void Light::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
{
- const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QAbstractLightData>>(change);
- const auto &data = typedChange->data;
- m_shaderDataId = data.shaderDataId;
+ BackendNode::syncFromFrontEnd(frontEnd, firstTime);
+ const QAbstractLight *node = qobject_cast<const QAbstractLight *>(frontEnd);
+ if (!node)
+ return;
- Q_ASSERT(m_renderer);
- BackendNode::markDirty(AbstractRenderer::LightsDirty);
+ if (firstTime) {
+ QAbstractLightPrivate *d = static_cast<QAbstractLightPrivate *>(QAbstractLightPrivate::get(const_cast<Qt3DCore::QNode *>(frontEnd)));
+ m_shaderDataId = d->m_shaderData ? d->m_shaderData->id() : QNodeId{};
+ BackendNode::markDirty(AbstractRenderer::LightsDirty);
+ }
}
RenderLightFunctor::RenderLightFunctor(AbstractRenderer *renderer, NodeManagers *managers)
diff --git a/src/render/lights/light_p.h b/src/render/lights/light_p.h
index 8ecc87585..5f5f8140e 100644
--- a/src/render/lights/light_p.h
+++ b/src/render/lights/light_p.h
@@ -66,9 +66,9 @@ class Q_AUTOTEST_EXPORT Light : public BackendNode
public:
Qt3DCore::QNodeId shaderData() const;
-private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
+private:
Qt3DCore::QNodeId m_shaderDataId;
};