summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHein-Pieter van Braam <hp@tmm.cx>2019-04-23 05:55:57 +0300
committerGitHub <noreply@github.com>2019-04-23 05:55:57 +0300
commita112eb599f270b2a0ba650088172363fe01c3698 (patch)
tree7636497cbe6c272681bdce258c48c796bd2deceb
parent510bed871cbda354b1cb097b52b82dc4525c100a (diff)
parent0110a88547b87bcd066f1ae74f46b2ba8b7ab2a5 (diff)
Merge pull request #28064 from DarknessCatt/issue-27077
Moving Polygon2D vertices along axis
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index 4a4e7f25b8..1afd7df049 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<InputEvent> &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) {