From d56e23195de665bc7125610a9dd33d4df7b25f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 29 Nov 2016 21:31:01 +0100 Subject: [PATCH] Add treatment of slider segments encoded by the same vertex appearing twice in succession. --- osu.Game.Mode.Osu/Objects/Slider.cs | 31 +++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/osu.Game.Mode.Osu/Objects/Slider.cs b/osu.Game.Mode.Osu/Objects/Slider.cs index 7ee131659a..c79d52d0dd 100644 --- a/osu.Game.Mode.Osu/Objects/Slider.cs +++ b/osu.Game.Mode.Osu/Objects/Slider.cs @@ -35,20 +35,43 @@ namespace osu.Game.Modes.Osu.Objects private List calculatedPath; - public void Calculate() + private void calculateSubpath(List 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(); + List subpath = new List(); + + 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);