Make approximators share an interface

This commit is contained in:
smoogipoo
2018-11-01 19:00:14 +09:00
parent c1304eca1b
commit 1aae123ff5
7 changed files with 88 additions and 96 deletions

View File

@ -28,14 +28,14 @@ namespace osu.Game.Rulesets.Objects
switch (PathType)
{
case PathType.Linear:
return new LinearApproximator(subControlPoints).CreateLinear();
return new LinearApproximator().Approximate(subControlPoints);
case PathType.PerfectCurve:
//we can only use CircularArc iff we have exactly three control points and no dissection.
if (ControlPoints.Length != 3 || subControlPoints.Length != 3)
break;
// Here we have exactly 3 control points. Attempt to fit a circular arc.
List<Vector2> subpath = new CircularArcApproximator(subControlPoints).CreateArc();
List<Vector2> subpath = new CircularArcApproximator().Approximate(subControlPoints);
// If for some reason a circular arc could not be fit to the 3 given points, fall back to a numerically stable bezier approximation.
if (subpath.Count == 0)
@ -43,10 +43,10 @@ namespace osu.Game.Rulesets.Objects
return subpath;
case PathType.Catmull:
return new CatmullApproximator(subControlPoints).CreateCatmull();
return new CatmullApproximator().Approximate(subControlPoints);
}
return new BezierApproximator(subControlPoints).CreateBezier();
return new BezierApproximator().Approximate(subControlPoints);
}
private void calculatePath()