From d5a2a73d327329bcdf6fcf91c549d2efe60a9908 Mon Sep 17 00:00:00 2001 From: ExMix Date: Tue, 14 Oct 2014 10:18:10 +0300 Subject: [PATCH] [core] move animation in RotateAndFollow mode --- map/location_state.cpp | 20 +++++++++++++++++--- map/location_state.hpp | 2 ++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/map/location_state.cpp b/map/location_state.cpp index 5f43226adc..423124e21d 100644 --- a/map/location_state.cpp +++ b/map/location_state.cpp @@ -103,6 +103,11 @@ public: } } + m2::PointD const & GetPositionForDraw() + { + return m_posAnim->GetCurrentValue(); + } + virtual void OnStep(double ts) { ASSERT(m_angleAnim != nullptr, ()); @@ -171,7 +176,7 @@ private: 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 posSpeed = 2 * 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); m_posAnim->ResetDestParams(dstPos, posSpeed); @@ -467,13 +472,14 @@ void State::draw(graphics::OverlayRenderer * r, m_framework->GetNavigator().GtoP(Position() + m2::PointD(m_errorRadius, 0.0))); double const drawScale = pxErrorRadius / s_cacheRadius; + m2::PointD const & pivotPosition = GetPositionForDraw(); math::Matrix locationDrawM = math::Shift( math::Scale( math::Identity(), drawScale, drawScale), - pivot()); + pivotPosition); math::Matrix const drawM = locationDrawM * m; // draw error sector @@ -488,7 +494,7 @@ void State::draw(graphics::OverlayRenderer * r, math::Rotate( math::Identity(), rotateAngle), - pivot()); + pivotPosition); if (!IsInRouting()) r->drawDisplayList(m_positionArrow.get(), compassDrawM * m); @@ -847,4 +853,12 @@ void State::SetDirection(double bearing) SetModeInfo(IncludeModeBit(m_modeInfo, KnownDirectionBit)); } +m2::PointD const State::GetPositionForDraw() const +{ + if (m_animTask != nullptr) + return m_framework->GtoP(static_cast(m_animTask.get())->GetPositionForDraw()); + + return pivot(); +} + } diff --git a/map/location_state.hpp b/map/location_state.hpp index 48ab0ac6e4..5dd9008af8 100644 --- a/map/location_state.hpp +++ b/map/location_state.hpp @@ -145,6 +145,8 @@ namespace location bool Assign(location::CompassInfo const & info); void SetDirection(double bearing); + const m2::PointD GetPositionForDraw() const; + private: // Mode bits // {