From b04e2cbb5c4f03fc30a201a916245cb856dc135f Mon Sep 17 00:00:00 2001 From: Thomas Tan Date: Fri, 26 Jan 2018 03:39:19 +0800 Subject: [PATCH 1/4] Fix osu star rating calculation The main bug was that the beatmap was not being processed prior to having its Skill values calculated, causing stacking to be ignored in difficulty calculation. The fix involves processing the beatmap with OsuBeatmapProcessor. Another minor bug was that sliders were not taking into account the stacked position midway through the slider (PositionAt does not return stacked position.), so I corrected by adding StackOffset. --- osu.Game.Rulesets.Osu/OsuDifficulty/OsuDifficultyCalculator.cs | 3 +-- .../OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs | 2 +- osu.Game/Beatmaps/DifficultyCalculator.cs | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu/OsuDifficulty/OsuDifficultyCalculator.cs b/osu.Game.Rulesets.Osu/OsuDifficulty/OsuDifficultyCalculator.cs index 70cfbebfff..fb5acbb643 100644 --- a/osu.Game.Rulesets.Osu/OsuDifficulty/OsuDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Osu/OsuDifficulty/OsuDifficultyCalculator.cs @@ -29,8 +29,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty protected override void PreprocessHitObjects() { - foreach (OsuHitObject h in Beatmap.HitObjects) - (h as Slider)?.Curve?.Calculate(); + new OsuBeatmapProcessor().PostProcess(Beatmap); } public override double Calculate(Dictionary categoryDifficulty = null) diff --git a/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs index 4f950353dc..a1c4a8a466 100644 --- a/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -95,7 +95,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing var computeVertex = new Action(t => { // ReSharper disable once PossibleInvalidOperationException (bugged in current r# version) - var diff = slider.PositionAt(t) - slider.LazyEndPosition.Value; + var diff = slider.PositionAt(t) + slider.StackOffset - slider.LazyEndPosition.Value; float dist = diff.Length; if (dist > approxFollowCircleRadius) diff --git a/osu.Game/Beatmaps/DifficultyCalculator.cs b/osu.Game/Beatmaps/DifficultyCalculator.cs index 798268d05f..c8cc831a35 100644 --- a/osu.Game/Beatmaps/DifficultyCalculator.cs +++ b/osu.Game/Beatmaps/DifficultyCalculator.cs @@ -19,7 +19,7 @@ namespace osu.Game.Beatmaps public abstract class DifficultyCalculator : DifficultyCalculator where T : HitObject { - protected readonly Beatmap Beatmap; + protected Beatmap Beatmap; protected readonly Mod[] Mods; protected DifficultyCalculator(Beatmap beatmap, Mod[] mods = null) From 469b13441b70b408e03f8c372e9888794d436525 Mon Sep 17 00:00:00 2001 From: Thomas Tan Date: Fri, 26 Jan 2018 04:02:35 +0800 Subject: [PATCH 2/4] Fix mistake --- osu.Game/Beatmaps/DifficultyCalculator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/DifficultyCalculator.cs b/osu.Game/Beatmaps/DifficultyCalculator.cs index c8cc831a35..798268d05f 100644 --- a/osu.Game/Beatmaps/DifficultyCalculator.cs +++ b/osu.Game/Beatmaps/DifficultyCalculator.cs @@ -19,7 +19,7 @@ namespace osu.Game.Beatmaps public abstract class DifficultyCalculator : DifficultyCalculator where T : HitObject { - protected Beatmap Beatmap; + protected readonly Beatmap Beatmap; protected readonly Mod[] Mods; protected DifficultyCalculator(Beatmap beatmap, Mod[] mods = null) From c36859ea3a4a7b098229b201635fce4f26d92558 Mon Sep 17 00:00:00 2001 From: Thomas Tan Date: Mon, 29 Jan 2018 16:22:14 +0800 Subject: [PATCH 3/4] Create Slider.StackedPositionAt method --- osu.Game.Rulesets.Osu/Objects/Slider.cs | 1 + .../OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs index 79bb14a475..daf7409ad1 100644 --- a/osu.Game.Rulesets.Osu/Objects/Slider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs @@ -23,6 +23,7 @@ namespace osu.Game.Rulesets.Osu.Objects public double EndTime => StartTime + this.SpanCount() * Curve.Distance / Velocity; public double Duration => EndTime - StartTime; + public Vector2 StackedPositionAt(double t) => this.PositionAt(t) + this.StackOffset; public override Vector2 EndPosition => this.PositionAt(1); public SliderCurve Curve { get; } = new SliderCurve(); diff --git a/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs index a1c4a8a466..7ee1bafd08 100644 --- a/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -95,7 +95,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing var computeVertex = new Action(t => { // ReSharper disable once PossibleInvalidOperationException (bugged in current r# version) - var diff = slider.PositionAt(t) + slider.StackOffset - slider.LazyEndPosition.Value; + var diff = slider.StackedPositionAt(t) - slider.LazyEndPosition.Value; float dist = diff.Length; if (dist > approxFollowCircleRadius) From 33c5fdcedb0ac324118aa4111a0e6856669c87f5 Mon Sep 17 00:00:00 2001 From: Thomas Tan Date: Mon, 29 Jan 2018 16:30:46 +0800 Subject: [PATCH 4/4] AppVeyor fix --- osu.Game.Rulesets.Osu/Objects/Slider.cs | 2 +- .../OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs index daf7409ad1..4fd3b55245 100644 --- a/osu.Game.Rulesets.Osu/Objects/Slider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs @@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Osu.Objects public double EndTime => StartTime + this.SpanCount() * Curve.Distance / Velocity; public double Duration => EndTime - StartTime; - public Vector2 StackedPositionAt(double t) => this.PositionAt(t) + this.StackOffset; + public Vector2 StackedPositionAt(double t) => this.PositionAt(t) + StackOffset; public override Vector2 EndPosition => this.PositionAt(1); public SliderCurve Curve { get; } = new SliderCurve(); diff --git a/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs index 7ee1bafd08..c817cd0ff3 100644 --- a/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -3,7 +3,6 @@ using System; using System.Linq; -using osu.Game.Rulesets.Objects.Types; using OpenTK; using osu.Game.Rulesets.Osu.Objects;