summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2021-03-22 10:44:27 +0200
committerTomi Korpipää <tomi.korpipaa@qt.io>2021-03-22 09:35:43 +0000
commit78a380f013d124f8680433ac9bb72bdb632fed5c (patch)
tree308ed55d8e69ada79cda92e2e13bb10ea4eaaf66
parent2f19925eef6dc37feefdc130588638ca1640de6e (diff)
Fix autotests after latest changes
Task-number: QT3DS-4221 Change-Id: I43947446a9ea28e55a834541a44dc6ca971d282a Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/engine/Qt3DSRuntimeView.cpp2
-rw-r--r--src/runtime/Qt3DSActivationManager.cpp2
-rw-r--r--src/runtime/Qt3DSComponentManager.cpp35
-rw-r--r--src/runtime/Qt3DSComponentManager.h3
-rw-r--r--src/runtime/Qt3DSIComponentManager.h3
-rw-r--r--src/runtime/Qt3DSPresentation.cpp8
-rw-r--r--src/runtime/Qt3DSQmlEngine.cpp7
-rw-r--r--src/runtime/Qt3DSQmlEngine.h2
8 files changed, 41 insertions, 21 deletions
diff --git a/src/engine/Qt3DSRuntimeView.cpp b/src/engine/Qt3DSRuntimeView.cpp
index 47e0001..62f7e82 100644
--- a/src/engine/Qt3DSRuntimeView.cpp
+++ b/src/engine/Qt3DSRuntimeView.cpp
@@ -637,7 +637,7 @@ void CRuntimeView::GoToTime(const char *elementPath, const float time)
Q3DStudio::CQmlEngine &theBridgeEngine
= static_cast<Q3DStudio::CQmlEngine &>(m_RuntimeFactoryCore->GetScriptEngineQml());
- theBridgeEngine.GotoTime(elementPath, time);
+ theBridgeEngine.GotoTime(elementPath, time, false);
}
}
diff --git a/src/runtime/Qt3DSActivationManager.cpp b/src/runtime/Qt3DSActivationManager.cpp
index 9aa16f5..120676f 100644
--- a/src/runtime/Qt3DSActivationManager.cpp
+++ b/src/runtime/Qt3DSActivationManager.cpp
@@ -690,7 +690,7 @@ struct STimeContext
// When the component is activated the first time go to the first slide
// Subsequent activations should continue from the deactivated slide
- if (theContextNode.GetCurrentSlide() == 0) {
+ if (theContextNode.GetCurrentSlide() == 0 || inComponentManager.hasSlideChangeQueued(&theContextNode)) {
inComponentManager.GotoSlideIndex(&theContextNode, 1, false);
}
inComponentManager.applyQueuedChanges(&theContextNode);
diff --git a/src/runtime/Qt3DSComponentManager.cpp b/src/runtime/Qt3DSComponentManager.cpp
index 9bbff99..bee989f 100644
--- a/src/runtime/Qt3DSComponentManager.cpp
+++ b/src/runtime/Qt3DSComponentManager.cpp
@@ -96,6 +96,12 @@ void CComponentManager::GotoSlideIndex(TElement *inComponent,
SComponentGotoSlideData theGotoSlideData(inGotoData);
const UINT8 theCurrentSlideIndex = theComponent->GetCurrentSlide();
+ TComponentGotoSlideDataMap::iterator iter = m_ComponentInitialSlideMap.find(inComponent);
+ if (iter != m_ComponentInitialSlideMap.end()) {
+ theGotoSlideData = iter->second;
+ m_ComponentInitialSlideMap.erase(iter);
+ }
+
QString elementPath;
// Primary presentation stores elementpaths with subpresentation prefix.
// Prepend it here so that slide change notification is directed at a correct elementpath.
@@ -352,6 +358,11 @@ bool CComponentManager::hasSlideChangeQueued(TElement *component)
return m_ComponentInitialSlideMap.find(component) != m_ComponentInitialSlideMap.end();
}
+bool CComponentManager::clearSlideChangeQueued(TElement *component)
+{
+ return m_ComponentInitialSlideMap.erase(component);
+}
+
//==============================================================================
/**
* Performs a switch to the previous slide.
@@ -369,7 +380,7 @@ void CComponentManager::GoToBackSlide(TElement *inComponent)
* @param inComponent reference to the TComponent
* @param inTime supplied time
*/
-void CComponentManager::GoToTime(TElement *inComponent, const TTimeUnit inTime)
+void CComponentManager::GoToTime(TElement *inComponent, const TTimeUnit inTime, bool relative)
{
if (inComponent == NULL)
return;
@@ -380,16 +391,18 @@ void CComponentManager::GoToTime(TElement *inComponent, const TTimeUnit inTime)
<< "Runtime: Attempt to goto time on inactive component!";
return;
}
-
- TTimeUnit endTime = 0;
- TComponent *component = static_cast<TComponent *>(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);
+ TTimeUnit time = inTime;
+ if (relative) {
+ TTimeUnit endTime = 0;
+ TComponent *component = static_cast<TComponent *>(inComponent);
+ endTime = component->GetTimePolicy().GetLoopingDuration();
+
+ // Normalize the value to dataInput range
+ qreal newTime = qreal(endTime) * (qreal(inTime) / 1000.0);
+ time = newTime;
+ }
+ SetupComponentGotoTimeCommand(inComponent, time);
+ m_Presentation.GetActivityZone()->GoToTime(*inComponent, time);
inComponent->SetDirty();
}
diff --git a/src/runtime/Qt3DSComponentManager.h b/src/runtime/Qt3DSComponentManager.h
index 59e151f..39c1f1b 100644
--- a/src/runtime/Qt3DSComponentManager.h
+++ b/src/runtime/Qt3DSComponentManager.h
@@ -96,6 +96,7 @@ public: // Slide
void queueChange(TElement *component, TElement *target, const char *attName,
const char *value, Q3DStudio::TAttributeHash attrHash) override;
bool hasSlideChangeQueued(TElement *component) override;
+ bool clearSlideChangeQueued(TElement *component) override;
UINT8 GetSlideCount(TElement *inComponent) override;
UINT8 GetCurrentSlide(TElement *inComponent) override;
@@ -123,7 +124,7 @@ public: // Slide
void ClearGotoTimeQueue() override;
public: // Time
- void GoToTime(TElement *inComponent, const TTimeUnit inTime) override;
+ void GoToTime(TElement *inComponent, const TTimeUnit inTime, bool relative) override;
void SetPause(TElement *inComponent, const BOOL inPause) override;
void SetTimePolicy(TElement *inComponent, const TTimeUnit inLoopDuration,
const UINT32 inRepetitions, const BOOL inPingPong, const BOOL inPlayThrough) override;
diff --git a/src/runtime/Qt3DSIComponentManager.h b/src/runtime/Qt3DSIComponentManager.h
index 11a1c39..6852096 100644
--- a/src/runtime/Qt3DSIComponentManager.h
+++ b/src/runtime/Qt3DSIComponentManager.h
@@ -124,6 +124,7 @@ public: // Slides
virtual void queueChange(TElement *component, TElement *target, const char *attName,
const char *value, TAttributeHash attrHash) = 0;
virtual bool hasSlideChangeQueued(TElement *component) = 0;
+ virtual bool clearSlideChangeQueued(TElement *component) = 0;
virtual void OnElementDeactivated(TElement *inElement) = 0;
@@ -142,7 +143,7 @@ public: // Slides
virtual void ClearGotoTimeQueue() = 0;
public: // Time
- virtual void GoToTime(TElement *inComponent, const TTimeUnit inTime) = 0;
+ virtual void GoToTime(TElement *inComponent, const TTimeUnit inTime, bool relative) = 0;
virtual void SetPause(TElement *inComponent, const BOOL inPause) = 0;
virtual void SetTimePolicy(TElement *inComponent, const TTimeUnit inLoopDuration,
const UINT32 inRepetitions, const BOOL inPingPong,
diff --git a/src/runtime/Qt3DSPresentation.cpp b/src/runtime/Qt3DSPresentation.cpp
index 71bbca9..e4c0797 100644
--- a/src/runtime/Qt3DSPresentation.cpp
+++ b/src/runtime/Qt3DSPresentation.cpp
@@ -476,7 +476,8 @@ void CPresentation::ProcessCommand(const SEventCommand &inCommand)
} else if (inCommand.m_Type == COMMAND_GOTOTIME) {
GetComponentManager().SetupComponentGotoTimeCommand(inCommand.m_Target,
inCommand.m_Arg1.m_INT32);
- GetComponentManager().GoToTime(inCommand.m_Target, inCommand.m_Arg1.m_INT32);
+ GetComponentManager().GoToTime(inCommand.m_Target, inCommand.m_Arg1.m_INT32,
+ inCommand.m_Arg2.m_INT32 > 0);
// Slide (Arg1 = slide index or slide name)
} else if (inCommand.m_Type == COMMAND_GOTOSLIDE) {
@@ -484,8 +485,11 @@ void CPresentation::ProcessCommand(const SEventCommand &inCommand)
IComponentManager &theManager(GetComponentManager());
Q3DStudio::SComponentGotoSlideData theGotoSlideData =
theManager.GetComponentGotoSlideCommand(inCommand.m_Target);
- if (theGotoSlideData.m_Slide > 0)
+ if (theGotoSlideData.m_Slide > 0) {
+ if (theManager.hasSlideChangeQueued(inCommand.m_Target))
+ theManager.clearSlideChangeQueued(inCommand.m_Target);
theManager.GotoSlideIndex(inCommand.m_Target, theGotoSlideData);
+ }
theManager.ReleaseComponentGotoSlideCommand(inCommand.m_Target);
} else if (inCommand.m_Type == COMMAND_GOTOSLIDENAME) {
diff --git a/src/runtime/Qt3DSQmlEngine.cpp b/src/runtime/Qt3DSQmlEngine.cpp
index 0988880..650edc4 100644
--- a/src/runtime/Qt3DSQmlEngine.cpp
+++ b/src/runtime/Qt3DSQmlEngine.cpp
@@ -475,7 +475,7 @@ public:
const SScriptEngineGotoSlideArgs &inArgs) override;
bool GetSlideInfo(const char *elementPath, int &currentIndex, int &previousIndex,
QString &currentName, QString &previousName) override;
- void GotoTime(const char *component, const Q3DStudio::FLOAT time) override;
+ void GotoTime(const char *component, const Q3DStudio::FLOAT time, bool relative) override;
bool RegisterCallback(Q3DStudio::UINT32 callbackType, const TScriptCallback inCallback,
void *inUserData) override;
void Shutdown(qt3ds::NVFoundationBase &inFoundation) override;
@@ -796,7 +796,7 @@ void CQmlEngineImpl::SetDataInputValue(
if (diDef.type == qt3ds::runtime::DataInOutTypeRangedNumber) {
qreal newTime = (qreal(value.toFloat() - diDef.min)
/ qreal(diDef.max - diDef.min));
- GotoTime(ctrlElem.elementPath.constData(), float(newTime));
+ GotoTime(ctrlElem.elementPath.constData(), float(newTime), true);
}
break;
}
@@ -2006,7 +2006,7 @@ bool CQmlEngineImpl::GetSlideInfo(const char *element, int &currentIndex, int &p
return false;
}
-void CQmlEngineImpl::GotoTime(const char *component, const Q3DStudio::FLOAT time)
+void CQmlEngineImpl::GotoTime(const char *component, const Q3DStudio::FLOAT time, bool relative)
{
TElement *theTarget = getTarget(component);
if (theTarget) {
@@ -2015,6 +2015,7 @@ void CQmlEngineImpl::GotoTime(const char *component, const Q3DStudio::FLOAT time
IPresentation *thePresentation = theTarget->GetBelongedPresentation();
theArg1.m_INT32 = static_cast<INT32>(time * 1000);
+ theArg2.m_INT32 = relative ? 1 : 0;
TElement *theParentTarget = &theTarget->GetComponentParent();
diff --git a/src/runtime/Qt3DSQmlEngine.h b/src/runtime/Qt3DSQmlEngine.h
index c515df1..8d40097 100644
--- a/src/runtime/Qt3DSQmlEngine.h
+++ b/src/runtime/Qt3DSQmlEngine.h
@@ -170,7 +170,7 @@ public: // Public functions but not functions on the script bridge
*
* @return none
*/
- virtual void GotoTime(const char *component, const Q3DStudio::FLOAT time) = 0;
+ virtual void GotoTime(const char *component, const Q3DStudio::FLOAT time, bool relative) = 0;
/**
* @brief Return values of an attribute