MCPcopy Create free account
hub / github.com/comaps/comaps / GenerateLine

Method GenerateLine

libs/drape_frontend/transit_scheme_builder.cpp:1086–1133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1084}
1085
1086void 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
1135void TransitSchemeBuilder::GenerateStop(ref_ptr<dp::GraphicsContext> context, StopNodeParamsSubway const & stopParams,
1136 m2::PointD const & pivot,

Callers

nothing calls this directly

Calls 15

ToVec2Function · 0.85
make_refFunction · 0.85
CreateRenderStateFunction · 0.85
GenerateLineCapsFunction · 0.85
GetRedFMethod · 0.80
GetGreenFMethod · 0.80
GetBlueFMethod · 0.80
GetAlphaFMethod · 0.80
InitStreamMethod · 0.80
InsertTriangleListMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected