summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-10-21 15:25:58 +0200
committerGitHub <noreply@github.com>2019-10-21 15:25:58 +0200
commitee3b28e9af9e8b63efd440b47fc22aab4967409d (patch)
tree9afd362d87c771231fc805936f46d2b74dfdf5b7
parent8fc423034b84d5200bbfb3ddf4658ae20b3d49fb (diff)
parentaf89a8707531826a0d7a972dae9d997f1ef6fbb9 (diff)
Merge pull request #32841 from Calinou/freelook-add-slow-modifier
Add a "slow" modifier to freelook
-rw-r--r--editor/editor_settings.cpp2
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp22
2 files changed, 11 insertions, 13 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 3ea59115b0..672844117d 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -559,8 +559,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["editors/3d/freelook/freelook_base_speed"] = PropertyInfo(Variant::REAL, "editors/3d/freelook/freelook_base_speed", PROPERTY_HINT_RANGE, "0.0, 10, 0.01");
_initial_set("editors/3d/freelook/freelook_activation_modifier", 0);
hints["editors/3d/freelook/freelook_activation_modifier"] = PropertyInfo(Variant::INT, "editors/3d/freelook/freelook_activation_modifier", PROPERTY_HINT_ENUM, "None,Shift,Alt,Meta,Ctrl");
- _initial_set("editors/3d/freelook/freelook_modifier_speed_factor", 3.0);
- hints["editors/3d/freelook/freelook_modifier_speed_factor"] = PropertyInfo(Variant::REAL, "editors/3d/freelook/freelook_modifier_speed_factor", PROPERTY_HINT_RANGE, "0.0, 10.0, 0.1");
_initial_set("editors/3d/freelook/freelook_speed_zoom_link", false);
// 2D
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 095350d0e1..1d8fd38858 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -2049,12 +2049,11 @@ void SpatialEditorViewport::_update_freelook(real_t delta) {
return;
}
- Vector3 forward = camera->get_transform().basis.xform(Vector3(0, 0, -1));
- Vector3 right = camera->get_transform().basis.xform(Vector3(1, 0, 0));
- Vector3 up = camera->get_transform().basis.xform(Vector3(0, 1, 0));
+ const Vector3 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 direction;
- bool speed_modifier = false;
if (is_shortcut_pressed("spatial_editor/freelook_left")) {
direction -= right;
@@ -2074,17 +2073,17 @@ void SpatialEditorViewport::_update_freelook(real_t delta) {
if (is_shortcut_pressed("spatial_editor/freelook_down")) {
direction -= up;
}
- if (is_shortcut_pressed("spatial_editor/freelook_speed_modifier")) {
- speed_modifier = true;
- }
real_t speed = freelook_speed;
- if (speed_modifier) {
- real_t modifier_speed_factor = EditorSettings::get_singleton()->get("editors/3d/freelook/freelook_modifier_speed_factor");
- speed *= modifier_speed_factor;
+
+ if (is_shortcut_pressed("spatial_editor/freelook_speed_modifier")) {
+ speed *= 3.0;
+ }
+ if (is_shortcut_pressed("spatial_editor/freelook_slow_modifier")) {
+ speed *= 0.333333;
}
- Vector3 motion = direction * speed * delta;
+ const Vector3 motion = direction * speed * delta;
cursor.pos += motion;
cursor.eye_pos += motion;
}
@@ -3588,6 +3587,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
ED_SHORTCUT("spatial_editor/freelook_up", TTR("Freelook Up"), KEY_E);
ED_SHORTCUT("spatial_editor/freelook_down", TTR("Freelook Down"), KEY_Q);
ED_SHORTCUT("spatial_editor/freelook_speed_modifier", TTR("Freelook Speed Modifier"), KEY_SHIFT);
+ ED_SHORTCUT("spatial_editor/freelook_slow_modifier", TTR("Freelook Slow Modifier"), KEY_ALT);
preview_camera = memnew(CheckBox);
preview_camera->set_text(TTR("Preview"));