diff options
author | Jere Tuliniemi <jere.tuliniemi@qt.io> | 2019-08-12 09:27:35 +0300 |
---|---|---|
committer | Jere Tuliniemi <jere.tuliniemi@qt.io> | 2019-08-13 13:37:15 +0300 |
commit | 4ce1ac65981572f7493b08d032f7d0074db45c67 (patch) | |
tree | b54ed363191375e0fda339b455d70606174f5409 /src | |
parent | 12e4c533b0e7cabd9676f4f767f221aea1343102 (diff) |
Fix multiple activation issues
QT3DS-3766 had object have their master slide values when activated.
This is fixed by applying initial values of the slide to inactive
objects also.
QT3DS-3768 had referenced materials not updating if the original
material was changed while inactive. This is fixed by updating values of
all materials even when they are inactive.
QT3DS-3771 had objects be able to be activated from slides where they
were not according to the editor. This is fixed by having a slide check
when the user changes the activation state.
Task-number: QT3DS-3766
Task-number: QT3DS-3768
Task-number: QT3DS-3771
Change-Id: I7898d693384b05b381d9bc775b68c0833447f496
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/Qt3DSRenderRuntimeBindingImplTranslation.cpp | 6 | ||||
-rw-r--r-- | src/runtime/Qt3DSQmlElementHelper.cpp | 15 | ||||
-rw-r--r-- | src/runtime/Qt3DSSlideSystem.cpp | 41 | ||||
-rw-r--r-- | src/runtime/Qt3DSSlideSystem.h | 3 |
4 files changed, 57 insertions, 8 deletions
diff --git a/src/engine/Qt3DSRenderRuntimeBindingImplTranslation.cpp b/src/engine/Qt3DSRenderRuntimeBindingImplTranslation.cpp index c0b72a6..b4f5980 100644 --- a/src/engine/Qt3DSRenderRuntimeBindingImplTranslation.cpp +++ b/src/engine/Qt3DSRenderRuntimeBindingImplTranslation.cpp @@ -1638,8 +1638,12 @@ struct STranslatorCreator { TTranslatorType &theTranslator(static_cast<TTranslatorType &>(inTranslator)); SRuntimePropertyParser theParser(inPresentation, inRenderContext, *theTranslator.m_Element); - if (theTranslator.Element().GetActive()) { + bool isMaterial = QString(theTranslator.Element().GetTypeDescription().m_TypeName.c_str()) + .contains(QLatin1String("Material")); + if (theTranslator.Element().GetActive() || isMaterial) { // Don't push properties from inactive elements. + // Exceptions to this rule are Materials since materials that reference them need + // the values even when the original material is inactive for (long idx = 0, end = theTranslator.Element().GetAttributeCount(); idx < end; ++idx) { qt3ds::runtime::element::TPropertyDescAndValuePtr thePropInfo = diff --git a/src/runtime/Qt3DSQmlElementHelper.cpp b/src/runtime/Qt3DSQmlElementHelper.cpp index 0a13a1f..43f5b50 100644 --- a/src/runtime/Qt3DSQmlElementHelper.cpp +++ b/src/runtime/Qt3DSQmlElementHelper.cpp @@ -34,6 +34,8 @@ #include "Qt3DSAttributeHashes.h" #include "Qt3DSElementSystem.h" #include "Qt3DSRuntimeFactory.h" +#include "Qt3DSSlideSystem.h" +#include "Qt3DSActivationManager.h" #include "qmath.h" using namespace Q3DStudio; @@ -156,6 +158,19 @@ bool CQmlElementHelper::SetAttribute(TElement *theElement, const char *theAttNam theAttributeKey.m_Hash = CHash::HashAttribute(theAttName); bool force = false; + // Fail if trying to change the activation state of an object in another slide + if (theAttributeKey.m_Hash == Q3DStudio::ATTRIBUTE_EYEBALL) { + CPresentation *presentation = static_cast<CPresentation *>( + theElement->GetBelongedPresentation()); + ISlideSystem &slideSystem = presentation->GetSlideSystem(); + TElement *componentElement = theElement->GetActivityZone().GetItemTimeParent(*theElement); + TComponent *component = presentation->GetComponentManager().GetComponent(componentElement); + if (!slideSystem.isElementInSlide(*theElement, *componentElement, + component->GetCurrentSlide())) { + return false; + } + } + // Early out for our single 'read only' attribute if (ATTRIBUTE_URI == theAttributeKey.m_Hash) { // we didn't push anything onto the stack diff --git a/src/runtime/Qt3DSSlideSystem.cpp b/src/runtime/Qt3DSSlideSystem.cpp index 33c7544..64a7707 100644 --- a/src/runtime/Qt3DSSlideSystem.cpp +++ b/src/runtime/Qt3DSSlideSystem.cpp @@ -495,21 +495,28 @@ struct SSlideSystem : public ISlideSystem struct SElementOperator { - bool m_InvertActive; - SElementOperator(bool inInvert = false) - : m_InvertActive(inInvert) + bool m_slideRollback; + SElementOperator(bool inSlideRollback = false) + : m_slideRollback(inSlideRollback) { } + + // Returns true if element properties should be updated bool handleElementActive(SElement &inElement, bool inActive) { - if (m_InvertActive && inElement.Flags().IsExplicitActive()) - inActive = !inActive; + // Always deactivate element when exiting slide + if (m_slideRollback) + inActive = false; + inElement.Flags().SetExplicitActive(inActive); - if (m_InvertActive) + // No need to update element properties when exiting slide + if (m_slideRollback) return false; - return inActive; + // Always update element properties to initial properties when entering a slide + // so that initially inactive objects have their slide values + return true; } void handleElementAttribute(SElement &inElement, const SSlideAttribute &inAttribute) @@ -665,6 +672,26 @@ struct SSlideSystem : public ISlideSystem SSlide *theSlide = FindSlide(inKey); theSlide->m_activeSlide = active; } + + bool isElementInSlide(const SElement &element, SElement &component, + int slideIndex) const override + { + TComponentSlideHash::const_iterator result = m_Slides.find(&component); + if (result == m_Slides.end()) + return false; + + QT3DSU8 idx = 0; + for (const SSlide *slide = result->second; slide; slide = slide->m_NextSlide, ++idx) { + if (slideIndex == idx) { + for (const SSlideElement *slideElement = slide->m_FirstElement; slideElement; + slideElement = slideElement->m_NextElement) { + if (slideElement->m_ElementHandle == element.m_Handle) + return true; + } + } + } + return false; + } }; } diff --git a/src/runtime/Qt3DSSlideSystem.h b/src/runtime/Qt3DSSlideSystem.h index d3accbd..265b1fa 100644 --- a/src/runtime/Qt3DSSlideSystem.h +++ b/src/runtime/Qt3DSSlideSystem.h @@ -153,6 +153,9 @@ namespace runtime { virtual QT3DSU8 FindSlide(element::SElement &inComponent, QT3DSU32 inSlideHashName) const = 0; virtual const char8_t *GetSlideName(SSlideKey inKey) const = 0; virtual QT3DSU8 GetPlaythroughToSlideIndex(SSlideKey inKey) const = 0; + virtual bool isElementInSlide(const element::SElement &element, + element::SElement &component, + int slideIndex) const = 0; static ISlideSystem &CreateSlideSystem(NVFoundationBase &inFnd, IStringTable &inStrTable, IElementAllocator &inElemAllocator); |