1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 14:03:21 +08:00

Fix time snap of sliders not matching when SV is not 1.0x

This regressed with https://github.com/ppy/osu/pull/20850 because the
function was used in other places which expect it to factor slider
velocity into the equation.

Rather than reverting, I've added a new argument, as based on the method
naming alone it was hard to discern whether SV should actually be
considered.

The reason for the change in #20850 was to avoid the SV coming in from a
reference object which may not have a correct SV in the first place. In
such cases, passing `false` to the function will give the expected
behaviour.
This commit is contained in:
Dean Herbert 2022-11-01 15:00:23 +09:00
parent 00bd77ce76
commit 2a88409dfe
4 changed files with 7 additions and 6 deletions

View File

@ -193,7 +193,7 @@ namespace osu.Game.Tests.Visual.Editing
IBindable<double> IDistanceSnapProvider.DistanceSpacingMultiplier => DistanceSpacingMultiplier; IBindable<double> IDistanceSnapProvider.DistanceSpacingMultiplier => DistanceSpacingMultiplier;
public float GetBeatSnapDistanceAt(HitObject referenceObject) => beat_snap_distance; public float GetBeatSnapDistanceAt(HitObject referenceObject, bool useReferenceSliderVelocity = true) => beat_snap_distance;
public float DurationToDistance(HitObject referenceObject, double duration) => (float)duration; public float DurationToDistance(HitObject referenceObject, double duration) => (float)duration;

View File

@ -259,9 +259,9 @@ namespace osu.Game.Rulesets.Edit
return true; return true;
} }
public virtual float GetBeatSnapDistanceAt(HitObject referenceObject) public virtual float GetBeatSnapDistanceAt(HitObject referenceObject, bool useReferenceSliderVelocity = true)
{ {
return (float)(100 * EditorBeatmap.Difficulty.SliderMultiplier * 1 / BeatSnapProvider.BeatDivisor); return (float)(100 * (useReferenceSliderVelocity ? referenceObject.DifficultyControlPoint.SliderVelocity : 1) * EditorBeatmap.Difficulty.SliderMultiplier * 1 / BeatSnapProvider.BeatDivisor);
} }
public virtual float DurationToDistance(HitObject referenceObject, double duration) public virtual float DurationToDistance(HitObject referenceObject, double duration)
@ -273,7 +273,7 @@ namespace osu.Game.Rulesets.Edit
public virtual double DistanceToDuration(HitObject referenceObject, float distance) public virtual double DistanceToDuration(HitObject referenceObject, float distance)
{ {
double beatLength = BeatSnapProvider.GetBeatLengthAtTime(referenceObject.StartTime); double beatLength = BeatSnapProvider.GetBeatLengthAtTime(referenceObject.StartTime);
return distance / GetBeatSnapDistanceAt(referenceObject) * beatLength; return distance / GetBeatSnapDistanceAt(referenceObject) * beatLength * referenceObject.DifficultyControlPoint.SliderVelocity;
} }
public virtual double FindSnappedDuration(HitObject referenceObject, float distance) public virtual double FindSnappedDuration(HitObject referenceObject, float distance)

View File

@ -27,8 +27,9 @@ namespace osu.Game.Rulesets.Edit
/// Retrieves the distance between two points within a timing point that are one beat length apart. /// Retrieves the distance between two points within a timing point that are one beat length apart.
/// </summary> /// </summary>
/// <param name="referenceObject">An object to be used as a reference point for this operation.</param> /// <param name="referenceObject">An object to be used as a reference point for this operation.</param>
/// <param name="useReferenceSliderVelocity">Whether the <paramref name="referenceObject"/>'s slider velocity should be factored into the returned distance.</param>
/// <returns>The distance between two points residing in the timing point that are one beat length apart.</returns> /// <returns>The distance between two points residing in the timing point that are one beat length apart.</returns>
float GetBeatSnapDistanceAt(HitObject referenceObject); float GetBeatSnapDistanceAt(HitObject referenceObject, bool useReferenceSliderVelocity = true);
/// <summary> /// <summary>
/// Converts a duration to a distance without applying any snapping. /// Converts a duration to a distance without applying any snapping.

View File

@ -97,7 +97,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
private void updateSpacing() private void updateSpacing()
{ {
float distanceSpacingMultiplier = (float)DistanceSpacingMultiplier.Value; float distanceSpacingMultiplier = (float)DistanceSpacingMultiplier.Value;
float beatSnapDistance = SnapProvider.GetBeatSnapDistanceAt(ReferenceObject); float beatSnapDistance = SnapProvider.GetBeatSnapDistanceAt(ReferenceObject, false);
DistanceBetweenTicks = beatSnapDistance * distanceSpacingMultiplier; DistanceBetweenTicks = beatSnapDistance * distanceSpacingMultiplier;