diff options
| author | Rémi Verschelde | 2017-03-24 22:50:39 +0100 |
|---|---|---|
| committer | GitHub | 2017-03-24 22:50:39 +0100 |
| commit | 98baec68809ebf2dc15dbd44822bb945b039ae6b (patch) | |
| tree | c54bcccdc9391954bc470f7bc0a6c83f1fe004cd /editor/plugins | |
| parent | ca3596b043b2f4c5a4f6858bd6176b7d1cbc931a (diff) | |
| parent | f5004b78d0468641cd03619ecfecb42429621a70 (diff) | |
| download | godot-98baec68809ebf2dc15dbd44822bb945b039ae6b.tar.gz godot-98baec68809ebf2dc15dbd44822bb945b039ae6b.tar.zst godot-98baec68809ebf2dc15dbd44822bb945b039ae6b.zip | |
Merge pull request #8109 from RandomShaper/warped-panning
Implement warped mouse panning for 2D & 3D editors
Diffstat (limited to 'editor/plugins')
| -rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 12 | ||||
| -rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 10 |
2 files changed, 19 insertions, 3 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 7b015e484..7f2daae42 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1471,8 +1471,16 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent &p_event) { if (drag == DRAG_NONE) { if ((m.button_mask & BUTTON_MASK_LEFT && tool == TOOL_PAN) || m.button_mask & BUTTON_MASK_MIDDLE || (m.button_mask & BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE))) { - h_scroll->set_value(h_scroll->get_value() - m.relative_x / zoom); - v_scroll->set_value(v_scroll->get_value() - m.relative_y / zoom); + + Point2i relative; + if (bool(EditorSettings::get_singleton()->get("editors/2d/warped_mouse_panning"))) { + relative = Input::get_singleton()->warp_mouse_motion(m, viewport->get_global_rect()); + } else { + relative = Point2i(m.relative_x, m.relative_y); + } + + h_scroll->set_value(h_scroll->get_value() - relative.x / zoom); + v_scroll->set_value(v_scroll->get_value() - relative.y / zoom); } return; diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index fcfb20bd7..c00652bc3 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -29,6 +29,7 @@ #include "spatial_editor_plugin.h" #include "camera_matrix.h" +#include "core/os/input.h" #include "editor/animation_editor.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" @@ -1400,12 +1401,19 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { if (nav_scheme == NAVIGATION_MAYA && m.mod.shift) pan_speed *= pan_speed_modifier; + Point2i relative; + if (bool(EditorSettings::get_singleton()->get("editors/3d/warped_mouse_panning"))) { + relative = Input::get_singleton()->warp_mouse_motion(m, surface->get_global_rect()); + } else { + relative = Point2i(m.relative_x, m.relative_y); + } + Transform camera_transform; camera_transform.translate(cursor.pos); camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot); camera_transform.basis.rotate(Vector3(0, 1, 0), -cursor.y_rot); - Vector3 translation(-m.relative_x * pan_speed, m.relative_y * pan_speed, 0); + Vector3 translation(-relative.x * pan_speed, relative.y * pan_speed, 0); translation *= cursor.distance / DISTANCE_DEFAULT; camera_transform.translate(translation); cursor.pos = camera_transform.origin; |
