diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-05-04 15:23:41 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2017-05-05 04:47:31 +0000 |
commit | 6fd0fc4217fe689092957e0bad8a927acb4aa09a (patch) | |
tree | 0f616e4e679ab4ec22b8715d308b98a9c956300a | |
parent | 67dea992954a4499d81ee63457263f913ca92c50 (diff) |
Apply layer filter to light sources
Cannot just take all entities with light components: the layer filter
must be applied as usual.
Task-number: QTBUG-60573
Change-Id: I361fab88745113c1b24b68cbff52051139046d9c
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r-- | src/render/backend/renderviewbuilder.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/render/backend/renderviewbuilder.cpp b/src/render/backend/renderviewbuilder.cpp index 0aab31b86..f47c6f419 100644 --- a/src/render/backend/renderviewbuilder.cpp +++ b/src/render/backend/renderviewbuilder.cpp @@ -188,8 +188,6 @@ public: RenderView *rv = m_renderViewJob->renderView(); if (!rv->noDraw()) { - // Set the light sources - rv->setLightSources(std::move(m_lightGathererJob->lights())); rv->setEnvironmentLight(m_lightGathererJob->takeEnvironmentLight()); // We sort the vector so that the removal can then be performed linearly @@ -208,6 +206,14 @@ public: QVector<Entity *> filteredEntities = m_filterEntityByLayerJob->filteredEntities(); RenderViewBuilder::removeEntitiesNotInSubset(renderableEntities, filteredEntities); + // Set the light sources, with layer filters applied. + QVector<LightSource> lightSources = m_lightGathererJob->lights(); + for (int i = 0; i < lightSources.count(); ++i) { + if (!filteredEntities.contains(lightSources[i].entity)) + lightSources.removeAt(i--); + } + rv->setLightSources(lightSources); + // Filter out frustum culled entity for drawable entities if (isDraw && rv->frustumCulling()) RenderViewBuilder::removeEntitiesNotInSubset(renderableEntities, m_frustumCullingJob->visibleEntities()); |