diff options
author | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2016-06-09 16:30:39 +0300 |
---|---|---|
committer | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2016-07-07 15:31:07 +0300 |
commit | 2ac8539d73b9502c5ca05b85f2a05c019f393a84 (patch) | |
tree | 2430a55b00ea26b1edbd7eb28d3b6297f65e6bb7 /geometry | |
parent | c949c0c407bbd1742a03b7189ee42c59f03dcbae (diff) |
Calculate current rotation angle in perspective mode.
Diffstat (limited to 'geometry')
-rw-r--r-- | geometry/screenbase.cpp | 35 | ||||
-rw-r--r-- | geometry/screenbase.hpp | 2 |
2 files changed, 26 insertions, 11 deletions
diff --git a/geometry/screenbase.cpp b/geometry/screenbase.cpp index fd5ce38f9b..7dc94b4efd 100644 --- a/geometry/screenbase.cpp +++ b/geometry/screenbase.cpp @@ -7,6 +7,13 @@ #include "std/cmath.hpp" +double constexpr kPerspectiveAngleFOV = math::pi / 3.0; +double constexpr kMaxPerspectiveAngle1 = math::pi4; +double constexpr kMaxPerspectiveAngle2 = math::pi * 55.0 / 180.0; + +double constexpr kStartPerspectiveScale1 = 1.7e-5; +double constexpr kEndPerspectiveScale1 = 0.3e-5; +double constexpr kEndPerspectiveScale2 = 0.13e-5; ScreenBase::ScreenBase() : m_PixelRect(0, 0, 640, 480), @@ -26,7 +33,6 @@ ScreenBase::ScreenBase() : { m_GtoP = math::Identity<double, 3>(); m_PtoG = math::Identity<double, 3>(); -// UpdateDependentParameters(); } ScreenBase::ScreenBase(m2::RectI const & pxRect, m2::AnyRectD const & glbRect) @@ -77,13 +83,20 @@ void ScreenBase::UpdateDependentParameters() double ScreenBase::CalculatePerspectiveAngle(double scale) { - double const kStartPerspectiveScale = 0.13e-4; - double const kMaxScale = 0.13e-5; - double const kMaxPerspectiveAngle = math::pi4; - - if (scale > kStartPerspectiveScale) + if (scale > kStartPerspectiveScale1) return 0.0; - return kMaxPerspectiveAngle * (kStartPerspectiveScale - scale) / (kStartPerspectiveScale - kMaxScale); + else if (scale > kEndPerspectiveScale1) + { + double const k = (kStartPerspectiveScale1 - scale) / (kStartPerspectiveScale1 - kEndPerspectiveScale1); + return kMaxPerspectiveAngle1 * k; + } + else if (scale > kEndPerspectiveScale2) + { + double const k = (kEndPerspectiveScale1 - scale) / (kEndPerspectiveScale1 - kEndPerspectiveScale2); + return kMaxPerspectiveAngle1 + (kMaxPerspectiveAngle2 - kMaxPerspectiveAngle1) * k; + } + else + return kMaxPerspectiveAngle2 * 0.99; } void ScreenBase::UpdatePerspectiveParameters() @@ -91,10 +104,12 @@ void ScreenBase::UpdatePerspectiveParameters() double const angle = CalculatePerspectiveAngle(m_Scale); if (angle > 0.0) { - if (m_isPerspective) - SetRotationAngle(angle); + if (!m_isPerspective || (angle < kMaxPerspectiveAngle1 && m_3dMaxAngleX > kMaxPerspectiveAngle1)) + ApplyPerspective(angle, kMaxPerspectiveAngle1, kPerspectiveAngleFOV); + else if (angle > m_3dMaxAngleX) + ApplyPerspective(angle, kMaxPerspectiveAngle2, kPerspectiveAngleFOV); else - ApplyPerspective(angle, math::pi4, math::pi / 3); + SetRotationAngle(angle); } else if (m_isPerspective) ResetPerspective(); diff --git a/geometry/screenbase.hpp b/geometry/screenbase.hpp index ef5125d9e4..24b4076643 100644 --- a/geometry/screenbase.hpp +++ b/geometry/screenbase.hpp @@ -132,7 +132,7 @@ public: void SetRotationAngle(double rotationAngle); double GetRotationAngle() const { return m_3dAngleX; } - + double GetMaxRotationAngle() const { return m_3dMaxAngleX; } double GetAngleFOV() const { return m_3dFOV; } m2::PointD P3dtoP(m2::PointD const & pt) const; |