From b72b071c257f8e66e9cf8bc7d947c6f6107db9b1 Mon Sep 17 00:00:00 2001 From: StanR Date: Sat, 9 Oct 2021 12:35:17 +0300 Subject: [PATCH 1/3] Fix instant spinners giving insane amounts of strain --- .../Preprocessing/OsuDifficultyHitObject.cs | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs index 8e8f9bc06e..6574fd388d 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -69,23 +69,26 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing 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 (lastLastObject != null) + if (!(lastObject is Spinner)) { - Vector2 lastLastCursorPosition = getEndCursorPosition(lastLastObject); + Vector2 lastCursorPosition = getEndCursorPosition(lastObject); - Vector2 v1 = lastLastCursorPosition - lastObject.StackedPosition; - Vector2 v2 = BaseObject.StackedPosition - lastCursorPosition; + // Don't need to jump to reach spinners + if (!(BaseObject is Spinner)) + JumpDistance = (BaseObject.StackedPosition * scalingFactor - lastCursorPosition * scalingFactor).Length; - float dot = Vector2.Dot(v1, v2); - float det = v1.X * v2.Y - v1.Y * v2.X; + if (lastLastObject != null) + { + Vector2 lastLastCursorPosition = getEndCursorPosition(lastLastObject); - Angle = Math.Abs(Math.Atan2(det, dot)); + 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; + + Angle = Math.Abs(Math.Atan2(det, dot)); + } } } From 3b0b8707fe2e27cddcb740444d6d03628420b5fd Mon Sep 17 00:00:00 2001 From: StanR Date: Sat, 9 Oct 2021 20:28:42 +0300 Subject: [PATCH 2/3] Reduce nesting, check all objects for spinners --- .../Preprocessing/OsuDifficultyHitObject.cs | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs index 6574fd388d..f4a1ca6f4a 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -54,6 +54,10 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing private void setDistances() { + // We don't need to calculate neither angle nor distance when one of the last->curr objects is a spinner + if (BaseObject is Spinner || lastObject is Spinner) + return; + // We will scale distances by this factor, so we can assume a uniform CircleSize among beatmaps. float scalingFactor = normalized_radius / (float)BaseObject.Radius; @@ -69,26 +73,21 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing TravelDistance = lastSlider.LazyTravelDistance * scalingFactor; } - if (!(lastObject is Spinner)) + Vector2 lastCursorPosition = getEndCursorPosition(lastObject); + + JumpDistance = (BaseObject.StackedPosition * scalingFactor - lastCursorPosition * scalingFactor).Length; + + if (lastLastObject != null && !(lastLastObject is Spinner)) { - Vector2 lastCursorPosition = getEndCursorPosition(lastObject); + Vector2 lastLastCursorPosition = getEndCursorPosition(lastLastObject); - // Don't need to jump to reach spinners - if (!(BaseObject is Spinner)) - JumpDistance = (BaseObject.StackedPosition * scalingFactor - lastCursorPosition * scalingFactor).Length; + Vector2 v1 = lastLastCursorPosition - lastObject.StackedPosition; + Vector2 v2 = BaseObject.StackedPosition - lastCursorPosition; - if (lastLastObject != null) - { - Vector2 lastLastCursorPosition = getEndCursorPosition(lastLastObject); + float dot = Vector2.Dot(v1, v2); + float det = v1.X * v2.Y - v1.Y * v2.X; - 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; - - Angle = Math.Abs(Math.Atan2(det, dot)); - } + Angle = Math.Abs(Math.Atan2(det, dot)); } } From abd32e30f16521ba1f1df33c8ba4224bab3ca2d5 Mon Sep 17 00:00:00 2001 From: StanR Date: Sat, 9 Oct 2021 21:11:24 +0300 Subject: [PATCH 3/3] Update osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs Co-authored-by: Liam DeVoe --- .../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 f4a1ca6f4a..5e5993aefe 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -54,7 +54,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing private void setDistances() { - // We don't need to calculate neither angle nor distance when one of the last->curr objects is a spinner + // We don't need to calculate either angle or distance when one of the last->curr objects is a spinner if (BaseObject is Spinner || lastObject is Spinner) return;