diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-10-31 09:29:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-31 09:29:54 +0100 |
commit | 31a487660ae373632c5ffedff6d269e76426f22a (patch) | |
tree | 26d980a70a3aa21137960eb6c27880814c104500 /editor/plugins | |
parent | d582cab2079863ce31864ba1382bf955b10ba69c (diff) | |
parent | b9521f862d532c1e950a15d9a9b08b7354e59b66 (diff) |
Merge pull request #12499 from Zylann/freelook_toggle_mode
Add option to use freelook with a toggle shortcut
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index f96cbabde7..01aa967a6d 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -847,6 +847,7 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) { selection_menu->set_invalidate_click_until_motion(); } } + void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (previewing) @@ -1576,7 +1577,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } } - } else if (m->get_button_mask() & BUTTON_MASK_RIGHT) { + } else if ((m->get_button_mask() & BUTTON_MASK_RIGHT) || freelook_active) { if (nav_scheme == NAVIGATION_MAYA && m->get_alt()) { nav_mode = NAVIGATION_ZOOM; @@ -1791,6 +1792,13 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { set_message(TTR("Animation Key Inserted.")); } + if (ED_IS_SHORTCUT("spatial_editor/freelook_toggle", p_event)) { + set_freelook_active(!is_freelook_active()); + + } else if (k->get_scancode() == KEY_ESCAPE) { + set_freelook_active(false); + } + if (k->get_scancode() == KEY_SPACE) { if (!k->is_pressed()) emit_signal("toggle_maximize_view", this); } @@ -1815,9 +1823,15 @@ void SpatialEditorViewport::set_freelook_active(bool active_now) { freelook_speed = base_speed * cursor.distance; } + // Hide mouse like in an FPS (warping doesn't work) + OS::get_singleton()->set_mouse_mode(OS::MOUSE_MODE_CAPTURED); + } else if (freelook_active && !active_now) { // Sync camera cursor to cursor to "cut" interpolation jumps due to changing referential cursor = camera_cursor; + + // Restore mouse + OS::get_singleton()->set_mouse_mode(OS::MOUSE_MODE_VISIBLE); } freelook_active = active_now; @@ -4595,6 +4609,8 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { ED_SHORTCUT("spatial_editor/display_wireframe", TTR("Display Wireframe"), KEY_Z); + ED_SHORTCUT("spatial_editor/freelook_toggle", TTR("Toggle Freelook"), KEY_MASK_SHIFT + KEY_F); + PopupMenu *p; transform_menu = memnew(MenuButton); |