wip
This commit is contained in:
@@ -853,51 +853,53 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
|
||||
QColor center_lane_color = bg_colors[CENTER_LANE_COLOR];
|
||||
QLinearGradient path_gradient(0, height(), 0, 0);
|
||||
|
||||
if (experimentalMode || scene.acceleration_path) {
|
||||
// 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_const = sm["uiPlan"].getUiPlan().getAccel();
|
||||
const int max_len = std::min<int>(scene.track_vertices.length() / 2, acceleration_const.size());
|
||||
if (edgeColor != bg_colors[STATUS_DISENGAGED]) {
|
||||
if (experimentalMode || scene.acceleration_path) {
|
||||
// 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_const = sm["uiPlan"].getUiPlan().getAccel();
|
||||
const int max_len = std::min<int>(scene.track_vertices.length() / 2, acceleration_const.size());
|
||||
|
||||
// Copy of the acceleration vector
|
||||
std::vector<float> acceleration;
|
||||
for (int i = 0; i < acceleration_const.size(); i++) {
|
||||
acceleration.push_back(acceleration_const[i]);
|
||||
}
|
||||
|
||||
try {
|
||||
for (int i = 0; i < max_len; ++i) {
|
||||
// Rewrote to generate color based off of bg_colors[CENTER_LANE_COLOR] constant
|
||||
if (scene.track_vertices[i].y() < 0 || scene.track_vertices[i].y() > height()) continue;
|
||||
|
||||
float lin_grad_point = (height() - scene.track_vertices[i].y()) / height();
|
||||
|
||||
double _h, _s, _l; // Use double for compatibility with QColor::getHslF()
|
||||
center_lane_color.getHslF(&_h, &_s, &_l);
|
||||
|
||||
// Calculate saturation and lightness based on acceleration
|
||||
float adjusted_saturation = std::min(std::abs(acceleration[i] * 1.5f), 1.f);
|
||||
float adjusted_lightness = util::map_val(adjusted_saturation, 0.f, 1.f, static_cast<float>(_l), 0.95f); // Using base lightness as a starting point
|
||||
|
||||
// Calculate dynamic alpha based on lin_grad_point
|
||||
float dynamic_alpha = util::map_val(lin_grad_point, 0.75f / 2.f, 0.75f, CENTER_LANE_ALPHA, 0.f);
|
||||
|
||||
QColor final_color = QColor::fromHslF(static_cast<float>(_h / 360.f), adjusted_saturation, adjusted_lightness, dynamic_alpha);
|
||||
path_gradient.setColorAt(lin_grad_point, final_color);
|
||||
|
||||
i += (i + 2) < max_len ? 1 : 0; // Skipping a point to optimize rendering
|
||||
// Copy of the acceleration vector
|
||||
std::vector<float> acceleration;
|
||||
for (int i = 0; i < acceleration_const.size(); i++) {
|
||||
acceleration.push_back(acceleration_const[i]);
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
// Default shading if for some reason the above code fails
|
||||
path_gradient = QLinearGradient(0, height(), 0, 0);
|
||||
|
||||
try {
|
||||
for (int i = 0; i < max_len; ++i) {
|
||||
// Rewrote to generate color based off of bg_colors[CENTER_LANE_COLOR] constant
|
||||
if (scene.track_vertices[i].y() < 0 || scene.track_vertices[i].y() > height()) continue;
|
||||
|
||||
float lin_grad_point = (height() - scene.track_vertices[i].y()) / height();
|
||||
|
||||
double _h, _s, _l; // Use double for compatibility with QColor::getHslF()
|
||||
center_lane_color.getHslF(&_h, &_s, &_l);
|
||||
|
||||
// Calculate saturation and lightness based on acceleration
|
||||
float adjusted_saturation = std::min(std::abs(acceleration[i] * 1.5f), 1.f);
|
||||
float adjusted_lightness = util::map_val(adjusted_saturation, 0.f, 1.f, static_cast<float>(_l), 0.95f); // Using base lightness as a starting point
|
||||
|
||||
// Calculate dynamic alpha based on lin_grad_point
|
||||
float dynamic_alpha = util::map_val(lin_grad_point, 0.75f / 2.f, 0.75f, CENTER_LANE_ALPHA, 0.f);
|
||||
|
||||
QColor final_color = QColor::fromHslF(static_cast<float>(_h / 360.f), adjusted_saturation, adjusted_lightness, dynamic_alpha);
|
||||
path_gradient.setColorAt(lin_grad_point, final_color);
|
||||
|
||||
i += (i + 2) < max_len ? 1 : 0; // Skipping a point to optimize rendering
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
// Default shading if for some reason the above code fails
|
||||
path_gradient = QLinearGradient(0, height(), 0, 0);
|
||||
path_gradient.setColorAt(0.0, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(CENTER_LANE_ALPHA * 255 * 0.5)));
|
||||
path_gradient.setColorAt(0.5, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(CENTER_LANE_ALPHA * 255 * 0.4)));
|
||||
path_gradient.setColorAt(1.0, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(CENTER_LANE_ALPHA * 255 * 0.0)));
|
||||
}
|
||||
} else {
|
||||
path_gradient.setColorAt(0.0, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(CENTER_LANE_ALPHA * 255 * 0.5)));
|
||||
path_gradient.setColorAt(0.5, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(CENTER_LANE_ALPHA * 255 * 0.4)));
|
||||
path_gradient.setColorAt(1.0, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(CENTER_LANE_ALPHA * 255 * 0.0)));
|
||||
}
|
||||
} else {
|
||||
path_gradient.setColorAt(0.0, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(CENTER_LANE_ALPHA * 255 * 0.5)));
|
||||
path_gradient.setColorAt(0.5, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(CENTER_LANE_ALPHA * 255 * 0.4)));
|
||||
path_gradient.setColorAt(1.0, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(CENTER_LANE_ALPHA * 255 * 0.0)));
|
||||
}
|
||||
|
||||
painter.setBrush(path_gradient);
|
||||
|
||||
Reference in New Issue
Block a user