diff --git a/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs b/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs
index 160e7e026b..ea9eaf41bb 100644
--- a/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs
@@ -9,6 +9,7 @@
using osu.Framework.Graphics.Shapes;
using osu.Framework.Layout;
using osu.Framework.Utils;
+using osu.Game.Utils;
using osuTK;
namespace osu.Game.Screens.Edit.Compose.Components
@@ -215,11 +216,11 @@ private void generateOutline(Vector2 drawSize)
public Vector2 GetSnappedPosition(Vector2 original)
{
- Vector2 relativeToStart = original - StartPosition;
+ Vector2 relativeToStart = GeometryUtils.RotateVector(original - StartPosition, GridLineRotation);
Vector2 offset = Vector2.Divide(relativeToStart, Spacing);
Vector2 roundedOffset = new Vector2(MathF.Round(offset.X), MathF.Round(offset.Y));
- return StartPosition + Vector2.Multiply(roundedOffset, Spacing);
+ return StartPosition + GeometryUtils.RotateVector(Vector2.Multiply(roundedOffset, Spacing), -GridLineRotation);
}
}
}
diff --git a/osu.Game/Utils/GeometryUtils.cs b/osu.Game/Utils/GeometryUtils.cs
index 725e93d098..fcc6b8ae2a 100644
--- a/osu.Game/Utils/GeometryUtils.cs
+++ b/osu.Game/Utils/GeometryUtils.cs
@@ -27,9 +27,8 @@ public static Vector2 RotatePointAroundOrigin(Vector2 point, Vector2 origin, flo
point.X -= origin.X;
point.Y -= origin.Y;
- Vector2 ret;
- ret.X = point.X * MathF.Cos(MathUtils.DegreesToRadians(angle)) + point.Y * MathF.Sin(MathUtils.DegreesToRadians(angle));
- ret.Y = point.X * -MathF.Sin(MathUtils.DegreesToRadians(angle)) + point.Y * MathF.Cos(MathUtils.DegreesToRadians(angle));
+ Vector2 ret = RotateVector(point, angle);
+ Matrix2
ret.X += origin.X;
ret.Y += origin.Y;
@@ -37,6 +36,19 @@ public static Vector2 RotatePointAroundOrigin(Vector2 point, Vector2 origin, flo
return ret;
}
+ ///
+ /// Rotate a vector around the origin.
+ ///
+ /// The vector.
+ /// The angle to rotate (in degrees).
+ public static Vector2 RotateVector(Vector2 vector, float angle)
+ {
+ return new Vector2(
+ vector.X * MathF.Cos(MathUtils.DegreesToRadians(angle)) + vector.Y * MathF.Sin(MathUtils.DegreesToRadians(angle)),
+ vector.X * -MathF.Sin(MathUtils.DegreesToRadians(angle)) + vector.Y * MathF.Cos(MathUtils.DegreesToRadians(angle))
+ );
+ }
+
///
/// Given a flip direction, a surrounding quad for all selected objects, and a position,
/// will return the flipped position in screen space coordinates.