summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2020-03-24 14:05:26 +0200
committerJanne Kangas <janne.kangas@qt.io>2020-03-25 14:10:42 +0200
commitaac88d209f4af370e77ec8fc509b70900453a7d5 (patch)
tree73779ba308a0b5f4fe261283f94b6fa82f0a094a
parent6afe2ec07b50911960886510bcd4506bc97b5771 (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>
-rw-r--r--src/runtime/Qt3DSComponentManager.cpp48
-rw-r--r--src/runtime/Qt3DSComponentManager.h8
-rw-r--r--src/runtime/Qt3DSIComponentManager.h4
-rw-r--r--src/runtime/Qt3DSPresentation.cpp3
-rw-r--r--src/runtime/Qt3DSQmlEngine.cpp2
5 files changed, 56 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
diff --git a/src/runtime/Qt3DSComponentManager.h b/src/runtime/Qt3DSComponentManager.h
index 6933ab4..59e151f 100644
--- a/src/runtime/Qt3DSComponentManager.h
+++ b/src/runtime/Qt3DSComponentManager.h
@@ -67,6 +67,7 @@ struct SComponentTimePolicyOverride
};
typedef eastl::hash_map<TElement *, SComponentGotoSlideData> TComponentGotoSlideDataMap;
+typedef eastl::hash_map<TElement *, TTimeUnit> TComponentGotoTimeMap;
typedef eastl::hash_map<TElement *, Q3DStudio::INT32> TComponentIntMap;
//==============================================================================
@@ -116,6 +117,11 @@ public: // Slide
SComponentGotoSlideData GetComponentGotoSlideCommand(TElement *inElement) override;
void ReleaseComponentGotoSlideCommand(TElement *inElement) override;
+ bool HasComponentGotoTimeCommand(TElement *inElement) override;
+ void SetupComponentGotoTimeCommand(TElement *inElement, Q3DStudio::TTimeUnit time) override;
+ void ReleaseComponentGotoTimeCommand(TElement *inElement) override;
+ void ClearGotoTimeQueue() override;
+
public: // Time
void GoToTime(TElement *inComponent, const TTimeUnit inTime) override;
void SetPause(TElement *inComponent, const BOOL inPause) override;
@@ -136,6 +142,8 @@ private:
TComponentGotoSlideDataMap m_ComponentInitialSlideMap;
TComponentGotoSlideDataMap m_ComponentGotoSlideMap;
+ TComponentGotoTimeMap m_ComponentGotoTimeMap;
+
TComponentIntMap m_PlaythroughOverrideMap;
QHash<TElement *, QHash<TElement *, QHash<TAttributeHash, UVariant>>> m_queuedChanges;
diff --git a/src/runtime/Qt3DSIComponentManager.h b/src/runtime/Qt3DSIComponentManager.h
index 2008e01..11a1c39 100644
--- a/src/runtime/Qt3DSIComponentManager.h
+++ b/src/runtime/Qt3DSIComponentManager.h
@@ -136,6 +136,10 @@ public: // Slides
virtual bool HasComponentGotoSlideCommand(TElement *inElement) = 0;
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 ReleaseComponentGotoTimeCommand(TElement *inElement) = 0;
+ virtual void ClearGotoTimeQueue() = 0;
public: // Time
virtual void GoToTime(TElement *inComponent, const TTimeUnit inTime) = 0;
diff --git a/src/runtime/Qt3DSPresentation.cpp b/src/runtime/Qt3DSPresentation.cpp
index 851cfef..71bbca9 100644
--- a/src/runtime/Qt3DSPresentation.cpp
+++ b/src/runtime/Qt3DSPresentation.cpp
@@ -226,6 +226,7 @@ void CPresentation::PostUpdate(const TTimeUnit inGlobalTime)
}
m_PreviousGlobalTime = inGlobalTime;
+ m_ComponentManager.ClearGotoTimeQueue();
}
void CPresentation::NotifyDataOutputs()
@@ -473,6 +474,8 @@ void CPresentation::ProcessCommand(const SEventCommand &inCommand)
} else if (inCommand.m_Type == COMMAND_PAUSE) {
GetComponentManager().SetPause(inCommand.m_Target, true);
} 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);
// Slide (Arg1 = slide index or slide name)
diff --git a/src/runtime/Qt3DSQmlEngine.cpp b/src/runtime/Qt3DSQmlEngine.cpp
index 5507655..d063e5e 100644
--- a/src/runtime/Qt3DSQmlEngine.cpp
+++ b/src/runtime/Qt3DSQmlEngine.cpp
@@ -1975,6 +1975,8 @@ void CQmlEngineImpl::GotoTime(const char *component, const Q3DStudio::FLOAT time
TElement *theParentTarget = &theTarget->GetComponentParent();
+ thePresentation->GetComponentManager().SetupComponentGotoTimeCommand(theTarget,
+ theArg1.m_INT32);
thePresentation->FireCommand(COMMAND_GOTOTIME, theParentTarget, &theArg1, &theArg2);
}
}