diff options
| author | Rémi Verschelde | 2017-05-07 15:06:35 +0200 |
|---|---|---|
| committer | GitHub | 2017-05-07 15:06:35 +0200 |
| commit | 66725d9b21dc50b0bb38baa4aa376b7bbb56e0e4 (patch) | |
| tree | 791a69cb445bc95d2023b620a84a21d1629e1f39 /editor/plugins/spatial_editor_plugin.cpp | |
| parent | 642a760952888a873620479dbed6c1ddd73ddea5 (diff) | |
| parent | 7839a89027fd1a0647afd96ca2710e1f468d298e (diff) | |
| download | godot-66725d9b21dc50b0bb38baa4aa376b7bbb56e0e4.tar.gz godot-66725d9b21dc50b0bb38baa4aa376b7bbb56e0e4.tar.zst godot-66725d9b21dc50b0bb38baa4aa376b7bbb56e0e4.zip | |
Merge pull request #8660 from Hinsbart/warp
Spatial Editor: Mouse warping for orbit & freelook modes.
Diffstat (limited to 'editor/plugins/spatial_editor_plugin.cpp')
| -rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 8a8add561..087010a3f 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -1339,12 +1339,7 @@ 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); - } + Point2i relative = _get_warped_mouse_motion(m); Transform camera_transform; @@ -1380,8 +1375,9 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { } break; case NAVIGATION_ORBIT: { - cursor.x_rot += m.relative_y / 80.0; - cursor.y_rot += m.relative_x / 80.0; + Point2i relative = _get_warped_mouse_motion(m); + cursor.x_rot += relative.y / 80.0; + cursor.y_rot += relative.x / 80.0; if (cursor.x_rot > Math_PI / 2.0) cursor.x_rot = Math_PI / 2.0; if (cursor.x_rot < -Math_PI / 2.0) @@ -1394,8 +1390,9 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { // Freelook only works properly in perspective. // It technically works too in ortho, but it's awful for a user due to fov being near zero if (!orthogonal) { - cursor.x_rot += m.relative_y / 120.0; - cursor.y_rot += m.relative_x / 120.0; + Point2i relative = _get_warped_mouse_motion(m); + cursor.x_rot += relative.y / 120.0; + cursor.y_rot += relative.x / 120.0; if (cursor.x_rot > Math_PI / 2.0) cursor.x_rot = Math_PI / 2.0; if (cursor.x_rot < -Math_PI / 2.0) @@ -1503,6 +1500,16 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { } } +Point2i SpatialEditorViewport::_get_warped_mouse_motion(const InputEventMouseMotion &p_ev_mouse_motion) const { + Point2i relative; + if (bool(EditorSettings::get_singleton()->get("editors/3d/warped_mouse_panning"))) { + relative = Input::get_singleton()->warp_mouse_motion(p_ev_mouse_motion, surface->get_global_rect()); + } else { + relative = Point2i(p_ev_mouse_motion.relative_x, p_ev_mouse_motion.relative_y); + } + return relative; +} + void SpatialEditorViewport::_update_freelook(real_t delta) { const Input &input = *Input::get_singleton(); |
