diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-09-12 12:10:03 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-09-12 12:39:05 +0100 |
commit | 3f03499bf8a7cf3c3f8d19a020179c1205980bde (patch) | |
tree | 518b0ef3fb1b31d3856f43124150ef41acb8c1aa /src/render/jobs/pickboundingvolumeutils.cpp | |
parent | 8a4b9ebadb9e63ae367694f04786c7faf6306f27 (diff) | |
parent | bf5fd7a78c91e29332ce70ad844b756150f32f18 (diff) |
Merge branch '5.9' into 5.10
Change-Id: Id6a3d4ec579a2f2a2e559c22a2293d0e184f0bdf
Diffstat (limited to 'src/render/jobs/pickboundingvolumeutils.cpp')
-rw-r--r-- | src/render/jobs/pickboundingvolumeutils.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/render/jobs/pickboundingvolumeutils.cpp b/src/render/jobs/pickboundingvolumeutils.cpp index 22b92a3f2..5a32f0203 100644 --- a/src/render/jobs/pickboundingvolumeutils.cpp +++ b/src/render/jobs/pickboundingvolumeutils.cpp @@ -52,6 +52,8 @@ #include <Qt3DRender/private/segmentsvisitor_p.h> #include <Qt3DRender/private/pointsvisitor_p.h> +#include <vector> + QT_BEGIN_NAMESPACE namespace Qt3DRender { @@ -565,27 +567,29 @@ bool HierarchicalEntityPicker::collectHits(Entity *root) m_entities.clear(); QRayCastingService rayCasting; - QVector<Entity *> worklist; - worklist << root; + std::vector<std::pair<Entity *, bool>> worklist; + worklist.push_back({root, !root->componentHandle<ObjectPicker, 16>().isNull()}); while (!worklist.empty()) { - Entity *current = worklist.takeLast(); + auto current = worklist.back(); + worklist.pop_back(); // first pick entry sub-scene-graph QCollisionQueryResult::Hit queryResult = - rayCasting.query(m_ray, current->worldBoundingVolumeWithChildren()); + rayCasting.query(m_ray, current.first->worldBoundingVolumeWithChildren()); if (queryResult.m_distance < 0.f) continue; // if we get a hit, we check again for this specific entity - queryResult = rayCasting.query(m_ray, current->worldBoundingVolume()); - if (queryResult.m_distance >= 0.f) { - m_entities.push_back(current); + queryResult = rayCasting.query(m_ray, current.first->worldBoundingVolume()); + if (queryResult.m_distance >= 0.f && current.second) { + m_entities.push_back(current.first); m_hits.push_back(queryResult); } // and pick children - worklist << current->children(); + for (auto child: current.first->children()) + worklist.push_back({child, current.second || !child->componentHandle<ObjectPicker, 16>().isNull()}); } return !m_hits.empty(); |