diff options
author | Eric M <itsjusteza@gmail.com> | 2023-01-10 21:30:07 +1000 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-03-27 16:29:21 +0200 |
commit | 74b5a0ca4f3223f7d26fb7f5f80266bfca58c79c (patch) | |
tree | c4154a0e07aea8f0b0fb414f2f85cf80e65b6aee /editor/plugins | |
parent | ca0ba83f0307cad3e8119945e6e2de9570190803 (diff) |
Fix cancelling selection (pressing escape) while gizmo editing making uncommitted changes.
* Pressing escape while gizmo editing will discard the changes made during that edit 'session'
(cherry picked from commit 871ddf80c097717ad55026ce0cf60481af489eae)
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/collision_shape_2d_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | editor/plugins/collision_shape_2d_editor_plugin.h | 1 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 5 |
3 files changed, 12 insertions, 0 deletions
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index c2d5885e43..4afbb87197 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -356,6 +356,7 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e return false; } + original_point = handles[edit_handle]; original = get_handle_value(edit_handle); original_transform = node->get_global_transform(); last_point = original; @@ -572,6 +573,11 @@ void CollisionShape2DEditor::edit(Node *p_node) { _get_current_shape_type(); } else { + if (pressed) { + set_handle(edit_handle, original_point); + pressed = false; + } + edit_handle = -1; shape_type = -1; diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h index 68fc0ddbdf..9c37b6cf9d 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.h +++ b/editor/plugins/collision_shape_2d_editor_plugin.h @@ -71,6 +71,7 @@ class CollisionShape2DEditor : public Control { bool pressed; Variant original; Transform2D original_transform; + Vector2 original_point; Point2 last_point; Variant get_handle_value(int idx) const; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 333771ceb4..7c5b8600d4 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2102,6 +2102,11 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } if (_edit.mode == TRANSFORM_NONE) { + if (_edit.gizmo.is_valid()) { + // Restore. + _edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, _edit.gizmo_initial_value, true); + _edit.gizmo = Ref<EditorNode3DGizmo>(); + } if (k->get_keycode() == Key::ESCAPE && !cursor.region_select) { _clear_selected(); return; |