mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Make rounding error even less precise
Basically matching the old code more closely to avoid too much precision from doing math in a slightly different way.
This commit is contained in:
parent
e71fef4b6a
commit
4ecc4632aa
@ -52,7 +52,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
double beatLength;
|
||||
|
||||
if (hitObject is IHasSliderVelocity hasSliderVelocity)
|
||||
beatLength = timingPoint.BeatLength / hasSliderVelocity.GetPrecisionAdjustedSliderVelocityMultiplier(ManiaRuleset.SHORT_NAME);
|
||||
beatLength = hasSliderVelocity.GetPrecisionAdjustedBeatLength(timingPoint, ManiaRuleset.SHORT_NAME);
|
||||
else
|
||||
beatLength = timingPoint.BeatLength;
|
||||
|
||||
|
@ -188,7 +188,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
|
||||
double beatLength;
|
||||
|
||||
if (obj is IHasSliderVelocity hasSliderVelocity)
|
||||
beatLength = timingPoint.BeatLength / hasSliderVelocity.GetPrecisionAdjustedSliderVelocityMultiplier(TaikoRuleset.SHORT_NAME);
|
||||
beatLength = hasSliderVelocity.GetPrecisionAdjustedBeatLength(timingPoint, TaikoRuleset.SHORT_NAME);
|
||||
else
|
||||
beatLength = timingPoint.BeatLength;
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
|
||||
namespace osu.Game.Rulesets.Objects.Types
|
||||
{
|
||||
@ -19,21 +20,28 @@ namespace osu.Game.Rulesets.Objects.Types
|
||||
BindableNumber<double> SliderVelocityMultiplierBindable { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Introduces floating-point errors for rulesets that depend on it.
|
||||
/// Introduces floating-point errors to post-multiplied beat length for rulesets that depend on it.
|
||||
/// </summary>
|
||||
public double GetPrecisionAdjustedSliderVelocityMultiplier(string rulesetShortName)
|
||||
public double GetPrecisionAdjustedBeatLength(TimingControlPoint timingControlPoint, string rulesetShortName)
|
||||
{
|
||||
double beatLength = -100 / SliderVelocityMultiplier;
|
||||
double sliderVelocityAsBeatLength = -100 / SliderVelocityMultiplier;
|
||||
|
||||
// Note: In stable, the division occurs on floats, but with compiler optimisations turned on actually seems to occur on doubles via some .NET black magic (possibly inlining?).
|
||||
double bpmMultiplier;
|
||||
|
||||
switch (rulesetShortName)
|
||||
{
|
||||
case "taiko":
|
||||
case "mania":
|
||||
return 1 / (beatLength < 0 ? Math.Clamp((float)-beatLength, 10, 10000) / 100.0 : 1);
|
||||
bpmMultiplier = sliderVelocityAsBeatLength < 0 ? Math.Clamp((float)-sliderVelocityAsBeatLength, 10, 10000) / 100.0 : 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 1 / (beatLength < 0 ? Math.Clamp((float)-beatLength, 10, 1000) / 100.0 : 1);
|
||||
bpmMultiplier = sliderVelocityAsBeatLength < 0 ? Math.Clamp((float)-sliderVelocityAsBeatLength, 10, 1000) / 100.0 : 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return timingControlPoint.BeatLength * bpmMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user