Centralise and repair circle size calculations game-wide

This commit is contained in:
Dean Herbert 2023-10-18 19:50:42 +09:00
parent 6ae82c5e73
commit 3a5490892c
No known key found for this signature in database
6 changed files with 29 additions and 23 deletions

View File

@ -151,7 +151,7 @@ namespace osu.Game.Rulesets.Catch.Objects
TimePreempt = (float)IBeatmapDifficultyInfo.DifficultyRange(difficulty.ApproachRate, 1800, 1200, 450);
Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2;
Scale = IBeatmapDifficultyInfo.CalculateScaleFromCircleSize(difficulty.CircleSize);
}
protected override HitWindows CreateHitWindows() => HitWindows.Empty;

View File

@ -145,7 +145,7 @@ namespace osu.Game.Rulesets.Catch.UI
Size = new Vector2(BASE_SIZE);
if (difficulty != null)
Scale = calculateScale(difficulty);
Scale = new Vector2(IBeatmapDifficultyInfo.CalculateScaleFromCircleSize(difficulty.CircleSize));
CatchWidth = CalculateCatchWidth(Scale);
@ -182,11 +182,6 @@ namespace osu.Game.Rulesets.Catch.UI
/// </summary>
public Drawable CreateProxiedContent() => caughtObjectContainer.CreateProxy();
/// <summary>
/// Calculates the scale of the catcher based off the provided beatmap difficulty.
/// </summary>
private static Vector2 calculateScale(IBeatmapDifficultyInfo difficulty) => new Vector2(1.0f - 0.7f * (difficulty.CircleSize - 5) / 5);
/// <summary>
/// Calculates the width of the area used for attempting catches in gameplay.
/// </summary>
@ -197,7 +192,7 @@ namespace osu.Game.Rulesets.Catch.UI
/// Calculates the width of the area used for attempting catches in gameplay.
/// </summary>
/// <param name="difficulty">The beatmap difficulty.</param>
public static float CalculateCatchWidth(IBeatmapDifficultyInfo difficulty) => CalculateCatchWidth(calculateScale(difficulty));
public static float CalculateCatchWidth(IBeatmapDifficultyInfo difficulty) => CalculateCatchWidth(new Vector2(IBeatmapDifficultyInfo.CalculateScaleFromCircleSize(difficulty.CircleSize)));
/// <summary>
/// Determine if this catcher can catch a <see cref="CatchHitObject"/> in the current position.

View File

@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.Osu.Tests
{
const double time_slider_start = 1000;
float circleRadius = OsuHitObject.OBJECT_RADIUS * (1.0f - 0.7f * (circleSize - 5) / 5) / 2;
float circleRadius = OsuHitObject.OBJECT_RADIUS * IBeatmapDifficultyInfo.CalculateScaleFromCircleSize(circleSize);
float followCircleRadius = circleRadius * 1.2f;
performTest(new Beatmap<OsuHitObject>

View File

@ -155,17 +155,7 @@ namespace osu.Game.Rulesets.Osu.Objects
// This adjustment is necessary for AR>10, otherwise TimePreempt can become smaller leading to hitcircles not fully fading in.
TimeFadeIn = 400 * Math.Min(1, TimePreempt / PREEMPT_MIN);
// The following comment is copied verbatim from osu-stable:
//
// Builds of osu! up to 2013-05-04 had the gamefield being rounded down, which caused incorrect radius calculations
// in widescreen cases. This ratio adjusts to allow for old replays to work post-fix, which in turn increases the lenience
// for all plays, but by an amount so small it should only be effective in replays.
//
// To match expectations of gameplay we need to apply this multiplier to circle scale. It's weird but is what it is.
// It works out to under 1 game pixel and is generally not meaningful to gameplay, but is to replay playback accuracy.
const float broken_gamefield_rounding_allowance = 1.00041f;
Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2 * broken_gamefield_rounding_allowance;
Scale = IBeatmapDifficultyInfo.CalculateScaleFromCircleSize(difficulty.CircleSize);
}
protected override HitWindows CreateHitWindows() => new OsuHitWindows();

View File

@ -208,8 +208,7 @@ namespace osu.Game.Rulesets.Osu.Statistics
if (score.HitEvents.Count == 0)
return;
// Todo: This should probably not be done like this.
float radius = OsuHitObject.OBJECT_RADIUS * (1.0f - 0.7f * (playableBeatmap.Difficulty.CircleSize - 5) / 5) / 2;
float radius = OsuHitObject.OBJECT_RADIUS * IBeatmapDifficultyInfo.CalculateScaleFromCircleSize(playableBeatmap.Difficulty.CircleSize);
foreach (var e in score.HitEvents.Where(e => e.HitObject is HitCircle && !(e.HitObject is SliderTailCircle)))
{

View File

@ -44,6 +44,21 @@ namespace osu.Game.Beatmaps
/// </summary>
double SliderTickRate { get; }
static float CalculateScaleFromCircleSize(float circleSize)
{
// The following comment is copied verbatim from osu-stable:
//
// Builds of osu! up to 2013-05-04 had the gamefield being rounded down, which caused incorrect radius calculations
// in widescreen cases. This ratio adjusts to allow for old replays to work post-fix, which in turn increases the lenience
// for all plays, but by an amount so small it should only be effective in replays.
//
// To match expectations of gameplay we need to apply this multiplier to circle scale. It's weird but is what it is.
// It works out to under 1 game pixel and is generally not meaningful to gameplay, but is to replay playback accuracy.
const float broken_gamefield_rounding_allowance = 1.00041f;
return (float)(1.0f - 0.7f * DifficultyRange(circleSize)) / 2 * broken_gamefield_rounding_allowance;
}
/// <summary>
/// Maps a difficulty value [0, 10] to a two-piece linear range of values.
/// </summary>
@ -55,13 +70,20 @@ namespace osu.Game.Beatmaps
static double DifficultyRange(double difficulty, double min, double mid, double max)
{
if (difficulty > 5)
return mid + (max - mid) * (difficulty - 5) / 5;
return mid + (max - mid) * DifficultyRange(difficulty);
if (difficulty < 5)
return mid - (mid - min) * (5 - difficulty) / 5;
return mid;
}
/// <summary>
/// Maps a difficulty value [0, 10] to a linear range of [-1, 1].
/// </summary>
/// <param name="difficulty">The difficulty value to be mapped.</param>
/// <returns>Value to which the difficulty value maps in the specified range.</returns>
static double DifficultyRange(double difficulty) => (difficulty - 5) / 5;
/// <summary>
/// Maps a difficulty value [0, 10] to a two-piece linear range of values.
/// </summary>