diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index d0b0425e8c..b577d78be8 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -128,20 +128,12 @@ static void draw_lead(UIState *s, const cereal::RadarState::LeadData::Reader &le } static void ui_draw_lane_line(UIState *s, const model_path_vertices_data *pvd, NVGcolor color) { + if (pvd->cnt == 0) return; + nvgBeginPath(s->vg); - bool started = false; - for (int i=0; icnt; i++) { - float x = pvd->v[i].x; - float y = pvd->v[i].y; - if (x < 0 || y < 0.) { - continue; - } - if (!started) { - nvgMoveTo(s->vg, x, y); - started = true; - } else { - nvgLineTo(s->vg, x, y); - } + nvgMoveTo(s->vg, pvd->v[0].x, pvd->v[0].y); + for (int i=1; icnt; i++) { + nvgLineTo(s->vg, pvd->v[i].x, pvd->v[i].y); } nvgClosePath(s->vg); nvgFillColor(s->vg, color); @@ -214,20 +206,12 @@ static void update_all_track_data(UIState *s) { static void ui_draw_track(UIState *s, bool is_mpc, track_vertices_data *pvd) { + if (pvd->cnt == 0) return; + nvgBeginPath(s->vg); - bool started = false; - for(int i = 0;i < pvd->cnt;i++) { - float x = pvd->v[i].x; - float y = pvd->v[i].y; - if (x < 0 || y < 0) { - continue; - } - if (!started) { - nvgMoveTo(s->vg, x, y); - started = true; - } else { - nvgLineTo(s->vg, x, y); - } + nvgMoveTo(s->vg, pvd->v[0].x, pvd->v[0].y); + for (int i=1; icnt; i++) { + nvgLineTo(s->vg, pvd->v[i].x, pvd->v[i].y); } nvgClosePath(s->vg);