mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-03-01 14:23:53 +08:00
ui: more granular accel gradient in experimental mode (#27391)
* add accel * debugging * use uiPlan for acceleration * draw on same frame, ui color enhancements * adjustments * not needed * add back alerts and wide cam * use linear accel -> saturation (red -> green transition is more gradual, should be easier to understand) * 1.5x was good from the non-linear previous commit * fix crash? * revert draw on same frame * bump lightness add lightness mod with comment for future use (reverting in next commit) * revert (but keep lightness bump) * max accel isn't blueish (#3DFF3D) * clean up * revert lightness * remove experiment * try a different domain * doesn't work This reverts commit 7a398b03920d6d2d2c804d1290803bc533051fc1. * clean that up * actually should be 0.75 * some clean up * debug timing * fix * debug * round * revert wide * not used * clean up * remove slow qDebug * this too * draw max constant points, ensure we draw first and last * clean up * more clean up * draft * Revert "draft" This reverts commit 59db097611dc633f397c509bf95490eb0614b7f0. * Revert "Revert "draft"" This reverts commit ee86c385b39dbe36430effd58fc5c41ede51f9f0. * simplify * clean that up * and all that * and more * aaaand that * aaaand that * track vert is created in update_line_data, it us the sum of two equal len lists * keep debugging stuff around * keep debugging stuff around * remove prints * rm that * moreee * use existing helper 😄 * clean up * make it const * F --------- Co-authored-by: Bruce Wayne <harald.the.engineer@gmail.com> Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
This commit is contained in:
@@ -511,24 +511,34 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
|
||||
}
|
||||
|
||||
// paint path
|
||||
QLinearGradient bg(0, height(), 0, height() / 4);
|
||||
float start_hue, end_hue;
|
||||
QLinearGradient bg(0, height(), 0, 0);
|
||||
if (sm["controlsState"].getControlsState().getExperimentalMode()) {
|
||||
const auto &acceleration = sm["modelV2"].getModelV2().getAcceleration();
|
||||
float acceleration_future = 0;
|
||||
if (acceleration.getZ().size() > 16) {
|
||||
acceleration_future = acceleration.getX()[16]; // 2.5 seconds
|
||||
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;
|
||||
|
||||
// Some points are out of frame
|
||||
if (right_points[i].y() < 0 || right_points[i].y() > height()) continue;
|
||||
|
||||
// Flip so 0 is bottom of frame
|
||||
float lin_grad_point = (height() - right_points[i].y()) / height();
|
||||
|
||||
// speed up: 120, slow down: 0
|
||||
float path_hue = fmax(fmin(60 + acceleration[i] * 35, 120), 0);
|
||||
// FIXME: painter.drawPolygon can be slow if hue is not rounded
|
||||
path_hue = int(path_hue * 100 + 0.5) / 100;
|
||||
|
||||
float saturation = fmin(fabs(acceleration[i] * 1.5), 1);
|
||||
float lightness = util::map_val(saturation, 0.0f, 1.0f, 0.95f, 0.62f); // lighter when grey
|
||||
float alpha = util::map_val(lin_grad_point, 0.75f / 2.f, 0.75f, 0.4f, 0.0f); // matches previous alpha fade
|
||||
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;
|
||||
}
|
||||
start_hue = 60;
|
||||
// speed up: 120, slow down: 0
|
||||
end_hue = fmax(fmin(start_hue + acceleration_future * 45, 148), 0);
|
||||
|
||||
// FIXME: painter.drawPolygon can be slow if hue is not rounded
|
||||
end_hue = int(end_hue * 100 + 0.5) / 100;
|
||||
|
||||
bg.setColorAt(0.0, QColor::fromHslF(start_hue / 360., 0.97, 0.56, 0.4));
|
||||
bg.setColorAt(0.5, QColor::fromHslF(end_hue / 360., 1.0, 0.68, 0.35));
|
||||
bg.setColorAt(1.0, QColor::fromHslF(end_hue / 360., 1.0, 0.68, 0.0));
|
||||
} else {
|
||||
bg.setColorAt(0.0, QColor::fromHslF(148 / 360., 0.94, 0.51, 0.4));
|
||||
bg.setColorAt(0.5, QColor::fromHslF(112 / 360., 1.0, 0.68, 0.35));
|
||||
|
||||
Reference in New Issue
Block a user