From 76f81cfc2156309b4d15c74d3883f8e8fe0ecb66 Mon Sep 17 00:00:00 2001 From: aXu-AP <1621768+aXu-AP@users.noreply.github.com> Date: Fri, 20 Oct 2023 10:32:31 +0300 Subject: [PATCH] Fix Polygon2D undo on transforming vertices Fix: Action not committed to history when transforming all points in UV editor's Points mode. --- editor/plugins/polygon_2d_editor_plugin.cpp | 25 ++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 7a62f2ef762..00567587ce2 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -759,20 +759,29 @@ void Polygon2DEditor::_uv_input(const Ref &p_input) { } } else { if (uv_drag && !uv_create) { - if (uv_edit_mode[0]->is_pressed()) { // Edit UV. + if (uv_edit_mode[0]->is_pressed()) { undo_redo->create_action(TTR("Transform UV Map")); undo_redo->add_do_method(node, "set_uv", node->get_uv()); undo_redo->add_undo_method(node, "set_uv", points_prev); undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); - } else if (uv_edit_mode[1]->is_pressed() && uv_move_current == UV_MODE_EDIT_POINT) { // Edit polygon. - undo_redo->create_action(TTR("Transform Polygon")); - undo_redo->add_do_method(node, "set_polygon", node->get_polygon()); - undo_redo->add_undo_method(node, "set_polygon", points_prev); - undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); - undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); - undo_redo->commit_action(); + } else if (uv_edit_mode[1]->is_pressed()) { + switch (uv_move_current) { + case UV_MODE_EDIT_POINT: + case UV_MODE_MOVE: + case UV_MODE_ROTATE: + case UV_MODE_SCALE: { + undo_redo->create_action(TTR("Transform Polygon")); + undo_redo->add_do_method(node, "set_polygon", node->get_polygon()); + undo_redo->add_undo_method(node, "set_polygon", points_prev); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); + undo_redo->commit_action(); + } break; + default: { + } break; + } } uv_drag = false;