summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRyan Roden-Corrent <ryan@rcorre.net>2021-11-08 17:53:35 -0500
committerRyan Roden-Corrent <ryan@rcorre.net>2021-11-09 06:50:39 -0500
commit3bd7c4f2a93e2dfa495ffe68291a26b7112081e2 (patch)
treee9389d99c36b5c5754a9040d0b14335c8cd98d6e /editor
parentc89061e982a27ba6e5dc6ea54ae812976de2d2db (diff)
Clamp rotation for up/down orbiting shortcuts.
This prevents the viewport from going upside-down. This was suggested at: https://github.com/godotengine/godot/pull/51984#issuecomment-948614191: > For 3.4, I think we can just clamp the angle value when using the > camera orbiting shortcuts. We can investigate what to do with panning > and freelook in 3.5 and 4.0.
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index fa5381bb10..e4bc9ef690 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -2245,12 +2245,14 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
_menu_option(VIEW_RIGHT);
}
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_down", p_event)) {
- cursor.x_rot -= Math_PI / 12.0;
+ // Clamp rotation to roughly -90..90 degrees so the user can't look upside-down and end up disoriented.
+ cursor.x_rot = CLAMP(cursor.x_rot - Math_PI / 12.0, -1.57, 1.57);
view_type = VIEW_TYPE_USER;
_update_name();
}
if (ED_IS_SHORTCUT("spatial_editor/orbit_view_up", p_event)) {
- cursor.x_rot += Math_PI / 12.0;
+ // Clamp rotation to roughly -90..90 degrees so the user can't look upside-down and end up disoriented.
+ cursor.x_rot = CLAMP(cursor.x_rot + Math_PI / 12.0, -1.57, 1.57);
view_type = VIEW_TYPE_USER;
_update_name();
}