From 771620cef1e871b0bfe1e419bb74849f6c894b4c Mon Sep 17 00:00:00 2001 From: Xexxar Date: Sun, 7 Nov 2021 14:21:18 +0000 Subject: [PATCH 1/4] refactored duplicate code for simplicity --- .../Preprocessing/OsuDifficultyHitObject.cs | 34 +++++++------------ 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs index 3e220f6199..a03d11575a 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -147,6 +147,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing Vector2 currMovement = Vector2.Subtract(currMovementObj.StackedPosition, currCursorPosition); double currMovementLength = scalingFactor * currMovement.Length; + double currRadius = assumed_slider_radius; if (i == slider.NestedHitObjects.Count - 1) { @@ -160,31 +161,20 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing currMovement = lazyMovement; currMovementLength = scalingFactor * currMovement.Length; + } + else if (currMovementObj is SliderRepeat) + currRadius = normalized_radius; - 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; - } + if (currMovementLength > currRadius) + { + // this finds the positional delta from the required radius and the current position, and updates the currCursorPosition accordingly, as well as rewarding distance. + currCursorPosition = Vector2.Add(currCursorPosition, Vector2.Multiply(currMovement, (float)((currMovementLength - currRadius) / currMovementLength))); + currMovementLength *= (currMovementLength - currRadius) / currMovementLength; + slider.LazyTravelDistance += (float)currMovementLength; + } + if (i == slider.NestedHitObjects.Count - 1) 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. From 6aecd682affbcfe63934814002be22e95c9bb8d1 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sun, 7 Nov 2021 23:26:13 +0900 Subject: [PATCH 2/4] Refactor a bit --- .../Preprocessing/OsuDifficultyHitObject.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs index a03d11575a..606f6a5394 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -147,7 +147,9 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing Vector2 currMovement = Vector2.Subtract(currMovementObj.StackedPosition, currCursorPosition); double currMovementLength = scalingFactor * currMovement.Length; - double currRadius = assumed_slider_radius; + + // Amount of movement required so that the cursor position needs to be updated. + double requiredMovement = assumed_slider_radius; if (i == slider.NestedHitObjects.Count - 1) { @@ -163,13 +165,16 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing currMovementLength = scalingFactor * currMovement.Length; } else if (currMovementObj is SliderRepeat) - currRadius = normalized_radius; + { + // For a slider repeat, assume a tighter movement threshold to better assess repeat sliders. + requiredMovement = normalized_radius; + } - if (currMovementLength > currRadius) + if (currMovementLength > requiredMovement) { // this finds the positional delta from the required radius and the current position, and updates the currCursorPosition accordingly, as well as rewarding distance. - currCursorPosition = Vector2.Add(currCursorPosition, Vector2.Multiply(currMovement, (float)((currMovementLength - currRadius) / currMovementLength))); - currMovementLength *= (currMovementLength - currRadius) / currMovementLength; + currCursorPosition = Vector2.Add(currCursorPosition, Vector2.Multiply(currMovement, (float)((currMovementLength - requiredMovement) / currMovementLength))); + currMovementLength *= (currMovementLength - requiredMovement) / currMovementLength; slider.LazyTravelDistance += (float)currMovementLength; } From 95f2bef119ba54f55a0983fc1ea795704b390c69 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sun, 7 Nov 2021 23:27:37 +0900 Subject: [PATCH 3/4] Update tests --- .../OsuDifficultyCalculatorTest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs b/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs index 7cd06c5225..79d575ab3f 100644 --- a/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs +++ b/osu.Game.Rulesets.Osu.Tests/OsuDifficultyCalculatorTest.cs @@ -15,13 +15,13 @@ namespace osu.Game.Rulesets.Osu.Tests { protected override string ResourceAssembly => "osu.Game.Rulesets.Osu"; - [TestCase(6.5295339534769958d, "diffcalc-test")] - [TestCase(1.1514260533755143d, "zero-length-sliders")] + [TestCase(6.531832890435525d, "diffcalc-test")] + [TestCase(1.4644923495008817d, "zero-length-sliders")] public void Test(double expected, string name) => base.Test(expected, name); - [TestCase(9.047752485219954d, "diffcalc-test")] - [TestCase(1.3985711787077566d, "zero-length-sliders")] + [TestCase(8.8067616302940852d, "diffcalc-test")] + [TestCase(1.7763214959309293d, "zero-length-sliders")] public void TestClockRateAdjusted(double expected, string name) => Test(expected, name, new OsuModDoubleTime()); From 03476e018e65591d08b47507a7ce410914b06e0f Mon Sep 17 00:00:00 2001 From: Xexxar Date: Sun, 7 Nov 2021 14:49:26 +0000 Subject: [PATCH 4/4] fixed comment --- .../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 a03d11575a..313078f153 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -101,7 +101,7 @@ 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 the distance beyond the s. tailJumpDistance is maximum_slider_radius since the full distance of radial leniency is still possible. + // JumpDistance is the leniency distance beyond the assumed_slider_radius. 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