mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 00:43:25 +08:00
Revert "fix incorrect rotated bound checking"
This reverts commit 4165ded813
.
This commit is contained in:
parent
dfe6c70996
commit
ae38002777
@ -80,32 +80,12 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
changeHandler?.BeginChange();
|
changeHandler?.BeginChange();
|
||||||
|
|
||||||
objectsInScale = selectedMovableObjects.ToDictionary(ho => ho, ho => new OriginalHitObjectState(ho));
|
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;
|
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)
|
public override void Update(Vector2 scale, Vector2? origin = null, Axes adjustAxis = Axes.Both, float axisRotation = 0)
|
||||||
{
|
{
|
||||||
if (!OperationInProgress.Value)
|
if (!OperationInProgress.Value)
|
||||||
@ -233,23 +213,10 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
|
|
||||||
scale = clampScaleToAdjustAxis(scale, adjustAxis);
|
scale = clampScaleToAdjustAxis(scale, adjustAxis);
|
||||||
Vector2 actualOrigin = origin ?? defaultOrigin.Value;
|
Vector2 actualOrigin = origin ?? defaultOrigin.Value;
|
||||||
var selectionQuad = axisRotation == 0 ? OriginalSurroundingQuad.Value : getOriginalSurroundingQuad(axisRotation)!.Value;
|
var selectionQuad = OriginalSurroundingQuad.Value;
|
||||||
var points = new[]
|
|
||||||
{
|
|
||||||
selectionQuad.TopLeft,
|
|
||||||
selectionQuad.TopRight,
|
|
||||||
selectionQuad.BottomLeft,
|
|
||||||
selectionQuad.BottomRight
|
|
||||||
};
|
|
||||||
|
|
||||||
float cos = MathF.Cos(float.DegreesToRadians(-axisRotation));
|
scale = clampToBound(scale, selectionQuad.BottomRight, OsuPlayfield.BASE_SIZE);
|
||||||
float sin = MathF.Sin(float.DegreesToRadians(-axisRotation));
|
scale = clampToBound(scale, selectionQuad.TopLeft, Vector2.Zero);
|
||||||
|
|
||||||
foreach (var point in points)
|
|
||||||
{
|
|
||||||
scale = clampToBound(scale, point, Vector2.Zero);
|
|
||||||
scale = clampToBound(scale, point, OsuPlayfield.BASE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Vector2.ComponentMax(scale, new Vector2(Precision.FLOAT_EPSILON));
|
return Vector2.ComponentMax(scale, new Vector2(Precision.FLOAT_EPSILON));
|
||||||
|
|
||||||
@ -259,17 +226,19 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
{
|
{
|
||||||
p -= actualOrigin;
|
p -= actualOrigin;
|
||||||
bound -= 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 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);
|
var b = new Vector2(sin * sin * p.X + sin * cos * p.Y, sin * cos * p.X + cos * cos * p.Y);
|
||||||
|
|
||||||
switch (adjustAxis)
|
switch (adjustAxis)
|
||||||
{
|
{
|
||||||
case Axes.X:
|
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;
|
break;
|
||||||
|
|
||||||
case Axes.Y:
|
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;
|
break;
|
||||||
|
|
||||||
case Axes.Both:
|
case Axes.Both:
|
||||||
@ -306,14 +275,12 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
public Vector2 Position { get; }
|
public Vector2 Position { get; }
|
||||||
public Vector2[]? PathControlPointPositions { get; }
|
public Vector2[]? PathControlPointPositions { get; }
|
||||||
public PathType?[]? PathControlPointTypes { get; }
|
public PathType?[]? PathControlPointTypes { get; }
|
||||||
public Vector2? EndPosition { get; }
|
|
||||||
|
|
||||||
public OriginalHitObjectState(OsuHitObject hitObject)
|
public OriginalHitObjectState(OsuHitObject hitObject)
|
||||||
{
|
{
|
||||||
Position = hitObject.Position;
|
Position = hitObject.Position;
|
||||||
PathControlPointPositions = (hitObject as IHasPath)?.Path.ControlPoints.Select(p => p.Position).ToArray();
|
PathControlPointPositions = (hitObject as IHasPath)?.Path.ControlPoints.Select(p => p.Position).ToArray();
|
||||||
PathControlPointTypes = (hitObject as IHasPath)?.Path.ControlPoints.Select(p => p.Type).ToArray();
|
PathControlPointTypes = (hitObject as IHasPath)?.Path.ControlPoints.Select(p => p.Type).ToArray();
|
||||||
EndPosition = (hitObject as IHasPath)?.Path.PositionAt(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,8 +113,7 @@ namespace osu.Game.Utils
|
|||||||
/// Returns a quad surrounding the provided points.
|
/// Returns a quad surrounding the provided points.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="points">The points to calculate a quad for.</param>
|
/// <param name="points">The points to calculate a quad for.</param>
|
||||||
/// <param name="axisRotation">The rotation in degrees of the axis to align the quad to.</param>
|
public static Quad GetSurroundingQuad(IEnumerable<Vector2> points)
|
||||||
public static Quad GetSurroundingQuad(IEnumerable<Vector2> points, float axisRotation = 0)
|
|
||||||
{
|
{
|
||||||
if (!points.Any())
|
if (!points.Any())
|
||||||
return new Quad();
|
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
|
// 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)
|
foreach (var p in points)
|
||||||
{
|
{
|
||||||
var pr = RotateVector(p, axisRotation);
|
minPosition = Vector2.ComponentMin(minPosition, p);
|
||||||
minPosition = Vector2.ComponentMin(minPosition, pr);
|
maxPosition = Vector2.ComponentMax(maxPosition, p);
|
||||||
maxPosition = Vector2.ComponentMax(maxPosition, pr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var p1 = RotateVector(minPosition, -axisRotation);
|
Vector2 size = maxPosition - minPosition;
|
||||||
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);
|
|
||||||
|
|
||||||
return new Quad(p1, p2, p3, p4);
|
return new Quad(minPosition.X, minPosition.Y, size.X, size.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a gamefield-space quad surrounding the provided hit objects.
|
/// Returns a gamefield-space quad surrounding the provided hit objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObjects">The hit objects to calculate a quad for.</param>
|
/// <param name="hitObjects">The hit objects to calculate a quad for.</param>
|
||||||
/// <param name="axisRotation">The rotation in degrees of the axis to align the quad to.</param>
|
public static Quad GetSurroundingQuad(IEnumerable<IHasPosition> hitObjects) =>
|
||||||
public static Quad GetSurroundingQuad(IEnumerable<IHasPosition> hitObjects, float axisRotation = 0) =>
|
|
||||||
GetSurroundingQuad(hitObjects.SelectMany(h =>
|
GetSurroundingQuad(hitObjects.SelectMany(h =>
|
||||||
{
|
{
|
||||||
if (h is IHasPath path)
|
if (h is IHasPath path)
|
||||||
@ -157,6 +151,6 @@ namespace osu.Game.Utils
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new[] { h.Position };
|
return new[] { h.Position };
|
||||||
}), axisRotation);
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user