summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp29
-rw-r--r--editor/plugins/spatial_editor_plugin.h4
2 files changed, 32 insertions, 1 deletions
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 30fff474d7..ecdc67e04c 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -1918,6 +1918,11 @@ void SpatialEditorViewport::_nav_zoom(Ref<InputEventWithModifiers> p_event, cons
void SpatialEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {
+ if (lock_rotation) {
+ _nav_pan(p_event, p_relative);
+ return;
+ }
+
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");
@@ -2553,6 +2558,19 @@ void SpatialEditorViewport::_menu_option(int p_option) {
_update_name();
} break;
+ case VIEW_LOCK_ROTATION: {
+
+ int idx = view_menu->get_popup()->get_item_index(VIEW_LOCK_ROTATION);
+ bool current = view_menu->get_popup()->is_item_checked(idx);
+ lock_rotation = !current;
+ view_menu->get_popup()->set_item_checked(idx, !current);
+ if (lock_rotation) {
+ view_menu->set_icon(get_icon("Lock", "EditorIcons"));
+ } else {
+ view_menu->set_icon(Ref<Texture>());
+ }
+
+ } break;
case VIEW_AUDIO_LISTENER: {
int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER);
@@ -2826,6 +2844,12 @@ void SpatialEditorViewport::set_state(const Dictionary &p_state) {
if (!view_menu->get_popup()->is_item_checked(idx))
_menu_option(display);
}
+ if (p_state.has("lock_rotation")) {
+ lock_rotation = p_state["lock_rotation"];
+
+ int idx = view_menu->get_popup()->get_item_index(VIEW_LOCK_ROTATION);
+ view_menu->get_popup()->set_item_checked(idx, lock_rotation);
+ }
if (p_state.has("use_environment")) {
bool env = p_state["use_environment"];
@@ -2913,6 +2937,8 @@ Dictionary SpatialEditorViewport::get_state() const {
d["half_res"] = viewport_container->get_stretch_shrink() > 1;
if (previewing)
d["previewing"] = EditorNode::get_singleton()->get_edited_scene()->get_path_to(previewing);
+ if (lock_rotation)
+ d["lock_rotation"] = lock_rotation;
return d;
}
@@ -2941,6 +2967,7 @@ void SpatialEditorViewport::_bind_methods() {
void SpatialEditorViewport::reset() {
orthogonal = false;
+ lock_rotation = false;
message_time = 0;
message = "";
last_message = "";
@@ -3367,6 +3394,8 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
view_menu->get_popup()->add_radio_check_item(TTR("Orthogonal") + " (" + ED_GET_SHORTCUT("spatial_editor/switch_perspective_orthogonal")->get_as_text() + ")", VIEW_ORTHOGONAL);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE), true);
view_menu->get_popup()->add_separator();
+ view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_lock_rotation", TTR("Lock View Rotation")), VIEW_LOCK_ROTATION);
+ view_menu->get_popup()->add_separator();
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_normal", TTR("Display Normal")), VIEW_DISPLAY_NORMAL);
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_wireframe", TTR("Display Wireframe")), VIEW_DISPLAY_WIREFRAME);
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_overdraw", TTR("Display Overdraw")), VIEW_DISPLAY_OVERDRAW);
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 637926a913..ed95a9a602 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -93,7 +93,8 @@ class SpatialEditorViewport : public Control {
VIEW_DISPLAY_NORMAL,
VIEW_DISPLAY_WIREFRAME,
VIEW_DISPLAY_OVERDRAW,
- VIEW_DISPLAY_SHADELESS
+ VIEW_DISPLAY_SHADELESS,
+ VIEW_LOCK_ROTATION
};
public:
@@ -131,6 +132,7 @@ private:
Camera *camera;
bool transforming;
bool orthogonal;
+ bool lock_rotation;
float gizmo_scale;
bool freelook_active;