  }
  
  static void update_model(UIState *s, const cereal::ModelDataV2::Reader &model) {
    UIScene &scene = s->scene;
    const float max_distance = fmin(model.getPosition().getX()[TRAJECTORY_SIZE - 1], MAX_DRAW_DISTANCE);
    // update lane lines
    const auto lane_lines = model.getLaneLines();
    const auto lane_line_probs = model.getLaneLineProbs();
    for (int i = 0; i < std::size(scene.lane_line_vertices); i++) {
      scene.lane_line_probs[i] = lane_line_probs[i];
 
</s> remove     update_line_data(s, lane_lines[i], 0.025 * scene.lane_line_probs[i], 0, &scene.lane_line_vertices[i], max_distance);
 </s> add     update_line_data(s, lane_lines[i], 0.025 * scene.lane_line_probs[i], 0, &scene.lane_line_vertices[i], max_idx); </s> remove   int max_idx = -1;
 </s> add  </s> remove                              float y_off, float z_off, line_vertices_data *pvd, float max_distance) {
 </s> add                              float y_off, float z_off, line_vertices_data *pvd, int max_idx) { </s> remove   for (int i = 0; ((i < TRAJECTORY_SIZE) and (line_x[i] < fmax(MIN_DRAW_DISTANCE, max_distance))); i++) {
 </s> add   for (int i = 0; i <= max_idx; i++) { </s> remove     update_line_data(s, road_edges[i], 0.025, 0, &scene.road_edge_vertices[i], max_distance);
 </s> add     update_line_data(s, road_edges[i], 0.025, 0, &scene.road_edge_vertices[i], max_idx);
  auto model_position = model.getPosition();
  const float max_distance = std::clamp(model_position.getX()[TRAJECTORY_SIZE - 1],
                                        MIN_DRAW_DISTANCE, MAX_DRAW_DISTANCE);

  int max_idx = get_path_length_idx(model_position, max_distance);
  }
  
  static void update_model(UIState *s, const cereal::ModelDataV2::Reader &model) {
    UIScene &scene = s->scene;
  auto model_position = model.getPosition();
  const float max_distance = std::clamp(model_position.getX()[TRAJECTORY_SIZE - 1],
                                        MIN_DRAW_DISTANCE, MAX_DRAW_DISTANCE);

  int max_idx = get_path_length_idx(model_position, max_distance);
    // update lane lines
    const auto lane_lines = model.getLaneLines();
    const auto lane_line_probs = model.getLaneLineProbs();
    for (int i = 0; i < std::size(scene.lane_line_vertices); i++) {
      scene.lane_line_probs[i] = lane_line_probs[i];
keep keep keep keep replace keep keep keep keep keep
 ui/update_line_data: use max_idx as paramater instead of max_distance (#20256) 
selfdrive/ui/ui.cc