1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 06:35:05 +08:00

Check if path lists are empty

This commit is contained in:
Magnus-Cosmos 2023-09-19 02:28:28 -04:00
parent a9b45c6fdc
commit 73db68a49a
No known key found for this signature in database
GPG Key ID: 97018602A1AEE703

View File

@ -261,14 +261,17 @@ 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;
// No need to calculate path when there is only 1 vertex
if (segmentVertices.Length == 1)
calculatedPath.Add(segmentVertices[0]);
else if (segmentVertices.Length > 1)
{
List<Vector2> subPath = calculateSubPath(segmentVertices, segmentType);
// 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))
int skipFirst = calculatedPath.Count > 0 && subPath.Count > 0 && calculatedPath.Last() == subPath[0] ? 1 : 0;
foreach (Vector2 t in subPath.Skip(skipFirst))
calculatedPath.Add(t);
}