      pvd->cnt += 1;
    }
  }
  
  static void update_all_lane_lines_data(UIState *s, const PathData &path, model_path_vertices_data *pstart) {
    update_lane_line_data(s, path.points, 0.025*path.prob, pstart, path.validLen);
    float var = fmin(path.std, 0.7);
    update_lane_line_data(s, path.points, var, pstart + 1, path.validLen);
  }
  
  static void ui_draw_lane(UIState *s, const PathData *path, model_path_vertices_data *pstart, NVGcolor color) {
    ui_draw_lane_line(s, pstart, color);
    color.a /= 25;
 
</s> remove static void ui_draw_lane(UIState *s, const PathData *path, model_path_vertices_data *pstart, NVGcolor color) {
 </s> add static void ui_draw_lane(UIState *s,  model_path_vertices_data *pstart, NVGcolor color) { </s> remove     update_all_lane_lines_data(s, scene->model.left_lane, pvd);
    update_all_lane_lines_data(s, scene->model.right_lane, pvd + MODEL_LANE_PATH_CNT);
 </s> add     update_all_lane_lines_data(s, scene->model.getLeftLane(), scene->left_lane_points, pvd);
    update_all_lane_lines_data(s, scene->model.getRightLane(), scene->right_lane_points, pvd + MODEL_LANE_PATH_CNT); </s> remove static void read_path(PathData& p, const cereal::ModelData::PathData::Reader &pathp) {
  p = {};

  p.prob = pathp.getProb();
  p.std = pathp.getStd();

  auto polyp = pathp.getPoly();
  for (int i = 0; i < POLYFIT_DEGREE; i++) {
    p.poly[i] = polyp[i];
  }

  // Compute points locations
  for (int i = 0; i < MODEL_PATH_DISTANCE; i++) {
    p.points[i] = p.poly[0] * (i*i*i) + p.poly[1] * (i*i)+ p.poly[2] * i + p.poly[3];
  }

  p.validLen = pathp.getValidLen();
}

static void read_model(ModelData &d, const cereal::ModelData::Reader &model) {
  d = {};
  read_path(d.path, model.getPath());
  read_path(d.left_lane, model.getLeftLane());
  read_path(d.right_lane, model.getRightLane());
  auto leadd = model.getLead();
  d.lead = (LeadData){
      .dist = leadd.getDist(), .prob = leadd.getProb(), .std = leadd.getStd(),
  };
}

 </s> add  </s> remove 
typedef struct PathData {
  float points[MODEL_PATH_DISTANCE];
  float prob;
  float std;
  float stds[MODEL_PATH_DISTANCE];
  float poly[POLYFIT_DEGREE];
  float validLen;
} PathData;

typedef struct LeadData {
  float dist;
  float prob;
  float std;
  float rel_y;
  float rel_y_std;
  float rel_v;
  float rel_v_std;
  float rel_a;
  float rel_a_std;
} LeadData;

typedef struct ModelData {
  PathData path;
  PathData left_lane;
  PathData right_lane;
  LeadData lead;
  LeadData lead_future;
  float meta[OTHER_META_SIZE + DESIRE_PRED_SIZE];
  float speed[SPEED_PERCENTILES];
} ModelData;

#endif
 </s> add 
static void update_all_lane_lines_data(UIState *s, const cereal::ModelData::PathData::Reader &path, const float *points, model_path_vertices_data *pstart) {
  update_lane_line_data(s, points, 0.025*path.getProb(), pstart, path.getValidLen());
  update_lane_line_data(s, points, fmin(path.getStd(), 0.7), pstart + 1, path.getValidLen());
      pvd->cnt += 1;
    }
  }
  
static void update_all_lane_lines_data(UIState *s, const cereal::ModelData::PathData::Reader &path, const float *points, model_path_vertices_data *pstart) {
  update_lane_line_data(s, points, 0.025*path.getProb(), pstart, path.getValidLen());
  update_lane_line_data(s, points, fmin(path.getStd(), 0.7), pstart + 1, path.getValidLen());
static void update_all_lane_lines_data(UIState *s, const cereal::ModelData::PathData::Reader &path, const float *points, model_path_vertices_data *pstart) {
  update_lane_line_data(s, points, 0.025*path.getProb(), pstart, path.getValidLen());
  update_lane_line_data(s, points, fmin(path.getStd(), 0.7), pstart + 1, path.getValidLen());
static void update_all_lane_lines_data(UIState *s, const cereal::ModelData::PathData::Reader &path, const float *points, model_path_vertices_data *pstart) {
  update_lane_line_data(s, points, 0.025*path.getProb(), pstart, path.getValidLen());
  update_lane_line_data(s, points, fmin(path.getStd(), 0.7), pstart + 1, path.getValidLen());
static void update_all_lane_lines_data(UIState *s, const cereal::ModelData::PathData::Reader &path, const float *points, model_path_vertices_data *pstart) {
  update_lane_line_data(s, points, 0.025*path.getProb(), pstart, path.getValidLen());
  update_lane_line_data(s, points, fmin(path.getStd(), 0.7), pstart + 1, path.getValidLen());
  }
  
  static void ui_draw_lane(UIState *s, const PathData *path, model_path_vertices_data *pstart, NVGcolor color) {
    ui_draw_lane_line(s, pstart, color);
    color.a /= 25;
keep keep keep keep replace replace replace replace keep keep keep keep keep
 ui: refactor model related functions (#2026)

* remove read_model

* remove structs for c-capnp

* remove duplicate #define from modeld

* add function fill_path_points

* fix Indentation

* use MODEL_PATH_DISTANCE instead of 192

* fix type

use validLen

* rename left_path_points&right_path_points to xxx_lane_points 
selfdrive/ui/paint.cc