diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-03-08 13:09:10 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-03-08 13:09:10 +0100 |
commit | 2c0797b2577bbdbf7f3c7635f820ac46a206669b (patch) | |
tree | 15cef0d99b7ca5ef39fc7d2c5018c940d8ab4188 /editor/plugins/cast_2d_editor_plugin.cpp | |
parent | 7688460bf78d5fc198f8a2cbe0943981744a4dc2 (diff) | |
parent | f2f3f17de851896ce0096876e370dd67076c50ef (diff) | |
download | redot-engine-2c0797b2577bbdbf7f3c7635f820ac46a206669b.tar.gz |
Merge pull request #87161 from ryevdokimov/do-not-commit
Do not commit transforms and handles if no changes were made
Diffstat (limited to 'editor/plugins/cast_2d_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/cast_2d_editor_plugin.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/editor/plugins/cast_2d_editor_plugin.cpp b/editor/plugins/cast_2d_editor_plugin.cpp index 64db19d85e..c9d7ff8e08 100644 --- a/editor/plugins/cast_2d_editor_plugin.cpp +++ b/editor/plugins/cast_2d_editor_plugin.cpp @@ -65,10 +65,13 @@ bool Cast2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) { Vector2 target_position = node->get("target_position"); + Vector2 gpoint = mb->get_position(); + if (mb->is_pressed()) { - if (xform.xform(target_position).distance_to(mb->get_position()) < 8) { + if (xform.xform(target_position).distance_to(gpoint) < 8) { pressed = true; original_target_position = target_position; + original_mouse_pos = gpoint; return true; } else { @@ -77,16 +80,17 @@ bool Cast2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return false; } } else if (pressed) { - EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); - undo_redo->create_action(TTR("Set Target Position")); - undo_redo->add_do_property(node, "target_position", target_position); - undo_redo->add_do_method(canvas_item_editor, "update_viewport"); - undo_redo->add_undo_property(node, "target_position", original_target_position); - undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); - undo_redo->commit_action(); + if (original_mouse_pos != gpoint) { + EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); + undo_redo->create_action(TTR("Set Target Position")); + undo_redo->add_do_property(node, "target_position", target_position); + undo_redo->add_do_method(canvas_item_editor, "update_viewport"); + undo_redo->add_undo_property(node, "target_position", original_target_position); + undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); + undo_redo->commit_action(); + } pressed = false; - return true; } } |