diff --git a/osu.Game.Rulesets.Osu/Edit/OsuSelectionScaleHandler.cs b/osu.Game.Rulesets.Osu/Edit/OsuSelectionScaleHandler.cs
index d336261499..8b87246456 100644
--- a/osu.Game.Rulesets.Osu/Edit/OsuSelectionScaleHandler.cs
+++ b/osu.Game.Rulesets.Osu/Edit/OsuSelectionScaleHandler.cs
@@ -80,32 +80,12 @@ namespace osu.Game.Rulesets.Osu.Edit
changeHandler?.BeginChange();
objectsInScale = selectedMovableObjects.ToDictionary(ho => ho, ho => new OriginalHitObjectState(ho));
- OriginalSurroundingQuad = getOriginalSurroundingQuad()!;
+ OriginalSurroundingQuad = objectsInScale.Count == 1 && objectsInScale.First().Key is Slider slider
+ ? GeometryUtils.GetSurroundingQuad(slider.Path.ControlPoints.Select(p => slider.Position + p.Position))
+ : GeometryUtils.GetSurroundingQuad(objectsInScale.Keys);
defaultOrigin = OriginalSurroundingQuad.Value.Centre;
}
- private Quad? getOriginalSurroundingQuad(float axisRotation = 0)
- {
- if (objectsInScale == null)
- return null;
-
- return objectsInScale.Count == 1 && objectsInScale.First().Value.PathControlPointPositions != null
- ? GeometryUtils.GetSurroundingQuad(objectsInScale.First().Value.PathControlPointPositions!.Select(p => objectsInScale.First().Value.Position + p), axisRotation)
- : GeometryUtils.GetSurroundingQuad(objectsInScale.Values.SelectMany(s =>
- {
- if (s.EndPosition.HasValue)
- {
- return new[]
- {
- s.Position,
- s.Position + s.EndPosition.Value
- };
- }
-
- return new[] { s.Position };
- }), axisRotation);
- }
-
public override void Update(Vector2 scale, Vector2? origin = null, Axes adjustAxis = Axes.Both, float axisRotation = 0)
{
if (!OperationInProgress.Value)
@@ -233,23 +213,10 @@ namespace osu.Game.Rulesets.Osu.Edit
scale = clampScaleToAdjustAxis(scale, adjustAxis);
Vector2 actualOrigin = origin ?? defaultOrigin.Value;
- var selectionQuad = axisRotation == 0 ? OriginalSurroundingQuad.Value : getOriginalSurroundingQuad(axisRotation)!.Value;
- var points = new[]
- {
- selectionQuad.TopLeft,
- selectionQuad.TopRight,
- selectionQuad.BottomLeft,
- selectionQuad.BottomRight
- };
+ var selectionQuad = OriginalSurroundingQuad.Value;
- float cos = MathF.Cos(float.DegreesToRadians(-axisRotation));
- float sin = MathF.Sin(float.DegreesToRadians(-axisRotation));
-
- foreach (var point in points)
- {
- scale = clampToBound(scale, point, Vector2.Zero);
- scale = clampToBound(scale, point, OsuPlayfield.BASE_SIZE);
- }
+ scale = clampToBound(scale, selectionQuad.BottomRight, OsuPlayfield.BASE_SIZE);
+ scale = clampToBound(scale, selectionQuad.TopLeft, Vector2.Zero);
return Vector2.ComponentMax(scale, new Vector2(Precision.FLOAT_EPSILON));
@@ -259,17 +226,19 @@ namespace osu.Game.Rulesets.Osu.Edit
{
p -= actualOrigin;
bound -= actualOrigin;
+ float cos = MathF.Cos(float.DegreesToRadians(-axisRotation));
+ float sin = MathF.Sin(float.DegreesToRadians(-axisRotation));
var a = new Vector2(cos * cos * p.X - sin * cos * p.Y, -sin * cos * p.X + sin * sin * p.Y);
var b = new Vector2(sin * sin * p.X + sin * cos * p.Y, sin * cos * p.X + cos * cos * p.Y);
switch (adjustAxis)
{
case Axes.X:
- s.X = MathF.Min(s.X, minPositiveComponent(Vector2.Divide(bound - b, a)));
+ s.X = MathF.Min(scale.X, minPositiveComponent(Vector2.Divide(bound - b, a)));
break;
case Axes.Y:
- s.Y = MathF.Min(s.Y, minPositiveComponent(Vector2.Divide(bound - a, b)));
+ s.Y = MathF.Min(scale.Y, minPositiveComponent(Vector2.Divide(bound - a, b)));
break;
case Axes.Both:
@@ -306,14 +275,12 @@ namespace osu.Game.Rulesets.Osu.Edit
public Vector2 Position { get; }
public Vector2[]? PathControlPointPositions { get; }
public PathType?[]? PathControlPointTypes { get; }
- public Vector2? EndPosition { get; }
public OriginalHitObjectState(OsuHitObject hitObject)
{
Position = hitObject.Position;
PathControlPointPositions = (hitObject as IHasPath)?.Path.ControlPoints.Select(p => p.Position).ToArray();
PathControlPointTypes = (hitObject as IHasPath)?.Path.ControlPoints.Select(p => p.Type).ToArray();
- EndPosition = (hitObject as IHasPath)?.Path.PositionAt(1);
}
}
}
diff --git a/osu.Game/Utils/GeometryUtils.cs b/osu.Game/Utils/GeometryUtils.cs
index 23c25cfffa..f6e7e81007 100644
--- a/osu.Game/Utils/GeometryUtils.cs
+++ b/osu.Game/Utils/GeometryUtils.cs
@@ -113,8 +113,7 @@ namespace osu.Game.Utils
/// Returns a quad surrounding the provided points.
///
/// The points to calculate a quad for.
- /// The rotation in degrees of the axis to align the quad to.
- public static Quad GetSurroundingQuad(IEnumerable points, float axisRotation = 0)
+ public static Quad GetSurroundingQuad(IEnumerable points)
{
if (!points.Any())
return new Quad();
@@ -125,25 +124,20 @@ namespace osu.Game.Utils
// Go through all hitobjects to make sure they would remain in the bounds of the editor after movement, before any movement is attempted
foreach (var p in points)
{
- var pr = RotateVector(p, axisRotation);
- minPosition = Vector2.ComponentMin(minPosition, pr);
- maxPosition = Vector2.ComponentMax(maxPosition, pr);
+ minPosition = Vector2.ComponentMin(minPosition, p);
+ maxPosition = Vector2.ComponentMax(maxPosition, p);
}
- var p1 = RotateVector(minPosition, -axisRotation);
- var p2 = RotateVector(new Vector2(minPosition.X, maxPosition.Y), -axisRotation);
- var p3 = RotateVector(maxPosition, -axisRotation);
- var p4 = RotateVector(new Vector2(maxPosition.X, minPosition.Y), -axisRotation);
+ Vector2 size = maxPosition - minPosition;
- return new Quad(p1, p2, p3, p4);
+ return new Quad(minPosition.X, minPosition.Y, size.X, size.Y);
}
///
/// Returns a gamefield-space quad surrounding the provided hit objects.
///
/// The hit objects to calculate a quad for.
- /// The rotation in degrees of the axis to align the quad to.
- public static Quad GetSurroundingQuad(IEnumerable hitObjects, float axisRotation = 0) =>
+ public static Quad GetSurroundingQuad(IEnumerable hitObjects) =>
GetSurroundingQuad(hitObjects.SelectMany(h =>
{
if (h is IHasPath path)
@@ -157,6 +151,6 @@ namespace osu.Game.Utils
}
return new[] { h.Position };
- }), axisRotation);
+ }));
}
}