summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2018-11-06 13:46:48 +0100
committerChristian Stromme <christian.stromme@qt.io>2018-11-07 11:28:35 +0000
commitd8a37e66b3a12c0a839e65b93314f0077ff30b3c (patch)
tree93e4071ff1229f27b01c18d088d0ee16d66ea107
parent6d5c9b2be5c9c6cd0d407148bb84e81b37d58fc5 (diff)
Fix unlinked properties not being applied when there are no tracks
Notifying property changes was delayed until the track starts, but if there's no tracks this will never happen, so instead we now delay the calls until the slide animator (always present) is first called, which happens even if the slide is initially paused. Task-number: QT3DS-2596 Change-Id: I3fd49977b90ac370680446ecbfc7b3301130de34 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--src/runtime/q3dsslideplayer.cpp14
-rw-r--r--src/runtime/q3dsslideplayer_p.h2
-rw-r--r--tests/scenes/slideplayer/unlinked/unlinkedNoTracks.uip60
3 files changed, 75 insertions, 1 deletions
diff --git a/src/runtime/q3dsslideplayer.cpp b/src/runtime/q3dsslideplayer.cpp
index 9c9b5bf..3dfd2d0 100644
--- a/src/runtime/q3dsslideplayer.cpp
+++ b/src/runtime/q3dsslideplayer.cpp
@@ -73,6 +73,7 @@ public:
if (!slidePlayer)
return;
+ slidePlayer->flushQueuedCalls();
slidePlayer->setSlideTime(m_slide, newValue * 1000.0f);
m_previousValue = newValue;
}
@@ -1036,8 +1037,11 @@ void Q3DSSlidePlayer::processPropertyChanges(Q3DSSlide *currentSlide, Q3DSSlide
// Set the property values
const auto &propertyChanges = currentSlide->propertyChanges();
- for (auto it = propertyChanges.cbegin(); it != propertyChanges.cend(); ++it)
+ for (auto it = propertyChanges.cbegin(); it != propertyChanges.cend(); ++it) {
it.key()->applyPropertyChanges(*it.value());
+ // The property changes are immutable, so as longs as that's true it should be save to capture the iterator...
+ m_queuedCalls.push_back([it]() { it.key()->notifyPropertyChanges(*it.value()); });
+ }
// Now update the properties from dynamic property values
for (auto it = dynamicPropertyChanges.cbegin(), ite = dynamicPropertyChanges.cend(); it != ite; ++it)
@@ -1145,6 +1149,14 @@ void Q3DSSlidePlayer::evaluateDynamicObjectVisibility(Q3DSGraphObject *obj)
setObjectVisibility(obj, parentVisible, true, time);
}
+void Q3DSSlidePlayer::flushQueuedCalls()
+{
+ for (const auto &fn : qAsConst(m_queuedCalls))
+ fn();
+
+ m_queuedCalls.clear();
+}
+
void Q3DSSlidePlayer::objectAboutToBeAddedToScene(Q3DSGraphObject *obj)
{
evaluateDynamicObjectVisibility(obj);
diff --git a/src/runtime/q3dsslideplayer_p.h b/src/runtime/q3dsslideplayer_p.h
index 832fb84..5166c1b 100644
--- a/src/runtime/q3dsslideplayer_p.h
+++ b/src/runtime/q3dsslideplayer_p.h
@@ -153,6 +153,7 @@ private:
bool isSlideVisible(Q3DSSlide *slide);
void processPropertyChanges(Q3DSSlide *currentSlide, Q3DSSlide *previousSlide);
void evaluateDynamicObjectVisibility(Q3DSGraphObject *obj);
+ void flushQueuedCalls();
struct Data {
Q3DSSlideDeck *slideDeck = nullptr;
@@ -169,6 +170,7 @@ private:
QSharedPointer<Q3DSAnimationManager> m_animationManager;
PlayerMode m_mode = PlayerMode::Viewer;
PlayerType m_type = PlayerType::Scene;
+ QVector<std::function<void()>> m_queuedCalls;
// This class handles animation callback from animationmanager and calls setSlideTime
friend class Q3DSSlidePositionCallback;
diff --git a/tests/scenes/slideplayer/unlinked/unlinkedNoTracks.uip b/tests/scenes/slideplayer/unlinked/unlinkedNoTracks.uip
new file mode 100644
index 0000000..4b4d2c5
--- /dev/null
+++ b/tests/scenes/slideplayer/unlinked/unlinkedNoTracks.uip
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<UIP version="4" >
+ <Project >
+ <ProjectSettings author="" company="" presentationWidth="1920" presentationHeight="1080" maintainAspect="False" >
+ <CustomColors count="16" >#ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff</CustomColors>
+ </ProjectSettings>
+ <Graph >
+ <Scene id="Scene" >
+ <Layer id="Layer" >
+ <Camera id="Camera" />
+ <Light id="Light" />
+ <Model id="Cone" >
+ <Material id="Default" name="Default" />
+ </Model>
+ <Component id="Component" >
+ <Model id="Cone_001" >
+ <Material id="Default_001" name="Default" />
+ </Model>
+ </Component>
+ </Layer>
+ </Scene>
+ </Graph>
+ <Logic >
+ <State name="Master Slide" component="#Scene" >
+ <Add ref="#Layer" />
+ <Add ref="#Camera" />
+ <Add ref="#Light" />
+ <Add ref="#Cone" name="Cone" rotation="0 0 0" scale="1 3 1" sourcepath="#Cone" />
+ <Add ref="#Default" diffuse="1 1 1" />
+ <State id="Scene-Slide1" name="Slide1" playmode="Play Through To..." >
+ <Set ref="#Layer" endtime="2000" />
+ <Set ref="#Camera" endtime="2000" />
+ <Set ref="#Light" endtime="2000" />
+ <Set ref="#Cone" endtime="2000" rotation="0 0 90" />
+ <Set ref="#Default" diffuse="0 0 1" />
+ <Add ref="#Component" name="Component" endtime="2000" />
+ </State>
+ <State id="Scene-Slide2" name="Slide2" playmode="Play Through To..." playthroughto="Previous" >
+ <Set ref="#Layer" endtime="2000" />
+ <Set ref="#Camera" endtime="2000" />
+ <Set ref="#Light" endtime="2000" />
+ <Set ref="#Cone" endtime="2000" rotation="-90 0 0" />
+ <Set ref="#Default" diffuse="1 0 0" />
+ </State>
+ </State>
+ <State name="Master Slide" component="#Component" >
+ <Add ref="#Cone_001" name="Cone" endtime="1000" position="0 -100 0" rotation="0 0 -90" scale="1 3 1" sourcepath="#Cone" />
+ <Add ref="#Default_001" diffuse="1 1 1" />
+ <State id="Component-Slide1" name="Slide1" playmode="Play Through To..." >
+ <Set ref="#Cone_001" endtime="800" rotation="0 0 90" />
+ <Set ref="#Default_001" diffuse="1 0 0" />
+ </State>
+ <State id="Component-Slide2" name="Slide2" initialplaystate="Play" playmode="Play Through To..." playthroughto="Previous" >
+ <Set ref="#Cone_001" endtime="800" rotation="0 0 -90" />
+ <Set ref="#Default_001" diffuse="0.631373 1 0.0392157" />
+ </State>
+ </State>
+ </Logic>
+ </Project>
+</UIP>