Merge pull request #83659 from aXu-AP/uv-edit-transform-points-undo

Fix Polygon2D undo on transforming vertices
This commit is contained in:
Rémi Verschelde 2023-10-20 15:13:26 +02:00
commit 365507fcf3
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -759,20 +759,29 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
} }
} else { } else {
if (uv_drag && !uv_create) { 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->create_action(TTR("Transform UV Map"));
undo_redo->add_do_method(node, "set_uv", node->get_uv()); undo_redo->add_do_method(node, "set_uv", node->get_uv());
undo_redo->add_undo_method(node, "set_uv", points_prev); undo_redo->add_undo_method(node, "set_uv", points_prev);
undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); undo_redo->add_do_method(uv_edit_draw, "queue_redraw");
undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->add_undo_method(uv_edit_draw, "queue_redraw");
undo_redo->commit_action(); undo_redo->commit_action();
} else if (uv_edit_mode[1]->is_pressed() && uv_move_current == UV_MODE_EDIT_POINT) { // Edit polygon. } else if (uv_edit_mode[1]->is_pressed()) {
undo_redo->create_action(TTR("Transform Polygon")); switch (uv_move_current) {
undo_redo->add_do_method(node, "set_polygon", node->get_polygon()); case UV_MODE_EDIT_POINT:
undo_redo->add_undo_method(node, "set_polygon", points_prev); case UV_MODE_MOVE:
undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); case UV_MODE_ROTATE:
undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); case UV_MODE_SCALE: {
undo_redo->commit_action(); 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; uv_drag = false;