Merge pull request #28064 from DarknessCatt/issue-27077

Moving Polygon2D vertices along axis
This commit is contained in:
Hein-Pieter van Braam 2019-04-23 05:55:57 +03:00 committed by GitHub
commit a112eb599f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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))) { 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))); 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); edited_point = PosVertex(edited_point, cpoint);
if (!wip_active) { if (!wip_active) {