summaryrefslogtreecommitdiffstats
path: root/editor/plugins
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2020-04-18 16:20:35 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2020-04-18 16:24:12 +0200
commit8a48fb3517c52a8501dd56be7bf72ee43210efd3 (patch)
tree14afef43bc95b2edd9fdc4fd0a56dadcbc4108fa /editor/plugins
parentd817be92c2d9edce842ab37ab13117743f8a3bee (diff)
downloadredot-engine-8a48fb3517c52a8501dd56be7bf72ee43210efd3.tar.gz
Add editor freelook navigation scheme settings
Depending on what one is trying to achieve, a different freelook mode may be more desirable. This closes #34034.
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp22
-rw-r--r--editor/plugins/node_3d_editor_plugin.h6
2 files changed, 26 insertions, 2 deletions
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 354c951a7c..f51b9b20e4 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -2287,9 +2287,27 @@ void Node3DEditorViewport::_update_freelook(real_t delta) {
return;
}
- const Vector3 forward = camera->get_transform().basis.xform(Vector3(0, 0, -1));
+ const FreelookNavigationScheme navigation_scheme = (FreelookNavigationScheme)EditorSettings::get_singleton()->get("editors/3d/freelook/freelook_navigation_scheme").operator int();
+
+ Vector3 forward;
+ if (navigation_scheme == FREELOOK_FULLY_AXIS_LOCKED) {
+ // Forward/backward keys will always go straight forward/backward, never moving on the Y axis.
+ forward = Vector3(0, 0, -1).rotated(Vector3(0, 1, 0), camera->get_rotation().y);
+ } else {
+ // Forward/backward keys will be relative to the camera pitch.
+ forward = camera->get_transform().basis.xform(Vector3(0, 0, -1));
+ }
+
const Vector3 right = camera->get_transform().basis.xform(Vector3(1, 0, 0));
- const Vector3 up = camera->get_transform().basis.xform(Vector3(0, 1, 0));
+
+ Vector3 up;
+ if (navigation_scheme == FREELOOK_PARTIALLY_AXIS_LOCKED || navigation_scheme == FREELOOK_FULLY_AXIS_LOCKED) {
+ // Up/down keys will always go up/down regardless of camera pitch.
+ up = Vector3(0, 1, 0);
+ } else {
+ // Up/down keys will be relative to the camera pitch.
+ up = camera->get_transform().basis.xform(Vector3(0, 1, 0));
+ }
Vector3 direction;
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index 2c3b15cfc8..1a998a45f0 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -241,6 +241,12 @@ public:
NAVIGATION_MODO,
};
+ enum FreelookNavigationScheme {
+ FREELOOK_DEFAULT,
+ FREELOOK_PARTIALLY_AXIS_LOCKED,
+ FREELOOK_FULLY_AXIS_LOCKED,
+ };
+
private:
float cpu_time_history[FRAME_TIME_HISTORY];
int cpu_time_history_index;