1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 02:52:54 +08:00

enforce minimum duration based on snap

This commit is contained in:
OliBomby 2024-07-22 11:58:53 +02:00
parent 9fb9a54a4d
commit c57232c220

View File

@ -228,7 +228,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
private Vector2 lengthAdjustMouseOffset; private Vector2 lengthAdjustMouseOffset;
private double oldDuration; private double oldDuration;
private double oldVelocity; private double oldVelocityMultiplier;
private double desiredDistance; private double desiredDistance;
private bool isAdjustingLength; private bool isAdjustingLength;
private bool adjustVelocityMomentary; private bool adjustVelocityMomentary;
@ -239,7 +239,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
adjustVelocityMomentary = e.ShiftPressed; adjustVelocityMomentary = e.ShiftPressed;
lengthAdjustMouseOffset = ToLocalSpace(e.ScreenSpaceMouseDownPosition) - HitObject.Position - HitObject.Path.PositionAt(1); lengthAdjustMouseOffset = ToLocalSpace(e.ScreenSpaceMouseDownPosition) - HitObject.Position - HitObject.Path.PositionAt(1);
oldDuration = HitObject.Path.Distance / HitObject.SliderVelocityMultiplier; oldDuration = HitObject.Path.Distance / HitObject.SliderVelocityMultiplier;
oldVelocity = HitObject.SliderVelocityMultiplier; oldVelocityMultiplier = HitObject.SliderVelocityMultiplier;
changeHandler?.BeginChange(); changeHandler?.BeginChange();
} }
@ -255,13 +255,17 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
private void adjustLength(double proposedDistance, bool adjustVelocity) private void adjustLength(double proposedDistance, bool adjustVelocity)
{ {
desiredDistance = proposedDistance; desiredDistance = proposedDistance;
proposedDistance = MathHelper.Clamp(proposedDistance, 1, HitObject.Path.CalculatedDistance); double proposedVelocity = oldVelocityMultiplier;
double proposedVelocity = oldVelocity;
if (adjustVelocity) if (adjustVelocity)
{ {
proposedDistance = MathHelper.Clamp(proposedDistance, 0.1 * oldDuration, 10 * oldDuration);
proposedVelocity = proposedDistance / oldDuration; proposedVelocity = proposedDistance / oldDuration;
proposedDistance = MathHelper.Clamp(proposedDistance, 0.1 * oldDuration, 10 * oldDuration);
}
else
{
double minDistance = distanceSnapProvider?.GetBeatSnapDistanceAt(HitObject, false) * oldVelocityMultiplier ?? 1;
proposedDistance = MathHelper.Clamp(proposedDistance, minDistance, HitObject.Path.CalculatedDistance);
} }
if (Precision.AlmostEquals(proposedDistance, HitObject.Path.Distance) && Precision.AlmostEquals(proposedVelocity, HitObject.SliderVelocityMultiplier)) if (Precision.AlmostEquals(proposedDistance, HitObject.Path.Distance) && Precision.AlmostEquals(proposedVelocity, HitObject.SliderVelocityMultiplier))