Fix snapped distances potentially exceeding the source distance

This results in slider placement including "excess" length, where the
curve is not applied to the placed path. This is generally not what we
want.

I considered adding a bool parameter (or enum) to change the
floor/rounding mode, but on further examination I think this is what we
always expect from this function.
This commit is contained in:
Dean Herbert
2020-08-25 18:56:15 +09:00
parent 997ea2f27e
commit 6c7475f085
3 changed files with 15 additions and 8 deletions

View File

@ -293,7 +293,13 @@ namespace osu.Game.Rulesets.Edit
public override float GetSnappedDistanceFromDistance(double referenceTime, float distance)
{
var snappedEndTime = BeatSnapProvider.SnapTime(referenceTime + DistanceToDuration(referenceTime, distance), referenceTime);
double actualDuration = referenceTime + DistanceToDuration(referenceTime, distance);
double snappedEndTime = BeatSnapProvider.SnapTime(actualDuration, 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);
return DurationToDistance(referenceTime, snappedEndTime - referenceTime);
}