From c75ea919bf696a81e00857f1345ce0b2f7c81cd7 Mon Sep 17 00:00:00 2001 From: Jere Tuliniemi Date: Wed, 18 Mar 2020 16:00:48 +0200 Subject: Delayed loading: Load subpresentation with setAttribute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Trigger a load when changing the subpresentation attribute of a material. Also add the subpresentation to the activity list. Task-number: QT3DS-4090 Change-Id: Ief5c819bcf5cdf94702ba96e71491c8c898d02a6 Reviewed-by: Antti Määttä Reviewed-by: Miikka Heikkinen --- src/runtime/Qt3DSApplication.cpp | 13 ++++++++++++- src/runtime/Qt3DSQmlElementHelper.cpp | 7 +++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/runtime/Qt3DSApplication.cpp b/src/runtime/Qt3DSApplication.cpp index c597802..1abc903 100644 --- a/src/runtime/Qt3DSApplication.cpp +++ b/src/runtime/Qt3DSApplication.cpp @@ -1950,8 +1950,19 @@ struct SApp : public IApplication if (iter != m_AssetMap.end() && iter->second->getType() == AssetValueTypes::Presentation) { CPresentation *ret = iter->second->getData().m_Presentation; - if (!ret && load) + if (!ret && load) { AssetHandlers::handlePresentation(*this, *iter->second); + SPresentationAsset &thePresentationAsset + = *iter->second->getDataPtr(); + CPresentation *thePresentation = thePresentationAsset.m_Presentation; + if (thePresentation) { + QT3DS_PERF_SCOPED_TIMER(m_CoreFactory->GetPerfTimer(), + "Application: SetActivityZone") + thePresentation->SetActivityZone( + &m_ActivityZoneManager->CreateActivityZone(*thePresentation)); + thePresentation->SetActive(thePresentationAsset.m_Active); + } + } return iter->second->getData().m_Presentation; } } diff --git a/src/runtime/Qt3DSQmlElementHelper.cpp b/src/runtime/Qt3DSQmlElementHelper.cpp index 0becf4f..77196ae 100644 --- a/src/runtime/Qt3DSQmlElementHelper.cpp +++ b/src/runtime/Qt3DSQmlElementHelper.cpp @@ -325,6 +325,13 @@ bool CQmlElementHelper::SetAttribute(TElement *theElement, const char *theAttNam else return false; + if (attributeAndValue.attribute.m_Hash == Q3DStudio::ATTRIBUTE_SUBPRESENTATION) { + auto presentation = theElement->GetBelongedPresentation(); + auto stringValue = presentation->GetStringTable().HandleToStr( + attributeAndValue.value.m_StringHandle); + presentation->GetApplication().LoadAndGetPresentationById(stringValue.c_str()); + } + return true; } -- cgit v1.2.3