Revert changes in SliderPath

This commit is contained in:
Pasi4K5 2023-08-19 00:16:05 +02:00
parent 3481c41a22
commit 0e691d5935

View File

@ -202,7 +202,7 @@ namespace osu.Game.Rulesets.Objects
{ {
ensureValid(); ensureValid();
return segmentEnds.Select(i => cumulativeLength[i] / Distance); return segmentEnds.Select(i => cumulativeLength[i] / calculatedLength);
} }
private void invalidate() private void invalidate()
@ -251,7 +251,6 @@ namespace osu.Game.Rulesets.Objects
calculatedPath.Add(t); calculatedPath.Add(t);
} }
if (i > 0)
// Remember the index of the segment end // Remember the index of the segment end
segmentEnds.Add(calculatedPath.Count - 1); segmentEnds.Add(calculatedPath.Count - 1);
@ -315,11 +314,15 @@ namespace osu.Game.Rulesets.Objects
if (calculatedLength > expectedDistance) if (calculatedLength > expectedDistance)
{ {
// The path will be shortened further, in which case we should trim any more unnecessary lengths // The path will be shortened further, in which case we should trim any more unnecessary lengths and their associated path segments
while (cumulativeLength.Count > 0 && cumulativeLength[^1] >= expectedDistance) while (cumulativeLength.Count > 0 && cumulativeLength[^1] >= expectedDistance)
{ {
cumulativeLength.RemoveAt(cumulativeLength.Count - 1); cumulativeLength.RemoveAt(cumulativeLength.Count - 1);
calculatedPath.RemoveAt(pathEndIndex--); calculatedPath.RemoveAt(pathEndIndex--);
// Shorten the last segment to the expected distance
if (segmentEnds.Count > 0)
segmentEnds[^1]--;
} }
} }
@ -336,12 +339,6 @@ namespace osu.Game.Rulesets.Objects
calculatedPath[pathEndIndex] = calculatedPath[pathEndIndex - 1] + dir * (float)(expectedDistance - cumulativeLength[^1]); calculatedPath[pathEndIndex] = calculatedPath[pathEndIndex - 1] + dir * (float)(expectedDistance - cumulativeLength[^1]);
cumulativeLength.Add(expectedDistance); cumulativeLength.Add(expectedDistance);
// Shorten the segments to the expected distance
for (int i = 0; i < segmentEnds.Count; i++)
{
segmentEnds[i] = Math.Min(segmentEnds[i], cumulativeLength.Count - 1);
}
} }
} }