mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-03-02 13:43:53 +08:00
paint.cc car_space_to_full_frame less paramaters (#19676)
This commit is contained in:
@@ -41,7 +41,7 @@ const mat3 intrinsic_matrix = (mat3){{
|
||||
|
||||
// Projects a point in car to space to the corresponding point in full frame
|
||||
// image space.
|
||||
bool car_space_to_full_frame(const UIState *s, float in_x, float in_y, float in_z, float *out_x, float *out_y, float margin) {
|
||||
bool car_space_to_full_frame(const UIState *s, float in_x, float in_y, float in_z, vertex_data *out, float margin) {
|
||||
const vec4 car_space_projective = (vec4){{in_x, in_y, in_z, 1.}};
|
||||
// We'll call the car space point p.
|
||||
// First project into normalized image coordinates with the extrinsics matrix.
|
||||
@@ -52,10 +52,10 @@ bool car_space_to_full_frame(const UIState *s, float in_x, float in_y, float in_
|
||||
const vec3 KEp = matvecmul3(intrinsic_matrix, Ep);
|
||||
|
||||
// Project.
|
||||
*out_x = KEp.v[0] / KEp.v[2];
|
||||
*out_y = KEp.v[1] / KEp.v[2];
|
||||
out->x = KEp.v[0] / KEp.v[2];
|
||||
out->y = KEp.v[1] / KEp.v[2];
|
||||
|
||||
return *out_x >= -margin && *out_x <= s->fb_w + margin && *out_y >= -margin && *out_y <= s->fb_h + margin;
|
||||
return out->x >= -margin && out->x <= s->fb_w + margin && out->y >= -margin && out->y <= s->fb_h + margin;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,11 +68,10 @@ static void ui_draw_text(NVGcontext *vg, float x, float y, const char* string, f
|
||||
|
||||
static void draw_chevron(UIState *s, float x_in, float y_in, float sz,
|
||||
NVGcolor fillColor, NVGcolor glowColor) {
|
||||
float x, y;
|
||||
if (!car_space_to_full_frame(s, x_in, y_in, 0.0, &x, &y)) {
|
||||
return;
|
||||
}
|
||||
vertex_data out;
|
||||
if (!car_space_to_full_frame(s, x_in, y_in, 0.0, &out)) return;
|
||||
|
||||
auto [x, y] = out;
|
||||
sz = std::clamp((sz * 30) / (x_in / 3 + 30), 15.0f, 30.0f);
|
||||
|
||||
// glow
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "ui.hpp"
|
||||
|
||||
bool car_space_to_full_frame(const UIState *s, float in_x, float in_y, float in_z, float *out_x, float *out_y, float margin=0.0);
|
||||
bool car_space_to_full_frame(const UIState *s, float in_x, float in_y, float in_z, vertex_data *out, float margin=0.0);
|
||||
void ui_draw(UIState *s);
|
||||
void ui_draw_image(NVGcontext *vg, const Rect &r, int image, float alpha);
|
||||
void ui_draw_rect(NVGcontext *vg, float x, float y, float w, float h, NVGcolor color, float r = 0, int width = 0);
|
||||
|
||||
@@ -113,11 +113,11 @@ static void update_line_data(const UIState *s, const cereal::ModelDataV2::XYZTDa
|
||||
vertex_data *v = &pvd->v[0];
|
||||
const float margin = 500.0f;
|
||||
for (int i = 0; ((i < TRAJECTORY_SIZE) and (line_x[i] < fmax(MIN_DRAW_DISTANCE, max_distance))); i++) {
|
||||
v += car_space_to_full_frame(s, line_x[i], -line_y[i] - y_off, -line_z[i] + z_off, &v->x, &v->y, margin);
|
||||
v += car_space_to_full_frame(s, line_x[i], -line_y[i] - y_off, -line_z[i] + z_off, v, margin);
|
||||
max_idx = i;
|
||||
}
|
||||
for (int i = max_idx; i >= 0; i--) {
|
||||
v += car_space_to_full_frame(s, line_x[i], -line_y[i] + y_off, -line_z[i] + z_off, &v->x, &v->y, margin);
|
||||
v += car_space_to_full_frame(s, line_x[i], -line_y[i] + y_off, -line_z[i] + z_off, v, margin);
|
||||
}
|
||||
pvd->cnt = v - pvd->v;
|
||||
assert(pvd->cnt < std::size(pvd->v));
|
||||
|
||||
Reference in New Issue
Block a user