From 283d953c4fc5da054b875c4c958ce75c238740fd Mon Sep 17 00:00:00 2001 From: aitani9 <55509723+aitani9@users.noreply.github.com> Date: Wed, 21 Jul 2021 14:07:00 -0700 Subject: [PATCH 1/4] Fix blinds moving when barrel roll mod is active --- osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs | 35 +++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs b/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs index 636cd63c69..f37058564e 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -32,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.Mods public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset) { - drawableRuleset.Overlays.Add(blinds = new DrawableOsuBlinds(drawableRuleset.Playfield.HitObjectContainer, drawableRuleset.Beatmap)); + drawableRuleset.Overlays.Add(blinds = new DrawableOsuBlinds(drawableRuleset.Playfield, drawableRuleset.Beatmap, drawableRuleset.Mods)); } public void ApplyToHealthProcessor(HealthProcessor healthProcessor) @@ -67,6 +68,8 @@ namespace osu.Game.Rulesets.Osu.Mods private readonly CompositeDrawable restrictTo; + private readonly bool barrelRollActive; + /// /// /// Percentage of playfield to extend blinds over. Basically moves the origin points where the blinds start. @@ -80,13 +83,24 @@ namespace osu.Game.Rulesets.Osu.Mods /// private const float leniency = 0.1f; - public DrawableOsuBlinds(CompositeDrawable restrictTo, Beatmap beatmap) + public DrawableOsuBlinds(CompositeDrawable restrictTo, Beatmap beatmap, IEnumerable mods) { this.restrictTo = restrictTo; this.beatmap = beatmap; targetBreakMultiplier = 0; easing = 1; + + barrelRollActive = false; + + foreach (Mod mod in mods) + { + if (mod is OsuModBarrelRoll) + { + barrelRollActive = true; + break; + } + } } [BackgroundDependencyLoader] @@ -128,8 +142,21 @@ namespace osu.Game.Rulesets.Osu.Mods protected override void Update() { - float start = Parent.ToLocalSpace(restrictTo.ScreenSpaceDrawQuad.TopLeft).X; - float end = Parent.ToLocalSpace(restrictTo.ScreenSpaceDrawQuad.TopRight).X; + float start, end; + + if (barrelRollActive) + { + float origin = restrictTo.ToSpaceOfOtherDrawable(restrictTo.OriginPosition, Parent).X; + float halfDiagonal = MathF.Sqrt(MathF.Pow(restrictTo.DrawWidth / 2, 2) + MathF.Pow(restrictTo.DrawHeight / 2, 2)); + + start = origin - halfDiagonal; + end = origin + halfDiagonal; + } + else + { + start = Parent.ToLocalSpace(restrictTo.ScreenSpaceDrawQuad.TopLeft).X; + end = Parent.ToLocalSpace(restrictTo.ScreenSpaceDrawQuad.TopRight).X; + } float rawWidth = end - start; From e6b28e1386a481ee8e06aef41ae30ef1fae61370 Mon Sep 17 00:00:00 2001 From: aitani9 <55509723+aitani9@users.noreply.github.com> Date: Thu, 22 Jul 2021 14:01:31 -0700 Subject: [PATCH 2/4] Rename `origin` to `center` for clarity --- osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs b/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs index f37058564e..c4872aaf64 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs @@ -146,11 +146,11 @@ namespace osu.Game.Rulesets.Osu.Mods if (barrelRollActive) { - float origin = restrictTo.ToSpaceOfOtherDrawable(restrictTo.OriginPosition, Parent).X; + float center = restrictTo.ToSpaceOfOtherDrawable(restrictTo.OriginPosition, Parent).X; float halfDiagonal = MathF.Sqrt(MathF.Pow(restrictTo.DrawWidth / 2, 2) + MathF.Pow(restrictTo.DrawHeight / 2, 2)); - start = origin - halfDiagonal; - end = origin + halfDiagonal; + start = center - halfDiagonal; + end = center + halfDiagonal; } else { From 80cb7c77b911f380a7fd558d375509bc3e729bf4 Mon Sep 17 00:00:00 2001 From: aitani9 <55509723+aitani9@users.noreply.github.com> Date: Thu, 22 Jul 2021 14:04:01 -0700 Subject: [PATCH 3/4] Calculate the diagonal length using `Vector2.LengthFast` instead of manually --- osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs b/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs index c4872aaf64..09d73566a1 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs @@ -147,7 +147,7 @@ namespace osu.Game.Rulesets.Osu.Mods if (barrelRollActive) { float center = restrictTo.ToSpaceOfOtherDrawable(restrictTo.OriginPosition, Parent).X; - float halfDiagonal = MathF.Sqrt(MathF.Pow(restrictTo.DrawWidth / 2, 2) + MathF.Pow(restrictTo.DrawHeight / 2, 2)); + float halfDiagonal = (restrictTo.DrawSize / 2).LengthFast; start = center - halfDiagonal; end = center + halfDiagonal; From 715f3e3f7c1240baed2b64c2c096923f9fcec180 Mon Sep 17 00:00:00 2001 From: aitani9 <55509723+aitani9@users.noreply.github.com> Date: Thu, 22 Jul 2021 14:07:41 -0700 Subject: [PATCH 4/4] Make blinds move correctly whenever the playfield is rotated --- osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs | 31 +++++++--------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs b/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs index 09d73566a1..3102db270e 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs @@ -2,13 +2,13 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; +using osu.Framework.Utils; using osu.Game.Beatmaps; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Osu.Objects; @@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.Mods public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset) { - drawableRuleset.Overlays.Add(blinds = new DrawableOsuBlinds(drawableRuleset.Playfield, drawableRuleset.Beatmap, drawableRuleset.Mods)); + drawableRuleset.Overlays.Add(blinds = new DrawableOsuBlinds(drawableRuleset.Playfield, drawableRuleset.Beatmap)); } public void ApplyToHealthProcessor(HealthProcessor healthProcessor) @@ -68,8 +68,6 @@ namespace osu.Game.Rulesets.Osu.Mods private readonly CompositeDrawable restrictTo; - private readonly bool barrelRollActive; - /// /// /// Percentage of playfield to extend blinds over. Basically moves the origin points where the blinds start. @@ -83,24 +81,13 @@ namespace osu.Game.Rulesets.Osu.Mods /// private const float leniency = 0.1f; - public DrawableOsuBlinds(CompositeDrawable restrictTo, Beatmap beatmap, IEnumerable mods) + public DrawableOsuBlinds(CompositeDrawable restrictTo, Beatmap beatmap) { this.restrictTo = restrictTo; this.beatmap = beatmap; targetBreakMultiplier = 0; easing = 1; - - barrelRollActive = false; - - foreach (Mod mod in mods) - { - if (mod is OsuModBarrelRoll) - { - barrelRollActive = true; - break; - } - } } [BackgroundDependencyLoader] @@ -144,7 +131,12 @@ namespace osu.Game.Rulesets.Osu.Mods { float start, end; - if (barrelRollActive) + if (Precision.AlmostEquals(restrictTo.Rotation, 0)) + { + start = Parent.ToLocalSpace(restrictTo.ScreenSpaceDrawQuad.TopLeft).X; + end = Parent.ToLocalSpace(restrictTo.ScreenSpaceDrawQuad.TopRight).X; + } + else { float center = restrictTo.ToSpaceOfOtherDrawable(restrictTo.OriginPosition, Parent).X; float halfDiagonal = (restrictTo.DrawSize / 2).LengthFast; @@ -152,11 +144,6 @@ namespace osu.Game.Rulesets.Osu.Mods start = center - halfDiagonal; end = center + halfDiagonal; } - else - { - start = Parent.ToLocalSpace(restrictTo.ScreenSpaceDrawQuad.TopLeft).X; - end = Parent.ToLocalSpace(restrictTo.ScreenSpaceDrawQuad.TopRight).X; - } float rawWidth = end - start;