1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:07:44 +08:00

Add 1ms lenience to avoid potential precision issues

This commit is contained in:
Dean Herbert 2020-08-25 20:57:31 +09:00
parent 6c7475f085
commit 127330b8f9

View File

@ -25,7 +25,7 @@ using osu.Game.Screens.Edit.Components.RadioButtons;
using osu.Game.Screens.Edit.Compose;
using osu.Game.Screens.Edit.Compose.Components;
using osuTK;
using Key = osuTK.Input.Key;
using osuTK.Input;
namespace osu.Game.Rulesets.Edit
{
@ -297,9 +297,12 @@ namespace osu.Game.Rulesets.Edit
double snappedEndTime = BeatSnapProvider.SnapTime(actualDuration, referenceTime);
double beatLength = BeatSnapProvider.GetBeatLengthAtTime(referenceTime);
// we don't want to exceed the actual duration and snap to a point in the future.
if (snappedEndTime > actualDuration)
snappedEndTime -= BeatSnapProvider.GetBeatLengthAtTime(referenceTime);
// as we are snapping to beat length via SnapTime (which will round-to-nearest), check for snapping in the forward direction and reverse it.
if (snappedEndTime > actualDuration + 1)
snappedEndTime -= beatLength;
return DurationToDistance(referenceTime, snappedEndTime - referenceTime);
}