diff options
author | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2017-01-10 17:16:35 +0300 |
---|---|---|
committer | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2017-01-11 10:34:49 +0300 |
commit | 840ca2bb19bb287cee1558c51c6fd896e74e3595 (patch) | |
tree | 9a43812a7967c7acc8c6a74de740eb320521c0cf /drape_frontend | |
parent | bd44a4fd31a00065d1e82b5e385e362f23ea3513 (diff) |
Added different frequency of arrows on traffic lines
Diffstat (limited to 'drape_frontend')
-rw-r--r-- | drape_frontend/traffic_generator.cpp | 52 | ||||
-rw-r--r-- | drape_frontend/traffic_generator.hpp | 5 | ||||
-rw-r--r-- | drape_frontend/traffic_renderer.cpp | 2 |
3 files changed, 45 insertions, 14 deletions
diff --git a/drape_frontend/traffic_generator.cpp b/drape_frontend/traffic_generator.cpp index 373847354b..61239beb3b 100644 --- a/drape_frontend/traffic_generator.cpp +++ b/drape_frontend/traffic_generator.cpp @@ -24,6 +24,31 @@ namespace df namespace { +// Values of the following arrays are based on traffic-arrow texture. +static array<float, static_cast<size_t>(traffic::SpeedGroup::Count)> kCoordVOffsets = +{ + 0.75f, // G0 + 0.75f, // G1 + 0.75f, // G2 + 0.5f, // G3 + 0.25f, // G4 + 0.0f, // G5 + 0.75f, // TempBlock + 0.0f, // Unknown +}; + +static array<float, static_cast<size_t>(traffic::SpeedGroup::Count)> kMinCoordU = +{ + 0.15f, // G0 + 0.15f, // G1 + 0.15f, // G2 + 0.33f, // G3 + 0.5f, // G4 + 0.0f, // G5 + 0.15f, // TempBlock + 0.0f, // Unknown +}; + dp::BindingInfo const & GetTrafficStaticBindingInfo() { static unique_ptr<dp::BindingInfo> s_info; @@ -52,7 +77,7 @@ dp::BindingInfo const & GetTrafficLineStaticBindingInfo() } void SubmitStaticVertex(glsl::vec3 const & pivot, glsl::vec2 const & normal, float side, - float offsetFromStart, glsl::vec2 const & texCoord, + float offsetFromStart, glsl::vec4 const & texCoord, vector<TrafficStaticVertex> & staticGeom) { staticGeom.emplace_back(pivot, TrafficStaticVertex::TNormal(normal, side, offsetFromStart), texCoord); @@ -63,7 +88,7 @@ void GenerateCapTriangles(glsl::vec3 const & pivot, vector<glsl::vec2> const & n vector<TrafficStaticVertex> & staticGeometry) { float const kEps = 1e-5; - glsl::vec2 const uv = glsl::ToVec2(colorRegion.GetTexRect().Center()); + glsl::vec4 const uv = glsl::vec4(glsl::ToVec2(colorRegion.GetTexRect().Center()), 0.0f, 0.0f); size_t const trianglesCount = normals.size() / 3; for (int j = 0; j < trianglesCount; j++) { @@ -141,6 +166,8 @@ void TrafficGenerator::FlushSegmentsGeometry(TileKey const & tileKey, TrafficSeg ASSERT(m_colorsCacheValid, ()); dp::TextureManager::ColorRegion const & colorRegion = m_colorsCache[static_cast<size_t>(segmentColoringIt->second)]; + float const vOffset = kCoordVOffsets[static_cast<size_t>(segmentColoringIt->second)]; + float const minU = kMinCoordU[static_cast<size_t>(segmentColoringIt->second)]; int width = 0; if (TrafficRenderer::CanBeRendereredAsLine(g.m_roadClass, tileKey.m_zoomLevel, width)) @@ -161,7 +188,8 @@ void TrafficGenerator::FlushSegmentsGeometry(TileKey const & tileKey, TrafficSeg { vector<TrafficStaticVertex> staticGeometry; bool const generateCaps = (tileKey.m_zoomLevel > kGenerateCapsZoomLevel[static_cast<uint32_t>(g.m_roadClass)]); - GenerateSegment(colorRegion, g.m_polyline, tileKey.GetGlobalRect().Center(), generateCaps, depth, staticGeometry); + GenerateSegment(colorRegion, g.m_polyline, tileKey.GetGlobalRect().Center(), generateCaps, depth, + vOffset, minU, staticGeometry); if (staticGeometry.empty()) continue; @@ -215,7 +243,8 @@ void TrafficGenerator::FlushGeometry(TrafficBatcherKey const & key, dp::GLState void TrafficGenerator::GenerateSegment(dp::TextureManager::ColorRegion const & colorRegion, m2::PolylineD const & polyline, m2::PointD const & tileCenter, - bool generateCaps, float depth, vector<TrafficStaticVertex> & staticGeometry) + bool generateCaps, float depth, float vOffset, float minU, + vector<TrafficStaticVertex> & staticGeometry) { vector<m2::PointD> const & path = polyline.GetPoints(); ASSERT_GREATER(path.size(), 1, ()); @@ -229,7 +258,8 @@ void TrafficGenerator::GenerateSegment(dp::TextureManager::ColorRegion const & c glsl::vec2 lastPoint, lastTangent, lastLeftNormal, lastRightNormal; bool firstFilled = false; - glsl::vec2 const uv = glsl::ToVec2(colorRegion.GetTexRect().Center()); + glsl::vec4 const uvStart = glsl::vec4(glsl::ToVec2(colorRegion.GetTexRect().Center()), vOffset, 1.0f); + glsl::vec4 const uvEnd = glsl::vec4(uvStart.x, uvStart.y, uvStart.z, minU); for (size_t i = 1; i < path.size(); ++i) { if (path[i].EqualDxDy(path[i - 1], 1.0E-5)) @@ -257,12 +287,12 @@ void TrafficGenerator::GenerateSegment(dp::TextureManager::ColorRegion const & c glsl::vec3 const startPivot = glsl::vec3(p1, depth); glsl::vec3 const endPivot = glsl::vec3(p2, depth); - SubmitStaticVertex(startPivot, rightNormal, -1.0f, 0.0f, uv, staticGeometry); - SubmitStaticVertex(startPivot, leftNormal, 1.0f, 0.0f, uv, staticGeometry); - SubmitStaticVertex(endPivot, rightNormal, -1.0f, maskSize, uv, staticGeometry); - SubmitStaticVertex(endPivot, rightNormal, -1.0f, maskSize, uv, staticGeometry); - SubmitStaticVertex(startPivot, leftNormal, 1.0f, 0.0f, uv, staticGeometry); - SubmitStaticVertex(endPivot, leftNormal, 1.0f, maskSize, uv, staticGeometry); + SubmitStaticVertex(startPivot, rightNormal, -1.0f, 0.0f, uvStart, staticGeometry); + SubmitStaticVertex(startPivot, leftNormal, 1.0f, 0.0f, uvStart, staticGeometry); + SubmitStaticVertex(endPivot, rightNormal, -1.0f, maskSize, uvEnd, staticGeometry); + SubmitStaticVertex(endPivot, rightNormal, -1.0f, maskSize, uvEnd, staticGeometry); + SubmitStaticVertex(startPivot, leftNormal, 1.0f, 0.0f, uvStart, staticGeometry); + SubmitStaticVertex(endPivot, leftNormal, 1.0f, maskSize, uvEnd, staticGeometry); } // Generate caps. diff --git a/drape_frontend/traffic_generator.hpp b/drape_frontend/traffic_generator.hpp index 7983a1cddd..e9c331c8d2 100644 --- a/drape_frontend/traffic_generator.hpp +++ b/drape_frontend/traffic_generator.hpp @@ -93,7 +93,7 @@ struct TrafficStaticVertex { using TPosition = glsl::vec3; using TNormal = glsl::vec4; - using TTexCoord = glsl::vec2; + using TTexCoord = glsl::vec4; TrafficStaticVertex() = default; TrafficStaticVertex(TPosition const & position, TNormal const & normal, @@ -180,7 +180,8 @@ private: void GenerateSegment(dp::TextureManager::ColorRegion const & colorRegion, m2::PolylineD const & polyline, m2::PointD const & tileCenter, - bool generateCaps, float depth, vector<TrafficStaticVertex> & staticGeometry); + bool generateCaps, float depth, float vOffset, float minU, + vector<TrafficStaticVertex> & staticGeometry); void GenerateLineSegment(dp::TextureManager::ColorRegion const & colorRegion, m2::PolylineD const & polyline, m2::PointD const & tileCenter, float depth, vector<TrafficLineStaticVertex> & staticGeometry); diff --git a/drape_frontend/traffic_renderer.cpp b/drape_frontend/traffic_renderer.cpp index c3ab0c3c08..139d8ba5d9 100644 --- a/drape_frontend/traffic_renderer.cpp +++ b/drape_frontend/traffic_renderer.cpp @@ -24,7 +24,7 @@ int constexpr kMinVisibleArrowZoomLevel = 16; int constexpr kRoadClass2MinVisibleArrowZoomLevel = 17; int constexpr kOutlineMinZoomLevel = 14; -float const kTrafficArrowAspect = 24.0f / 8.0f; +float const kTrafficArrowAspect = 128.0f / 8.0f; float const kLeftWidthInPixel[] = { |