@ -15,10 +15,10 @@
// TODO: choose based on frame input size
// TODO: choose based on frame input size
# ifdef QCOM2
# ifdef QCOM2
const float y_offset = 150.0 ;
const float y_offset = 150.0 ;
const float zoom = 1.1 ;
const float zoom = 2912.8 ;
# else
# else
const float y_offset = 0.0 ;
const float y_offset = 0.0 ;
const float zoom = 2.3 5 ;
const float zoom = 2138. 5 ;
# endif
# endif
static void ui_draw_text ( const UIState * s , float x , float y , const char * string , float size , NVGcolor color , const char * font_name ) {
static void ui_draw_text ( const UIState * s , float x , float y , const char * string , float size , NVGcolor color , const char * font_name ) {
@ -83,7 +83,7 @@ static void draw_lead(UIState *s, int idx) {
fillAlpha = ( int ) ( fmin ( fillAlpha , 255 ) ) ;
fillAlpha = ( int ) ( fmin ( fillAlpha , 255 ) ) ;
}
}
float sz = std : : clamp ( ( 25 * 30 ) / ( d_rel / 3 + 30 ) , 15.0f , 30.0f ) * zoom ;
float sz = std : : clamp ( ( 25 * 30 ) / ( d_rel / 3 + 30 ) , 15.0f , 30.0f ) * s - > zoom ;
x = std : : clamp ( x , 0.f , s - > viz_rect . right ( ) - sz / 2 ) ;
x = std : : clamp ( x , 0.f , s - > viz_rect . right ( ) - sz / 2 ) ;
y = std : : fmin ( s - > viz_rect . bottom ( ) - sz * .6 , y ) ;
y = std : : fmin ( s - > viz_rect . bottom ( ) - sz * .6 , y ) ;
draw_chevron ( s , x , y , sz , nvgRGBA ( 201 , 34 , 49 , fillAlpha ) , COLOR_YELLOW ) ;
draw_chevron ( s , x , y , sz , nvgRGBA ( 201 , 34 , 49 , fillAlpha ) , COLOR_YELLOW ) ;
@ -312,7 +312,7 @@ static void ui_draw_vision_alert(UIState *s) {
. h = alr_h } ;
. h = alr_h } ;
ui_fill_rect ( s - > vg , rect , color ) ;
ui_fill_rect ( s - > vg , rect , color ) ;
ui_fill_rect ( s - > vg , rect , nvgLinearGradient ( s - > vg , rect . x , rect . y , rect . x , rect . bottom ( ) ,
ui_fill_rect ( s - > vg , rect , nvgLinearGradient ( s - > vg , rect . x , rect . y , rect . x , rect . bottom ( ) ,
nvgRGBAf ( 0.0 , 0.0 , 0.0 , 0.05 ) , nvgRGBAf ( 0.0 , 0.0 , 0.0 , 0.35 ) ) ) ;
nvgRGBAf ( 0.0 , 0.0 , 0.0 , 0.05 ) , nvgRGBAf ( 0.0 , 0.0 , 0.0 , 0.35 ) ) ) ;
nvgFillColor ( s - > vg , COLOR_WHITE ) ;
nvgFillColor ( s - > vg , COLOR_WHITE ) ;
@ -593,9 +593,17 @@ void ui_nvg_init(UIState *s) {
glBindVertexArray ( 0 ) ;
glBindVertexArray ( 0 ) ;
}
}
auto intrinsic_matrix = s - > wide_camera ? ecam_intrinsic_matrix : fcam_intrinsic_matrix ;
s - > zoom = zoom / intrinsic_matrix . v [ 0 ] ;
if ( s - > wide_camera ) {
s - > zoom * = 0.5 ;
}
s - > video_rect = Rect { bdr_s , bdr_s , s - > fb_w - 2 * bdr_s , s - > fb_h - 2 * bdr_s } ;
s - > video_rect = Rect { bdr_s , bdr_s , s - > fb_w - 2 * bdr_s , s - > fb_h - 2 * bdr_s } ;
float zx = zoom * 2 * fcam_intrinsic_matrix . v [ 2 ] / s - > video_rect . w ;
float zx = s - > zoom * 2 * intrinsic_matrix . v [ 2 ] / s - > video_rect . w ;
float zy = zoom * 2 * fcam_intrinsic_matrix . v [ 5 ] / s - > video_rect . h ;
float zy = s - > zoom * 2 * intrinsic_matrix . v [ 5 ] / s - > video_rect . h ;
const mat4 frame_transform = { {
const mat4 frame_transform = { {
zx , 0.0 , 0.0 , 0.0 ,
zx , 0.0 , 0.0 , 0.0 ,
@ -612,10 +620,10 @@ void ui_nvg_init(UIState *s) {
nvgTranslate ( s - > vg , s - > video_rect . x + s - > video_rect . w / 2 , s - > video_rect . y + s - > video_rect . h / 2 + y_offset ) ;
nvgTranslate ( s - > vg , s - > video_rect . x + s - > video_rect . w / 2 , s - > video_rect . y + s - > video_rect . h / 2 + y_offset ) ;
// 2) Apply same scaling as video
// 2) Apply same scaling as video
nvgScale ( s - > vg , zoom , zoom ) ;
nvgScale ( s - > vg , s - > zoom , s - > zoom ) ;
// 3) Put (0, 0) in top left corner of video
// 3) Put (0, 0) in top left corner of video
nvgTranslate ( s - > vg , - fcam_ intrinsic_matrix. v [ 2 ] , - fcam_ intrinsic_matrix. v [ 5 ] ) ;
nvgTranslate ( s - > vg , - intrinsic_matrix . v [ 2 ] , - intrinsic_matrix . v [ 5 ] ) ;
nvgCurrentTransform ( s - > vg , s - > car_space_transform ) ;
nvgCurrentTransform ( s - > vg , s - > car_space_transform ) ;
nvgResetTransform ( s - > vg ) ;
nvgResetTransform ( s - > vg ) ;