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();
return segmentEnds.Select(i => cumulativeLength[i] / Distance);
return segmentEnds.Select(i => cumulativeLength[i] / calculatedLength);
}
private void invalidate()
@ -251,9 +251,8 @@ namespace osu.Game.Rulesets.Objects
calculatedPath.Add(t);
}
if (i > 0)
// Remember the index of the segment end
segmentEnds.Add(calculatedPath.Count - 1);
// Remember the index of the segment end
segmentEnds.Add(calculatedPath.Count - 1);
// Start the new segment at the current vertex
start = i;
@ -315,11 +314,15 @@ namespace osu.Game.Rulesets.Objects
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)
{
cumulativeLength.RemoveAt(cumulativeLength.Count - 1);
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]);
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);
}
}
}