    }
    return max_idx;
  }
  
  static void update_leads(UIState *s, const cereal::RadarState::Reader &radar_state, const cereal::ModelDataV2::XYZTData::Reader &line) {
    for (int i = 0; i < 2; ++i) {
      auto lead_data = (i == 0) ? radar_state.getLeadOne() : radar_state.getLeadTwo();
      if (lead_data.getStatus()) {
        float z = line.getZ()[get_path_length_idx(line, lead_data.getDRel())];
        calib_frame_to_full_frame(s, lead_data.getDRel(), -lead_data.getYRel(), z + 1.22, &s->scene.lead_vertices[i]);
 
</s> remove static int get_path_length_idx(const cereal::ModelDataV2::XYZTData::Reader &line, const float path_height) {
 </s> add int get_path_length_idx(const cereal::ModelDataV2::XYZTData::Reader &line, const float path_height) { </s> remove static void update_line_data(const UIState *s, const cereal::ModelDataV2::XYZTData::Reader &line,
 </s> add void update_line_data(const UIState *s, const cereal::ModelDataV2::XYZTData::Reader &line, </s> remove static void update_model(UIState *s, const cereal::ModelDataV2::Reader &model) {
 </s> add void update_model(UIState *s, const cereal::ModelDataV2::Reader &model) { </s> remove   }
  if (s->worldObjectsVisible()) {
    if (sm.updated("modelV2")) {
      update_model(s, sm["modelV2"].getModelV2());
    }
    if (sm.updated("radarState") && sm.rcv_frame("modelV2") > s->scene.started_frame) {
      update_leads(s, sm["radarState"].getRadarState(), sm["modelV2"].getModelV2().getPosition());
    }
 </s> add     scene.calibration_wide_valid = wfde_list.size() == 3;
void update_leads(UIState *s, const cereal::RadarState::Reader &radar_state, const cereal::ModelDataV2::XYZTData::Reader &line) {
    }
    return max_idx;
  }
  
void update_leads(UIState *s, const cereal::RadarState::Reader &radar_state, const cereal::ModelDataV2::XYZTData::Reader &line) {
    for (int i = 0; i < 2; ++i) {
      auto lead_data = (i == 0) ? radar_state.getLeadOne() : radar_state.getLeadTwo();
      if (lead_data.getStatus()) {
        float z = line.getZ()[get_path_length_idx(line, lead_data.getDRel())];
        calib_frame_to_full_frame(s, lead_data.getDRel(), -lead_data.getYRel(), z + 1.22, &s->scene.lead_vertices[i]);
keep keep keep keep replace keep keep keep keep keep
 UI: draw onroad objects on right frame (#26306)

* update before draw

* fix a lot of janky

* fix more flicker

* cleanup

* fix flicker when opening settings

* simplify 
selfdrive/ui/ui.cc