1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-14 05:47:20 +08:00

Remove EffectiveBPMPreprocessor

This commit is contained in:
tsunyoku 2025-01-21 14:24:04 +00:00
parent c8b05ce114
commit fa20bc6631
3 changed files with 32 additions and 58 deletions

View File

@ -1,50 +0,0 @@
// 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.
using System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Reading
{
public class EffectiveBPMPreprocessor
{
private readonly IList<TaikoDifficultyHitObject> noteObjects;
private readonly double globalSliderVelocity;
public EffectiveBPMPreprocessor(IBeatmap beatmap, List<TaikoDifficultyHitObject> noteObjects)
{
this.noteObjects = noteObjects;
globalSliderVelocity = beatmap.Difficulty.SliderMultiplier;
}
/// <summary>
/// Calculates and sets the effective BPM and slider velocity for each note object, considering clock rate and scroll speed.
/// </summary>
public void ProcessEffectiveBPM(ControlPointInfo controlPointInfo, double clockRate)
{
foreach (var currentNoteObject in noteObjects)
{
double startTime = currentNoteObject.StartTime * clockRate;
// Retrieve the timing point at the note's start time
TimingControlPoint currentControlPoint = controlPointInfo.TimingPointAt(startTime);
// Calculate the slider velocity at the note's start time.
double currentSliderVelocity = calculateSliderVelocity(controlPointInfo, startTime, clockRate);
currentNoteObject.CurrentSliderVelocity = currentSliderVelocity;
currentNoteObject.EffectiveBPM = currentControlPoint.BPM * currentSliderVelocity;
}
}
/// <summary>
/// Calculates the slider velocity based on control point info and clock rate.
/// </summary>
private double calculateSliderVelocity(ControlPointInfo controlPointInfo, double startTime, double clockRate)
{
var activeEffectControlPoint = controlPointInfo.EffectPointAt(startTime);
return globalSliderVelocity * (activeEffectControlPoint.ScrollSpeed) * clockRate;
}
}
}

View File

@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Taiko.Objects;
@ -76,11 +77,15 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
/// <param name="rimHitObjects">The list of rim (kat) <see cref="DifficultyHitObject"/>s in the current beatmap.</param>
/// <param name="noteObjects">The list of <see cref="DifficultyHitObject"/>s that is a hit (i.e. not a drumroll or swell) in the current beatmap.</param>
/// <param name="index">The position of this <see cref="DifficultyHitObject"/> in the <paramref name="objects"/> list.</param>
/// <param name="controlPointInfo">The control point info of the beatmap.</param>
/// <param name="globalSliderVelocity">The global slider velocity of the beatmap.</param>
public TaikoDifficultyHitObject(HitObject hitObject, HitObject lastObject, HitObject lastLastObject, double clockRate,
List<DifficultyHitObject> objects,
List<TaikoDifficultyHitObject> centreHitObjects,
List<TaikoDifficultyHitObject> rimHitObjects,
List<TaikoDifficultyHitObject> noteObjects, int index)
List<TaikoDifficultyHitObject> noteObjects, int index,
ControlPointInfo controlPointInfo,
double globalSliderVelocity)
: base(hitObject, lastObject, clockRate, objects, index)
{
noteDifficultyHitObjects = noteObjects;
@ -111,6 +116,26 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
NoteIndex = noteObjects.Count;
noteObjects.Add(this);
}
double startTime = hitObject.StartTime * clockRate;
// Retrieve the timing point at the note's start time
TimingControlPoint currentControlPoint = controlPointInfo.TimingPointAt(startTime);
// Calculate the slider velocity at the note's start time.
double currentSliderVelocity = calculateSliderVelocity(controlPointInfo, globalSliderVelocity, startTime, clockRate);
CurrentSliderVelocity = currentSliderVelocity;
EffectiveBPM = currentControlPoint.BPM * currentSliderVelocity;
}
/// <summary>
/// Calculates the slider velocity based on control point info and clock rate.
/// </summary>
private static double calculateSliderVelocity(ControlPointInfo controlPointInfo, double globalSliderVelocity, double startTime, double clockRate)
{
var activeEffectControlPoint = controlPointInfo.EffectPointAt(startTime);
return globalSliderVelocity * (activeEffectControlPoint.ScrollSpeed) * clockRate;
}
public TaikoDifficultyHitObject? PreviousMono(int backwardsIndex) => monoDifficultyHitObjects?.ElementAtOrDefault(MonoIndex - (backwardsIndex + 1));

View File

@ -13,7 +13,6 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour;
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Reading;
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Rhythm.Data;
using osu.Game.Rulesets.Taiko.Difficulty.Skills;
using osu.Game.Rulesets.Taiko.Mods;
@ -72,7 +71,6 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
var centreObjects = new List<TaikoDifficultyHitObject>();
var rimObjects = new List<TaikoDifficultyHitObject>();
var noteObjects = new List<TaikoDifficultyHitObject>();
EffectiveBPMPreprocessor bpmLoader = new EffectiveBPMPreprocessor(beatmap, noteObjects);
// Generate TaikoDifficultyHitObjects from the beatmap's hit objects.
for (int i = 2; i < beatmap.HitObjects.Count; i++)
@ -86,15 +84,16 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
centreObjects,
rimObjects,
noteObjects,
difficultyHitObjects.Count
difficultyHitObjects.Count,
beatmap.ControlPointInfo,
beatmap.Difficulty.SliderMultiplier
));
}
var groupedHitObjects = SameRhythmHitObjects.GroupHitObjects(noteObjects);
TaikoColourDifficultyPreprocessor.ProcessAndAssign(difficultyHitObjects);
SamePatterns.GroupPatterns(groupedHitObjects);
bpmLoader.ProcessEffectiveBPM(beatmap.ControlPointInfo, clockRate);
var groupedHitObjects = SameRhythmGroupedHitObjects.GroupHitObjects(noteObjects);
SamePatternsGroupedHitObjects.GroupPatterns(groupedHitObjects);
return difficultyHitObjects;
}