diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/aspects/qaspectengine.cpp | 1 | ||||
-rw-r--r-- | src/core/aspects/qaspectmanager.cpp | 9 | ||||
-rw-r--r-- | src/core/aspects/qaspectmanager_p.h | 4 | ||||
-rw-r--r-- | src/core/jobs/qthreadpooler.cpp | 2 | ||||
-rw-r--r-- | src/core/jobs/task.cpp | 2 | ||||
-rw-r--r-- | src/core/nodes/qentity.cpp | 8 | ||||
-rw-r--r-- | src/core/nodes/qnode_p.h | 2 | ||||
-rw-r--r-- | src/core/transforms/qjoint.cpp | 14 | ||||
-rw-r--r-- | src/core/transforms/qtransform.cpp | 13 | ||||
-rw-r--r-- | src/core/transforms/qtransform.h | 1 | ||||
-rw-r--r-- | src/core/transforms/qtransform_p.h | 2 |
11 files changed, 31 insertions, 27 deletions
diff --git a/src/core/aspects/qaspectengine.cpp b/src/core/aspects/qaspectengine.cpp index 6d1a8ca30..426741a61 100644 --- a/src/core/aspects/qaspectengine.cpp +++ b/src/core/aspects/qaspectengine.cpp @@ -275,6 +275,7 @@ void QAspectEnginePrivate::initialize() arbiter->setPostman(m_postman); arbiter->setScene(m_scene); m_initialized = true; + m_aspectManager->setPostConstructorInit(m_scene->postConstructorInit()); #if QT_CONFIG(qt3d_profile_jobs) m_commandDebugger->setAspectEngine(q_func()); m_commandDebugger->initialize(); diff --git a/src/core/aspects/qaspectmanager.cpp b/src/core/aspects/qaspectmanager.cpp index 6bca77a9e..a33f771e9 100644 --- a/src/core/aspects/qaspectmanager.cpp +++ b/src/core/aspects/qaspectmanager.cpp @@ -374,6 +374,11 @@ QServiceLocator *QAspectManager::serviceLocator() const return m_serviceLocator.data(); } +void QAspectManager::setPostConstructorInit(NodePostConstructorInit *postConstructorInit) +{ + m_postConstructorInit = postConstructorInit; +} + /*! \internal \brief Drives the Qt3D simulation loop in the main thread @@ -429,6 +434,10 @@ void QAspectManager::processFrame() changeArbiterStats.startTime = QThreadPooler::m_jobsStatTimer.nsecsElapsed(); #endif + // Tell the NodePostConstructorInit to process any pending nodes which will add them to our list of + // tree changes + m_postConstructorInit->processNodes(); + // Add and Remove Nodes const QVector<NodeTreeChange> nodeTreeChanges = std::move(m_nodeTreeChanges); for (const NodeTreeChange &change : nodeTreeChanges) { diff --git a/src/core/aspects/qaspectmanager_p.h b/src/core/aspects/qaspectmanager_p.h index b39ad1f89..38ddbc55d 100644 --- a/src/core/aspects/qaspectmanager_p.h +++ b/src/core/aspects/qaspectmanager_p.h @@ -74,6 +74,7 @@ class QChangeArbiter; class QAbstractAspect; class QAbstractAspectJobManager; class QServiceLocator; +class NodePostConstructorInit; struct NodeTreeChange; class Q_3DCORE_PRIVATE_EXPORT QAspectManager : public QObject @@ -105,6 +106,7 @@ public: QAbstractAspectJobManager *jobManager() const; QChangeArbiter *changeArbiter() const; QServiceLocator *serviceLocator() const; + void setPostConstructorInit(NodePostConstructorInit *postConstructorInit); private: bool event(QEvent *event) override; @@ -121,6 +123,8 @@ private: bool m_simulationLoopRunning; QAspectEngine::RunMode m_driveMode; QVector<NodeTreeChange> m_nodeTreeChanges; + NodePostConstructorInit* m_postConstructorInit; + }; } // namespace Qt3DCore diff --git a/src/core/jobs/qthreadpooler.cpp b/src/core/jobs/qthreadpooler.cpp index 0e9af58dd..a9f4e7a31 100644 --- a/src/core/jobs/qthreadpooler.cpp +++ b/src/core/jobs/qthreadpooler.cpp @@ -183,7 +183,7 @@ int QThreadPooler::currentCount() const { // The caller have to set the mutex - return m_taskCount.load(); + return m_taskCount.loadRelaxed(); } int QThreadPooler::maxThreadCount() const diff --git a/src/core/jobs/task.cpp b/src/core/jobs/task.cpp index 4291a4779..091aabfd6 100644 --- a/src/core/jobs/task.cpp +++ b/src/core/jobs/task.cpp @@ -118,7 +118,7 @@ void SyncTaskRunnable::run() m_atomicCount->deref(); // Wait for the other worker threads to be done - while (m_atomicCount->load() > 0) + while (m_atomicCount->loadRelaxed() > 0) QThread::currentThread()->yieldCurrentThread(); if (m_pooler) diff --git a/src/core/nodes/qentity.cpp b/src/core/nodes/qentity.cpp index 546f1d670..0ff8c4646 100644 --- a/src/core/nodes/qentity.cpp +++ b/src/core/nodes/qentity.cpp @@ -295,13 +295,7 @@ void QEntity::onParentChanged(QObject *) if (!d->m_hasBackendNode) return; - const auto parentID = parentEntity() ? parentEntity()->id() : Qt3DCore::QNodeId(); - auto parentChange = Qt3DCore::QPropertyUpdatedChangePtr::create(id()); - parentChange->setPropertyName("parentEntityUpdated"); - parentChange->setValue(QVariant::fromValue(parentID)); - const bool blocked = blockNotifications(false); - notifyObservers(parentChange); - blockNotifications(blocked); + d->update(); } } // namespace Qt3DCore diff --git a/src/core/nodes/qnode_p.h b/src/core/nodes/qnode_p.h index 491059ff9..d8310731c 100644 --- a/src/core/nodes/qnode_p.h +++ b/src/core/nodes/qnode_p.h @@ -194,7 +194,7 @@ public: void removeNode(QNode *node); void addNode(QNode *node); -private Q_SLOTS: +public Q_SLOTS: void processNodes(); private: diff --git a/src/core/transforms/qjoint.cpp b/src/core/transforms/qjoint.cpp index 017773ff6..553fbd654 100644 --- a/src/core/transforms/qjoint.cpp +++ b/src/core/transforms/qjoint.cpp @@ -352,11 +352,8 @@ void QJoint::addChildJoint(QJoint *joint) // Ensures proper bookkeeping d->registerDestructionHelper(joint, &QJoint::removeChildJoint, d->m_childJoints); - if (d->m_changeArbiter != nullptr) { - const auto change = QPropertyNodeAddedChangePtr::create(id(), joint); - change->setPropertyName("childJoint"); - d->notifyObservers(change); - } + if (d->m_changeArbiter != nullptr) + d->update(); } } @@ -369,11 +366,8 @@ void QJoint::removeChildJoint(QJoint *joint) Q_D(QJoint); if (d->m_childJoints.contains(joint)) { - if (d->m_changeArbiter != nullptr) { - const auto change = QPropertyNodeRemovedChangePtr::create(id(), joint); - change->setPropertyName("childJoint"); - d->notifyObservers(change); - } + if (d->m_changeArbiter != nullptr) + d->update(); d->m_childJoints.removeOne(joint); diff --git a/src/core/transforms/qtransform.cpp b/src/core/transforms/qtransform.cpp index bedf108f2..e5902f11f 100644 --- a/src/core/transforms/qtransform.cpp +++ b/src/core/transforms/qtransform.cpp @@ -239,12 +239,13 @@ QTransform::QTransform(QTransformPrivate &dd, QNode *parent) */ void QTransform::sceneChangeEvent(const QSceneChangePtr &change) { + Q_D(QTransform); switch (change->type()) { case PropertyUpdated: { Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(change); if (propertyChange->propertyName() == QByteArrayLiteral("worldMatrix")) { const bool blocked = blockNotifications(true); - setWorldMatrix(propertyChange->value().value<QMatrix4x4>()); + d->setWorldMatrix(propertyChange->value().value<QMatrix4x4>()); blockNotifications(blocked); } break; @@ -254,13 +255,13 @@ void QTransform::sceneChangeEvent(const QSceneChangePtr &change) } } -void QTransform::setWorldMatrix(const QMatrix4x4 &worldMatrix) +void QTransformPrivate::setWorldMatrix(const QMatrix4x4 &worldMatrix) { - Q_D(QTransform); - if (d->m_worldMatrix == worldMatrix) + Q_Q(QTransform); + if (m_worldMatrix == worldMatrix) return; - d->m_worldMatrix = worldMatrix; - emit worldMatrixChanged(worldMatrix); + m_worldMatrix = worldMatrix; + emit q->worldMatrixChanged(worldMatrix); } void QTransform::setMatrix(const QMatrix4x4 &m) diff --git a/src/core/transforms/qtransform.h b/src/core/transforms/qtransform.h index 527760df7..503ea4d4a 100644 --- a/src/core/transforms/qtransform.h +++ b/src/core/transforms/qtransform.h @@ -120,7 +120,6 @@ Q_SIGNALS: protected: explicit QTransform(QTransformPrivate &dd, QNode *parent = nullptr); void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override; - void setWorldMatrix(const QMatrix4x4 &worldMatrix); private: Q_DECLARE_PRIVATE(QTransform) diff --git a/src/core/transforms/qtransform_p.h b/src/core/transforms/qtransform_p.h index d44e5e157..028a9aba7 100644 --- a/src/core/transforms/qtransform_p.h +++ b/src/core/transforms/qtransform_p.h @@ -77,6 +77,8 @@ public: mutable bool m_matrixDirty; QMatrix4x4 m_worldMatrix; + + void setWorldMatrix(const QMatrix4x4 &worldMatrix); }; struct QTransformData |