mirror of https://github.com/ppy/osu
Ensure SliderCurve is assigned Calculated before used.
This commit is contained in:
parent
fc192906ea
commit
e88d02d3c4
|
@ -29,8 +29,6 @@ public override HitObject Parse(string text)
|
|||
result = new HitCircle();
|
||||
break;
|
||||
case HitObjectType.Slider:
|
||||
Slider s = new Slider();
|
||||
|
||||
CurveTypes curveType = CurveTypes.Catmull;
|
||||
int repeatCount = 0;
|
||||
double length = 0;
|
||||
|
@ -79,18 +77,13 @@ public override HitObject Parse(string text)
|
|||
if (split.Length > 7)
|
||||
length = Convert.ToDouble(split[7], CultureInfo.InvariantCulture);
|
||||
|
||||
s.RepeatCount = repeatCount;
|
||||
|
||||
s.Curve = new SliderCurve
|
||||
result = new Slider
|
||||
{
|
||||
ControlPoints = points,
|
||||
Length = length,
|
||||
CurveType = curveType
|
||||
CurveType = curveType,
|
||||
RepeatCount = repeatCount
|
||||
};
|
||||
|
||||
s.Curve.Calculate();
|
||||
|
||||
result = s;
|
||||
break;
|
||||
case HitObjectType.Spinner:
|
||||
result = new Spinner();
|
||||
|
@ -101,7 +94,8 @@ public override HitObject Parse(string text)
|
|||
}
|
||||
result.Position = new Vector2(int.Parse(split[0]), int.Parse(split[1]));
|
||||
result.StartTime = double.Parse(split[2]);
|
||||
result.Sample = new HitSampleInfo {
|
||||
result.Sample = new HitSampleInfo
|
||||
{
|
||||
Type = (SampleType)int.Parse(split[4]),
|
||||
Set = SampleSet.Soft,
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using OpenTK;
|
||||
|
||||
|
@ -19,11 +20,28 @@ public override int StackHeight
|
|||
set
|
||||
{
|
||||
stackHeight = value;
|
||||
if (Curve != null)
|
||||
Curve.Offset = StackOffset;
|
||||
Curve.Offset = StackOffset;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Vector2> ControlPoints
|
||||
{
|
||||
get { return Curve.ControlPoints; }
|
||||
set { Curve.ControlPoints = value; }
|
||||
}
|
||||
|
||||
public double Length
|
||||
{
|
||||
get { return Curve.Length; }
|
||||
set { Curve.Length = value; }
|
||||
}
|
||||
|
||||
public CurveTypes CurveType
|
||||
{
|
||||
get { return Curve.CurveType; }
|
||||
set { Curve.CurveType = value; }
|
||||
}
|
||||
|
||||
public double Velocity;
|
||||
|
||||
public override void SetDefaultsFromBeatmap(Beatmap beatmap)
|
||||
|
@ -35,7 +53,7 @@ public override void SetDefaultsFromBeatmap(Beatmap beatmap)
|
|||
|
||||
public int RepeatCount;
|
||||
|
||||
public SliderCurve Curve;
|
||||
internal readonly SliderCurve Curve = new SliderCurve();
|
||||
}
|
||||
|
||||
public enum CurveTypes
|
||||
|
|
|
@ -172,6 +172,9 @@ private Vector2 interpolateVertices(int i, double d)
|
|||
/// <param name="p1">End progress. Ranges from 0 (beginning of the slider) to 1 (end of the slider).</param>
|
||||
public void GetPathToProgress(List<Vector2> path, double p0, double p1)
|
||||
{
|
||||
if (calculatedPath.Count == 0 && ControlPoints.Count > 0)
|
||||
Calculate();
|
||||
|
||||
double d0 = progressToDistance(p0);
|
||||
double d1 = progressToDistance(p1);
|
||||
|
||||
|
@ -196,6 +199,9 @@ public void GetPathToProgress(List<Vector2> path, double p0, double p1)
|
|||
/// <returns></returns>
|
||||
public Vector2 PositionAt(double progress)
|
||||
{
|
||||
if (calculatedPath.Count == 0 && ControlPoints.Count > 0)
|
||||
Calculate();
|
||||
|
||||
double d = progressToDistance(progress);
|
||||
return interpolateVertices(indexOfDistance(d), d) + Offset;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue