summaryrefslogtreecommitdiffstats
path: root/src/core/aspects/qaspectengine.cpp
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2019-08-14 11:50:10 +0100
committerPaul Lemire <paul.lemire@kdab.com>2019-08-29 08:32:29 +0200
commitc1b1bbbb72a9d0c11d92c8cdb998c52d515932da (patch)
treeea126554b3dde2505deb10b1a5b381fd82384b13 /src/core/aspects/qaspectengine.cpp
parentfa801839d384e9d6eea09350433e354cf753c267 (diff)
Use sync method when initializing new backend nodes
If the node type supports syncing, use that rather than the creation message. The message is still needed since that is passed to the instantiation functor (none of qt3d's classes appear to use anything but the node id, but can't be sure no other classes do, and can't add other virtual method without breaking BC). Change-Id: Id99f448070b8722a7809b968798772c9eb3c8397 Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/core/aspects/qaspectengine.cpp')
-rw-r--r--src/core/aspects/qaspectengine.cpp40
1 files changed, 35 insertions, 5 deletions
diff --git a/src/core/aspects/qaspectengine.cpp b/src/core/aspects/qaspectengine.cpp
index c5e4b2b26..41662e2a3 100644
--- a/src/core/aspects/qaspectengine.cpp
+++ b/src/core/aspects/qaspectengine.cpp
@@ -52,7 +52,6 @@
#include <Qt3DCore/private/qeventfilterservice_p.h>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qnodevisitor_p.h>
-#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <Qt3DCore/private/qpostman_p.h>
#include <Qt3DCore/private/qscene_p.h>
#include <Qt3DCore/private/qservicelocator_p.h>
@@ -64,6 +63,34 @@
QT_BEGIN_NAMESPACE
+namespace{
+
+QVector<Qt3DCore::QNode *> getNodesForCreation(Qt3DCore::QNode *root)
+{
+ using namespace Qt3DCore;
+
+ QVector<QNode *> nodes;
+ QNodeVisitor visitor;
+ visitor.traverse(root, [&nodes](QNode *node) {
+ nodes.append(node);
+
+ // Store the metaobject of the node in the QNode so that we have it available
+ // to us during destruction in the QNode destructor. This allows us to send
+ // the QNodeId and the metaobject as typeinfo to the backend aspects so they
+ // in turn can find the correct QBackendNodeMapper object to handle the destruction
+ // of the corresponding backend nodes.
+ QNodePrivate *d = QNodePrivate::get(node);
+ d->m_typeInfo = const_cast<QMetaObject*>(QNodePrivate::findStaticMetaObject(node->metaObject()));
+
+ // Mark this node as having been handled for creation so that it is picked up
+ d->m_hasBackendNode = true;
+ });
+
+ return nodes;
+}
+
+}
+
namespace Qt3DCore {
QAspectEnginePrivate *QAspectEnginePrivate::get(QAspectEngine *q)
@@ -120,6 +147,11 @@ void QAspectEnginePrivate::initEntity(QEntity *entity)
}
}
+void QAspectEnginePrivate::addNode(QNode *node)
+{
+ m_aspectManager->addNodes(getNodesForCreation(node));
+}
+
/*!
* \class Qt3DCore::QAspectEngine
* \inheaderfile Qt3DCore/QAspectEngine
@@ -437,9 +469,7 @@ void QAspectEngine::setRootEntity(QEntityPtr root)
// deregister the nodes from the scene
d->initNodeTree(root.data());
- // Traverse tree to generate a vector of creation changes
- const QNodeCreatedChangeGenerator generator(root.data());
- auto creationChanges = generator.creationChanges();
+ const QVector<QNode *> nodes = getNodesForCreation(root.data());
// Specify if the AspectManager should be driving the simulation loop or not
d->m_aspectManager->setRunMode(d->m_runMode);
@@ -451,7 +481,7 @@ void QAspectEngine::setRootEntity(QEntityPtr root)
// TODO: Pass the creation changes via the arbiter rather than relying upon
// an invokeMethod call.
qCDebug(Aspects) << "Begin setting scene root on aspect manager";
- d->m_aspectManager->setRootEntity(root.data(), creationChanges);
+ d->m_aspectManager->setRootEntity(root.data(), nodes);
qCDebug(Aspects) << "Done setting scene root on aspect manager";
d->m_aspectManager->enterSimulationLoop();
}