diff options
author | Kevin Ottens <kevin.ottens@kdab.com> | 2016-05-03 14:18:26 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-05-04 08:33:31 +0000 |
commit | a1fcb2a80eaac8f49b082bd587b8c7935d816ea7 (patch) | |
tree | 8417b555d30c64f578beda97e7619416fb66f749 /src/render/backend/renderview.cpp | |
parent | 67a6c7fc59f750c1b535b545983625d3ebc86cdf (diff) |
Adjust LayerFilter's layers property behavior
Now an empty list filters out all layers instead of letting everything
go through. Also, enabled == false is now honored, a disabled filter
lets everything go through (whatever is the layers list).
Change-Id: I5ef183c27a9dd045f423c1bf13d563c61b432cfa
Task-number: QTBUG-51440
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/backend/renderview.cpp')
-rw-r--r-- | src/render/backend/renderview.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/render/backend/renderview.cpp b/src/render/backend/renderview.cpp index 1a7005558..514550ce6 100644 --- a/src/render/backend/renderview.cpp +++ b/src/render/backend/renderview.cpp @@ -100,11 +100,11 @@ int LIGHT_COLOR_NAMES[MAX_LIGHTS]; int LIGHT_INTENSITY_NAMES[MAX_LIGHTS]; QString LIGHT_STRUCT_NAMES[MAX_LIGHTS]; -// TODO: Should we treat lack of layer data as implicitly meaning that an -// entity is in all layers? -bool isEntityInLayers(const Entity *entity, const QVector<int> &filterLayerIds) +bool isEntityInLayers(const Entity *entity, bool hasLayerFilter, const QVector<int> &filterLayerIds) { - if (filterLayerIds.isEmpty()) + if (hasLayerFilter && filterLayerIds.isEmpty()) + return false; + else if (filterLayerIds.isEmpty()) return true; const QList<Layer *> entityLayers = entity->renderComponents<Layer>(); @@ -490,20 +490,20 @@ void RenderView::addClearBuffers(const ClearBuffers *cb) { } // TODO: Convert into a job that caches lookup of entities for layers -static void findEntitiesInLayers(Entity *e, const QVector<int> &filterLayerIds, QVector<Entity *> &entities) +static void findEntitiesInLayers(Entity *e, bool hasLayerFilter, const QVector<int> &filterLayerIds, QVector<Entity *> &entities) { // Bail if sub-tree is disabled if (!e->isEnabled()) return; // Check this entity - if (isEntityInLayers(e, filterLayerIds)) + if (isEntityInLayers(e, hasLayerFilter, filterLayerIds)) entities.push_back(e); // Recurse to children const auto children = e->children(); for (Entity *child : children) - findEntitiesInLayers(child, filterLayerIds, entities); + findEntitiesInLayers(child, hasLayerFilter, filterLayerIds, entities); } // Tries to order renderCommand by shader so as to minimize shader changes @@ -517,7 +517,7 @@ void RenderView::buildRenderCommands(Entity *rootEntity, const Plane *planes) QVector<Entity *> entities; const int entityCount = m_renderer->nodeManagers()->renderNodesManager()->count(); entities.reserve(entityCount); - findEntitiesInLayers(rootEntity, m_data->m_layerIds, entities); + findEntitiesInLayers(rootEntity, hasLayerFilter(), layerFilterIds(), entities); #if defined(QT3D_RENDER_VIEW_JOB_TIMINGS) qDebug() << "Found" << entities.size() << "entities in layers" << m_data->m_layers << "in" << timer.nsecsElapsed() / 1.0e6 << "ms"; |