From b9d212427c51e2e0c36829eb79edeee32b5ca985 Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Fri, 5 Aug 2016 15:09:59 -0700 Subject: [PATCH] Fixed follow-and-rotate animation jittering --- drape_frontend/animation/animation.hpp | 6 ++++++ drape_frontend/animation/follow_animation.cpp | 4 ++++ drape_frontend/animation_system.cpp | 8 +++++--- drape_frontend/user_event_stream.cpp | 2 ++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drape_frontend/animation/animation.hpp b/drape_frontend/animation/animation.hpp index 3153dcf37b..8d788e55f6 100644 --- a/drape_frontend/animation/animation.hpp +++ b/drape_frontend/animation/animation.hpp @@ -76,6 +76,7 @@ public: : m_couldBeInterrupted(couldBeInterrupted) , m_couldBeBlended(couldBeBlended) , m_interruptedOnCombine(false) + , m_couldBeRewinded(true) {} virtual void OnStart() { if (m_onStartAction != nullptr) m_onStartAction(this); } @@ -114,6 +115,9 @@ public: void SetCouldBeInterrupted(bool enable) { m_couldBeInterrupted = enable; } void SetCouldBeBlended(bool enable) { m_couldBeBlended = enable; } + + void SetCouldBeRewinded(bool enable) { m_couldBeRewinded = enable; } + bool CouldBeRewinded() const { return m_couldBeRewinded; } protected: TAction m_onStartAction; @@ -126,6 +130,8 @@ protected: bool m_couldBeBlended; // Animation must be interrupted in case of combining another animation. bool m_interruptedOnCombine; + // Animation could be rewinded in case of finishing. + bool m_couldBeRewinded; }; } // namespace df diff --git a/drape_frontend/animation/follow_animation.cpp b/drape_frontend/animation/follow_animation.cpp index 9054257fd0..d8da05fe65 100644 --- a/drape_frontend/animation/follow_animation.cpp +++ b/drape_frontend/animation/follow_animation.cpp @@ -41,6 +41,10 @@ MapFollowAnimation::MapFollowAnimation(ScreenBase const & screen, m_properties.insert(Animation::Angle); if (m_offsetInterpolator.IsActive() || m_scaleInterpolator.IsActive() || m_angleInterpolator.IsActive()) m_properties.insert(Animation::Position); + + // If MapFollowAnimation affects only angles, disable rewinding. + SetCouldBeRewinded(!m_angleInterpolator.IsActive() || m_scaleInterpolator.IsActive() || + m_offsetInterpolator.IsActive()); } Animation::TObjectProperties const & MapFollowAnimation::GetProperties(TObject object) const diff --git a/drape_frontend/animation_system.cpp b/drape_frontend/animation_system.cpp index fd8e6b039b..b1acd5c1ff 100644 --- a/drape_frontend/animation_system.cpp +++ b/drape_frontend/animation_system.cpp @@ -270,7 +270,8 @@ void AnimationSystem::FinishAnimations(function const if (predicate(anim)) { #ifdef DEBUG_ANIMATIONS - LOG(LINFO, ("Finish animation", anim->GetType(), ", rewind:", rewind)); + LOG(LINFO, ("Finish animation", anim->GetType(), ", rewind:", rewind, + ", couldBeRewinded:", anim->CouldBeRewinded())); changed = true; #endif finishAnimations.splice(finishAnimations.end(), frontList, it++); @@ -291,7 +292,8 @@ void AnimationSystem::FinishAnimations(function const if (predicate(*it)) { #ifdef DEBUG_ANIMATIONS - LOG(LINFO, ("Finish animation", (*it)->GetType(), ", rewind:", rewind)); + LOG(LINFO, ("Finish animation", (*it)->GetType(), ", rewind:", rewind, + ", couldBeRewinded:", anim->CouldBeRewinded())); changed = true; #endif it = lst.erase(it); @@ -306,7 +308,7 @@ void AnimationSystem::FinishAnimations(function const for (auto & anim : finishAnimations) { - if (rewind) + if (rewind && anim->CouldBeRewinded()) anim->Finish(); SaveAnimationResult(*anim); } diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp index 63572d3a52..cd13b1ba52 100644 --- a/drape_frontend/user_event_stream.cpp +++ b/drape_frontend/user_event_stream.cpp @@ -390,7 +390,9 @@ bool UserEventStream::InterruptFollowAnimations(bool force) ResetAnimations(Animation::Arrow); } else + { return false; + } } return true; }