1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 20:33:11 +08:00

Add PointsInSegment method

This commit is contained in:
Naxess 2021-03-22 15:55:30 +01:00
parent bee2f55d00
commit 7a2cb526e4

View File

@ -156,6 +156,38 @@ namespace osu.Game.Rulesets.Objects
return interpolateVertices(indexOfDistance(d), d); return interpolateVertices(indexOfDistance(d), d);
} }
/// <summary>
/// Returns the control points belonging to the same segment as the one given.
/// The first point has a PathType which all other points inherit.
/// </summary>
/// <param name="controlPoint">One of the control points in the segment.</param>
/// <returns></returns>
public List<PathControlPoint> PointsInSegment(PathControlPoint controlPoint)
{
bool found = false;
List<PathControlPoint> pointsInCurrentSegment = new List<PathControlPoint>();
foreach (PathControlPoint point in ControlPoints)
{
if (point.Type.Value is PathType)
{
if (!found)
pointsInCurrentSegment.Clear();
else
{
pointsInCurrentSegment.Add(point);
break;
}
}
pointsInCurrentSegment.Add(point);
if (point == controlPoint)
found = true;
}
return pointsInCurrentSegment;
}
private void invalidate() private void invalidate()
{ {
pathCache.Invalidate(); pathCache.Invalidate();