diff --git a/drape_frontend/animation_system.cpp b/drape_frontend/animation_system.cpp index 7a6530d262..7888f88200 100644 --- a/drape_frontend/animation_system.cpp +++ b/drape_frontend/animation_system.cpp @@ -673,7 +673,7 @@ bool MapFollowAnimation::HasScale() const } PerspectiveSwitchAnimation::PerspectiveSwitchAnimation(double startAngle, double endAngle, double angleFOV) - : Animation(false /* couldBeInterrupted */, true /* couldBeBlended */) + : Animation(false /* couldBeInterrupted */, false /* couldBeBlended */) , m_angleInterpolator(GetRotateDuration(startAngle, endAngle), startAngle, endAngle) , m_startAngle(startAngle) , m_endAngle(endAngle) @@ -924,8 +924,10 @@ void SequenceAnimation::Advance(double elapsedSeconds) void SequenceAnimation::Finish() { for (auto & anim : m_animations) + { anim->Finish(); - AnimationSystem::Instance().SaveAnimationResult(*m_animations.back()); + AnimationSystem::Instance().SaveAnimationResult(*anim); + } m_animations.clear(); ObtainObjectProperties(); Animation::Finish(); diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 7217c1f715..2917101a8c 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -1410,6 +1410,12 @@ void FrontendRenderer::OnAnimationStarted(ref_ptr anim) m_myPositionController->AnimationStarted(anim); } +void FrontendRenderer::OnPerspectiveSwitchRejected() +{ + if (m_perspectiveDiscarded) + m_perspectiveDiscarded = false; +} + TTilesCollection FrontendRenderer::ResolveTileKeys(ScreenBase const & screen) { m2::RectD const & rect = screen.ClipRect(); diff --git a/drape_frontend/frontend_renderer.hpp b/drape_frontend/frontend_renderer.hpp index 636f2304b7..095d624d3d 100755 --- a/drape_frontend/frontend_renderer.hpp +++ b/drape_frontend/frontend_renderer.hpp @@ -194,6 +194,7 @@ private: void CorrectGlobalScalePoint(m2::PointD & pt) const override; void OnScaleEnded() override; void OnAnimationStarted(ref_ptr anim) override; + void OnPerspectiveSwitchRejected() override; class Routine : public threads::IRoutine { diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp index 191fa6ac17..8f31cafe1e 100644 --- a/drape_frontend/user_event_stream.cpp +++ b/drape_frontend/user_event_stream.cpp @@ -169,11 +169,8 @@ void UserEventStream::AddEvent(UserEvent const & event) m_events.push_back(event); } -ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool & viewportChanged) +ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChanged, bool & viewportChanged) { - modelViewChange = false; - viewportChanged = false; - list events; { @@ -182,7 +179,7 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool & swap(m_events, events); } - modelViewChange = !events.empty() || m_state == STATE_SCALE || m_state == STATE_DRAG; + m_modelViewChanged = !events.empty() || m_state == STATE_SCALE || m_state == STATE_DRAG; for (UserEvent const & e : events) { if (m_perspectiveAnimation && FilterEventWhile3dAnimation(e.m_type)) @@ -198,7 +195,7 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool & break; case UserEvent::EVENT_RESIZE: m_navigator.OnSize(e.m_resize.m_width, e.m_resize.m_height); - viewportChanged = true; + m_viewportChanged = true; breakAnim = true; TouchCancel(m_touches); if (m_state == STATE_DOUBLE_TAP_HOLD) @@ -274,10 +271,10 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool & } if (breakAnim) - modelViewChange = true; + m_modelViewChanged = true; } - ApplyAnimations(modelViewChange, viewportChanged); + ApplyAnimations(); if (m_perspectiveAnimation) { @@ -290,7 +287,7 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool & SetRect(m_pendingEvent->m_rectEvent.m_rect, m_pendingEvent->m_rectEvent.m_zoom, m_pendingEvent->m_rectEvent.m_applyRotation, m_pendingEvent->m_rectEvent.m_isAnim); m_pendingEvent.reset(); - modelViewChange = true; + m_modelViewChanged = true; } } @@ -302,10 +299,15 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool & DetectLongTap(m_touches[0]); } + modelViewChanged = m_modelViewChanged; + viewportChanged = m_viewportChanged; + m_modelViewChanged = false; + m_viewportChanged = false; + return m_navigator.Screen(); } -void UserEventStream::ApplyAnimations(bool & modelViewChanged, bool & viewportChanged) +void UserEventStream::ApplyAnimations() { if (m_animationSystem.AnimationExists(Animation::MapPlane)) { @@ -325,7 +327,7 @@ void UserEventStream::ApplyAnimations(bool & modelViewChanged, bool & viewportCh { m_navigator.Disable3dMode(); } - viewportChanged = true; + m_viewportChanged = true; } double perspectiveAngle; @@ -335,7 +337,7 @@ void UserEventStream::ApplyAnimations(bool & modelViewChanged, bool & viewportCh m_navigator.SetRotationIn3dMode(perspectiveAngle); } - modelViewChanged = true; + m_modelViewChanged = true; } } @@ -634,6 +636,12 @@ void UserEventStream::SetEnable3dMode(double maxRotationAngle, double angleFOV, void UserEventStream::SetDisable3dModeAnimation() { ResetAnimationsBeforeSwitch3D(); + if (m_discardedFOV > 0.0 && IsScaleAllowableIn3d(GetDrawTileScale(GetCurrentScreen()))) + { + m_discardedFOV = m_discardedAngle = 0.0; + m_listener->OnPerspectiveSwitchRejected(); + return; + } double const startAngle = m_navigator.Screen().GetRotationAngle(); double const endAngle = 0.0; @@ -655,11 +663,7 @@ void UserEventStream::ResetAnimations(Animation::Type animType, bool finishAll) bool const hasAnimations = m_animationSystem.HasAnimations(); m_animationSystem.FinishAnimations(animType, true /* rewind */, finishAll); if (hasAnimations) - { - m2::AnyRectD rect; - if (m_animationSystem.GetRect(GetCurrentScreen(), rect)) - m_navigator.SetFromRect(rect); - } + ApplyAnimations(); } void UserEventStream::ResetMapPlaneAnimations() @@ -667,17 +671,14 @@ void UserEventStream::ResetMapPlaneAnimations() bool const hasAnimations = m_animationSystem.HasAnimations(); m_animationSystem.FinishObjectAnimations(Animation::MapPlane, false /* rewind */, false /* finishAll */); if (hasAnimations) - { - m2::AnyRectD rect; - if (m_animationSystem.GetRect(GetCurrentScreen(), rect)) - m_navigator.SetFromRect(rect); - } + ApplyAnimations(); } void UserEventStream::ResetAnimationsBeforeSwitch3D() { ResetAnimations(Animation::MapLinear); ResetAnimations(Animation::MapScale); + ResetAnimations(Animation::Sequence); ResetAnimations(Animation::MapPerspective, true /* finishAll */); } diff --git a/drape_frontend/user_event_stream.hpp b/drape_frontend/user_event_stream.hpp index d0c21deae9..0e90780891 100644 --- a/drape_frontend/user_event_stream.hpp +++ b/drape_frontend/user_event_stream.hpp @@ -258,11 +258,12 @@ public: virtual void OnScaleEnded() = 0; virtual void OnAnimationStarted(ref_ptr anim) = 0; + virtual void OnPerspectiveSwitchRejected() = 0; }; UserEventStream(); void AddEvent(UserEvent const & event); - ScreenBase const & ProcessEvents(bool & modelViewChange, bool & viewportChanged); + ScreenBase const & ProcessEvents(bool & modelViewChanged, bool & viewportChanged); ScreenBase const & GetCurrentScreen() const; m2::AnyRectD GetTargetRect() const; @@ -351,7 +352,7 @@ private: void EndFilter(Touch const & t); void CancelFilter(Touch const & t); - void ApplyAnimations(bool & modelViewChanged, bool & viewportChanged); + void ApplyAnimations(); void ResetAnimations(Animation::Type animType, bool finishAll = false); void ResetMapPlaneAnimations(); void ResetAnimationsBeforeSwitch3D(); @@ -378,6 +379,9 @@ private: AnimationSystem & m_animationSystem; + bool m_modelViewChanged = false; + bool m_viewportChanged = false; + bool m_perspectiveAnimation = false; unique_ptr m_pendingEvent; double m_discardedFOV = 0.0;