prevent flipping objects far offscreen

This commit is contained in:
OliBomby 2024-07-03 19:08:31 +02:00
parent 4165ded813
commit dfe6c70996
1 changed files with 4 additions and 0 deletions

View File

@ -15,6 +15,7 @@
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Screens.Edit.Compose.Components;
using osu.Game.Utils;
using osuTK;
@ -119,6 +120,9 @@ public override bool HandleFlip(Direction direction, bool flipOverOrigin)
{
var flippedPosition = GeometryUtils.GetFlippedPosition(flipAxis, flipQuad, h.Position);
// Clamp the flipped position inside the playfield bounds, because the flipped position might be outside the playfield bounds if the origin is not centered.
flippedPosition = Vector2.Clamp(flippedPosition, Vector2.Zero, OsuPlayfield.BASE_SIZE);
if (!Precision.AlmostEquals(flippedPosition, h.Position))
{
h.Position = flippedPosition;