diff options
author | Antti Määttä <antti.maatta@qt.io> | 2021-03-24 10:04:53 +0200 |
---|---|---|
committer | Antti Määttä <antti.maatta@qt.io> | 2021-03-24 12:34:16 +0200 |
commit | 1b7c77d64cf46054c9cc565e9a65b13d2f71ba88 (patch) | |
tree | b7a8d05452e07ab51a9c844e000d48c04fece806 /src/runtime | |
parent | daa2e4de8a5f24e3c03cabb3d573023068705c81 (diff) |
Fix time calculation with data inputs
The time needs to be calculated after the time policy has been
initialized.
Task-number: QT3DS-4218
Change-Id: I62c215cbbf8ca6c8ed8881817e9e9a84415b8924
Reviewed-by: Tony Leinonen <tony.leinonen@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/runtime')
-rw-r--r-- | src/runtime/Qt3DSActivationManager.cpp | 1 | ||||
-rw-r--r-- | src/runtime/Qt3DSComponentManager.cpp | 19 | ||||
-rw-r--r-- | src/runtime/Qt3DSComponentManager.h | 4 | ||||
-rw-r--r-- | src/runtime/Qt3DSIComponentManager.h | 2 | ||||
-rw-r--r-- | src/runtime/Qt3DSPresentation.cpp | 3 | ||||
-rw-r--r-- | src/runtime/Qt3DSQmlEngine.cpp | 3 |
6 files changed, 19 insertions, 13 deletions
diff --git a/src/runtime/Qt3DSActivationManager.cpp b/src/runtime/Qt3DSActivationManager.cpp index d7182d1..61261c8 100644 --- a/src/runtime/Qt3DSActivationManager.cpp +++ b/src/runtime/Qt3DSActivationManager.cpp @@ -204,6 +204,7 @@ struct STimeContext , m_AllNodesDirty(true) , m_TimeDataNeedsUpdate(true) { + m_TimePolicy.Initialize(); } QT3DS_IMPLEMENT_REF_COUNT_ADDREF_RELEASE(m_Allocator) diff --git a/src/runtime/Qt3DSComponentManager.cpp b/src/runtime/Qt3DSComponentManager.cpp index bee989f..f20176b 100644 --- a/src/runtime/Qt3DSComponentManager.cpp +++ b/src/runtime/Qt3DSComponentManager.cpp @@ -190,7 +190,11 @@ void CComponentManager::GotoSlideIndex(TElement *inComponent, if (theGotoSlideData.m_StartTime.hasValue()) thePolicy.SetTime(*theGotoSlideData.m_StartTime); } else { - thePolicy.SetTime(m_ComponentGotoTimeMap[theComponent]); + auto &timeValue = m_ComponentGotoTimeMap[theComponent]; + TTimeUnit time = timeValue.first; + if (timeValue.second) + time = TTimeUnit(qreal(thePolicy.GetLoopingDuration()) * (qreal(time) / 1000.0)); + thePolicy.SetTime(time); } inComponent->SetDirty(); @@ -391,20 +395,19 @@ void CComponentManager::GoToTime(TElement *inComponent, const TTimeUnit inTime, << "Runtime: Attempt to goto time on inactive component!"; return; } + SetupComponentGotoTimeCommand(inComponent, inTime, relative); TTimeUnit time = inTime; if (relative) { TTimeUnit endTime = 0; TComponent *component = static_cast<TComponent *>(inComponent); endTime = component->GetTimePolicy().GetLoopingDuration(); - + if (endTime == CTimePolicy::FOREVER) + endTime = component->m_ActivationManagerNode.m_StopTime; // Normalize the value to dataInput range - qreal newTime = qreal(endTime) * (qreal(inTime) / 1000.0); - time = newTime; + time = TTimeUnit(qreal(endTime) * (qreal(inTime) / 1000.0)); } - SetupComponentGotoTimeCommand(inComponent, time); m_Presentation.GetActivityZone()->GoToTime(*inComponent, time); inComponent->SetDirty(); - } //============================================================================== @@ -567,9 +570,9 @@ void CComponentManager::ClearGotoTimeQueue() m_ComponentGotoTimeMap.clear(); } -void CComponentManager::SetupComponentGotoTimeCommand(TElement *inElement, TTimeUnit time) +void CComponentManager::SetupComponentGotoTimeCommand(TElement *inElement, TTimeUnit time, bool relative) { - m_ComponentGotoTimeMap[inElement] = time; + m_ComponentGotoTimeMap[inElement] = std::pair<TTimeUnit, bool>(time, relative); } } // namespace Q3DStudio diff --git a/src/runtime/Qt3DSComponentManager.h b/src/runtime/Qt3DSComponentManager.h index 39c1f1b..4f7677f 100644 --- a/src/runtime/Qt3DSComponentManager.h +++ b/src/runtime/Qt3DSComponentManager.h @@ -67,7 +67,7 @@ struct SComponentTimePolicyOverride }; typedef eastl::hash_map<TElement *, SComponentGotoSlideData> TComponentGotoSlideDataMap; -typedef eastl::hash_map<TElement *, TTimeUnit> TComponentGotoTimeMap; +typedef eastl::hash_map<TElement *, std::pair<TTimeUnit, bool>> TComponentGotoTimeMap; typedef eastl::hash_map<TElement *, Q3DStudio::INT32> TComponentIntMap; //============================================================================== @@ -119,7 +119,7 @@ public: // Slide void ReleaseComponentGotoSlideCommand(TElement *inElement) override; bool HasComponentGotoTimeCommand(TElement *inElement) override; - void SetupComponentGotoTimeCommand(TElement *inElement, Q3DStudio::TTimeUnit time) override; + void SetupComponentGotoTimeCommand(TElement *inElement, Q3DStudio::TTimeUnit time, bool relative) override; void ReleaseComponentGotoTimeCommand(TElement *inElement) override; void ClearGotoTimeQueue() override; diff --git a/src/runtime/Qt3DSIComponentManager.h b/src/runtime/Qt3DSIComponentManager.h index 6852096..8c5a085 100644 --- a/src/runtime/Qt3DSIComponentManager.h +++ b/src/runtime/Qt3DSIComponentManager.h @@ -138,7 +138,7 @@ public: // Slides virtual SComponentGotoSlideData GetComponentGotoSlideCommand(TElement *inElement) = 0; virtual void ReleaseComponentGotoSlideCommand(TElement *inElement) = 0; virtual bool HasComponentGotoTimeCommand(TElement *inElement) = 0; - virtual void SetupComponentGotoTimeCommand(TElement *inElement, TTimeUnit time) = 0; + virtual void SetupComponentGotoTimeCommand(TElement *inElement, TTimeUnit time, bool relative) = 0; virtual void ReleaseComponentGotoTimeCommand(TElement *inElement) = 0; virtual void ClearGotoTimeQueue() = 0; diff --git a/src/runtime/Qt3DSPresentation.cpp b/src/runtime/Qt3DSPresentation.cpp index e4c0797..6baf3be 100644 --- a/src/runtime/Qt3DSPresentation.cpp +++ b/src/runtime/Qt3DSPresentation.cpp @@ -475,7 +475,8 @@ void CPresentation::ProcessCommand(const SEventCommand &inCommand) GetComponentManager().SetPause(inCommand.m_Target, true); } else if (inCommand.m_Type == COMMAND_GOTOTIME) { GetComponentManager().SetupComponentGotoTimeCommand(inCommand.m_Target, - inCommand.m_Arg1.m_INT32); + inCommand.m_Arg1.m_INT32, + inCommand.m_Arg2.m_INT32 > 0); GetComponentManager().GoToTime(inCommand.m_Target, inCommand.m_Arg1.m_INT32, inCommand.m_Arg2.m_INT32 > 0); diff --git a/src/runtime/Qt3DSQmlEngine.cpp b/src/runtime/Qt3DSQmlEngine.cpp index 650edc4..c74d0c0 100644 --- a/src/runtime/Qt3DSQmlEngine.cpp +++ b/src/runtime/Qt3DSQmlEngine.cpp @@ -2020,7 +2020,8 @@ void CQmlEngineImpl::GotoTime(const char *component, const Q3DStudio::FLOAT time TElement *theParentTarget = &theTarget->GetComponentParent(); thePresentation->GetComponentManager().SetupComponentGotoTimeCommand(theTarget, - theArg1.m_INT32); + theArg1.m_INT32, + relative); thePresentation->FireCommand(COMMAND_GOTOTIME, theParentTarget, &theArg1, &theArg2); } } |