| 82 | } |
| 83 | |
| 84 | void ConstructLineSegments(std::vector<m2::PointD> const & path, std::vector<glsl::vec4> const & segmentsColors, |
| 85 | std::vector<LineSegment> & segments) |
| 86 | { |
| 87 | ASSERT_LESS(1, path.size(), ()); |
| 88 | |
| 89 | if (!segmentsColors.empty()) |
| 90 | ASSERT_EQUAL(segmentsColors.size() + 1, path.size(), ()); |
| 91 | |
| 92 | m2::PointD prevPoint = path[0]; |
| 93 | for (size_t i = 1; i < path.size(); ++i) |
| 94 | { |
| 95 | m2::PointF const p1 = m2::PointF(prevPoint.x, prevPoint.y); |
| 96 | m2::PointF const p2 = m2::PointF(path[i].x, path[i].y); |
| 97 | if (p1.EqualDxDy(p2, 1.0E-5)) |
| 98 | continue; |
| 99 | |
| 100 | // Important! Do emplace_back first and fill parameters later. |
| 101 | // Fill parameters first and push_back later will cause ugly bug in clang 3.6 -O3 optimization. |
| 102 | segments.emplace_back(glsl::ToVec2(p1), glsl::ToVec2(p2)); |
| 103 | LineSegment & segment = segments.back(); |
| 104 | |
| 105 | CalculateTangentAndNormals(glsl::ToVec2(p1), glsl::ToVec2(p2), segment.m_tangent, segment.m_leftBaseNormal, |
| 106 | segment.m_rightBaseNormal); |
| 107 | |
| 108 | segment.m_leftNormals[StartPoint] = segment.m_leftNormals[EndPoint] = segment.m_leftBaseNormal; |
| 109 | segment.m_rightNormals[StartPoint] = segment.m_rightNormals[EndPoint] = segment.m_rightBaseNormal; |
| 110 | if (!segmentsColors.empty()) |
| 111 | segment.m_color = segmentsColors[i - 1]; |
| 112 | |
| 113 | prevPoint = path[i]; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | void UpdateNormals(LineSegment * segment, LineSegment * prevSegment, LineSegment * nextSegment) |
| 118 | { |
no test coverage detected