From 7eb0edf0464c75a78caa07f6075f75d4c6db52af Mon Sep 17 00:00:00 2001 From: Xexxar Date: Wed, 3 Nov 2021 17:59:09 +0000 Subject: [PATCH 1/5] added stanrs requested changes --- .../Preprocessing/OsuDifficultyHitObject.cs | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs index 9be61ba506..46237f732f 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -100,21 +100,23 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing for (int i = 1; i < lastSlider.NestedHitObjects.Count; i++) { - Vector2 currSlider = Vector2.Subtract(((OsuHitObject)lastSlider.NestedHitObjects[i]).StackedPosition, currSliderPosition); + var currSliderObj = (OsuHitObject)lastSlider.NestedHitObjects[i]; + + Vector2 currSlider = Vector2.Subtract(currSliderObj.StackedPosition, currSliderPosition); double currSliderLength = currSlider.Length * scalingFactor; - if ((OsuHitObject)lastSlider.NestedHitObjects[i] is SliderEndCircle && !((OsuHitObject)lastSlider.NestedHitObjects[i] is SliderRepeat)) + if (currSliderObj is SliderEndCircle && !(currSliderObj is SliderRepeat)) { - Vector2 possSlider = Vector2.Subtract((Vector2)lastSlider.LazyEndPosition, currSliderPosition); - if (possSlider.Length < currSlider.Length) - currSlider = possSlider; // Take the least distance from slider end vs lazy end. + Vector2 lazySlider = Vector2.Subtract((Vector2)lastSlider.LazyEndPosition, currSliderPosition); + if (lazySlider.Length < currSlider.Length) + currSlider = lazySlider; // Take the least distance from slider end vs lazy end. currSliderLength = currSlider.Length * scalingFactor; } - if ((OsuHitObject)lastSlider.NestedHitObjects[i] is SliderTick) + if (currSliderObj is SliderTick) { - if (currSliderLength > 120) + if (currSliderLength > 120) // 120 is used here as 120 = 2.4 * radius, which means that the cursor assumes the position of least movement required to reach the active tick window. { currSliderPosition = Vector2.Add(currSliderPosition, Vector2.Multiply(currSlider, (float)((currSliderLength - 120) / currSliderLength))); currSliderLength *= (currSliderLength - 120) / currSliderLength; @@ -122,9 +124,9 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing else currSliderLength = 0; } - else if ((OsuHitObject)lastSlider.NestedHitObjects[i] is SliderRepeat) + else if (currSliderObj is SliderRepeat) { - if (currSliderLength > 50) + if (currSliderLength > 50) // 50 is used here as 50 = radius. This is a way to reward motion of back and forths sliders where we assume the player moves to atleast the rim of the hitcircle. { currSliderPosition = Vector2.Add(currSliderPosition, Vector2.Multiply(currSlider, (float)((currSliderLength - 50) / currSliderLength))); currSliderLength *= (currSliderLength - 50) / currSliderLength; @@ -134,16 +136,10 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing } else { - if (currSliderLength > 0) - { - currSliderPosition = Vector2.Add(currSliderPosition, Vector2.Multiply(currSlider, (float)((currSliderLength - 0) / currSliderLength))); - currSliderLength *= (currSliderLength - 0) / currSliderLength; - } - else - currSliderLength = 0; + currSliderPosition = Vector2.Add(currSliderPosition, currSlider); } - if ((OsuHitObject)lastSlider.NestedHitObjects[i] is SliderRepeat) + if (currSliderObj is SliderRepeat) repeatCount++; TravelDistance += currSliderLength; From 6c6a440f1bdd4f4f6e5574157cd82dfd2db178a9 Mon Sep 17 00:00:00 2001 From: Xexxar Date: Wed, 3 Nov 2021 18:09:44 +0000 Subject: [PATCH 2/5] applied constants to numbers --- .../Preprocessing/OsuDifficultyHitObject.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs index 46237f732f..b1de132aa7 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -14,6 +14,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing { private const int normalized_radius = 50; // Change radius to 50 to make 100 the diameter. Easier for mental maths. private const int min_delta_time = 25; + private const int minimum_slider_radius = normalized_radius * 2.4; protected new OsuHitObject BaseObject => (OsuHitObject)base.BaseObject; @@ -116,20 +117,20 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing if (currSliderObj is SliderTick) { - if (currSliderLength > 120) // 120 is used here as 120 = 2.4 * radius, which means that the cursor assumes the position of least movement required to reach the active tick window. + if (currSliderLength > minimum_slider_radius) // minimum_slider_radius is used here as 120 = 2.4 * radius, which means that the cursor assumes the position of least movement required to reach the active tick window. { - currSliderPosition = Vector2.Add(currSliderPosition, Vector2.Multiply(currSlider, (float)((currSliderLength - 120) / currSliderLength))); - currSliderLength *= (currSliderLength - 120) / currSliderLength; + currSliderPosition = Vector2.Add(currSliderPosition, Vector2.Multiply(currSlider, (float)((currSliderLength - minimum_slider_radius) / currSliderLength))); + currSliderLength *= (currSliderLength - minimum_slider_radius) / currSliderLength; } else currSliderLength = 0; } else if (currSliderObj is SliderRepeat) { - if (currSliderLength > 50) // 50 is used here as 50 = radius. This is a way to reward motion of back and forths sliders where we assume the player moves to atleast the rim of the hitcircle. + if (currSliderLength > normalized_radius) // normalized_radius is used here as 50 = radius. This is a way to reward motion of back and forths sliders where we assume the player moves to atleast the rim of the hitcircle. { - currSliderPosition = Vector2.Add(currSliderPosition, Vector2.Multiply(currSlider, (float)((currSliderLength - 50) / currSliderLength))); - currSliderLength *= (currSliderLength - 50) / currSliderLength; + currSliderPosition = Vector2.Add(currSliderPosition, Vector2.Multiply(currSlider, (float)((currSliderLength - normalized_radius) / currSliderLength))); + currSliderLength *= (currSliderLength - normalized_radius) / currSliderLength; } else currSliderLength = 0; @@ -154,8 +155,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing // such that they're not jumping from the lazy position but rather from very close to (or the end of) the slider. // In such cases, a leniency is applied by also considering the jump distance from the tail of the slider, and taking the minimum jump distance. // Additional distance is removed based on position of jump relative to slider follow circle radius. - // JumpDistance is 50 since follow radius = 1.4 * radius. tailJumpDistance is 120 since the full distance of radial leniency is still possible. - MovementDistance = Math.Max(0, Math.Min(JumpDistance - 50, tailJumpDistance - 120)); + // JumpDistance is normalized_radius because lazyCursorPos uses a tighter 1.4 followCircle. tailJumpDistance is minimum_slider_radius since the full distance of radial leniency is still possible. + MovementDistance = Math.Max(0, Math.Min(JumpDistance - normalized_radius, tailJumpDistance - 120)); } else { From 23dbf04764ab3ada804cdbcdb76800dbaa301775 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 4 Nov 2021 09:17:51 +0900 Subject: [PATCH 3/5] Fix incorrect type --- .../Difficulty/Preprocessing/OsuDifficultyHitObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs index b1de132aa7..d8b176cc29 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing { private const int normalized_radius = 50; // Change radius to 50 to make 100 the diameter. Easier for mental maths. private const int min_delta_time = 25; - private const int minimum_slider_radius = normalized_radius * 2.4; + private const float minimum_slider_radius = normalized_radius * 2.4f; protected new OsuHitObject BaseObject => (OsuHitObject)base.BaseObject; From d76158cbad8142d022f4a71d42f857da2c0e49aa Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 4 Nov 2021 09:20:46 +0900 Subject: [PATCH 4/5] Resolve inspection --- .../Difficulty/Preprocessing/OsuDifficultyHitObject.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs index d8b176cc29..e1b4ee51e1 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Diagnostics; using System.Linq; using osu.Game.Rulesets.Difficulty.Preprocessing; using osu.Game.Rulesets.Objects; @@ -108,6 +109,9 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing if (currSliderObj is SliderEndCircle && !(currSliderObj is SliderRepeat)) { + // Calculated above/ + Debug.Assert(lastSlider.LazyEndPosition != null); + Vector2 lazySlider = Vector2.Subtract((Vector2)lastSlider.LazyEndPosition, currSliderPosition); if (lazySlider.Length < currSlider.Length) currSlider = lazySlider; // Take the least distance from slider end vs lazy end. From 3e08772660ef53624a8ccc8359897b8cb6d230a1 Mon Sep 17 00:00:00 2001 From: Xexxar Date: Sat, 6 Nov 2021 19:16:58 +0000 Subject: [PATCH 5/5] updated slider to use lazytraveldistance code location --- .../Preprocessing/OsuDifficultyHitObject.cs | 138 +++++++----------- 1 file changed, 56 insertions(+), 82 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs index b1de132aa7..92b50412d9 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -14,7 +14,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing { private const int normalized_radius = 50; // Change radius to 50 to make 100 the diameter. Easier for mental maths. private const int min_delta_time = 25; - private const int minimum_slider_radius = normalized_radius * 2.4; + private const float maximum_slider_radius = normalized_radius * 2.4f; + private const float assumed_slider_radius = normalized_radius * 1.6f; protected new OsuHitObject BaseObject => (OsuHitObject)base.BaseObject; @@ -90,63 +91,9 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing if (lastObject is Slider lastSlider) { computeSliderCursorPosition(lastSlider); - TravelDistance = 0; + TravelDistance = lastSlider.LazyTravelDistance; TravelTime = Math.Max(lastSlider.LazyTravelTime / clockRate, min_delta_time); MovementTime = Math.Max(StrainTime - TravelTime, min_delta_time); - MovementDistance = Vector2.Subtract(lastSlider.TailCircle.StackedPosition, BaseObject.StackedPosition).Length * scalingFactor; - - int repeatCount = 0; - - Vector2 currSliderPosition = ((OsuHitObject)lastSlider.NestedHitObjects[0]).StackedPosition; - - for (int i = 1; i < lastSlider.NestedHitObjects.Count; i++) - { - var currSliderObj = (OsuHitObject)lastSlider.NestedHitObjects[i]; - - Vector2 currSlider = Vector2.Subtract(currSliderObj.StackedPosition, currSliderPosition); - double currSliderLength = currSlider.Length * scalingFactor; - - if (currSliderObj is SliderEndCircle && !(currSliderObj is SliderRepeat)) - { - Vector2 lazySlider = Vector2.Subtract((Vector2)lastSlider.LazyEndPosition, currSliderPosition); - if (lazySlider.Length < currSlider.Length) - currSlider = lazySlider; // Take the least distance from slider end vs lazy end. - - currSliderLength = currSlider.Length * scalingFactor; - } - - if (currSliderObj is SliderTick) - { - if (currSliderLength > minimum_slider_radius) // minimum_slider_radius is used here as 120 = 2.4 * radius, which means that the cursor assumes the position of least movement required to reach the active tick window. - { - currSliderPosition = Vector2.Add(currSliderPosition, Vector2.Multiply(currSlider, (float)((currSliderLength - minimum_slider_radius) / currSliderLength))); - currSliderLength *= (currSliderLength - minimum_slider_radius) / currSliderLength; - } - else - currSliderLength = 0; - } - else if (currSliderObj is SliderRepeat) - { - if (currSliderLength > normalized_radius) // normalized_radius is used here as 50 = radius. This is a way to reward motion of back and forths sliders where we assume the player moves to atleast the rim of the hitcircle. - { - currSliderPosition = Vector2.Add(currSliderPosition, Vector2.Multiply(currSlider, (float)((currSliderLength - normalized_radius) / currSliderLength))); - currSliderLength *= (currSliderLength - normalized_radius) / currSliderLength; - } - else - currSliderLength = 0; - } - else - { - currSliderPosition = Vector2.Add(currSliderPosition, currSlider); - } - - if (currSliderObj is SliderRepeat) - repeatCount++; - - TravelDistance += currSliderLength; - } - - TravelDistance *= Math.Pow(1 + repeatCount / 2.5, 1.0 / 2.5); // Bonus for repeat sliders until a better per nested object strain system can be achieved. // Jump distance from the slider tail to the next object, as opposed to the lazy position of JumpDistance. float tailJumpDistance = Vector2.Subtract(lastSlider.TailCircle.StackedPosition, BaseObject.StackedPosition).Length * scalingFactor; @@ -155,8 +102,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing // such that they're not jumping from the lazy position but rather from very close to (or the end of) the slider. // In such cases, a leniency is applied by also considering the jump distance from the tail of the slider, and taking the minimum jump distance. // Additional distance is removed based on position of jump relative to slider follow circle radius. - // JumpDistance is normalized_radius because lazyCursorPos uses a tighter 1.4 followCircle. tailJumpDistance is minimum_slider_radius since the full distance of radial leniency is still possible. - MovementDistance = Math.Max(0, Math.Min(JumpDistance - normalized_radius, tailJumpDistance - 120)); + // JumpDistance is the distance beyond the s. tailJumpDistance is maximum_slider_radius since the full distance of radial leniency is still possible. + MovementDistance = Math.Max(0, Math.Min(JumpDistance - (maximum_slider_radius - assumed_slider_radius), tailJumpDistance - maximum_slider_radius)); } else { @@ -183,37 +130,64 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing if (slider.LazyEndPosition != null) return; - slider.LazyEndPosition = slider.StackedPosition; + slider.LazyTravelTime = slider.NestedHitObjects[slider.NestedHitObjects.Count - 1].StartTime - slider.StartTime; - float approxFollowCircleRadius = (float)(slider.Radius * 1.4); // using 1.4 to better follow the real movement of a cursor. - var computeVertex = new Action(t => - { - double progress = (t - slider.StartTime) / slider.SpanDuration; - if (progress % 2 >= 1) - progress = 1 - progress % 1; + double endTimeMin = slider.LazyTravelTime / slider.SpanDuration; + if (endTimeMin % 2 >= 1) + endTimeMin = 1 - endTimeMin % 1; else - progress %= 1; + endTimeMin %= 1; - // ReSharper disable once PossibleInvalidOperationException (bugged in current r# version) - var diff = slider.StackedPosition + slider.Path.PositionAt(progress) - slider.LazyEndPosition.Value; - float dist = diff.Length; + slider.LazyEndPosition = slider.StackedPosition + slider.Path.PositionAt(endTimeMin); // temporary lazy end position until a real result can be derived. + var currCursorPosition = slider.StackedPosition; + double scalingFactor = normalized_radius / slider.Radius; // lazySliderDistance is coded to be sensitive to scaling, this makes the maths easier with the thresholds being used. - slider.LazyTravelTime = t - slider.StartTime; + for (int i = 1; i < slider.NestedHitObjects.Count; i++) + { + var currMovementObj = (OsuHitObject)slider.NestedHitObjects[i]; - if (dist > approxFollowCircleRadius) + Vector2 currMovement = Vector2.Subtract(currMovementObj.StackedPosition, currCursorPosition); + double currMovementLength = scalingFactor * currMovement.Length; + + if (i == slider.NestedHitObjects.Count - 1) { - // The cursor would be outside the follow circle, we need to move it - diff.Normalize(); // Obtain direction of diff - dist -= approxFollowCircleRadius; - slider.LazyEndPosition += diff * dist; - slider.LazyTravelDistance += dist; - } - }); + // The end of a slider has special aim rules due to the relaxed time constraint on position. + // There is both a lazy end position as well as the actual end slider position. We assume the player takes the simpler movement. + // For sliders that are circular, the lazy end position may actually be farther away than the sliders true end. + // This code is designed to prevent buffing situations where lazy end is actually a less efficient movement. + Vector2 lazyMovement = Vector2.Subtract((Vector2)slider.LazyEndPosition, currCursorPosition); - // Skip the head circle - var scoringTimes = slider.NestedHitObjects.Skip(1).Select(t => t.StartTime); - foreach (double time in scoringTimes) - computeVertex(time); + if (lazyMovement.Length < currMovement.Length) + currMovement = lazyMovement; + + currMovementLength = scalingFactor * currMovement.Length; + + if (currMovementLength > assumed_slider_radius) + { + // Calculate the vector movement, regardless of final location to get the true lazy end position. + currCursorPosition = Vector2.Add(currCursorPosition, Vector2.Multiply(currMovement, (float)((currMovementLength - assumed_slider_radius) / currMovementLength))); + currMovementLength *= (currMovementLength - assumed_slider_radius) / currMovementLength; + slider.LazyTravelDistance += (float)currMovementLength; + } + slider.LazyEndPosition = currCursorPosition; + } + else if (currMovementObj is SliderRepeat && currMovementLength > normalized_radius) + { + // For a slider repeat, assume a tighter movement threshold to better assess repeat sliders. + currCursorPosition = Vector2.Add(currCursorPosition, Vector2.Multiply(currMovement, (float)((currMovementLength - normalized_radius) / currMovementLength))); + currMovementLength *= (currMovementLength - normalized_radius) / currMovementLength; + slider.LazyTravelDistance += (float)currMovementLength; + } + else if (currMovementLength > assumed_slider_radius) + { + // For a slider ticks, use the assumed slider radius for a more accurate movement assessment. + currCursorPosition = Vector2.Add(currCursorPosition, Vector2.Multiply(currMovement, (float)((currMovementLength - assumed_slider_radius) / currMovementLength))); + currMovementLength *= (currMovementLength - assumed_slider_radius) / currMovementLength; + slider.LazyTravelDistance += (float)currMovementLength; + } + } + + slider.LazyTravelDistance *= (float)Math.Pow(1 + slider.RepeatCount / 2.5, 1.0 / 2.5); // Bonus for repeat sliders until a better per nested object strain system can be achieved. } private Vector2 getEndCursorPosition(OsuHitObject hitObject)