1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 15:27:24 +08:00

Adjust slider calculations to new method API

Code originally read

	Velocity = scoringDistance / beatLength
		 = BASE_SCORING_DISTANCE * SliderMultiplier * GetPrecisionAdjustedSliderVelocityMultiplier() / beatLength

Given (mathematically, floats are not generally as forgiving):

	GetPrecisionAdjustedBeatLength() = beatLength / GetPrecisionAdjustedSliderVelocityMultiplier()

it follows that (inverting both sides):

	1 / GetPrecisionAdjustedBeatLength() = GetPrecisionAdjustedSliderVelocityMultiplier() / beatLength

and therefore

	Velocity = BASE_SCORING_DISTANCE * SliderMultiplier * GetPrecisionAdjustedSliderVelocityMultiplier() / beatLength
		 = BASE_SCORING_DISTANCE * SliderMultiplier / GetPrecisionAdjustedBeatLength()

and to recover `scoringDistance`

	scoringDistance = Velocity * beatLength
This commit is contained in:
Bartłomiej Dach 2023-09-15 12:21:58 +02:00
parent 4275af1343
commit 5c6cd879dd
No known key found for this signature in database

View File

@ -16,6 +16,7 @@ using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Legacy;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Scoring;
@ -166,9 +167,11 @@ namespace osu.Game.Rulesets.Osu.Objects
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
double scoringDistance = BASE_SCORING_DISTANCE * difficulty.SliderMultiplier * ((IHasSliderVelocity)this).GetPrecisionAdjustedSliderVelocityMultiplier(OsuRuleset.SHORT_NAME);
Velocity = BASE_SCORING_DISTANCE * difficulty.SliderMultiplier / LegacyRulesetExtensions.GetPrecisionAdjustedBeatLength(this, timingPoint, OsuRuleset.SHORT_NAME);
// WARNING: this is intentionally not computed as `BASE_SCORING_DISTANCE * difficulty.SliderMultiplier`
// for backwards compatibility reasons (intentionally introducing floating point errors to match stable).
double scoringDistance = Velocity * timingPoint.BeatLength;
Velocity = scoringDistance / timingPoint.BeatLength;
TickDistance = GenerateTicks ? (scoringDistance / difficulty.SliderTickRate * TickDistanceMultiplier) : double.PositiveInfinity;
}