diff options
author | Christian Strømme <christian.stromme@qt.io> | 2018-09-11 13:52:36 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2018-09-12 08:35:21 +0000 |
commit | f9ddec6110281cf69bc4c9baa831b54243fdf68a (patch) | |
tree | 136fa042241a95724e0e6a2a623ec184dab8fd55 | |
parent | a4137e9b7589756a7c8634fde85e21fd3b1958e5 (diff) |
Fix frequent visibility updates at start/end for slides
The start and end time was used to decide if we should force a
re-evaluation of the objects visibility, which in some cases caused
a lot of traffic. This change makes the forced update explicit, so
we don't trigger unnecessarily updates.
Change-Id: I3005a968aacead42baa4907d0d25d91704151ac0
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r-- | src/runtime/q3dsslideplayer.cpp | 12 | ||||
-rw-r--r-- | src/runtime/q3dsslideplayer_p.h | 2 |
2 files changed, 5 insertions, 9 deletions
diff --git a/src/runtime/q3dsslideplayer.cpp b/src/runtime/q3dsslideplayer.cpp index 7682748..5594333 100644 --- a/src/runtime/q3dsslideplayer.cpp +++ b/src/runtime/q3dsslideplayer.cpp @@ -717,11 +717,11 @@ void Q3DSSlidePlayer::handleCurrentSlideChanged(Q3DSSlide *slide, if (parentChanged) cleanUpComponentPlayers(static_cast<Q3DSSlide *>(previousSlide->parent())); - setSlideTime(previousSlide, -1.0f); + setSlideTime(previousSlide, -1.0f, true); } if (slide && slideDidChange && isSlideVisible(slide)) { - setSlideTime(slide, 0.0f); + setSlideTime(slide, 0.0f, true); processPropertyChanges(slide, previousSlide); attatchPositionCallback(slide); m_animationManager->updateAnimations(slide, (m_mode == PlayerMode::Editor)); @@ -797,7 +797,7 @@ static bool objectHasVisibilityTag(Q3DSGraphObject *object) return (object->attached()->visibilityTag == Q3DSGraphObjectAttached::Visible); } -void Q3DSSlidePlayer::setSlideTime(Q3DSSlide *slide, float time) +void Q3DSSlidePlayer::setSlideTime(Q3DSSlide *slide, float time, bool forceUpdate) { if (!slide) return; @@ -814,10 +814,6 @@ void Q3DSSlidePlayer::setSlideTime(Q3DSSlide *slide, float time) parentVisible = (m_component->attached()->visibilityTag == Q3DSGraphObjectAttached::Visible); } - // We force an update if we are at the beginning (0.0f) or the end (-1.0f) - // to ensure the scenemanager has correct global values for visibility during - // slide changes - const bool forceUpdate = (qFuzzyCompare(time, 0.0f) || qFuzzyCompare(time, -1.0f)); const auto updateObjects = [=](Q3DSSlide *s) { if (!s) return; @@ -875,7 +871,7 @@ void Q3DSSlidePlayer::setObjectVisibility(Q3DSGraphObject *obj, bool parentVisib // updates its visibility we tell it to update with time from its last time update. if (player->state() != PlayerState::Idle && player->state() != PlayerState::Playing) { const float lastTime = player->position(); - player->setSlideTime(componentCurrentSlide, lastTime); + player->setSlideTime(componentCurrentSlide, lastTime, forceUpdate); } } } diff --git a/src/runtime/q3dsslideplayer_p.h b/src/runtime/q3dsslideplayer_p.h index 92e585b..75cd6a2 100644 --- a/src/runtime/q3dsslideplayer_p.h +++ b/src/runtime/q3dsslideplayer_p.h @@ -140,7 +140,7 @@ private: void setInternalState(PlayerState state); void onDurationChanged(float duration); void onSlideFinished(Q3DSSlide *slide); - void setSlideTime(Q3DSSlide *slide, float time); + void setSlideTime(Q3DSSlide *slide, float time, bool forceUpdate = false); void handleCurrentSlideChanged(Q3DSSlide *slide, Q3DSSlide *previousSlide, |