summaryrefslogtreecommitdiff
path: root/tests/auto/render/commons
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2020-03-07 09:27:16 +0000
committerMike Krus <mike.krus@kdab.com>2020-04-23 10:46:06 +0100
commit60f42119fe5c341880f4576e0c9ad8d99ee277d5 (patch)
treee3a4992e501593c64ad506c13c0ddae87e9f5018 /tests/auto/render/commons
parentee476605629a74fb824d3f014deb6e6be9e40e9f (diff)
downloadqt3d-60f42119fe5c341880f4576e0c9ad8d99ee277d5.tar.gz
Pull bounding volume info from front end
When an entity has a bounding QBoundingVolume component AND that has a QGeometryView, the bounding volume can be computed by the core aspect and the results get pulled to the render backend. Otherwise, we use the old code which computes the bounding volume in the render aspect. This means we have 2 jobs to compute bounding volumes and that the core version must complete before the render aspect runs. Change-Id: I4de45e48fa0c4d40d3d5084f387abfed5ea1a2f8 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests/auto/render/commons')
-rw-r--r--tests/auto/render/commons/testaspect.h27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/auto/render/commons/testaspect.h b/tests/auto/render/commons/testaspect.h
index dfbe78fbd..22d0a7172 100644
--- a/tests/auto/render/commons/testaspect.h
+++ b/tests/auto/render/commons/testaspect.h
@@ -41,13 +41,15 @@
#include <Qt3DRender/private/qrenderaspect_p.h>
#include <Qt3DRender/private/abstractrenderer_p.h>
#include <Qt3DCore/private/qaspectjobmanager_p.h>
+#include <Qt3DCore/private/qnodevisitor_p.h>
+#include <Qt3DCore/qabstractfrontendnodemanager.h>
#include <Qt3DRender/private/qrenderaspect_p.h>
QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class TestAspect : public Qt3DRender::QRenderAspect
+class TestAspect : public Qt3DRender::QRenderAspect, public Qt3DCore::QAbstractFrontEndNodeManager
{
public:
TestAspect(Qt3DCore::QNode *root);
@@ -60,8 +62,31 @@ public:
void onRegistered();
void onUnregistered();
+ void registerNode(Qt3DCore::QNode *node) { m_frontEndNodes.insert(node->id(), node); }
+ void registerTree(Qt3DCore::QEntity *root) {
+ using namespace Qt3DCore;
+ QNodeVisitor visitor;
+ visitor.traverse(root, [](QNode *) {}, [this](QEntity *entity) {
+ registerNode(entity);
+ const auto &components = entity->components();
+ for (const auto &c : components)
+ registerNode(c);
+ });
+ }
+ Qt3DCore::QNode *lookupNode(Qt3DCore::QNodeId id) const override { return m_frontEndNodes.value(id, nullptr); }
+ QVector<Qt3DCore::QNode *> lookupNodes(const QVector<Qt3DCore::QNodeId> &ids) const override {
+ QVector<Qt3DCore::QNode *> res;
+ for (const auto &id: ids) {
+ auto node = m_frontEndNodes.value(id, nullptr);
+ if (node)
+ res.push_back(node);
+ }
+ return res;
+ }
+
private:
QScopedPointer<Qt3DCore::QAspectJobManager> m_jobManager;
+ QHash<Qt3DCore::QNodeId, Qt3DCore::QNode *> m_frontEndNodes;
};
} // Qt3DRender