1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 17:32:54 +08:00

Fix slider path calculations for edge cases

This commit is contained in:
Magnus-Cosmos 2023-09-19 01:31:26 -04:00
parent bd7dab1d86
commit a9b45c6fdc
No known key found for this signature in database
GPG Key ID: 97018602A1AEE703

View File

@ -261,10 +261,14 @@ namespace osu.Game.Rulesets.Objects
// The current vertex ends the segment
var segmentVertices = vertices.AsSpan().Slice(start, i - start + 1);
var segmentType = ControlPoints[start].Type ?? PathType.Linear;
foreach (Vector2 t in calculateSubPath(segmentVertices, segmentType))
// No need to calculate path when there is only 1 vertex
if (segmentVertices.Length == 1)
calculatedPath.Add(segmentVertices[0]);
else if (segmentVertices.Length > 1)
{
if (calculatedPath.Count == 0 || calculatedPath.Last() != t)
// Skip the first vertex if it is the same as the last vertex from the previous segment
int skipFirst = calculatedPath.Last() == segmentVertices[0] ? 1 : 0;
foreach (Vector2 t in calculateSubPath(segmentVertices, segmentType).Skip(skipFirst))
calculatedPath.Add(t);
}