mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 14:47:18 +08:00
Merge pull request #21559 from OliBomby/stream-tool-1
Add segment end completions list to SliderPath
This commit is contained in:
commit
d1ca4ebd40
@ -42,6 +42,7 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
|
|
||||||
private readonly List<Vector2> calculatedPath = new List<Vector2>();
|
private readonly List<Vector2> calculatedPath = new List<Vector2>();
|
||||||
private readonly List<double> cumulativeLength = new List<double>();
|
private readonly List<double> cumulativeLength = new List<double>();
|
||||||
|
private readonly List<int> segmentEnds = new List<int>();
|
||||||
private readonly Cached pathCache = new Cached();
|
private readonly Cached pathCache = new Cached();
|
||||||
|
|
||||||
private double calculatedLength;
|
private double calculatedLength;
|
||||||
@ -196,6 +197,16 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
return pointsInCurrentSegment;
|
return pointsInCurrentSegment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the progress values at which segments of the path end.
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<double> GetSegmentEnds()
|
||||||
|
{
|
||||||
|
ensureValid();
|
||||||
|
|
||||||
|
return segmentEnds.Select(i => cumulativeLength[i] / calculatedLength);
|
||||||
|
}
|
||||||
|
|
||||||
private void invalidate()
|
private void invalidate()
|
||||||
{
|
{
|
||||||
pathCache.Invalidate();
|
pathCache.Invalidate();
|
||||||
@ -216,6 +227,7 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
private void calculatePath()
|
private void calculatePath()
|
||||||
{
|
{
|
||||||
calculatedPath.Clear();
|
calculatedPath.Clear();
|
||||||
|
segmentEnds.Clear();
|
||||||
|
|
||||||
if (ControlPoints.Count == 0)
|
if (ControlPoints.Count == 0)
|
||||||
return;
|
return;
|
||||||
@ -241,6 +253,9 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
calculatedPath.Add(t);
|
calculatedPath.Add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remember the index of the segment end
|
||||||
|
segmentEnds.Add(calculatedPath.Count - 1);
|
||||||
|
|
||||||
// Start the new segment at the current vertex
|
// Start the new segment at the current vertex
|
||||||
start = i;
|
start = i;
|
||||||
}
|
}
|
||||||
@ -306,6 +321,10 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
{
|
{
|
||||||
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]--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user