diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuDistanceSnapGrid.cs b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuDistanceSnapGrid.cs index 3c3c5cb939..c50aec40a5 100644 --- a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuDistanceSnapGrid.cs +++ b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuDistanceSnapGrid.cs @@ -113,7 +113,14 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor public void TestCursorInCentre() { AddStep("move mouse to centre", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position))); - assertSnappedDistance(0); + assertSnappedDistance(beat_length); + } + + [Test] + public void TestCursorAlmostInCentre() + { + AddStep("move mouse to almost centre", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position) + new Vector2(1))); + assertSnappedDistance(beat_length); } [Test] diff --git a/osu.Game/Screens/Edit/Compose/Components/CircularDistanceSnapGrid.cs b/osu.Game/Screens/Edit/Compose/Components/CircularDistanceSnapGrid.cs index 2c6bb766ad..771612fcf1 100644 --- a/osu.Game/Screens/Edit/Compose/Components/CircularDistanceSnapGrid.cs +++ b/osu.Game/Screens/Edit/Compose/Components/CircularDistanceSnapGrid.cs @@ -76,14 +76,19 @@ namespace osu.Game.Screens.Edit.Compose.Components Vector2 travelVector = (position - StartPosition); + // We need a non-zero travel vector in order to find a valid direction. if (travelVector == Vector2.Zero) - return (StartPosition, StartTime); + travelVector = new Vector2(0, -1); float travelLength = travelVector.Length; // FindSnappedDistance will always round down, but we want to potentially round upwards. travelLength += DistanceBetweenTicks / 2; + // We never want to snap towards zero. + if (travelLength < DistanceBetweenTicks) + travelLength = DistanceBetweenTicks; + // When interacting with the resolved snap provider, the distance spacing multiplier should first be removed // to allow for snapping at a non-multiplied ratio. float snappedDistance = SnapProvider.FindSnappedDistance(ReferenceObject, travelLength / distanceSpacingMultiplier);