Fix certain slider shapes incorrectly registering as a horizontal/vertical only slider.

This commit is contained in:
AeroKoder
2025-09-17 12:44:43 -07:00
parent 0dbee70ca9
commit 6dc3432735
3 changed files with 18 additions and 10 deletions

View File

@@ -253,7 +253,7 @@ namespace osu.Game.Rulesets.Osu.Edit
{
var hitObjects = selectedMovableObjects;
Quad quad = GeometryUtils.GetSurroundingQuad(hitObjects);
Quad quad = GeometryUtils.GetSurroundingQuad(hitObjects, true);
Vector2 delta = Vector2.Zero;

View File

@@ -81,12 +81,8 @@ namespace osu.Game.Rulesets.Osu.Edit
changeHandler?.BeginChange();
objectsInScale = selectedMovableObjects.ToDictionary(ho => ho, ho => new OriginalHitObjectState(ho));
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);
originalConvexHull = objectsInScale.Count == 1 && objectsInScale.First().Key is Slider slider2
? GeometryUtils.GetConvexHull(slider2.Path.ControlPoints.Select(p => slider2.Position + p.Position))
: GeometryUtils.GetConvexHull(objectsInScale.Keys);
OriginalSurroundingQuad = GeometryUtils.GetSurroundingQuad(objectsInScale.Keys);
originalConvexHull = GeometryUtils.GetConvexHull(objectsInScale.Keys);
defaultOrigin = GeometryUtils.MinimumEnclosingCircle(originalConvexHull).Item1;
}

View File

@@ -144,8 +144,9 @@ namespace osu.Game.Utils
/// Returns a gamefield-space quad surrounding the provided hit objects.
/// </summary>
/// <param name="hitObjects">The hit objects to calculate a quad for.</param>
public static Quad GetSurroundingQuad(IEnumerable<IHasPosition> hitObjects) =>
GetSurroundingQuad(enumerateStartAndEndPositions(hitObjects));
/// <param name="startAndEndOnly">Whether to only include the start and end positions of the slider, or include every control point in the slider.</param>
public static Quad GetSurroundingQuad(IEnumerable<IHasPosition> hitObjects, bool startAndEndOnly = false) =>
GetSurroundingQuad(startAndEndOnly ? enumerateStartAndEndPositions(hitObjects) : enumeratePositions(hitObjects));
/// <summary>
/// Returns the points that make up the convex hull of the provided points.
@@ -202,7 +203,7 @@ namespace osu.Game.Utils
}
public static List<Vector2> GetConvexHull(IEnumerable<IHasPosition> hitObjects) =>
GetConvexHull(enumerateStartAndEndPositions(hitObjects));
GetConvexHull(enumeratePositions(hitObjects));
private static IEnumerable<Vector2> enumerateStartAndEndPositions(IEnumerable<IHasPosition> hitObjects) =>
hitObjects.SelectMany(h =>
@@ -220,6 +221,17 @@ namespace osu.Game.Utils
return new[] { h.Position };
});
private static IEnumerable<Vector2> enumeratePositions(IEnumerable<IHasPosition> hitObjects) =>
hitObjects.SelectMany(h =>
{
if (h is IHasPath path)
{
return path.Path.ControlPoints.Select(p => h.Position + p.Position);
}
return new[] { h.Position };
});
#region Welzl helpers
// Function to check whether a point lies inside or on the boundaries of the circle