diff options
author | Janne Kangas <janne.kangas@qt.io> | 2020-03-24 14:05:26 +0200 |
---|---|---|
committer | Janne Kangas <janne.kangas@qt.io> | 2020-03-25 14:10:42 +0200 |
commit | aac88d209f4af370e77ec8fc509b70900453a7d5 (patch) | |
tree | 73779ba308a0b5f4fe261283f94b6fa82f0a094a /src/runtime/Qt3DSComponentManager.cpp | |
parent | 6afe2ec07b50911960886510bcd4506bc97b5771 (diff) |
Make sure GoToTime works also when triggered at simultaneous activation
Queue goto time command and skip rollbacking the newly activated slide in
the case we receive both goto time and goto slide commands. Instead, go to
specified time after the slide has been reaactivated (entered).
Task-id: QT3DS-4001
Change-Id: I2dd8d6ec3a42dcd65f40adb7920b34183c50b062
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Diffstat (limited to 'src/runtime/Qt3DSComponentManager.cpp')
-rw-r--r-- | src/runtime/Qt3DSComponentManager.cpp | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/src/runtime/Qt3DSComponentManager.cpp b/src/runtime/Qt3DSComponentManager.cpp index fd77467..bf18a64 100644 --- a/src/runtime/Qt3DSComponentManager.cpp +++ b/src/runtime/Qt3DSComponentManager.cpp @@ -126,8 +126,10 @@ void CComponentManager::GotoSlideIndex(TElement *inComponent, } // Update dynamic keys to use current values before slide switching, with the exception of - // master slides because playback only starts from non-master slides. - if (theCurrentSlideIndex > 0) { + // master slides because playback only starts from non-master slides. Skip rollback + // if we are expecting a gototime command, as rollback overwrites the attribute changes + // caused by gototime. + if (theCurrentSlideIndex > 0 && !HasComponentGotoTimeCommand(theComponent)) { m_Presentation.GetSlideSystem().InitializeDynamicKeys( SSlideKey(*theComponent, (qt3ds::QT3DSU8)theGotoSlideData.m_Slide), m_Presentation.GetAnimationSystem()); @@ -135,7 +137,7 @@ void CComponentManager::GotoSlideIndex(TElement *inComponent, m_Presentation.GetSlideSystem().RollbackSlide( SSlideKey(*inComponent, (qt3ds::QT3DSU8)theCurrentSlideIndex), m_Presentation.GetAnimationSystem(), m_Presentation.GetLogicSystem()); - } else { + } else if (theCurrentSlideIndex == 0){ m_Presentation.GetSlideSystem().ExecuteSlide(SSlideKey(*inComponent, 0), m_Presentation.GetAnimationSystem(), m_Presentation.GetLogicSystem()); @@ -176,7 +178,7 @@ void CComponentManager::GotoSlideIndex(TElement *inComponent, theComponent->SetPlayThrough(true); } - // Reset time for component to 0 + // Reset time for component to 0 (unless we have gototime in queue). if (theGotoSlideData.m_Paused.hasValue()) thePolicy.SetPaused(*theGotoSlideData.m_Paused); @@ -184,8 +186,12 @@ void CComponentManager::GotoSlideIndex(TElement *inComponent, thePolicy.SetRate(theGotoSlideData.m_Rate); thePolicy.SetReverse(theGotoSlideData.m_Reverse); - if (theGotoSlideData.m_StartTime.hasValue()) - thePolicy.SetTime(*theGotoSlideData.m_StartTime); + if (!HasComponentGotoTimeCommand(theComponent)) { + if (theGotoSlideData.m_StartTime.hasValue()) + thePolicy.SetTime(*theGotoSlideData.m_StartTime); + } else { + thePolicy.SetTime(m_ComponentGotoTimeMap[theComponent]); + } inComponent->SetDirty(); m_Presentation.FireEvent(EVENT_ONSLIDEENTER, inComponent); @@ -193,9 +199,10 @@ void CComponentManager::GotoSlideIndex(TElement *inComponent, if (theZone) theZone->OnSlideChange(*inComponent); - m_Presentation.GetApplication().ComponentSlideEntered(&m_Presentation, inComponent, - elementPath, theGotoSlideData.m_Slide, - GetCurrentSlideName(inComponent)); + ReleaseComponentGotoTimeCommand(inComponent); + m_Presentation.GetApplication().ComponentSlideEntered(&m_Presentation, inComponent, + elementPath, theGotoSlideData.m_Slide, + GetCurrentSlideName(inComponent)); // Signal current slide change m_Presentation.signalProxy()->SigSlideEntered(elementPath, GetCurrentSlide(inComponent), GetCurrentSlideName(inComponent)); @@ -377,6 +384,7 @@ void CComponentManager::GoToTime(TElement *inComponent, const TTimeUnit inTime) << "Runtime: Attempt to goto time on inactive component!"; return; } + SetupComponentGotoTimeCommand(inComponent, inTime); m_Presentation.GetActivityZone()->GoToTime(*inComponent, inTime); inComponent->SetDirty(); } @@ -524,4 +532,26 @@ void CComponentManager::ReleaseComponentGotoSlideCommand(TElement *inElement) m_ComponentGotoSlideMap.erase(iter); } +bool CComponentManager::HasComponentGotoTimeCommand(TElement *inElement) +{ + return m_ComponentGotoTimeMap.find(inElement) != m_ComponentGotoTimeMap.end(); +} + +void CComponentManager::ReleaseComponentGotoTimeCommand(TElement *inElement) +{ + TComponentGotoTimeMap::iterator iter = m_ComponentGotoTimeMap.find(inElement); + if (iter != m_ComponentGotoTimeMap.end()) + m_ComponentGotoTimeMap.erase(iter); +} + +void CComponentManager::ClearGotoTimeQueue() +{ + m_ComponentGotoTimeMap.clear(); +} + +void CComponentManager::SetupComponentGotoTimeCommand(TElement *inElement, TTimeUnit time) +{ + m_ComponentGotoTimeMap[inElement] = time; +} + } // namespace Q3DStudio |