diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2018-09-12 16:36:44 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2018-09-13 07:51:07 +0000 |
commit | a8cf177b48570420cbd7755a19704cd2a2fc1dea (patch) | |
tree | 59ab94ecf37f2c1813ebe0b4d755dbc9dd329d08 | |
parent | 1b367a8d0c62dc0d212795523c22d769a170f685 (diff) |
Add support for nested subpresentations
Task-number: QT3DS-2317
Change-Id: Ice12230f1550cf6dd2ccd224913261d560507ec5
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
-rw-r--r-- | src/runtime/q3dsengine.cpp | 8 | ||||
-rw-r--r-- | src/runtime/q3dsscenemanager.cpp | 27 | ||||
-rw-r--r-- | src/runtime/q3dsscenemanager_p.h | 5 |
3 files changed, 24 insertions, 16 deletions
diff --git a/src/runtime/q3dsengine.cpp b/src/runtime/q3dsengine.cpp index 4249bf7..053fda4 100644 --- a/src/runtime/q3dsengine.cpp +++ b/src/runtime/q3dsengine.cpp @@ -686,7 +686,13 @@ void Q3DSEngine::finalizePresentations() subPresentations.append(pres.subPres); } - mainPresSceneMgr->finalizeMainScene(subPresentations); + mainPresSceneMgr->setSubPresentations(subPresentations); + for (const Q3DSSubPresentation &sp : subPresentations) { + if (sp.sceneManager) + sp.sceneManager->setSubPresentations(subPresentations); + } + + mainPresSceneMgr->finalizeMainScene(); mainPresSceneMgr->setLayerComposition(m_mainLayerComposition); diff --git a/src/runtime/q3dsscenemanager.cpp b/src/runtime/q3dsscenemanager.cpp index 9b91f99..aae4ec2 100644 --- a/src/runtime/q3dsscenemanager.cpp +++ b/src/runtime/q3dsscenemanager.cpp @@ -882,23 +882,25 @@ Q3DSSceneManager::Scene Q3DSSceneManager::buildScene(Q3DSUipPresentation *presen } /* - To be called on the scenemanager corresponding to the main presentation - once after all subpresentation buildScene() calls have succeeded. This is - where the association of textures and subpresentation layers happens. That + To be called by the Q3DSEngine once after all subpresentation buildScene() + calls have succeeded. This is where the association of textures and + subpresentation layers happens (or later if loading is deferred). This cannot be done in the first buildScene since the textures for subpresentations (and the corresponding framegraph subtrees) are not yet generated at that stage. */ -void Q3DSSceneManager::finalizeMainScene(const QVector<Q3DSSubPresentation> &subPresentations) +void Q3DSSceneManager::setSubPresentations(const QVector<Q3DSSubPresentation> &subPresentations) { - Q_ASSERT(!m_flags.testFlag(SubPresentation)); - qCDebug(lcScene, "finalizeMainScene"); - - m_inFinalizeMainScene = true; - + m_inSetSubPresentations = true; m_subPresentations = subPresentations; - updateSubPresentationHosts(); + m_inSetSubPresentations = false; +} + +void Q3DSSceneManager::finalizeMainScene() +{ + Q_ASSERT(!m_flags.testFlag(SubPresentation)); + qCDebug(lcScene, "finalizeMainScene"); for (const Q3DSSubPresentation &subPres : m_subPresentations) { if (subPres.sceneManager) @@ -909,8 +911,6 @@ void Q3DSSceneManager::finalizeMainScene(const QVector<Q3DSSubPresentation> &sub if (!m_flags.testFlag(SubPresentation)) m_consoleCommands->runBootScript(); #endif - - m_inFinalizeMainScene = false; } void Q3DSSceneManager::loadSubUipPresentation(Q3DSSubPresentation *sp) @@ -920,7 +920,8 @@ void Q3DSSceneManager::loadSubUipPresentation(Q3DSSubPresentation *sp) *sp = m_engine->loadSubUipPresentation(sp->id); sp->id = id; if (sp->colorTex && sp->sceneManager) { - if (!m_inFinalizeMainScene) { + sp->sceneManager->setSubPresentations(m_subPresentations); + if (!m_inSetSubPresentations) { sp->sceneManager->prepareAnimators(); m_profiler->registerSubPresentationProfiler(sp->sceneManager->m_profiler); Q3DSUipPresentation::forAllObjectsOfType(sp->sceneManager->m_presentation->scene(), diff --git a/src/runtime/q3dsscenemanager_p.h b/src/runtime/q3dsscenemanager_p.h index c05dea2..6593a3a 100644 --- a/src/runtime/q3dsscenemanager_p.h +++ b/src/runtime/q3dsscenemanager_p.h @@ -689,7 +689,8 @@ public: ~Q3DSSceneManager(); Scene buildScene(Q3DSUipPresentation *presentation, const SceneBuilderParams ¶ms); - void finalizeMainScene(const QVector<Q3DSSubPresentation> &subPresentations); + void setSubPresentations(const QVector<Q3DSSubPresentation> &subPresentations); + void finalizeMainScene(); void updateSizes(const QSize &size, qreal dpr, const QRect &viewport = QRect(), bool forceSynchronous = false); void prepareEngineReset(); @@ -944,7 +945,7 @@ private: Q3DSInputManager *m_inputManager = nullptr; QVector<Q3DSGraphObject::Event> m_eventQueue; bool m_inDestructor = false; - bool m_inFinalizeMainScene = false; + bool m_inSetSubPresentations = false; bool m_layerCaching = true; bool m_layerUncachePending = false; QSet<Q3DSSceneManager *> m_layerCacheDeps; |