mirror of
https://github.com/osukey/osukey.git
synced 2025-07-04 09:49:55 +09:00
Add treatment of slider segments encoded by the same vertex appearing twice in succession.
This commit is contained in:
@ -35,20 +35,43 @@ namespace osu.Game.Modes.Osu.Objects
|
|||||||
|
|
||||||
private List<Vector2> calculatedPath;
|
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)
|
switch (CurveType)
|
||||||
{
|
{
|
||||||
case CurveTypes.Linear:
|
case CurveTypes.Linear:
|
||||||
calculatedPath = Path;
|
calculatedPath.AddRange(subpath);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
var bezier = new BezierApproximator(Path);
|
var bezier = new BezierApproximator(subpath);
|
||||||
calculatedPath = bezier.CreateBezier();
|
calculatedPath.AddRange(bezier.CreateBezier());
|
||||||
break;
|
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)
|
public Vector2 PositionAt(double progress)
|
||||||
{
|
{
|
||||||
progress = MathHelper.Clamp(progress, 0, 1);
|
progress = MathHelper.Clamp(progress, 0, 1);
|
||||||
|
Reference in New Issue
Block a user