mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-24 23:42:05 +08:00
ui/drawLaneLines: read the accel from the submaster outside of the loop (#28145)
* read the accel from the submaster outside of the loop. * const max_idx * remove data copy and converting from list to vector * correct name is len * fix drawing last point * add comment, remove right_points * fix --------- Co-authored-by: Shane Smiskol <shane@smiskol.com>
This commit is contained in:
@@ -513,17 +513,17 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
|
||||
// paint path
|
||||
QLinearGradient bg(0, height(), 0, 0);
|
||||
if (sm["controlsState"].getControlsState().getExperimentalMode()) {
|
||||
const QVector<QPointF> right_points = scene.track_vertices.mid(0, scene.track_vertices.length() / 2);
|
||||
|
||||
for (int i = 0; i < right_points.length(); i++) {
|
||||
const auto &acceleration = sm["uiPlan"].getUiPlan().getAccel();
|
||||
if (i >= acceleration.size()) break;
|
||||
// The first half of track_vertices are the points for the right side of the path
|
||||
// and the indices match the positions of accel from uiPlan
|
||||
const auto &acceleration = sm["uiPlan"].getUiPlan().getAccel();
|
||||
const int max_len = std::min<int>(scene.track_vertices.length() / 2, acceleration.size());
|
||||
|
||||
for (int i = 0; i < max_len; ++i) {
|
||||
// Some points are out of frame
|
||||
if (right_points[i].y() < 0 || right_points[i].y() > height()) continue;
|
||||
if (scene.track_vertices[i].y() < 0 || scene.track_vertices[i].y() > height()) continue;
|
||||
|
||||
// Flip so 0 is bottom of frame
|
||||
float lin_grad_point = (height() - right_points[i].y()) / height();
|
||||
float lin_grad_point = (height() - scene.track_vertices[i].y()) / height();
|
||||
|
||||
// speed up: 120, slow down: 0
|
||||
float path_hue = fmax(fmin(60 + acceleration[i] * 35, 120), 0);
|
||||
@@ -536,7 +536,7 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
|
||||
bg.setColorAt(lin_grad_point, QColor::fromHslF(path_hue / 360., saturation, lightness, alpha));
|
||||
|
||||
// Skip a point, unless next is last
|
||||
i += (i + 2) < right_points.length() ? 1 : 0;
|
||||
i += (i + 2) < max_len ? 1 : 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user