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

Code before:
						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;
			}
			if (curve->get_point_count() < 2) {
				return true;
			}


Review comment (suggestion):
```suggestion
			if (Math::abs(angle_in) < Math::abs(angle_out)) {
```

Code after:
						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;
			}
			if (curve->get_point_count() < 2) {
				return true;
			}