diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyBeatmap.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyBeatmap.cs index 53f9d6d5f1..d10cd869b3 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyBeatmap.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyBeatmap.cs @@ -39,11 +39,11 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing // If the map has less than two OsuHitObjects, the enumerator will not return anything. for (int i = 1; i < objects.Count; i++) { - var prev = objects[i - 1]; + var lastLast = i > 1 ? objects[i - 2] : null; + var last = objects[i - 1]; var current = objects[i]; - var next = i < objects.Count - 1 ? objects[i + 1] : null; - yield return new OsuDifficultyHitObject(prev, current, next, timeRate); + yield return new OsuDifficultyHitObject(lastLast, last, current, timeRate); } } } diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs index 6a0dd206ff..6275ac45fa 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -40,19 +40,23 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing /// public double StrainTime { get; private set; } + /// + /// Angle the player has to take to hit this . + /// Calculated as the angle between the circles (current-2, current-1, current). + /// public double? Angle { get; private set; } + private readonly OsuHitObject lastLastObject; private readonly OsuHitObject lastObject; - private readonly OsuHitObject nextObject; private readonly double timeRate; /// /// Initializes the object calculating extra data required for difficulty calculation. /// - public OsuDifficultyHitObject(OsuHitObject lastObject, OsuHitObject currentObject, OsuHitObject nextObject, double timeRate) + public OsuDifficultyHitObject(OsuHitObject lastLastObject, OsuHitObject lastObject, OsuHitObject currentObject, double timeRate) { + this.lastLastObject = lastLastObject; this.lastObject = lastObject; - this.nextObject = nextObject; this.timeRate = timeRate; BaseObject = currentObject; @@ -72,34 +76,21 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing scalingFactor *= 1 + smallCircleBonus; } - Vector2 lastCursorPosition = lastObject.StackedPosition; - - var lastSlider = lastObject as Slider; - if (lastSlider != null) - { - computeSliderCursorPosition(lastSlider); - lastCursorPosition = lastSlider.LazyEndPosition ?? lastCursorPosition; - + if (lastObject is Slider lastSlider) TravelDistance = lastSlider.LazyTravelDistance * scalingFactor; - } + + Vector2 lastCursorPosition = getEndCursorPosition(lastObject); // Don't need to jump to reach spinners if (!(BaseObject is Spinner)) JumpDistance = (BaseObject.StackedPosition * scalingFactor - lastCursorPosition * scalingFactor).Length; - if (nextObject != null) + if (lastLastObject != null) { - var endCursorPosition = BaseObject.StackedPosition; + Vector2 lastLastCursorPosition = getEndCursorPosition(lastLastObject); - var currentSlider = BaseObject as Slider; - if (currentSlider != null) - { - computeSliderCursorPosition(currentSlider); - endCursorPosition = currentSlider.LazyEndPosition ?? endCursorPosition; - } - - Vector2 v1 = lastCursorPosition - BaseObject.StackedPosition; - Vector2 v2 = nextObject.StackedPosition - endCursorPosition; + Vector2 v1 = lastLastCursorPosition - lastObject.StackedPosition; + Vector2 v2 = BaseObject.StackedPosition - lastCursorPosition; float dot = Vector2.Dot(v1, v2); float det = v1.X * v2.Y - v1.Y * v2.X; @@ -151,5 +142,19 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing computeVertex(time); computeVertex(slider.EndTime); } + + private Vector2 getEndCursorPosition(OsuHitObject hitObject) + { + Vector2 pos = hitObject.StackedPosition; + + var slider = hitObject as Slider; + if (slider != null) + { + computeSliderCursorPosition(slider); + pos = slider.LazyEndPosition ?? pos; + } + + return pos; + } } }