Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/FlyView/FlyView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import QGroundControl.Viewer3D
Item {
id: _root

readonly property bool _is3DMode: QGCViewer3DManager.displayMode === QGCViewer3DManager.View3D
readonly property bool _is3DMode: QGCViewer3DManager.displayMode === QGCViewer3DManager.View3D
readonly property bool _keepSceneAlive: QGroundControl.settingsManager.viewer3DSettings.keepSceneAlive.rawValue

// These should only be used by MainRootWindow
property var planController: _planController
Expand Down Expand Up @@ -157,15 +158,24 @@ Item {
}

Loader {
id: viewer3DLoader
z: 1
anchors.fill: parent
active: _is3DMode

onActiveChanged: {
if (active) {
setSource("qrc:/qml/QGroundControl/Viewer3D/Models3D/Viewer3DModel.qml",
)
id: viewer3DLoader
z: 1
anchors.fill: parent
visible: _is3DMode
}

Connections {
target: QGCViewer3DManager
function onDisplayModeChanged() {
if (QGCViewer3DManager.displayMode === QGCViewer3DManager.View3D) {
if (!viewer3DLoader.item) {
viewer3DLoader.setSource(
"qrc:/qml/QGroundControl/Viewer3D/Models3D/Viewer3DModel.qml",
{ missionController: Qt.binding(() => _missionController) }
)
}
} else if (!_keepSceneAlive) {
viewer3DLoader.source = ""
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/Settings/Viewer3D.SettingsGroup.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
"default": 0,
"label": "Altitude bias for vehicles in the 3D View",
"keywords": "altitude bias,3d data"
},
{
"name": "keepSceneAlive",
"shortDesc": "Keep the 3D scene loaded in memory when switching back to fly view. Disable on memory-constrained devices.",
"type": "bool",
"default": true,
"label": "Keep 3D scene alive when exiting 3D view",
"keywords": "3d view,memory,scene,alive"
}
]
}
1 change: 1 addition & 0 deletions src/Settings/Viewer3DSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ DECLARE_SETTINGSFACT(Viewer3DSettings, mapProvider)
DECLARE_SETTINGSFACT(Viewer3DSettings, osmFilePath)
DECLARE_SETTINGSFACT(Viewer3DSettings, buildingLevelHeight)
DECLARE_SETTINGSFACT(Viewer3DSettings, altitudeBias)
DECLARE_SETTINGSFACT(Viewer3DSettings, keepSceneAlive)
1 change: 1 addition & 0 deletions src/Settings/Viewer3DSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ class Viewer3DSettings : public SettingsGroup
DEFINE_SETTINGFACT(osmFilePath)
DEFINE_SETTINGFACT(buildingLevelHeight)
DEFINE_SETTINGFACT(altitudeBias)
DEFINE_SETTINGFACT(keepSceneAlive)
};
3 changes: 3 additions & 0 deletions src/UI/AppSettings/pages/Viewer3D.SettingsUI.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
},
{
"setting": "viewer3DSettings.mapProvider"
},
{
"setting": "viewer3DSettings.keepSceneAlive"
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions src/Viewer3D/Viewer3DQml/Models3D/Viewer3DVehicleItems.qml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ Node {

ListModel {
id: missionWaypointListModel
}

Component.onDestruction: {
// This is necessary insurance to prevent crashes after destruction when "keepSceneAlive" setting is disabled.
missionWaypointListModel.clear()
}

DroneModelDjiF450 {
Expand Down
Loading