Skip to content

Commit

Permalink
Clamp rotation for up/down orbiting shortcuts.
Browse files Browse the repository at this point in the history
This prevents the viewport from going upside-down.

This was suggested at:
godotengine#51984 (comment):

> 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.

(cherry picked from commit 3bd7c4f)
  • Loading branch information
rcorre authored and lekoder committed Dec 18, 2021
1 parent 7bbf94f commit ab4c86c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions editor/plugins/spatial_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2043,12 +2043,14 @@ void SpatialEditorViewport::_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();
}
Expand Down

0 comments on commit ab4c86c

Please sign in to comment.