From 6c148930b5d2ad601dba56bb87c402e988cdbfad Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 13 Mar 2018 14:02:37 +0900 Subject: [PATCH] Don't skip beats when scrolling in the direction of the closest beat --- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 3f01c2bd33..ba31e61397 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -148,10 +148,16 @@ namespace osu.Game.Rulesets.Edit double beatLength = timingPoint.BeatLength / beat_snap_divisor; int direction = state.Mouse.WheelDelta > 0 ? 1 : -1; - double unsnappedTime = adjustableClock.CurrentTime + beatLength * direction; + // The direction is added to prevent rounding issues by enforcing that abs(unsnappedTime - currentTime) > beatLength + double unsnappedTime = adjustableClock.CurrentTime + beatLength * direction + direction; // Unsnapped time may be between two beats, so we need to snap it to the closest beat - int closestBeat = (int)Math.Round(unsnappedTime / beatLength); + int closestBeat; + if (direction > 0) + closestBeat = (int)Math.Floor(unsnappedTime / beatLength); + else + closestBeat = (int)Math.Ceiling(unsnappedTime / beatLength); + double snappedTime = closestBeat * beatLength; adjustableClock.Seek(snappedTime);