| 1084 | } |
| 1085 | |
| 1086 | void TransitSchemeBuilder::GenerateLine(ref_ptr<dp::GraphicsContext> context, std::vector<m2::PointD> const & path, |
| 1087 | m2::PointD const & pivot, dp::Color const & colorConst, float lineOffset, |
| 1088 | float halfWidth, float depth, dp::Batcher & batcher) |
| 1089 | { |
| 1090 | using TV = TransitStaticVertex; |
| 1091 | |
| 1092 | TGeometryBuffer geometry; |
| 1093 | auto const color = |
| 1094 | glsl::vec4(colorConst.GetRedF(), colorConst.GetGreenF(), colorConst.GetBlueF(), colorConst.GetAlphaF()); |
| 1095 | size_t const kAverageSize = path.size() * 6; |
| 1096 | size_t constexpr kAverageCapSize = 12; |
| 1097 | geometry.reserve(kAverageSize + kAverageCapSize * 2); |
| 1098 | |
| 1099 | std::vector<SchemeSegment> segments; |
| 1100 | segments.reserve(path.size() - 1); |
| 1101 | |
| 1102 | for (size_t i = 1; i < path.size(); ++i) |
| 1103 | { |
| 1104 | if (path[i].EqualDxDy(path[i - 1], 1.0e-5)) |
| 1105 | continue; |
| 1106 | |
| 1107 | SchemeSegment segment; |
| 1108 | segment.m_p1 = glsl::ToVec2(MapShape::ConvertToLocal(path[i - 1], pivot, kShapeCoordScalar)); |
| 1109 | segment.m_p2 = glsl::ToVec2(MapShape::ConvertToLocal(path[i], pivot, kShapeCoordScalar)); |
| 1110 | CalculateTangentAndNormals(segment.m_p1, segment.m_p2, segment.m_tangent, segment.m_leftNormal, |
| 1111 | segment.m_rightNormal); |
| 1112 | |
| 1113 | auto const startPivot = glsl::vec3(segment.m_p1, depth); |
| 1114 | auto const endPivot = glsl::vec3(segment.m_p2, depth); |
| 1115 | auto const offset = lineOffset * segment.m_rightNormal; |
| 1116 | |
| 1117 | geometry.emplace_back(startPivot, TV::TNormal(segment.m_rightNormal * halfWidth - offset, -halfWidth, 0.0), color); |
| 1118 | geometry.emplace_back(startPivot, TV::TNormal(segment.m_leftNormal * halfWidth - offset, halfWidth, 0.0), color); |
| 1119 | geometry.emplace_back(endPivot, TV::TNormal(segment.m_rightNormal * halfWidth - offset, -halfWidth, 0.0), color); |
| 1120 | geometry.emplace_back(endPivot, TV::TNormal(segment.m_rightNormal * halfWidth - offset, -halfWidth, 0.0), color); |
| 1121 | geometry.emplace_back(startPivot, TV::TNormal(segment.m_leftNormal * halfWidth - offset, halfWidth, 0.0), color); |
| 1122 | geometry.emplace_back(endPivot, TV::TNormal(segment.m_leftNormal * halfWidth - offset, halfWidth, 0.0), color); |
| 1123 | |
| 1124 | segments.emplace_back(std::move(segment)); |
| 1125 | } |
| 1126 | |
| 1127 | dp::AttributeProvider provider(1 /* stream count */, static_cast<uint32_t>(geometry.size())); |
| 1128 | provider.InitStream(0 /* stream index */, GetTransitStaticBindingInfo(), make_ref(geometry.data())); |
| 1129 | auto state = CreateRenderState(gpu::Program::Transit, DepthLayer::TransitSchemeLayer); |
| 1130 | batcher.InsertTriangleList(context, state, make_ref(&provider)); |
| 1131 | |
| 1132 | GenerateLineCaps(context, segments, color, lineOffset, halfWidth, depth, batcher); |
| 1133 | } |
| 1134 | |
| 1135 | void TransitSchemeBuilder::GenerateStop(ref_ptr<dp::GraphicsContext> context, StopNodeParamsSubway const & stopParams, |
| 1136 | m2::PointD const & pivot, |
nothing calls this directly
no test coverage detected