From 521aa6b3874e4128524550c499be0f0a7ef63f1f Mon Sep 17 00:00:00 2001 From: ExMix Date: Tue, 7 Oct 2014 17:38:37 +0300 Subject: [PATCH] review fixes --- map/location_state.cpp | 24 +++++++++++++----------- map/navigator.cpp | 3 ++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/map/location_state.cpp b/map/location_state.cpp index 8c7cdd8c2b..f83aeeb408 100644 --- a/map/location_state.cpp +++ b/map/location_state.cpp @@ -71,8 +71,8 @@ public: { m_angleAnim.reset(new anim::SafeAngleInterpolation(srcAngle, srcAngle, 1.0)); m_posAnim.reset(new anim::SafeSegmentInterpolation(srcPos, srcPos, 1.0)); - m2::PointD srcInverted = InvertPxBinding(srcPixelBinding); - m2::PointD dstInverted = InvertPxBinding(dstPixelbinding); + m2::PointD const srcInverted = InvertPxBinding(srcPixelBinding); + m2::PointD const dstInverted = InvertPxBinding(dstPixelbinding); m_pxBindingAnim.reset(new anim::SafeSegmentInterpolation(srcInverted, dstInverted, m_fw->GetNavigator().ComputeMoveSpeed(srcInverted, dstInverted))); } @@ -82,19 +82,16 @@ public: ASSERT(m_angleAnim != nullptr, ()); ASSERT(m_posAnim != nullptr, ()); - double shortDist = fabs(ang::GetShortestDistance(m_angleAnim->GetCurrentValue(), dstAngle)); - if (dstPos.EqualDxDy(m_posAnim->GetCurrentValue(), POSITION_TOLERANCE) && shortDist < ANGLE_TOLERANCE) - return; - - if (IsVisual()) { + //Store new params even if animation is active but don't interrupt the current one. + //New animation to the pending params will be made after all. m_hasPendingAnimation = true; m_pendingDstPos = dstPos; m_pendingAngle = dstAngle; } else - SetParams(dstPos, dstAngle, shortDist); + SetParams(dstPos, dstAngle); } void Update() @@ -102,7 +99,7 @@ public: if (m_hasPendingAnimation) { m_hasPendingAnimation = false; - SetParams(m_pendingDstPos, m_pendingAngle, ang::GetShortestDistance(m_angleAnim->GetCurrentValue(), m_pendingAngle)); + SetParams(m_pendingDstPos, m_pendingAngle); } } @@ -168,8 +165,12 @@ private: m_fw->Invalidate(); } - void SetParams(m2::PointD const & dstPos, double dstAngle, double angleDist) + void SetParams(m2::PointD const & dstPos, double dstAngle) { + double const angleDist = fabs(ang::GetShortestDistance(m_angleAnim->GetCurrentValue(), dstAngle)); + if (dstPos.EqualDxDy(m_posAnim->GetCurrentValue(), POSITION_TOLERANCE) && angleDist < ANGLE_TOLERANCE) + return; + double const posSpeed = m_fw->GetNavigator().ComputeMoveSpeed(m_posAnim->GetCurrentValue(), dstPos); double const angleSpeed = angleDist < 1.0 ? 1.5 : m_fw->GetAnimator().GetRotationSpeed(); m_angleAnim->ResetDestParams(dstAngle, angleSpeed); @@ -334,7 +335,8 @@ void State::StartRouteFollow() void State::StopRoutingMode() { - SetModeInfo(ChangeMode(ExcludeModeBit(m_modeInfo, RoutingSessionBit), Follow)); + ASSERT(IsInRouting(), ()); + SetModeInfo(ChangeMode(ExcludeModeBit(m_modeInfo, RoutingSessionBit), GetMode() == RotateAndFollow ? Follow : NotFollow)); RotateOnNorth(); AnimateFollow(); } diff --git a/map/navigator.cpp b/map/navigator.cpp index d9567a0829..9fc7a3911e 100644 --- a/map/navigator.cpp +++ b/map/navigator.cpp @@ -74,8 +74,9 @@ void Navigator::CenterViewport(m2::PointD const & p) m_StartScreen.SetOrg(pt); } -double Navigator::ComputeMoveSpeed(m2::PointD const & p0, m2::PointD const & p1) const +double Navigator::ComputeMoveSpeed(m2::PointD const & /*p0*/, m2::PointD const & /*p1*/) const { + // we think that with fixed time interval will be better return 0.2;//max(0.5, min(0.5, 0.5 * GtoP(p0).Length(GtoP(p1)) / 50.0)); }