mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 22:34:09 +08:00
Update check to inflate in the correct direct
Also handles previously unhandled edge cases by comparing all four corners, instead of only two.
This commit is contained in:
parent
94b34a5474
commit
4fb3a1d641
@ -4,10 +4,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.MatrixExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input.Handlers.Tablet;
|
using osu.Framework.Input.Handlers.Tablet;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -131,9 +134,9 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
rotation.BindTo(handler.Rotation);
|
rotation.BindTo(handler.Rotation);
|
||||||
rotation.BindValueChanged(val =>
|
rotation.BindValueChanged(val =>
|
||||||
{
|
{
|
||||||
usableAreaContainer.RotateTo(val.NewValue, 100, Easing.OutQuint);
|
usableAreaContainer.RotateTo(val.NewValue, 100, Easing.OutQuint)
|
||||||
tabletContainer.RotateTo(-val.NewValue, 800, Easing.OutQuint)
|
.OnComplete(_ => checkBounds()); // required as we are using SSDQ.
|
||||||
.OnComplete(_ => checkBounds()); // required as we are using SSDQ.
|
tabletContainer.RotateTo(-val.NewValue, 800, Easing.OutQuint);
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
tablet.BindTo(handler.Tablet);
|
tablet.BindTo(handler.Tablet);
|
||||||
@ -171,10 +174,22 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
if (tablet.Value == null)
|
if (tablet.Value == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var usableSsdq = usableAreaContainer.ScreenSpaceDrawQuad;
|
// All of this manual logic is just to get around floating point issues when doing a contains check on the screen quads.
|
||||||
|
// This is best effort, as it's only used for display purposes. If we need for anything more, manual math on the raw values should be preferred.
|
||||||
|
var containerQuad = tabletContainer.ScreenSpaceDrawQuad.AABBFloat.Inflate(1);
|
||||||
|
var usableAreaQuad = Quad.FromRectangle(usableAreaContainer.ScreenSpaceDrawQuad.AABBFloat);
|
||||||
|
|
||||||
IsWithinBounds = tabletContainer.ScreenSpaceDrawQuad.Contains(usableSsdq.TopLeft + new Vector2(1)) &&
|
var matrix = Matrix3.Identity;
|
||||||
tabletContainer.ScreenSpaceDrawQuad.Contains(usableSsdq.BottomRight - new Vector2(1));
|
MatrixExtensions.TranslateFromLeft(ref matrix, usableAreaQuad.Centre);
|
||||||
|
MatrixExtensions.RotateFromLeft(ref matrix, MathUtils.DegreesToRadians(rotation.Value));
|
||||||
|
MatrixExtensions.TranslateFromLeft(ref matrix, -usableAreaQuad.Centre);
|
||||||
|
usableAreaQuad *= matrix;
|
||||||
|
|
||||||
|
IsWithinBounds =
|
||||||
|
containerQuad.Contains(usableAreaQuad.TopLeft) &&
|
||||||
|
containerQuad.Contains(usableAreaQuad.TopRight) &&
|
||||||
|
containerQuad.Contains(usableAreaQuad.BottomLeft) &&
|
||||||
|
containerQuad.Contains(usableAreaQuad.BottomRight);
|
||||||
|
|
||||||
usableFill.FadeColour(IsWithinBounds ? colour.Blue : colour.RedLight, 100);
|
usableFill.FadeColour(IsWithinBounds ? colour.Blue : colour.RedLight, 100);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user