1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 21:47:25 +08:00

Add treatment of slider segments encoded by the same vertex appearing twice in succession.

This commit is contained in:
Thomas Müller 2016-11-29 21:31:01 +01:00
parent 53df2932ad
commit d56e23195d

View File

@ -35,20 +35,43 @@ namespace osu.Game.Modes.Osu.Objects
private List<Vector2> calculatedPath;
public void Calculate()
private void calculateSubpath(List<Vector2> subpath)
{
// If we already constructed a subpath previously, then the new subpath
// will have as starting position the end position of the previous subpath.
// Hence we can and should remove the previous endpoint to avoid a segment
// with 0 length.
if (calculatedPath.Count > 0)
calculatedPath.RemoveAt(calculatedPath.Count - 1);
switch (CurveType)
{
case CurveTypes.Linear:
calculatedPath = Path;
calculatedPath.AddRange(subpath);
break;
default:
var bezier = new BezierApproximator(Path);
calculatedPath = bezier.CreateBezier();
var bezier = new BezierApproximator(subpath);
calculatedPath.AddRange(bezier.CreateBezier());
break;
}
}
public void Calculate()
{
calculatedPath = new List<Vector2>();
List<Vector2> subpath = new List<Vector2>();
for (int i = 0; i < Path.Count; ++i)
{
subpath.Add(Path[i]);
if (i == Path.Count-1 || Path[i] == Path[i+1])
{
calculateSubpath(subpath);
subpath.Clear();
}
}
}
public Vector2 PositionAt(double progress)
{
progress = MathHelper.Clamp(progress, 0, 1);