private void CastSpline(Vector3 direction)
        {
            Undo.RecordObject(EditorState.CurrentSpline, "Cast Curve Points");
            var pointsCount = EditorState.CurrentSpline.PointsCount;

            EditorState.CurrentSpline.SetAllControlPointsMode(BezierSpline.BezierControlPointMode.Free);

            var newPointsPositions = new Vector3[pointsCount];

            for (var i = 0; i < pointsCount; i++)
            {
                var worldPosition = handleTransform.TransformPoint(EditorState.CurrentSpline.Points[i].Position);
                PhysicsUtils.TryCastPoint(worldPosition, direction, out newPointsPositions[i]);
                newPointsPositions[i] = handleTransform.InverseTransformPoint(newPointsPositions[i]);
            }

            for (var i = 0; i < pointsCount; i += 3)
            {
                var prevPoint = i > 0 ? EditorState.CurrentSpline.Points[i - 1].Position : Vector3.zero;
                var nextPoint = i < pointsCount - 1 ? EditorState.CurrentSpline.Points[i + 1].Position : Vector3.zero;

                EditorState.CurrentSpline.SetPoint(i, newPointsPositions[i], false, true);

                var isPreviousPointCasted = i > 0 && newPointsPositions[i - 1] != prevPoint;
                if (isPreviousPointCasted)
                {
                    EditorState.CurrentSpline.SetPoint(i - 1, newPointsPositions[i - 1], false, false);
                }

                var isNextPointCasted = i < pointsCount - 1 && newPointsPositions[i + 1] != nextPoint;
                if (isNextPointCasted)
                {
                    EditorState.CurrentSpline.SetPoint(i + 1, newPointsPositions[i + 1], false, false);
                }
            }

            EditorState.WasSplineModified = true;
        }