| 481 | } |
| 482 | |
| 483 | drape_ptr<df::SubrouteData> RouteShape::CacheRoute(ref_ptr<dp::GraphicsContext> context, dp::DrapeID subrouteId, |
| 484 | SubrouteConstPtr subroute, size_t styleIndex, int recacheId) |
| 485 | { |
| 486 | size_t startIndex; |
| 487 | size_t endIndex; |
| 488 | if (subroute->m_styleType == df::SubrouteStyleType::Single) |
| 489 | { |
| 490 | ASSERT_EQUAL(styleIndex, 0, ()); |
| 491 | startIndex = 0; |
| 492 | endIndex = subroute->m_polyline.GetSize() - 1; |
| 493 | } |
| 494 | else |
| 495 | { |
| 496 | auto const & style = subroute->m_style[styleIndex]; |
| 497 | startIndex = style.m_startIndex; |
| 498 | endIndex = style.m_endIndex; |
| 499 | } |
| 500 | |
| 501 | ASSERT_LESS(startIndex, endIndex, ()); |
| 502 | |
| 503 | auto const points = subroute->m_polyline.ExtractSegment(startIndex, endIndex); |
| 504 | if (points.empty()) |
| 505 | return nullptr; |
| 506 | |
| 507 | std::vector<glsl::vec4> segmentsColors; |
| 508 | if (!subroute->m_traffic.empty()) |
| 509 | { |
| 510 | segmentsColors.reserve(endIndex - startIndex); |
| 511 | for (size_t i = startIndex; i < endIndex; ++i) |
| 512 | { |
| 513 | auto const speedGroup = TrafficGenerator::CheckColorsSimplification(subroute->m_traffic[i]); |
| 514 | auto const colorConstant = TrafficGenerator::GetColorBySpeedGroup(speedGroup, true /* route */); |
| 515 | dp::Color const color = df::GetColorConstant(colorConstant); |
| 516 | float const alpha = (speedGroup == traffic::SpeedGroup::G4 || speedGroup == traffic::SpeedGroup::G5 || |
| 517 | speedGroup == traffic::SpeedGroup::Unknown) |
| 518 | ? 0.0f |
| 519 | : 1.0f; |
| 520 | segmentsColors.emplace_back(color.GetRedF(), color.GetGreenF(), color.GetBlueF(), alpha); |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | auto subrouteData = make_unique_dp<df::SubrouteData>(); |
| 525 | subrouteData->m_subrouteId = subrouteId; |
| 526 | subrouteData->m_subroute = subroute; |
| 527 | subrouteData->m_startPointIndex = startIndex; |
| 528 | subrouteData->m_endPointIndex = endIndex; |
| 529 | subrouteData->m_styleIndex = styleIndex; |
| 530 | subrouteData->m_pivot = subroute->m_polyline.GetLimitRect().Center(); |
| 531 | subrouteData->m_recacheId = recacheId; |
| 532 | subrouteData->m_distanceOffset = subroute->m_polyline.GetLength(startIndex); |
| 533 | |
| 534 | std::vector<GeometryBufferData<GeometryBuffer>> geometryBufferData; |
| 535 | PrepareGeometry(points, subrouteData->m_pivot, segmentsColors, |
| 536 | static_cast<float>(subroute->m_baseDepthIndex * rs::kDepthPerSubroute), geometryBufferData); |
| 537 | |
| 538 | auto state = CreateRenderState( |
| 539 | subroute->m_style[styleIndex].m_pattern.m_isDashed ? gpu::Program::RouteDash : gpu::Program::Route, |
| 540 | DepthLayer::GeometryLayer); |
nothing calls this directly
no test coverage detected