mirror of
https://github.com/ppy/osu.git
synced 2025-03-11 02:17:19 +08:00
Fix "use current distance snap" button incorrectly factoring in last object with velocity
Closes https://github.com/ppy/osu/issues/32003.
This commit is contained in:
parent
a556049c1b
commit
de78518fea
@ -1,10 +1,12 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -14,7 +16,9 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
{
|
{
|
||||||
public override double ReadCurrentDistanceSnap(HitObject before, HitObject after)
|
public override double ReadCurrentDistanceSnap(HitObject before, HitObject after)
|
||||||
{
|
{
|
||||||
float expectedDistance = DurationToDistance(after.StartTime - before.GetEndTime(), before.StartTime);
|
var lastObjectWithVelocity = EditorBeatmap.HitObjects.TakeWhile(ho => ho != after).OfType<IHasSliderVelocity>().LastOrDefault();
|
||||||
|
|
||||||
|
float expectedDistance = DurationToDistance(after.StartTime - before.GetEndTime(), before.StartTime, lastObjectWithVelocity);
|
||||||
float actualDistance = Vector2.Distance(((OsuHitObject)before).EndPosition, ((OsuHitObject)after).Position);
|
float actualDistance = Vector2.Distance(((OsuHitObject)before).EndPosition, ((OsuHitObject)after).Position);
|
||||||
|
|
||||||
return actualDistance / expectedDistance;
|
return actualDistance / expectedDistance;
|
||||||
|
@ -52,7 +52,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
private EditorClock editorClock { get; set; } = null!;
|
private EditorClock editorClock { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private EditorBeatmap editorBeatmap { get; set; } = null!;
|
protected EditorBeatmap EditorBeatmap { get; private set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IBeatSnapProvider beatSnapProvider { get; set; } = null!;
|
private IBeatSnapProvider beatSnapProvider { get; set; } = null!;
|
||||||
@ -100,7 +100,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
DistanceSpacingMultiplier.Value = editorBeatmap.DistanceSpacing;
|
DistanceSpacingMultiplier.Value = EditorBeatmap.DistanceSpacing;
|
||||||
DistanceSpacingMultiplier.BindValueChanged(multiplier =>
|
DistanceSpacingMultiplier.BindValueChanged(multiplier =>
|
||||||
{
|
{
|
||||||
distanceSpacingSlider.ContractedLabelText = $"D. S. ({multiplier.NewValue:0.##x})";
|
distanceSpacingSlider.ContractedLabelText = $"D. S. ({multiplier.NewValue:0.##x})";
|
||||||
@ -109,7 +109,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
if (multiplier.NewValue != multiplier.OldValue)
|
if (multiplier.NewValue != multiplier.OldValue)
|
||||||
onScreenDisplay?.Display(new DistanceSpacingToast(multiplier.NewValue.ToLocalisableString(@"0.##x"), multiplier));
|
onScreenDisplay?.Display(new DistanceSpacingToast(multiplier.NewValue.ToLocalisableString(@"0.##x"), multiplier));
|
||||||
|
|
||||||
editorBeatmap.DistanceSpacing = multiplier.NewValue;
|
EditorBeatmap.DistanceSpacing = multiplier.NewValue;
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
DistanceSpacingMultiplier.BindDisabledChanged(disabled => distanceSpacingSlider.Alpha = disabled ? 0 : 1, true);
|
DistanceSpacingMultiplier.BindDisabledChanged(disabled => distanceSpacingSlider.Alpha = disabled ? 0 : 1, true);
|
||||||
@ -267,7 +267,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
public virtual float GetBeatSnapDistance(IHasSliderVelocity? withVelocity = null)
|
public virtual float GetBeatSnapDistance(IHasSliderVelocity? withVelocity = null)
|
||||||
{
|
{
|
||||||
return (float)(100 * (withVelocity?.SliderVelocityMultiplier ?? 1) * editorBeatmap.Difficulty.SliderMultiplier * 1
|
return (float)(100 * (withVelocity?.SliderVelocityMultiplier ?? 1) * EditorBeatmap.Difficulty.SliderMultiplier * 1
|
||||||
/ beatSnapProvider.BeatDivisor);
|
/ beatSnapProvider.BeatDivisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user