diff --git a/osu.Game/Rulesets/Objects/SliderPathExtensions.cs b/osu.Game/Rulesets/Objects/SliderPathExtensions.cs index 682e31fa96..2fa460ec01 100644 --- a/osu.Game/Rulesets/Objects/SliderPathExtensions.cs +++ b/osu.Game/Rulesets/Objects/SliderPathExtensions.cs @@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Objects inheritedLinearPoints.ForEach(p => p.Type = PathType.Linear); double[] segmentEnds = sliderPath.GetSegmentEnds().ToArray(); - double[] distinctSegmentEnds = segmentEnds.Distinct().ToArray(); + double[] distinctSegmentEnds = truncateEndingDuplicates(segmentEnds); // Remove control points at the end which do not affect the visual slider path ("invisible" control points). if (segmentEnds.Length >= 2 && Precision.AlmostEquals(segmentEnds[^1], segmentEnds[^2]) && distinctSegmentEnds.Length > 1) @@ -83,6 +83,24 @@ namespace osu.Game.Rulesets.Objects sliderPath.reverseControlPoints(out positionalOffset); } + /// + /// Keeps removing the last element of the provided array until the last two elements are not equal. + /// + /// The array to truncate. + /// The truncated array. + private static double[] truncateEndingDuplicates(double[] arr) + { + if (arr.Length < 2) + return arr; + + var result = arr.ToList(); + + while (Precision.AlmostEquals(result[^1], result[^2])) + result.RemoveAt(result.Count - 1); + + return result.ToArray(); + } + /// /// Reverses the order of the provided 's s. ///