VisualStyleBlendThreshold

This commit is contained in:
royjr
2025-09-21 12:48:32 -04:00
parent c61f327076
commit 54ca4b537d
4 changed files with 22 additions and 4 deletions
+1
View File
@@ -164,6 +164,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"StandstillTimer", {PERSISTENT | BACKUP, BOOL, "0"}},
{"VisualStyle", {PERSISTENT | BACKUP, INT, "0"}},
{"VisualStyleBlend", {PERSISTENT | BACKUP, BOOL, "0"}},
{"VisualStyleBlendThreshold", {PERSISTENT | BACKUP, INT, "20"}},
// MADS params
{"Mads", {PERSISTENT | BACKUP, BOOL, "1"}},
+3 -2
View File
@@ -518,6 +518,7 @@ bool ModelRenderer::mapToScreen(float in_x, float in_y, float in_z, QPointF *out
int visual_style = QString::fromStdString(Params().get("VisualStyle")).toInt();
int visual_blend = QString::fromStdString(Params().get("VisualStyleBlend")).toInt();
float visual_blend_threshold = QString::fromStdString(Params().get("VisualStyleBlendThreshold")).toFloat();
// Force top-down if VisualStyle == 3
if (visual_style == 3) {
@@ -532,9 +533,9 @@ bool ModelRenderer::mapToScreen(float in_x, float in_y, float in_z, QPointF *out
static double last_t = millis_since_boot();
// Hysteresis logic
if (target_blend < 0.5f && blend_speed_mph > 50.0f) {
if (target_blend < 0.5f && blend_speed_mph > visual_blend_threshold) {
target_blend = 1.0f; // switch to 2D
} else if (target_blend > 0.5f && blend_speed_mph < 45.0f) {
} else if (target_blend > 0.5f && blend_speed_mph < (visual_blend_threshold - 5)) {
target_blend = 0.0f; // switch back to 3D
}
@@ -44,8 +44,8 @@ VisualsPanel::VisualsPanel(QWidget *parent) : QWidget(parent) {
},
{
"VisualStyleBlend",
tr("Morph to Overhead Visual Style"),
tr("Morphing to Overhead view when using Minimal/Vision visual style."),
tr("Blend to Overhead Visual Style"),
tr("Blend to Overhead view when using Minimal/Vision visual style."),
"../assets/offroad/icon_monitoring.png",
false,
},
@@ -75,6 +75,21 @@ VisualsPanel::VisualsPanel(QWidget *parent) : QWidget(parent) {
param_watcher->addParam(param);
}
// Visuals: VisualStyleBlend Threshold
visual_style_threshold_settings = new OptionControlSP("VisualStyleBlendThreshold", tr("Adjust Visual Style Blend Threshold"),
tr("Adjust the threshold when Visual Style Blend activates."),
"", {10, 40}, 5, false, nullptr, false);
connect(visual_style_threshold_settings, &OptionControlSP::updateLabels, [=]() {
int value = QString::fromStdString(params.get("VisualStyleBlendThreshold")).toInt();
visual_style_threshold_settings->setLabel(QString::number(value) + " mph");
});
int value = QString::fromStdString(params.get("VisualStyleBlendThreshold")).toInt();
visual_style_threshold_settings->setLabel(QString::number(value) + " mph");
list->addItem(visual_style_threshold_settings);
// Visuals: Visual Style
std::vector<QString> visual_style_settings_texts{tr("Default"), tr("Minimal"), tr("Vision"), tr("Overhead")};
visual_style_settings = new ButtonParamControlSP(
@@ -30,4 +30,5 @@ protected:
ButtonParamControlSP *chevron_info_settings;
ButtonParamControlSP *dev_ui_settings;
ButtonParamControlSP *visual_style_settings;
OptionControlSP *visual_style_threshold_settings;
};