Repository: godotengine/godot
File: editor/plugins/path_2d_editor_plugin.cpp (C++)

Code before:
						if (mirror_handle_angle) {
							undo_redo->add_do_method(curve.ptr(), "set_point_in", action_point, mirror_handle_length ? -new_pos : (-new_pos.normalized() * orig_in_length));
							undo_redo->add_undo_method(curve.ptr(), "set_point_in", action_point, mirror_handle_length ? -moving_from : (-moving_from.normalized() * orig_in_length));
						}
						undo_redo->add_do_method(canvas_item_editor, "update_viewport");
						undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
						undo_redo->commit_action();
					}
				} break;
			}

			action = ACTION_NONE;

			return true;
		}
	}

	Ref<InputEventMouseMotion> mm = p_event;

	if (mm.is_valid()) {
		// When both control points were in range of click,
		// pick the point that drags the curve outwards.
		if (control_points_in_range == 2) {
			control_points_in_range = 0;
			Ref<Curve2D> curve = node->get_curve();
			Point2 relative = mm->get_relative();
			real_t angle_in = relative.angle_to(curve->get_point_position(action_point - 1) - curve->get_point_position(action_point));
			real_t angle_out = relative.angle_to(curve->get_point_position(action_point + 1) - curve->get_point_position(action_point));

			if (abs(angle_in) < abs(angle_out)) {
				action = ACTION_MOVING_IN;
				moving_from = curve->get_point_in(action_point);
				orig_out_length = curve->get_point_out(action_point).length();
			} else {
				action = ACTION_MOVING_OUT;
				moving_from = curve->get_point_out(action_point);
				orig_in_length = curve->get_point_in(action_point).length();
			}
		}

		if (action == ACTION_NONE && mode == MODE_EDIT) {
			// Handle Edge Follow
			bool old_edge = on_edge;

			Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_screen_transform();
			Vector2 gpoint = mm->get_position();

			Ref<Curve2D> curve = node->get_curve();
			if (curve.is_null()) {
				return true;
			}

Review comment (suggestion):
Mouse motion should to be transformed to be relative to the edited Path2D (and thus its curve), it can be rotated etc.

Assumming the transforming in the existing code down below is correct:
```suggestion
			Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_screen_transform();
			Point2 relative = xform.affine_inverse().basis_xform(mm->get_relative());
```

Code after:
						if (mirror_handle_angle) {
							undo_redo->add_do_method(curve.ptr(), "set_point_in", action_point, mirror_handle_length ? -new_pos : (-new_pos.normalized() * orig_in_length));
							undo_redo->add_undo_method(curve.ptr(), "set_point_in", action_point, mirror_handle_length ? -moving_from : (-moving_from.normalized() * orig_in_length));
						}
						undo_redo->add_do_method(canvas_item_editor, "update_viewport");
						undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
						undo_redo->commit_action();
					}
				} break;
			}

			action = ACTION_NONE;

			return true;
		}
	}

	Ref<InputEventMouseMotion> mm = p_event;

	if (mm.is_valid()) {
		// When both control points were in range of click,
		// pick the point that drags the curve outwards.
		if (control_points_in_range == 2) {
			control_points_in_range = 0;
			Ref<Curve2D> curve = node->get_curve();
			Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_screen_transform();
			Point2 relative = xform.affine_inverse().basis_xform(mm->get_relative());
			real_t angle_in = relative.angle_to(curve->get_point_position(action_point - 1) - curve->get_point_position(action_point));
			real_t angle_out = relative.angle_to(curve->get_point_position(action_point + 1) - curve->get_point_position(action_point));

			if (Math::abs(angle_in) < Math::abs(angle_out)) {
				action = ACTION_MOVING_IN;
				moving_from = curve->get_point_in(action_point);
				orig_out_length = curve->get_point_out(action_point).length();
			} else {
				action = ACTION_MOVING_OUT;
				moving_from = curve->get_point_out(action_point);
				orig_in_length = curve->get_point_in(action_point).length();
			}
		}

		if (action == ACTION_NONE && mode == MODE_EDIT) {
			// Handle Edge Follow
			bool old_edge = on_edge;

			Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_screen_transform();
			Vector2 gpoint = mm->get_position();

			Ref<Curve2D> curve = node->get_curve();
			if (curve.is_null()) {
				return true;