diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2017-03-22 21:18:47 +0100 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2017-03-22 21:36:52 +0100 |
commit | f5004b78d0468641cd03619ecfecb42429621a70 (patch) | |
tree | 42011a7bf4ab8b602899e9d3dacbc1fdeb21952f /editor/plugins/spatial_editor_plugin.cpp | |
parent | 33a2c5def0f55ef67196e35ac3309d3f9b70d967 (diff) | |
download | redot-engine-f5004b78d0468641cd03619ecfecb42429621a70.tar.gz |
Implement warped mouse panning for 2D & 3D editors
Enabled by default as in Blender, but can be disabled separately for 2D & 3D;
the core functionality is in Input so this could be reused or even exposed to scripts in the future
Diffstat (limited to 'editor/plugins/spatial_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index fcfb20bd7d..c00652bc35 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; |