From 1e5709265c9052660da31076f6f43d103b4c4bf9 Mon Sep 17 00:00:00 2001 From: Matheus Lima Cunha Date: Mon, 15 Apr 2019 15:01:29 -0300 Subject: [PATCH] Move vertex along a single axis while editing and holding shift (cherry picked from commit 0110a88547b87bcd066f1ae74f46b2ba8b7ab2a5) --- editor/plugins/abstract_polygon_2d_editor.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 4a4e7f25b8a..1afd7df0497 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -481,6 +481,17 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref &p_event) if (edited_point.valid() && (wip_active || (mm->get_button_mask() & BUTTON_MASK_LEFT))) { Vector2 cpoint = _get_node()->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint))); + + //Move the point in a single axis. Should only work when editing a polygon and while holding shift. + if (mode == MODE_EDIT && mm->get_shift()) { + Vector2 old_point = pre_move_edit.get(selected_point.vertex); + if (ABS(cpoint.x - old_point.x) > ABS(cpoint.y - old_point.y)) { + cpoint.y = old_point.y; + } else { + cpoint.x = old_point.x; + } + } + edited_point = PosVertex(edited_point, cpoint); if (!wip_active) {