|
|
|
@ -32,14 +32,6 @@ const mat3 intrinsic_matrix = (mat3){{ |
|
|
|
|
}}; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
const uint8_t alert_colors[][4] = { |
|
|
|
|
[STATUS_OFFROAD] = {0x07, 0x23, 0x39, 0xf1}, |
|
|
|
|
[STATUS_DISENGAGED] = {0x17, 0x33, 0x49, 0xc8}, |
|
|
|
|
[STATUS_ENGAGED] = {0x17, 0x86, 0x44, 0xf1}, |
|
|
|
|
[STATUS_WARNING] = {0xDA, 0x6F, 0x25, 0xf1}, |
|
|
|
|
[STATUS_ALERT] = {0xC9, 0x22, 0x31, 0xf1}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Projects a point in car to space to the corresponding point in full frame
|
|
|
|
|
// image space.
|
|
|
|
|
vec3 car_space_to_full_frame(const UIState *s, vec4 car_space_projective) { |
|
|
|
@ -233,7 +225,7 @@ static void ui_draw_track(UIState *s, bool is_mpc, track_vertices_data *pvd) { |
|
|
|
|
NVGpaint track_bg; |
|
|
|
|
if (is_mpc) { |
|
|
|
|
// Draw colored MPC track
|
|
|
|
|
const Color clr = bg_colors[s->status]; |
|
|
|
|
const NVGcolor clr = bg_colors[s->status]; |
|
|
|
|
track_bg = nvgLinearGradient(s->vg, s->fb_w, s->fb_h, s->fb_w, s->fb_h*.4, |
|
|
|
|
nvgRGBA(clr.r, clr.g, clr.b, 255), nvgRGBA(clr.r, clr.g, clr.b, 255/2)); |
|
|
|
|
} else { |
|
|
|
@ -443,25 +435,16 @@ static void ui_draw_vision_event(UIState *s) { |
|
|
|
|
// draw winding road sign
|
|
|
|
|
const int img_turn_size = 160*1.5; |
|
|
|
|
ui_draw_image(s->vg, viz_event_x - (img_turn_size / 4), viz_event_y + bdr_s - 25, img_turn_size, img_turn_size, s->img_turn, 1.0f); |
|
|
|
|
} else { |
|
|
|
|
} else if (s->scene.controls_state.getEngageable()) { |
|
|
|
|
// draw steering wheel
|
|
|
|
|
const int bg_wheel_size = 96; |
|
|
|
|
const int bg_wheel_x = viz_event_x + (viz_event_w-bg_wheel_size); |
|
|
|
|
const int bg_wheel_y = viz_event_y + (bg_wheel_size/2); |
|
|
|
|
NVGcolor color = COLOR_BLACK_ALPHA(0); |
|
|
|
|
if (s->status == STATUS_ENGAGED) { |
|
|
|
|
color = nvgRGBA(23, 134, 68, 255); |
|
|
|
|
} else if (s->status == STATUS_WARNING) { |
|
|
|
|
color = COLOR_OCHRE; |
|
|
|
|
} else { |
|
|
|
|
color = nvgRGBA(23, 51, 73, 255); |
|
|
|
|
} |
|
|
|
|
const NVGcolor color = bg_colors[s->status]; |
|
|
|
|
|
|
|
|
|
if (s->scene.controls_state.getEngageable()){ |
|
|
|
|
ui_draw_circle_image(s->vg, bg_wheel_x, bg_wheel_y, bg_wheel_size, s->img_wheel, color, 1.0f, bg_wheel_y - 25); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void ui_draw_vision_face(UIState *s) { |
|
|
|
|
const int face_size = 96; |
|
|
|
@ -541,7 +524,7 @@ static void ui_draw_vision_footer(UIState *s) { |
|
|
|
|
ui_draw_vision_face(s); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ui_draw_vision_alert(UIState *s, cereal::ControlsState::AlertSize va_size, int va_color, |
|
|
|
|
void ui_draw_vision_alert(UIState *s, cereal::ControlsState::AlertSize va_size, UIStatus va_color, |
|
|
|
|
const char* va_text1, const char* va_text2) { |
|
|
|
|
static std::map<cereal::ControlsState::AlertSize, const int> alert_size_map = { |
|
|
|
|
{cereal::ControlsState::AlertSize::NONE, 0}, |
|
|
|
@ -552,7 +535,8 @@ void ui_draw_vision_alert(UIState *s, cereal::ControlsState::AlertSize va_size, |
|
|
|
|
const UIScene *scene = &s->scene; |
|
|
|
|
bool longAlert1 = strlen(va_text1) > 15; |
|
|
|
|
|
|
|
|
|
const uint8_t *color = alert_colors[va_color]; |
|
|
|
|
NVGcolor color = bg_colors[va_color]; |
|
|
|
|
color.a *= s->alert_blinking_alpha; |
|
|
|
|
int alr_s = alert_size_map[va_size]; |
|
|
|
|
|
|
|
|
|
const int alr_x = scene->viz_rect.x - bdr_s; |
|
|
|
@ -560,7 +544,7 @@ void ui_draw_vision_alert(UIState *s, cereal::ControlsState::AlertSize va_size, |
|
|
|
|
const int alr_h = alr_s+(va_size==cereal::ControlsState::AlertSize::NONE?0:bdr_s); |
|
|
|
|
const int alr_y = s->fb_h-alr_h; |
|
|
|
|
|
|
|
|
|
ui_draw_rect(s->vg, alr_x, alr_y, alr_w, alr_h, nvgRGBA(color[0],color[1],color[2],(color[3]*s->alert_blinking_alpha))); |
|
|
|
|
ui_draw_rect(s->vg, alr_x, alr_y, alr_w, alr_h, color); |
|
|
|
|
|
|
|
|
|
NVGpaint gradient = nvgLinearGradient(s->vg, alr_x, alr_y, alr_x, alr_y+alr_h, |
|
|
|
|
nvgRGBAf(0.0,0.0,0.0,0.05), nvgRGBAf(0.0,0.0,0.0,0.35)); |
|
|
|
@ -589,6 +573,7 @@ void ui_draw_vision_alert(UIState *s, cereal::ControlsState::AlertSize va_size, |
|
|
|
|
static void ui_draw_vision(UIState *s) { |
|
|
|
|
const UIScene *scene = &s->scene; |
|
|
|
|
const Rect &viz_rect = scene->viz_rect; |
|
|
|
|
|
|
|
|
|
// Draw video frames
|
|
|
|
|
glEnable(GL_SCISSOR_TEST); |
|
|
|
|
glViewport(viz_rect.x+scene->ui_viz_ro, viz_rect.y, s->fb_w - bdr_s*2, viz_rect.h); |
|
|
|
@ -618,8 +603,8 @@ static void ui_draw_vision(UIState *s) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void ui_draw_background(UIState *s) { |
|
|
|
|
const Color color = bg_colors[s->status]; |
|
|
|
|
glClearColor(color.r/256.0, color.g/256.0, color.b/256.0, 1.0); |
|
|
|
|
const NVGcolor color = bg_colors[s->status]; |
|
|
|
|
glClearColor(color.r, color.g, color.b, 1.0); |
|
|
|
|
glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|