Consider slider lengths as part of Distance

This commit is contained in:
smoogipoo 2017-11-17 21:28:59 +09:00
parent 9260f5b64e
commit eb03b0db30
2 changed files with 18 additions and 9 deletions

View File

@ -46,10 +46,16 @@ namespace osu.Game.Rulesets.Osu.Objects
} }
/// <summary> /// <summary>
/// The position of the cursor at the point of completion of this <see cref="OsuHitObject"/>. /// The position of the cursor at the point of completion of this <see cref="Slider"/> if it was hit
/// This is set and used by difficulty calculation. /// with as few movements as possible. This is set and used by difficulty calculation.
/// </summary> /// </summary>
internal Vector2? CursorPosition; internal Vector2? LazyEndPosition;
/// <summary>
/// The distance travelled by the cursor upon completion of this <see cref="Slider"/> if it was hit
/// with as few movements as possible. This is set and used by difficulty calculation.
/// </summary>
internal float LazyTravelDistance;
public List<SampleInfoList> RepeatSamples { get; set; } = new List<SampleInfoList>(); public List<SampleInfoList> RepeatSamples { get; set; } = new List<SampleInfoList>();
public int RepeatCount { get; set; } = 1; public int RepeatCount { get; set; } = 1;

View File

@ -64,15 +64,17 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing
} }
Vector2 lastCursorPosition = t[1].StackedPosition; Vector2 lastCursorPosition = t[1].StackedPosition;
float lastTravelDistance = 0;
var lastSlider = t[1] as Slider; var lastSlider = t[1] as Slider;
if (lastSlider != null) if (lastSlider != null)
{ {
computeSliderCursorPosition(lastSlider); computeSliderCursorPosition(lastSlider);
lastCursorPosition = lastSlider.CursorPosition ?? lastCursorPosition; lastCursorPosition = lastSlider.LazyEndPosition ?? lastCursorPosition;
lastTravelDistance = lastSlider.LazyTravelDistance;
} }
Distance = (BaseObject.StackedPosition - lastCursorPosition).Length * scalingFactor; Distance = (lastTravelDistance + (BaseObject.StackedPosition - lastCursorPosition).Length) * scalingFactor;
} }
private void setTimingValues() private void setTimingValues()
@ -84,14 +86,14 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing
private void computeSliderCursorPosition(Slider slider) private void computeSliderCursorPosition(Slider slider)
{ {
if (slider.CursorPosition != null) if (slider.LazyEndPosition != null)
return; return;
slider.CursorPosition = slider.StackedPosition; slider.LazyEndPosition = slider.StackedPosition;
float approxFollowCircleRadius = (float)(slider.Radius * 3); float approxFollowCircleRadius = (float)(slider.Radius * 3);
var computeVertex = new Action<double>(t => var computeVertex = new Action<double>(t =>
{ {
var diff = slider.PositionAt(t) - slider.CursorPosition.Value; var diff = slider.PositionAt(t) - slider.LazyEndPosition.Value;
float dist = diff.Length; float dist = diff.Length;
if (dist > approxFollowCircleRadius) if (dist > approxFollowCircleRadius)
@ -99,7 +101,8 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing
// The cursor would be outside the follow circle, we need to move it // The cursor would be outside the follow circle, we need to move it
diff.Normalize(); // Obtain direction of diff diff.Normalize(); // Obtain direction of diff
dist -= approxFollowCircleRadius; dist -= approxFollowCircleRadius;
slider.CursorPosition += diff * dist; slider.LazyEndPosition += diff * dist;
slider.LazyTravelDistance += dist;
} }
}); });