mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-08 12:55:44 +08:00
3D Building on Map (#308)
* ui: 3D buildings on map * add toggle * toggleable offroad only * fixes * Revert "toggleable offroad only" This reverts commit 7c0c8d99bca3bbec00921c2d438e68b5f9054393.
This commit is contained in:
@@ -263,6 +263,7 @@ std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"MadsCruiseMain", PERSISTENT},
|
||||
{"MadsIconToggle", PERSISTENT},
|
||||
{"MapboxFullScreen", PERSISTENT},
|
||||
{"Map3DBuildings", PERSISTENT},
|
||||
{"MaxTimeOffroad", PERSISTENT},
|
||||
{"OnroadScreenOff", PERSISTENT},
|
||||
{"OnroadScreenOffBrightness", PERSISTENT},
|
||||
|
||||
@@ -112,6 +112,49 @@ void MapWindow::initLayers() {
|
||||
// TODO: remove, symbol-sort-key does not seem to matter outside of each layer
|
||||
m_map->setLayoutProperty("carPosLayer", "symbol-sort-key", 0);
|
||||
}
|
||||
if ((!m_map->layerExists("buildingsLayer")) && uiState()->scene.map_3d_buildings) { // Could put this behind the cellular metered toggle in case it increases data usage
|
||||
qDebug() << "Initializing buildingsLayer";
|
||||
QVariantMap buildings;
|
||||
buildings["id"] = "buildingsLayer";
|
||||
buildings["source"] = "composite";
|
||||
buildings["source-layer"] = "building";
|
||||
buildings["type"] = "fill-extrusion";
|
||||
buildings["minzoom"] = 15;
|
||||
m_map->addLayer(buildings);
|
||||
m_map->setFilter("buildingsLayer", QVariantList({"==", "extrude", "true"}));
|
||||
|
||||
QVariantList fillExtrusionHeight = { // scale buildings as you zoom in
|
||||
"interpolate",
|
||||
QVariantList{"linear"},
|
||||
QVariantList{"zoom"},
|
||||
15, 0,
|
||||
15.05, QVariantList{"get", "height"}
|
||||
};
|
||||
|
||||
QVariantList fillExtrusionBase = {
|
||||
"interpolate",
|
||||
QVariantList{"linear"},
|
||||
QVariantList{"zoom"},
|
||||
15, 0,
|
||||
15.05, QVariantList{"get", "min_height"}
|
||||
};
|
||||
|
||||
QVariantList fillExtrusionOpacity = {
|
||||
"interpolate",
|
||||
QVariantList{"linear"},
|
||||
QVariantList{"zoom"},
|
||||
15, 0, // transparent at zoom level 15
|
||||
15.5, .6, // fade in
|
||||
17, .6, // begin fading out
|
||||
20, 0 // fade out when zoomed in
|
||||
};
|
||||
|
||||
m_map->setPaintProperty("buildingsLayer", "fill-extrusion-color", QColor("grey"));
|
||||
m_map->setPaintProperty("buildingsLayer", "fill-extrusion-opacity", fillExtrusionOpacity);
|
||||
m_map->setPaintProperty("buildingsLayer", "fill-extrusion-height", fillExtrusionHeight);
|
||||
m_map->setPaintProperty("buildingsLayer", "fill-extrusion-base", fillExtrusionBase);
|
||||
m_map->setLayoutProperty("buildingsLayer", "visibility", "visible");
|
||||
}
|
||||
}
|
||||
|
||||
void MapWindow::updateState(const UIState &s) {
|
||||
|
||||
@@ -668,6 +668,12 @@ SPVisualsPanel::SPVisualsPanel(QWidget *parent) : ListWidget(parent) {
|
||||
tr("Enable this will display an icon that appears when the End-to-end model decides to start or stop."),
|
||||
"../assets/offroad/icon_road.png",
|
||||
},
|
||||
{
|
||||
"Map3DBuildings",
|
||||
tr("Map: Display 3D Buildings"),
|
||||
tr("Parse and display 3D buildings on map. Thanks to jakethesnake420 for this implementation."),
|
||||
"../assets/img_map.png",
|
||||
},
|
||||
};
|
||||
|
||||
// Visuals: Developer UI Info (Dev UI)
|
||||
|
||||
@@ -252,6 +252,7 @@ void ui_update_params(UIState *s) {
|
||||
s->scene.e2e_long_alert_light = params.getBool("EndToEndLongAlertLight");
|
||||
s->scene.e2e_long_alert_lead = params.getBool("EndToEndLongAlertLead");
|
||||
s->scene.e2e_long_alert_ui = params.getBool("EndToEndLongAlertUI");
|
||||
s->scene.map_3d_buildings = params.getBool("Map3DBuildings");
|
||||
|
||||
// Handle Onroad Screen Off params
|
||||
if (s->scene.onroadScreenOff > 0) {
|
||||
|
||||
@@ -237,6 +237,8 @@ typedef struct UIScene {
|
||||
float mads_path_range = DRIVING_PATH_WIDE - DRIVING_PATH_NARROW; // 0.9 - 0.25 = 0.65
|
||||
|
||||
bool onroad_settings_visible;
|
||||
|
||||
bool map_3d_buildings;
|
||||
} UIScene;
|
||||
|
||||
class UIState : public QObject {
|
||||
|
||||
Reference in New Issue
Block a user