diff --git a/drape_frontend/animation/follow_animation.cpp b/drape_frontend/animation/follow_animation.cpp index 0ddc6016ed..ccf359c87e 100644 --- a/drape_frontend/animation/follow_animation.cpp +++ b/drape_frontend/animation/follow_animation.cpp @@ -33,7 +33,7 @@ MapFollowAnimation::MapFollowAnimation(ScreenBase const & screen, m_properties.insert(Animation::Scale); if (m_angleInterpolator.IsActive()) m_properties.insert(Animation::Angle); - //if (m_offsetInterpolator.IsActive()) + if (m_offsetInterpolator.IsActive() || m_scaleInterpolator.IsActive() || m_angleInterpolator.IsActive()) m_properties.insert(Animation::Position); } @@ -117,8 +117,8 @@ bool MapFollowAnimation::GetProperty(TObject object, TProperty property, bool ta } else { - double scale = m_scaleInterpolator.GetScale() / m_scaleInterpolator.GetStartScale(); - double angle = m_angleInterpolator.GetAngle() - m_angleInterpolator.GetStartAngle(); + double const scale = m_scaleInterpolator.GetScale() / m_scaleInterpolator.GetStartScale(); + double const angle = m_angleInterpolator.GetAngle() - m_angleInterpolator.GetStartAngle(); m2::PointD offset = m_offsetInterpolator.GetPosition() * scale; offset.Rotate(angle); m2::PointD pos = m_globalPosition + offset; diff --git a/drape_frontend/animation/interpolators.cpp b/drape_frontend/animation/interpolators.cpp index c427a5f090..f933953be7 100644 --- a/drape_frontend/animation/interpolators.cpp +++ b/drape_frontend/animation/interpolators.cpp @@ -147,7 +147,6 @@ double PositionInterpolator::GetMoveDuration(m2::PointD const & startPosition, m double const pixelSpeed = kMaxSpeedScalar * minSize; return CalcAnimSpeedDuration(pixelLength, pixelSpeed); - } //static diff --git a/drape_frontend/navigator.cpp b/drape_frontend/navigator.cpp index 3ef11b1a32..08e7685980 100644 --- a/drape_frontend/navigator.cpp +++ b/drape_frontend/navigator.cpp @@ -45,7 +45,7 @@ void Navigator::SetFromScreen(ScreenBase const & screen, uint32_t tileSize, doub tmp = m_Screen; tmp.SetFromRect(m2::AnyRectD(newRect)); - ASSERT(CheckMaxScale(tmp, p.GetTileSize(), p.GetVisualScale()), ()); + ASSERT(CheckMaxScale(tmp, tileSize, visualScale), ()); } m_Screen = tmp; @@ -284,9 +284,13 @@ void Navigator::SetAutoPerspective(bool enable) m_Screen.SetAutoPerspective(enable); } -void Navigator::Enable3dMode(double currentRotationAngle, double maxRotationAngle, double angleFOV) +void Navigator::Enable3dMode() { - m_Screen.ApplyPerspective(currentRotationAngle, maxRotationAngle, angleFOV); + if (m_Screen.isPerspective()) + return; + double const angle = m_Screen.CalculateAutoPerspectiveAngle(m_Screen.GetScale()); + if (angle > 0) + m_Screen.ApplyPerspective(angle, angle, m_Screen.GetAngleFOV()); } void Navigator::SetRotationIn3dMode(double rotationAngle) diff --git a/drape_frontend/navigator.hpp b/drape_frontend/navigator.hpp index e285e9c34d..209a7f8e8c 100644 --- a/drape_frontend/navigator.hpp +++ b/drape_frontend/navigator.hpp @@ -47,7 +47,7 @@ public: bool InAction() const; void SetAutoPerspective(bool enable); - void Enable3dMode(double currentRotationAngle, double maxRotationAngle, double angleFOV); + void Enable3dMode(); void SetRotationIn3dMode(double rotationAngle); void Disable3dMode(); diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp index 106bd58023..6ad6f1c6c2 100644 --- a/drape_frontend/user_event_stream.cpp +++ b/drape_frontend/user_event_stream.cpp @@ -413,8 +413,8 @@ bool UserEventStream::SetFollowAndRotate(m2::PointD const & userPos, m2::PointD } screen.MatchGandP3d(userPos, pixelPos); - ASSERT_GREATER_OR_EQUAL(zoom, scales::GetUpperWorldScale(), ()); - ASSERT_LESS_OR_EQUAL(zoom, scales::GetUpperStyleScale(), ()); + ASSERT_GREATER_OR_EQUAL(preferredZoomLevel, scales::GetUpperWorldScale(), ()); + ASSERT_LESS_OR_EQUAL(preferredZoomLevel, scales::GetUpperStyleScale(), ()); ShrinkAndScaleInto(screen, df::GetWorldRect()); @@ -463,7 +463,9 @@ bool UserEventStream::SetFollowAndRotate(m2::PointD const & userPos, m2::PointD void UserEventStream::SetAutoPerspective(bool isAutoPerspective) { - if (!isAutoPerspective) + if (isAutoPerspective) + m_navigator.Enable3dMode(); + else m_navigator.Disable3dMode(); m_navigator.SetAutoPerspective(isAutoPerspective); return; diff --git a/geometry/screenbase.cpp b/geometry/screenbase.cpp index 1c4503ac5c..89455ae424 100644 --- a/geometry/screenbase.cpp +++ b/geometry/screenbase.cpp @@ -94,11 +94,8 @@ void ScreenBase::UpdateDependentParameters() } } -double ScreenBase::CalculatePerspectiveAngle(double scale) const +double ScreenBase::CalculateAutoPerspectiveAngle(double scale) { - if (!m_isAutoPerspective) - return m_3dAngleX; - if (scale > kStartPerspectiveScale1) return 0.0; @@ -117,6 +114,14 @@ double ScreenBase::CalculatePerspectiveAngle(double scale) const return kMaxPerspectiveAngle2 * 0.99; } +double ScreenBase::CalculatePerspectiveAngle(double scale) const +{ + if (!m_isAutoPerspective) + return m_3dAngleX; + + return CalculateAutoPerspectiveAngle(scale); +} + void ScreenBase::SetAutoPerspective(bool isAutoPerspective) { m_isAutoPerspective = isAutoPerspective; @@ -421,10 +426,12 @@ void ScreenBase::ResetPerspective() m_isPerspective = false; m_isAutoPerspective = false; + double const old_dy = m_ViewportRect.SizeY() * (m_3dScale - 1.0); + + m_3dScale = 1.0; m_3dAngleX = 0.0; m_3dMaxAngleX = 0.0; - double const old_dy = m_ViewportRect.SizeY() * (m_3dScale - 1.0); Move(0.0, -old_dy / 2.0); } diff --git a/geometry/screenbase.hpp b/geometry/screenbase.hpp index d3fbc6fc99..b5f43a1562 100644 --- a/geometry/screenbase.hpp +++ b/geometry/screenbase.hpp @@ -162,6 +162,8 @@ public: m2::RectD CalculatePixelRect(double scale) const; double CalculatePerspectiveAngle(double scale) const; + static double CalculateAutoPerspectiveAngle(double scale); + /// Compute arbitrary pixel transformation, that translates the (oldPt1, oldPt2) -> (newPt1, newPt2) static MatrixT const CalcTransform(m2::PointD const & oldPt1, m2::PointD const & oldPt2, m2::PointD const & newPt1, m2::PointD const & newPt2,