Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix edge cases which allow very short slider placement in editor #32328

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -143,7 +143,7 @@ public override void UpdateHitObjectFromPath(JuiceStream hitObject)
{
base.UpdateHitObjectFromPath(hitObject);

if (hitObject.Path.ControlPoints.Count <= 1 || !hitObject.Path.HasValidLength)
if (hitObject.Path.ControlPoints.Count <= 1 || !hitObject.Path.HasValidLengthForPlacement)
EditorBeatmap?.Remove(hitObject);
}
}
Original file line number Diff line number Diff line change
@@ -484,7 +484,7 @@ public void DragInProgress(DragEvent e)
// Snap the path to the current beat divisor before checking length validity.
hitObject.SnapTo(distanceSnapProvider);

if (!hitObject.Path.HasValidLength)
if (!hitObject.Path.HasValidLengthForPlacement)
{
for (int i = 0; i < hitObject.Path.ControlPoints.Count; i++)
hitObject.Path.ControlPoints[i].Position = oldControlPoints[i];
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ public partial class SliderPlacementBlueprint : HitObjectPlacementBlueprint

private readonly IncrementalBSplineBuilder bSplineBuilder = new IncrementalBSplineBuilder { Degree = 4 };

protected override bool IsValidForPlacement => HitObject.Path.HasValidLength;
protected override bool IsValidForPlacement => HitObject.Path.HasValidLengthForPlacement;

public SliderPlacementBlueprint()
: base(new Slider())
Original file line number Diff line number Diff line change
@@ -476,7 +476,7 @@ private void removeControlPoints(List<PathControlPoint> toRemove)
HitObject.SnapTo(distanceSnapProvider);

// If there are 0 or 1 remaining control points, or the slider has an invalid length, it is in a degenerate form and should be deleted
if (controlPoints.Count <= 1 || !HitObject.Path.HasValidLength)
if (controlPoints.Count <= 1 || !HitObject.Path.HasValidLengthForPlacement)
{
placementHandler?.Delete(HitObject);
return;
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu/Edit/OsuSelectionScaleHandler.cs
Original file line number Diff line number Diff line change
@@ -180,7 +180,7 @@ private void scaleSlider(Slider slider, Vector2 scale, Vector2 origin, OriginalH
Quad scaledQuad = GeometryUtils.GetSurroundingQuad(new OsuHitObject[] { slider });
(bool xInBounds, bool yInBounds) = isQuadInBounds(scaledQuad);

if (xInBounds && yInBounds && slider.Path.HasValidLength)
if (xInBounds && yInBounds && slider.Path.HasValidLengthForPlacement)
return;

for (int i = 0; i < slider.Path.ControlPoints.Count; i++)
5 changes: 4 additions & 1 deletion osu.Game/Rulesets/Objects/SliderPath.cs
Original file line number Diff line number Diff line change
@@ -31,7 +31,10 @@ public class SliderPath
/// </summary>
public readonly Bindable<double?> ExpectedDistance = new Bindable<double?>();

public bool HasValidLength => Precision.DefinitelyBigger(Distance, 0);
/// <summary>
/// Should be used to check whether placement can continue after a user editor operation.
/// </summary>
public bool HasValidLengthForPlacement => Precision.DefinitelyBigger(Distance, 0, 1);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've renamed this to better show that it's only used in the editor. I wanted to make these changes without affecting parsing logic to keep things simple, and this property felt a bit iffy with its previous name and location.


/// <summary>
/// The control points of the path.
Original file line number Diff line number Diff line change
@@ -441,7 +441,7 @@ protected override void OnDrag(DragEvent e)
double lengthOfOneRepeat = repeatHitObject.Duration / (repeatHitObject.RepeatCount + 1);
int proposedCount = Math.Max(0, (int)Math.Round(proposedDuration / lengthOfOneRepeat) - 1);

if (proposedCount == repeatHitObject.RepeatCount || Precision.AlmostEquals(lengthOfOneRepeat, 0))
if (proposedCount == repeatHitObject.RepeatCount || Precision.AlmostEquals(lengthOfOneRepeat, 0, 1))
return;

repeatHitObject.RepeatCount = proposedCount;
Loading