From 4c638f98ab8685cd44e416c55df2cb51bff2cc5e Mon Sep 17 00:00:00 2001 From: Vorblen Date: Sat, 20 Jun 2020 10:05:43 +0100 Subject: [PATCH] Fix "Fully Axis-Locked" Freelook Navigation Scheme Co-authored-by: Aaron Franke (cherry picked from commit 29e901c3420fc823fddebd3f8b885e8a816debe3) --- editor/plugins/spatial_editor_plugin.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 88983e419f7..9ed2d3231b4 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -2123,10 +2123,7 @@ void SpatialEditorViewport::_nav_orbit(Ref p_event, con cursor.x_rot += p_relative.y * radians_per_pixel; } cursor.y_rot += p_relative.x * radians_per_pixel; - if (cursor.x_rot > Math_PI / 2.0) - cursor.x_rot = Math_PI / 2.0; - if (cursor.x_rot < -Math_PI / 2.0) - cursor.x_rot = -Math_PI / 2.0; + cursor.x_rot = CLAMP(cursor.x_rot, -1.57, 1.57); name = ""; _update_name(); } @@ -2155,10 +2152,7 @@ void SpatialEditorViewport::_nav_look(Ref p_event, cons cursor.x_rot += p_relative.y * radians_per_pixel; } cursor.y_rot += p_relative.x * radians_per_pixel; - if (cursor.x_rot > Math_PI / 2.0) - cursor.x_rot = Math_PI / 2.0; - if (cursor.x_rot < -Math_PI / 2.0) - cursor.x_rot = -Math_PI / 2.0; + cursor.x_rot = CLAMP(cursor.x_rot, -1.57, 1.57); // Look is like the opposite of Orbit: the focus point rotates around the camera Transform camera_transform = to_camera_transform(cursor);