|
@@ -2073,7 +2073,12 @@ void SpatialEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const
|
|
camera_transform.translate(cursor.pos);
|
|
camera_transform.translate(cursor.pos);
|
|
camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot);
|
|
camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot);
|
|
camera_transform.basis.rotate(Vector3(0, 1, 0), -cursor.y_rot);
|
|
camera_transform.basis.rotate(Vector3(0, 1, 0), -cursor.y_rot);
|
|
- Vector3 translation(-p_relative.x * pan_speed, p_relative.y * pan_speed, 0);
|
|
|
|
|
|
+ const bool invert_x_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_x_axis");
|
|
|
|
+ const bool invert_y_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_y_axis");
|
|
|
|
+ Vector3 translation(
|
|
|
|
+ (invert_x_axis ? -1 : 1) * -p_relative.x * pan_speed,
|
|
|
|
+ (invert_y_axis ? -1 : 1) * p_relative.y * pan_speed,
|
|
|
|
+ 0);
|
|
translation *= cursor.distance / DISTANCE_DEFAULT;
|
|
translation *= cursor.distance / DISTANCE_DEFAULT;
|
|
camera_transform.translate(translation);
|
|
camera_transform.translate(translation);
|
|
cursor.pos = camera_transform.origin;
|
|
cursor.pos = camera_transform.origin;
|
|
@@ -2113,17 +2118,24 @@ void SpatialEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, con
|
|
_menu_option(VIEW_PERSPECTIVE);
|
|
_menu_option(VIEW_PERSPECTIVE);
|
|
}
|
|
}
|
|
|
|
|
|
- real_t degrees_per_pixel = EditorSettings::get_singleton()->get("editors/3d/navigation_feel/orbit_sensitivity");
|
|
|
|
- real_t radians_per_pixel = Math::deg2rad(degrees_per_pixel);
|
|
|
|
- bool invert_y_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_y_axis");
|
|
|
|
|
|
+ const real_t degrees_per_pixel = EditorSettings::get_singleton()->get("editors/3d/navigation_feel/orbit_sensitivity");
|
|
|
|
+ const real_t radians_per_pixel = Math::deg2rad(degrees_per_pixel);
|
|
|
|
+ const bool invert_y_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_y_axis");
|
|
|
|
+ const bool invert_x_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_x_axis");
|
|
|
|
|
|
if (invert_y_axis) {
|
|
if (invert_y_axis) {
|
|
cursor.x_rot -= p_relative.y * radians_per_pixel;
|
|
cursor.x_rot -= p_relative.y * radians_per_pixel;
|
|
} else {
|
|
} else {
|
|
cursor.x_rot += p_relative.y * radians_per_pixel;
|
|
cursor.x_rot += p_relative.y * radians_per_pixel;
|
|
}
|
|
}
|
|
- cursor.y_rot += p_relative.x * radians_per_pixel;
|
|
|
|
|
|
+ // Clamp the Y 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, -1.57, 1.57);
|
|
cursor.x_rot = CLAMP(cursor.x_rot, -1.57, 1.57);
|
|
|
|
+
|
|
|
|
+ if (invert_x_axis) {
|
|
|
|
+ cursor.y_rot -= p_relative.x * radians_per_pixel;
|
|
|
|
+ } else {
|
|
|
|
+ cursor.y_rot += p_relative.x * radians_per_pixel;
|
|
|
|
+ }
|
|
name = "";
|
|
name = "";
|
|
_update_name();
|
|
_update_name();
|
|
}
|
|
}
|
|
@@ -2139,21 +2151,23 @@ void SpatialEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, cons
|
|
_menu_option(VIEW_PERSPECTIVE);
|
|
_menu_option(VIEW_PERSPECTIVE);
|
|
}
|
|
}
|
|
|
|
|
|
- real_t degrees_per_pixel = EditorSettings::get_singleton()->get("editors/3d/navigation_feel/orbit_sensitivity");
|
|
|
|
- real_t radians_per_pixel = Math::deg2rad(degrees_per_pixel);
|
|
|
|
- bool invert_y_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_y_axis");
|
|
|
|
|
|
+ const real_t degrees_per_pixel = EditorSettings::get_singleton()->get("editors/3d/navigation_feel/orbit_sensitivity");
|
|
|
|
+ const real_t radians_per_pixel = Math::deg2rad(degrees_per_pixel);
|
|
|
|
+ const bool invert_y_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_y_axis");
|
|
|
|
|
|
// Note: do NOT assume the camera has the "current" transform, because it is interpolated and may have "lag".
|
|
// Note: do NOT assume the camera has the "current" transform, because it is interpolated and may have "lag".
|
|
- Transform prev_camera_transform = to_camera_transform(cursor);
|
|
|
|
|
|
+ const Transform prev_camera_transform = to_camera_transform(cursor);
|
|
|
|
|
|
if (invert_y_axis) {
|
|
if (invert_y_axis) {
|
|
cursor.x_rot -= p_relative.y * radians_per_pixel;
|
|
cursor.x_rot -= p_relative.y * radians_per_pixel;
|
|
} else {
|
|
} else {
|
|
cursor.x_rot += p_relative.y * radians_per_pixel;
|
|
cursor.x_rot += p_relative.y * radians_per_pixel;
|
|
}
|
|
}
|
|
- cursor.y_rot += p_relative.x * radians_per_pixel;
|
|
|
|
|
|
+ // Clamp the Y 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, -1.57, 1.57);
|
|
cursor.x_rot = CLAMP(cursor.x_rot, -1.57, 1.57);
|
|
|
|
|
|
|
|
+ cursor.y_rot += p_relative.x * radians_per_pixel;
|
|
|
|
+
|
|
// Look is like the opposite of Orbit: the focus point rotates around the camera
|
|
// Look is like the opposite of Orbit: the focus point rotates around the camera
|
|
Transform camera_transform = to_camera_transform(cursor);
|
|
Transform camera_transform = to_camera_transform(cursor);
|
|
Vector3 pos = camera_transform.xform(Vector3(0, 0, 0));
|
|
Vector3 pos = camera_transform.xform(Vector3(0, 0, 0));
|