diff --git a/drape_frontend/area_shape.cpp b/drape_frontend/area_shape.cpp index 2599ed4f2c..59d632eda5 100644 --- a/drape_frontend/area_shape.cpp +++ b/drape_frontend/area_shape.cpp @@ -37,25 +37,25 @@ void AreaShape::Draw(ref_ptr batcher, ref_ptr t for (auto const & edge : m_buildingEdges) { glsl::vec3 normal(glsl::ToVec2(edge.m_normal), 0.0f); - vertexes.push_back(gpu::Area3dVertex(glsl::vec3(glsl::ToVec2(edge.m_startVertex), -m_params.m_minPosZ), - normal, colorPoint)); - vertexes.push_back(gpu::Area3dVertex(glsl::vec3(glsl::ToVec2(edge.m_endVertex), -m_params.m_minPosZ), - normal, colorPoint)); - vertexes.push_back(gpu::Area3dVertex(glsl::vec3(glsl::ToVec2(edge.m_startVertex), -m_params.m_posZ), - normal, colorPoint)); + vertexes.emplace_back(gpu::Area3dVertex(glsl::vec3(glsl::ToVec2(edge.m_startVertex), -m_params.m_minPosZ), + normal, colorPoint)); + vertexes.emplace_back(gpu::Area3dVertex(glsl::vec3(glsl::ToVec2(edge.m_endVertex), -m_params.m_minPosZ), + normal, colorPoint)); + vertexes.emplace_back(gpu::Area3dVertex(glsl::vec3(glsl::ToVec2(edge.m_startVertex), -m_params.m_posZ), + normal, colorPoint)); - vertexes.push_back(gpu::Area3dVertex(glsl::vec3(glsl::ToVec2(edge.m_startVertex), -m_params.m_posZ), - normal, colorPoint)); - vertexes.push_back(gpu::Area3dVertex(glsl::vec3(glsl::ToVec2(edge.m_endVertex), -m_params.m_minPosZ), - normal, colorPoint)); - vertexes.push_back(gpu::Area3dVertex(glsl::vec3(glsl::ToVec2(edge.m_endVertex), -m_params.m_posZ), - normal, colorPoint)); + vertexes.emplace_back(gpu::Area3dVertex(glsl::vec3(glsl::ToVec2(edge.m_startVertex), -m_params.m_posZ), + normal, colorPoint)); + vertexes.emplace_back(gpu::Area3dVertex(glsl::vec3(glsl::ToVec2(edge.m_endVertex), -m_params.m_minPosZ), + normal, colorPoint)); + vertexes.emplace_back(gpu::Area3dVertex(glsl::vec3(glsl::ToVec2(edge.m_endVertex), -m_params.m_posZ), + normal, colorPoint)); } glsl::vec3 normal(0.0f, 0.0f, -1.0f); for (auto const & vertex : m_vertexes) - vertexes.push_back(gpu::Area3dVertex(glsl::vec3(glsl::ToVec2(vertex), -m_params.m_posZ), - normal, colorPoint)); + vertexes.emplace_back(gpu::Area3dVertex(glsl::vec3(glsl::ToVec2(vertex), -m_params.m_posZ), + normal, colorPoint)); dp::GLState state(gpu::AREA_3D_PROGRAM, dp::GLState::GeometryLayer); state.SetColorTexture(region.GetTexture()); @@ -71,8 +71,7 @@ void AreaShape::Draw(ref_ptr batcher, ref_ptr t vertexes.resize(m_vertexes.size()); transform(m_vertexes.begin(), m_vertexes.end(), vertexes.begin(), [&colorPoint, this](m2::PointF const & vertex) { - return gpu::AreaVertex(glsl::vec3(glsl::ToVec2(vertex), m_params.m_depth), - colorPoint); + return gpu::AreaVertex(glsl::vec3(glsl::ToVec2(vertex), m_params.m_depth), colorPoint); }); dp::GLState state(gpu::AREA_PROGRAM, dp::GLState::GeometryLayer); diff --git a/drape_frontend/arrow3d.cpp b/drape_frontend/arrow3d.cpp index 5640d414dd..6b83cd4407 100644 --- a/drape_frontend/arrow3d.cpp +++ b/drape_frontend/arrow3d.cpp @@ -21,22 +21,23 @@ double const kArrow3dScale = 1.2; Arrow3d::Arrow3d() : m_state(gpu::ARROW_3D_PROGRAM, dp::GLState::OverlayLayer) { - m_vertices = { 0.0f, 0.0f, -1.0f, - -1.0f, -1.0f, 0.0f, - 0.0f, 2.0f, 0.0f, + m_vertices = { + 0.0f, 0.0f, -1.0f, + -1.0f, -1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, - 0.0f, 0.0f, -1.0f, - 0.0f, 2.0f, 0.0f, - 1.0f, -1.0f, 0.0f, + 0.0f, 0.0f, -1.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, -1.0f, 0.0f, - 0.0f, 0.0f, -1.0f, - 0.0f, -0.5f, 0.0f, - -1.0f, -1.0f, 0.0f, + 0.0f, 0.0f, -1.0f, + 0.0f, -0.5f, 0.0f, + -1.0f, -1.0f, 0.0f, - 0.0f, 0.0f, -1.0f, - 1.0f, -1.0f, 0.0f, - 0.0f, -0.5f, 0.0f - }; + 0.0f, 0.0f, -1.0f, + 1.0f, -1.0f, 0.0f, + 0.0f, -0.5f, 0.0f + }; m_normals.resize(m_vertices.size()); for (size_t triangle = 0; triangle < m_vertices.size() / 9; ++triangle) diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 64bad412d3..b6eba50f70 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -34,7 +34,7 @@ namespace df namespace { - +constexpr float kIsometryAngle = math::pi * 80.0f / 180.0f; const double VSyncInterval = 0.06; //const double VSyncInterval = 0.014; @@ -523,7 +523,6 @@ void FrontendRenderer::AcceptMessage(ref_ptr message) if (m_enablePerspectiveInNavigation == msg->AllowPerspective() && m_enablePerspectiveInNavigation != isPerspective) { - if (m_enablePerspectiveInNavigation) AddUserEvent(EnablePerspectiveEvent(msg->GetRotationAngle(), msg->GetAngleFOV(), false /* animated */, true /* immediately start */)); @@ -943,7 +942,7 @@ void FrontendRenderer::RefreshPivotTransform(ScreenBase const & screen) else if (m_isIsometry) { math::Matrix transform(math::Identity()); - transform(2, 1) = -1.0f/tan(M_PI * 80.0f / 180.0f); + transform(2, 1) = -1.0f / tan(kIsometryAngle); transform(2, 2) = 1.0f / screen.GetHeight(); m_generalUniforms.SetMatrix4x4Value("pivotTransform", transform.m_data); } @@ -957,7 +956,7 @@ void FrontendRenderer::RefreshPivotTransform(ScreenBase const & screen) void FrontendRenderer::RefreshBgColor() { uint32_t color = drule::rules().GetBgColor(df::GetDrawTileScale(m_userEventStream.GetCurrentScreen())); - dp::Color c = dp::Extract(color, 255 - (color >> 24)); + dp::Color c = dp::Extract(color, 0 /*255 - (color >> 24)*/); GLFunctions::glClearColor(c.GetRedF(), c.GetGreenF(), c.GetBlueF(), 0.0f); } @@ -1274,6 +1273,8 @@ void FrontendRenderer::ReleaseResources() m_myPositionController.reset(); m_selectionShape.release(); m_routeRenderer.reset(); + m_framebuffer.reset(); + m_transparentLayer.reset(); m_gpuProgramManager.reset(); m_contextFactory->getDrawContext()->doneCurrent(); diff --git a/drape_frontend/path_symbol_shape.cpp b/drape_frontend/path_symbol_shape.cpp index 6f8770a1a2..896b3b6c5a 100644 --- a/drape_frontend/path_symbol_shape.cpp +++ b/drape_frontend/path_symbol_shape.cpp @@ -48,10 +48,10 @@ void PathSymbolShape::Draw(ref_ptr batcher, ref_ptr lock(m_mutex); + return m_is3dBuildings; +} + bool RequestedTiles::CheckTileKey(TileKey const & tileKey) const { lock_guard lock(m_mutex); diff --git a/drape_frontend/requested_tiles.hpp b/drape_frontend/requested_tiles.hpp index b3e44ee882..24fc6b3689 100755 --- a/drape_frontend/requested_tiles.hpp +++ b/drape_frontend/requested_tiles.hpp @@ -16,7 +16,7 @@ public: void Set(ScreenBase const & screen, bool is3dBuildings, TTilesCollection && tiles); TTilesCollection GetTiles(); ScreenBase GetScreen(); - bool Is3dBuildings() const { return m_is3dBuildings; } + bool Is3dBuildings(); bool CheckTileKey(TileKey const & tileKey) const; private: diff --git a/drape_frontend/text_layout.cpp b/drape_frontend/text_layout.cpp index f952a9499d..932509ddc3 100644 --- a/drape_frontend/text_layout.cpp +++ b/drape_frontend/text_layout.cpp @@ -33,10 +33,10 @@ public: { m2::RectF const & mask = glyph.GetTexRect(); - m_buffer.push_back(gpu::TextStaticVertex(m_colorCoord, glsl::ToVec2(mask.LeftTop()))); - m_buffer.push_back(gpu::TextStaticVertex(m_colorCoord, glsl::ToVec2(mask.LeftBottom()))); - m_buffer.push_back(gpu::TextStaticVertex(m_colorCoord, glsl::ToVec2(mask.RightTop()))); - m_buffer.push_back(gpu::TextStaticVertex(m_colorCoord, glsl::ToVec2(mask.RightBottom()))); + m_buffer.emplace_back(gpu::TextStaticVertex(m_colorCoord, glsl::ToVec2(mask.LeftTop()))); + m_buffer.emplace_back(gpu::TextStaticVertex(m_colorCoord, glsl::ToVec2(mask.LeftBottom()))); + m_buffer.emplace_back(gpu::TextStaticVertex(m_colorCoord, glsl::ToVec2(mask.RightTop()))); + m_buffer.emplace_back(gpu::TextStaticVertex(m_colorCoord, glsl::ToVec2(mask.RightBottom()))); } protected: @@ -79,10 +79,10 @@ public: m_penPosition += glsl::vec2(-xOffset, 0.0f); } - m_buffer.push_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(xOffset, bottomVector))); - m_buffer.push_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(xOffset, upVector))); - m_buffer.push_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(pixelSize.x + xOffset, bottomVector))); - m_buffer.push_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(pixelSize.x + xOffset, upVector))); + m_buffer.emplace_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(xOffset, bottomVector))); + m_buffer.emplace_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(xOffset, upVector))); + m_buffer.emplace_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(pixelSize.x + xOffset, bottomVector))); + m_buffer.emplace_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(pixelSize.x + xOffset, upVector))); m_penPosition += glsl::vec2(glyph.GetAdvanceX() * m_textRatio, glyph.GetAdvanceY() * m_textRatio); TBase::operator()(glyph); @@ -111,10 +111,10 @@ public: void operator() (dp::TextureManager::GlyphRegion const & glyph) { m2::RectF const & mask = glyph.GetTexRect(); - m_buffer.push_back(gpu::TextOutlinedStaticVertex(m_colorCoord, m_outlineCoord, glsl::ToVec2(mask.LeftTop()))); - m_buffer.push_back(gpu::TextOutlinedStaticVertex(m_colorCoord, m_outlineCoord, glsl::ToVec2(mask.LeftBottom()))); - m_buffer.push_back(gpu::TextOutlinedStaticVertex(m_colorCoord, m_outlineCoord, glsl::ToVec2(mask.RightTop()))); - m_buffer.push_back(gpu::TextOutlinedStaticVertex(m_colorCoord, m_outlineCoord, glsl::ToVec2(mask.RightBottom()))); + m_buffer.emplace_back(gpu::TextOutlinedStaticVertex(m_colorCoord, m_outlineCoord, glsl::ToVec2(mask.LeftTop()))); + m_buffer.emplace_back(gpu::TextOutlinedStaticVertex(m_colorCoord, m_outlineCoord, glsl::ToVec2(mask.LeftBottom()))); + m_buffer.emplace_back(gpu::TextOutlinedStaticVertex(m_colorCoord, m_outlineCoord, glsl::ToVec2(mask.RightTop()))); + m_buffer.emplace_back(gpu::TextOutlinedStaticVertex(m_colorCoord, m_outlineCoord, glsl::ToVec2(mask.RightBottom()))); } protected: @@ -159,10 +159,10 @@ public: m_penPosition += glsl::vec2(-xOffset, 0.0f); } - m_buffer.push_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(xOffset, bottomVector))); - m_buffer.push_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(xOffset, upVector))); - m_buffer.push_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(pixelSize.x + xOffset, bottomVector))); - m_buffer.push_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(pixelSize.x + xOffset, upVector))); + m_buffer.emplace_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(xOffset, bottomVector))); + m_buffer.emplace_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(xOffset, upVector))); + m_buffer.emplace_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(pixelSize.x + xOffset, bottomVector))); + m_buffer.emplace_back(gpu::TextDynamicVertex(m_pivot, m_penPosition + glsl::vec2(pixelSize.x + xOffset, upVector))); m_penPosition += glsl::vec2(glyph.GetAdvanceX() * m_textRatio, glyph.GetAdvanceY() * m_textRatio); TBase::operator()(glyph); diff --git a/drape_frontend/transparent_layer.cpp b/drape_frontend/transparent_layer.cpp index 82b8afb348..3f2268d336 100644 --- a/drape_frontend/transparent_layer.cpp +++ b/drape_frontend/transparent_layer.cpp @@ -17,10 +17,11 @@ namespace df TransparentLayer::TransparentLayer() { - m_vertices = { -1.0f, 1.0f, 0.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, - -1.0f, -1.0f, 0.0f, 0.0f, - 1.0f, -1.0f, 1.0f, 0.0f }; + m_vertices = { + -1.0f, 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + -1.0f, -1.0f, 0.0f, 0.0f, + 1.0f, -1.0f, 1.0f, 0.0f }; } TransparentLayer::~TransparentLayer() diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp index 2d244f0108..021912a96d 100644 --- a/drape_frontend/user_event_stream.cpp +++ b/drape_frontend/user_event_stream.cpp @@ -142,8 +142,7 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool & bool breakAnim = false; for (UserEvent const & e : events) { - if (m_perspectiveAnimation != nullptr && - FilterEventWhile3dAnimation(e.m_type)) + if (m_perspectiveAnimation != nullptr && FilterEventWhile3dAnimation(e.m_type)) continue; switch (e.m_type) @@ -337,9 +336,9 @@ bool UserEventStream::IsScaleAllowableIn3d(int scale) { int minScale = scales::GetMinAllowableIn3dScale(); if (df::VisualParams::Instance().GetVisualScale() <= 1.0) - minScale -= 1; + --minScale; if (GetPlatform().IsTablet()) - minScale += 1; + ++minScale; return scale >= minScale; } @@ -522,7 +521,7 @@ void UserEventStream::SetEnable3dMode(double maxRotationAngle, double angleFOV, 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)); } m_navigator.Enable3dMode(startAngle, maxRotationAngle, angleFOV); viewportChanged = true; diff --git a/geometry/geometry.pro b/geometry/geometry.pro index a8c15a3256..d51bfbb054 100644 --- a/geometry/geometry.pro +++ b/geometry/geometry.pro @@ -47,4 +47,3 @@ HEADERS += \ transformations.hpp \ tree4d.hpp \ triangle2d.hpp \ - point3d.hpp diff --git a/geometry/point3d.hpp b/geometry/point3d.hpp deleted file mode 100644 index f1a7927f1b..0000000000 --- a/geometry/point3d.hpp +++ /dev/null @@ -1,279 +0,0 @@ -#pragma once - -#include "base/assert.hpp" -#include "base/base.hpp" -#include "base/math.hpp" -#include "base/matrix.hpp" - -#include "std/array.hpp" -#include "std/cmath.hpp" -#include "std/functional.hpp" -#include "std/sstream.hpp" -#include "std/typeinfo.hpp" - - -namespace m3 -{ - template - class Point - { - public: - typedef T value_type; - - T x, y, z; - - Point() {} - Point(T x_, T y_, T z_) : x(x_), y(y_), z(z_) {} - template Point(Point const & u) : x(u.x), y(u.y), z(u.z) {} - - static Point Zero() { return Point(0, 0, 0, 0); } - - bool Equal(Point const & p, T eps) const - { - return ((fabs(x - p.x) < eps) && (fabs(y - p.y) < eps) && (fabs(z - p.z) < eps)); - } - - T SquareLength(Point const & p) const - { - return math::sqr(x- p.x) + math::sqr(y - p.y) + math::sqr(z - p.z); - } - - double Length(Point const & p) const - { - return sqrt(SquareLength(p)); - } - - Point MoveXY(T len, T ang) const - { - return Point(x + len * cos(ang), y + len * sin(ang), z, w); - } - - Point MoveXY(T len, T angSin, T angCos) const - { - return m3::Point(x + len * angCos, y + len * angSin, z, w); - } - - Point const & operator-=(Point const & a) - { - x -= a.x; - y -= a.y; - z -= a.z; - return *this; - } - - Point const & operator+=(Point const & a) - { - x += a.x; - y += a.y; - z += a.z; - return *this; - } - - template - Point const & operator*=(U const & k) - { - x = static_cast(x * k); - y = static_cast(y * k); - z = static_cast(z * k); - return *this; - } - - template - Point const & operator=(Point const & a) - { - x = static_cast(a.x); - y = static_cast(a.y); - z = static_cast(a.z); - return *this; - } - - bool operator == (m3::Point const & p) const - { - return x == p.x && y == p.y && z == p.z; - } - bool operator != (m3::Point const & p) const - { - return !(*this == p); - } - m3::Point operator + (m3::Point const & pt) const - { - return m3::Point(x + pt.x, y + pt.y, z + pt.z); - } - m3::Point operator - (m3::Point const & pt) const - { - return m3::Point(x - pt.x, y - pt.y, z - pt.z); - } - m3::Point operator -() const - { - return m3::Point(-x, -y, -z); - } - - m3::Point operator * (T scale) const - { - return m3::Point(x * scale, y * scale, z * scale); - } - - m3::Point const operator * (math::Matrix const & m) const - { - math::Matrix point = { x, y, z, 1}; - math::Matrix res = point * m; - return m3::Point(res(0, 0) / res(0, 3), res(0, 1) / res(0, 3), res(0, 2) / res(0, 3)); - } - - m3::Point operator / (T scale) const - { - return m3::Point(x / scale, y / scale, z / scale); - } - - m3::Point mid(m3::Point const & p) const - { - return m3::Point((x + p.x) * 0.5, (y + p.y) * 0.5, (z + p.z) * 0.5); - } - - /// @name VectorOperationsOnPoint - // @{ - double Length() const - { - return sqrt(x*x + y*y + z*z); - } - - Point Normalize() const - { - ASSERT(!IsAlmostZero(), ()); - double const module = this->Length(); - return Point(x / module, y / module, z / module); - } - // @} - - m3::Point const & operator *= (math::Matrix const & m) - { - math::Matrix point = { x, y, z, 1}; - math::Matrix res = point * m; - x = res(0, 0) / res(0, 3); - y = res(0, 1) / res(0, 3); - z = res(0, 2) / res(0, 3); - return *this; - } - - void RotateXY(double angle) - { - T cosAngle = cos(angle); - T sinAngle = sin(angle); - T oldX = x; - x = cosAngle * oldX - sinAngle * y; - y = sinAngle * oldX + cosAngle * y; - } - }; - - template - inline Point const operator- (Point const & a, Point const & b) - { - return Point(a.x - b.x, a.y - b.y, a.z - b.z); - } - - template - inline Point const operator+ (Point const & a, Point const & b) - { - return Point(a.x + b.x, a.y + b.y, a.x + b.z); - } - - template - Point const Cross(Point const & pt1, Point const & pt2) - { - Point const res(pt1.y * pt2.z - pt1.z * pt2.y, - pt1.z * pt2.x - pt1.x * pt2.z, - pt1.x * pt2.y - pt1.y * pt2.x; - return res; - } - - // Dot product of a and b, equals to |a|*|b|*cos(angle_between_a_and_b). - template - T const DotProduct(Point const & a, Point const & b) - { - return a.x * b.x + a.y * b.y + a.z * b.z; - } - - // Value of cross product of a and b, equals to |a|*|b|*sin(angle_between_a_and_b). - template - T const CrossProduct(Point const & a, Point const & b) - { - return Cross(a, b).Length(); - } - - template - Point const Shift(Point const & pt, U const & dx, U const & dy, U const & dz) - { - return Point(pt.x + dx, pt.y + dy, pt.z + dz); - } - - template - Point const Shift(Point const & pt, Point const & offset) - { - return Shift(pt, offset.x, offset.y, offset.z); - } - - template - Point const Floor(Point const & pt) - { - Point res; - res.x = floor(pt.x); - res.y = floor(pt.y); - res.z = floor(pt.z); - return res; - } - - template - int GetOrientation(PointT const & p1, PointT const & p2, PointT const & pt) - { - double const sa = CrossProduct(p1 - pt, p2 - pt); - if (sa > 0.0) - return 1; - if (sa < 0.0) - return -1; - return 0; - } - - template string DebugPrint(m3::Point const & p) - { - ostringstream out; - out.precision(20); - out << "m3::Point<" << typeid(T).name() << ">(" << p.x << ", " << p.y << ", " << p.z << ")"; - return out.str(); - } - - template - TArchive & operator >> (TArchive & ar, m3::Point & pt) - { - ar >> pt.x; - ar >> pt.y; - ar >> pt.z; - return ar; - } - - template - TArchive & operator << (TArchive & ar, m3::Point const & pt) - { - ar << pt.x; - ar << pt.y; - ar << pt.z; - return ar; - } - - template - bool operator< (Point const & l, Point const & r) - { - if (l.x != r.x) - return l.x < r.x; - if (l.y != r.y) - return l.y < r.y; - return l.z < r.z; - } - - typedef Point PointF; - typedef Point PointD; - typedef Point PointU; - typedef Point PointU64; - typedef Point PointI; - typedef Point PointI64; -} -