From f07a25c618432e08a145d714781b52c534a694da Mon Sep 17 00:00:00 2001 From: Jere Tuliniemi Date: Mon, 13 Apr 2020 23:11:35 +0300 Subject: Lazy load custom material subpresentations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Search through custom material string properties for subpresentation ids. Task-number: QT3DS-4090 Change-Id: Ia6a7227a9b9c5eb069f5670e7188644bf212ae8c Reviewed-by: Tomi Korpipää --- src/engine/Qt3DSRenderRuntimeBinding.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/engine/Qt3DSRenderRuntimeBinding.cpp b/src/engine/Qt3DSRenderRuntimeBinding.cpp index 7535af6..3d7dac8 100644 --- a/src/engine/Qt3DSRenderRuntimeBinding.cpp +++ b/src/engine/Qt3DSRenderRuntimeBinding.cpp @@ -254,6 +254,24 @@ struct Qt3DSRenderScene : public Q3DStudio::IScene Q3DStudio::UVariant value; if (theElement.GetAttribute(ATTRIBUTE_SUBPRESENTATION, value)) subs.push_back(m_Context->GetStringTable().HandleToStr(value.m_StringHandle)); + } else if (theTranslator && theTranslator->GetUIPType() + == GraphObjectTypes::CustomMaterial) { + // Add custom material strings to the subpresentation list since any string + // property could be a texture with a subpresentation source. + // Non-subpresentation strings are filtered out by the function caller. + int numProperties = theElement.GetNumProperties(); + for (int i = 0; i < numProperties; ++i) { + auto property = theElement.GetPropertyByIndex(i); + if (property.hasValue()) { + auto value = property.getValue(); + if (value.first.type() == ATTRIBUTETYPE_STRING) { + auto stringValue = m_Context->GetStringTable().HandleToStr( + value.second->m_StringHandle); + if (stringValue.IsValid()) + subs.push_back(stringValue); + } + } + } } } } -- cgit v1.2.3