diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderReversal.cs b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderReversal.cs index ddef74deb1..f26a889ec6 100644 --- a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderReversal.cs +++ b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderReversal.cs @@ -35,16 +35,13 @@ public partial class TestSceneSliderReversal : TestSceneOsuEditor private static PathControlPoint[] createPathSegment(PathType type, params Vector2[] positions) { - return new[] - { - new PathControlPoint - { - Type = type - }, - }.Concat(positions.Select(p => new PathControlPoint + return positions.Select(p => new PathControlPoint { Position = p - })).ToArray(); + }).Prepend(new PathControlPoint + { + Type = type + }).ToArray(); } [TestCase(0, 250)] diff --git a/osu.Game/Rulesets/Objects/SliderPathExtensions.cs b/osu.Game/Rulesets/Objects/SliderPathExtensions.cs index cb753229ae..9e9b542961 100644 --- a/osu.Game/Rulesets/Objects/SliderPathExtensions.cs +++ b/osu.Game/Rulesets/Objects/SliderPathExtensions.cs @@ -1,10 +1,10 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Utils; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Objects.Types; using osuTK; @@ -41,7 +41,7 @@ public static void Reverse(this SliderPath sliderPath, out Vector2 positionalOff double[] distinctSegmentEnds = segmentEnds.Distinct().ToArray(); // Remove control points at the end which do not affect the visual slider path ("invisible" control points). - if (segmentEnds.Length >= 2 && Math.Abs(segmentEnds[^1] - segmentEnds[^2]) < 1e-10 && distinctSegmentEnds.Length > 1) + if (segmentEnds.Length >= 2 && Precision.AlmostEquals(segmentEnds[^1], segmentEnds[^2]) && distinctSegmentEnds.Length > 1) { int numVisibleSegments = distinctSegmentEnds.Length - 2; var nonInheritedControlPoints = controlPoints.Where(p => p.Type is not null).ToList(); @@ -62,7 +62,10 @@ public static void Reverse(this SliderPath sliderPath, out Vector2 positionalOff } // Restore original control point types. - controlPoints.Zip(originalControlPointTypes).ForEach(x => x.First.Type = x.Second); + for (int i = 0; i < controlPoints.Count; i++) + { + controlPoints[i].Type = originalControlPointTypes[i]; + } // Recalculate perfect curve at the end of the slider path. if (controlPoints.Count >= 3 && controlPoints[^3].Type == PathType.PerfectCurve && controlPoints[^2].Type is null && distinctSegmentEnds.Length > 1)