From 6dff719947501d1f709cc9e28c456f03082ef0ad Mon Sep 17 00:00:00 2001 From: Daria Volvenkova Date: Sun, 15 Nov 2015 19:21:14 +0300 Subject: [PATCH] Review fixes. Conflicts: drape_frontend/frontend_renderer.cpp --- .../animation/perspective_animation.cpp | 3 ++- .../animation/perspective_animation.hpp | 9 ++++----- drape_frontend/framebuffer.cpp | 3 --- drape_frontend/framebuffer.hpp | 2 +- drape_frontend/frontend_renderer.cpp | 7 ++++--- drape_frontend/message_subclasses.hpp | 8 ++++---- drape_frontend/user_event_stream.cpp | 4 ++-- geometry/screenbase.cpp | 16 +++++++--------- map/framework.cpp | 2 +- 9 files changed, 25 insertions(+), 29 deletions(-) diff --git a/drape_frontend/animation/perspective_animation.cpp b/drape_frontend/animation/perspective_animation.cpp index d9d4d2c86f..7509035fa5 100644 --- a/drape_frontend/animation/perspective_animation.cpp +++ b/drape_frontend/animation/perspective_animation.cpp @@ -4,13 +4,14 @@ namespace df { +// static double PerspectiveAnimation::GetRotateDuration(double startAngle, double endAngle) { return 0.5 * fabs(endAngle - startAngle) / math::pi4; } PerspectiveAnimation::PerspectiveAnimation(double duration, double startRotationAngle, double endRotationAngle) - : PerspectiveAnimation(duration, 0.0, startRotationAngle, endRotationAngle) + : PerspectiveAnimation(duration, 0.0 /* delay */, startRotationAngle, endRotationAngle) { } diff --git a/drape_frontend/animation/perspective_animation.hpp b/drape_frontend/animation/perspective_animation.hpp index d6ef6a6638..7dc59b9fb9 100644 --- a/drape_frontend/animation/perspective_animation.hpp +++ b/drape_frontend/animation/perspective_animation.hpp @@ -10,19 +10,18 @@ class PerspectiveAnimation : public BaseInterpolator using TBase = BaseInterpolator; public: - static double GetRotateDuration(double startAngle, double endAngle); - PerspectiveAnimation(double duration, double startRotationAngle, double endRotationAngle); PerspectiveAnimation(double duration, double delay, double startRotationAngle, double endRotationAngle); + static double GetRotateDuration(double startAngle, double endAngle); + void Advance(double elapsedSeconds) override; double GetRotationAngle() const { return m_rotationAngle; } private: - double m_startRotationAngle; - double m_endRotationAngle; + double const m_startRotationAngle; + double const m_endRotationAngle; double m_rotationAngle; }; } // namespace df - diff --git a/drape_frontend/framebuffer.cpp b/drape_frontend/framebuffer.cpp index 2a9fe67116..21e0d85dc9 100644 --- a/drape_frontend/framebuffer.cpp +++ b/drape_frontend/framebuffer.cpp @@ -11,9 +11,6 @@ namespace df { -Framebuffer::Framebuffer() -{ -} Framebuffer::~Framebuffer() { diff --git a/drape_frontend/framebuffer.hpp b/drape_frontend/framebuffer.hpp index 79566de482..5091ad5d81 100644 --- a/drape_frontend/framebuffer.hpp +++ b/drape_frontend/framebuffer.hpp @@ -13,7 +13,7 @@ namespace df class Framebuffer { public: - Framebuffer(); + Framebuffer() = default; ~Framebuffer(); void SetDefaultContext(dp::OGLContext * context); diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index cf1b1097e4..e8a8699768 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -523,10 +523,11 @@ void FrontendRenderer::OnResize(ScreenBase const & screen) int const maxTextureSize = m_framebuffer->GetMaxSize(); if (maxSide > maxTextureSize) { - width = width * maxTextureSize / maxSide; - height = height * maxTextureSize / maxSide; + double const scale = maxTextureSize / static_cast(maxSide); + width = static_cast(width * scale); + height = static_cast(height * scale); LOG(LINFO, ("Max texture size:", maxTextureSize, ", expanded screen size:", maxSide, - ", scale:", maxTextureSize / (double)maxSide)); + ", scale:", scale)); } m_viewport.SetViewport(0, 0, width, height); diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp index b5ec01dff1..79b20c78a5 100644 --- a/drape_frontend/message_subclasses.hpp +++ b/drape_frontend/message_subclasses.hpp @@ -621,10 +621,10 @@ public: double GetAngleFOV() const { return m_angleFOV; } private: - int m_preferredZoomLevel; - int m_preferredZoomLevelIn3d; - double m_rotationAngle; - double m_angleFOV; + int const m_preferredZoomLevel; + int const m_preferredZoomLevelIn3d; + double const m_rotationAngle; + double const m_angleFOV; }; class InvalidateTexturesMessage : public BaseBlockingMessage diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp index 0db72657a0..d1968f4699 100644 --- a/drape_frontend/user_event_stream.cpp +++ b/drape_frontend/user_event_stream.cpp @@ -395,7 +395,7 @@ void UserEventStream::SetEnable3dModeAnimation(double maxRotationAngle) double const endAngle = maxRotationAngle; double const rotateDuration = PerspectiveAnimation::GetRotateDuration(startAngle, endAngle); m_perspectiveAnimation.reset( - new PerspectiveAnimation(rotateDuration, 0.0/*delay*/, startAngle, endAngle)); + new PerspectiveAnimation(rotateDuration, 0.0 /* delay */, startAngle, endAngle)); } void UserEventStream::SetDisable3dModeAnimation() @@ -405,7 +405,7 @@ void UserEventStream::SetDisable3dModeAnimation() double const startAngle = m_navigator.Screen().GetRotationAngle(); double const endAngle = 0.0; double const rotateDuration = PerspectiveAnimation::GetRotateDuration(startAngle, endAngle); - m_perspectiveAnimation.reset(new PerspectiveAnimation(rotateDuration, 0.0/*delay*/, startAngle, endAngle)); + m_perspectiveAnimation.reset(new PerspectiveAnimation(rotateDuration, 0.0 /* delay */, startAngle, endAngle)); } void UserEventStream::ResetCurrentAnimation(bool finishAnimation) diff --git a/geometry/screenbase.cpp b/geometry/screenbase.cpp index e365641683..2ef6edacd8 100644 --- a/geometry/screenbase.cpp +++ b/geometry/screenbase.cpp @@ -259,7 +259,11 @@ void ScreenBase::ExtractGtoPParams(MatrixT const & m, // when it is rotated through maxRotationAngle around its near horizontal side. void ScreenBase::ApplyPerspective(double currentRotationAngle, double maxRotationAngle, double angleFOV) { - ASSERT_NOT_EQUAL(angleFOV, 0.0, ()); + ASSERT_GREATER(angleFOV, 0.0, ()); + ASSERT_LESS(angleFOV, math::pi2, ()); + ASSERT_GREATER_OR_EQUAL(maxRotationAngle, 0.0, ()); + ASSERT_LESS(maxRotationAngle, math::pi2, ()); + if (m_isPerspective) ResetPerspective(); @@ -279,13 +283,9 @@ void ScreenBase::ApplyPerspective(double currentRotationAngle, double maxRotatio double const dy = m_PixelRect.SizeY() * (m_3dScaleX - 1.0); - Scale(1.0 / m_3dScaleX); - m_PixelRect.setMaxX(m_PixelRect.maxX() * m_3dScaleX); m_PixelRect.setMaxY(m_PixelRect.maxY() * m_3dScaleY); - Scale(m_3dScaleX); - Move(0.0, dy / 2.0); SetRotationAngle(currentRotationAngle); @@ -296,6 +296,7 @@ void ScreenBase::ApplyPerspective(double currentRotationAngle, double maxRotatio void ScreenBase::SetRotationAngle(double rotationAngle) { ASSERT(m_isPerspective, ()); + ASSERT_GREATER_OR_EQUAL(rotationAngle, 0.0, ()); ASSERT_LESS_OR_EQUAL(rotationAngle, m_3dMaxAngleX, ()); if (rotationAngle > m_3dMaxAngleX) @@ -342,13 +343,10 @@ void ScreenBase::ResetPerspective() m_isPerspective = false; double const dy = m_PixelRect.SizeY() * (1.0 - 1.0 / m_3dScaleX); - Scale(m_3dScaleX); m_PixelRect.setMaxX(m_PixelRect.maxX() / m_3dScaleX); m_PixelRect.setMaxY(m_PixelRect.maxY() / m_3dScaleY); - Scale(1.0 / m_3dScaleX); - Move(0, -dy / 2.0); m_3dScaleX = m_3dScaleY = 1.0; @@ -392,7 +390,7 @@ m2::PointD ScreenBase::P3dToP(m2::PointD const & pt) const double const a = (m_3dFarZ + m_3dNearZ) / (m_3dFarZ - m_3dNearZ); double const b = -2.0 * m_3dFarZ * m_3dNearZ / (m_3dFarZ - m_3dNearZ); - normalizedZ = (a * cameraDistanceZ + b) / cameraDistanceZ; + normalizedZ = a + b / cameraDistanceZ; } Vector3dT const normalizedPoint{normalizedX, normalizedY, normalizedZ, 1.0}; diff --git a/map/framework.cpp b/map/framework.cpp index c7b71e37ff..c5d9e48c71 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1836,7 +1836,7 @@ void Framework::FollowRoute() int const scale = (m_currentRouterType == RouterType::Pedestrian) ? scales::GetUpperComfortScale() : scales::GetNavigationScale(); - int const scale3d = scale + 1; + int const scale3d = (m_currentRouterType == RouterType::Pedestrian) ? scale + 1 : scale + 2; double const rotationAngle = math::pi4; double const angleFOV = math::pi / 3.0;