From e9da995ae5de6ca37e624adcba23808cd7a0ff57 Mon Sep 17 00:00:00 2001 From: Tony Leinonen Date: Tue, 16 Mar 2021 13:57:14 +0200 Subject: Calculate newTime when commands are being processed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit newTime was calculated too early and the object did not have time to switch slides and have correct information. Calculating newTime at a later stage when the object has had time to switch slides. Task-number: QT3DS-4221 Change-Id: If04a29278c6d97e550ecb7f2e5975d02abcd01d4 Reviewed-by: Antti Määttä Reviewed-by: Tomi Korpipää --- src/runtime/Qt3DSComponentManager.cpp | 12 ++++++++++-- src/runtime/Qt3DSQmlEngine.cpp | 10 ++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/runtime/Qt3DSComponentManager.cpp b/src/runtime/Qt3DSComponentManager.cpp index 38eeeac..03c7b2c 100644 --- a/src/runtime/Qt3DSComponentManager.cpp +++ b/src/runtime/Qt3DSComponentManager.cpp @@ -388,9 +388,17 @@ void CComponentManager::GoToTime(TElement *inComponent, const TTimeUnit inTime) return; } - SetupComponentGotoTimeCommand(inComponent, inTime); - m_Presentation.GetActivityZone()->GoToTime(*inComponent, inTime); + TTimeUnit endTime = 0; + TComponent *component = static_cast(inComponent); + endTime = component->GetTimePolicy().GetLoopingDuration(); + + // Normalize the value to dataInput range + qreal newTime = qreal(endTime) * (qreal(inTime) / 1000.0); + + SetupComponentGotoTimeCommand(inComponent, newTime); + m_Presentation.GetActivityZone()->GoToTime(*inComponent, newTime); inComponent->SetDirty(); + } //============================================================================== diff --git a/src/runtime/Qt3DSQmlEngine.cpp b/src/runtime/Qt3DSQmlEngine.cpp index 2c44b7d..0988880 100644 --- a/src/runtime/Qt3DSQmlEngine.cpp +++ b/src/runtime/Qt3DSQmlEngine.cpp @@ -794,15 +794,9 @@ void CQmlEngineImpl::SetDataInputValue( case ATTRIBUTETYPE_DATAINPUT_TIMELINE: { // Quietly ignore other than number type data inputs when adjusting timeline if (diDef.type == qt3ds::runtime::DataInOutTypeRangedNumber) { - TTimeUnit endTime = 0; - TElement *element = getTarget(ctrlElem.elementPath.constData()); - TComponent *component = static_cast(element); - endTime = component->GetTimePolicy().GetLoopingDuration(); - - // Normalize the value to dataInput range - qreal newTime = qreal(endTime) * (qreal(value.toFloat() - diDef.min) + qreal newTime = (qreal(value.toFloat() - diDef.min) / qreal(diDef.max - diDef.min)); - GotoTime(ctrlElem.elementPath.constData(), float(newTime / 1000.0)); + GotoTime(ctrlElem.elementPath.constData(), float(newTime)); } break; } -- cgit v1.2.3