1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-05 17:02:58 +08:00

Fix all spinner ticks being alive and causing performance degradation

Regressed in https://github.com/ppy/osu/pull/25216.

The new logic will ensure at least one tick is ready for judgement.
There shouldn't be a case where more than one is needed in a single
frame.
This commit is contained in:
Dean Herbert 2023-11-01 18:28:05 +09:00
parent 57d8b5ddc9
commit c2de03aa44
No known key found for this signature in database
2 changed files with 15 additions and 6 deletions

View File

@ -275,6 +275,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
if (spinningSample != null && spinnerFrequencyModulate) if (spinningSample != null && spinnerFrequencyModulate)
spinningSample.Frequency.Value = spinning_sample_modulated_base_frequency + Progress; spinningSample.Frequency.Value = spinning_sample_modulated_base_frequency + Progress;
// Ticks can theoretically be judged at any point in the spinner's duration.
// For performance reasons, we only want to keep the next tick alive.
var next = NestedHitObjects.FirstOrDefault(h => !h.Judged);
// See default `LifetimeStart` as set in `DrawableSpinnerTick`.
if (next?.LifetimeStart == double.MaxValue)
{
// the tick can be theoretically judged at any point in the spinner's duration,
// so it must be alive throughout the spinner's entire lifetime.
// this mostly matters for correct sample playback.
next.LifetimeStart = HitObject.StartTime;
}
} }
protected override void UpdateAfterChildren() protected override void UpdateAfterChildren()

View File

@ -11,8 +11,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
public override bool DisplayResult => false; public override bool DisplayResult => false;
protected DrawableSpinner DrawableSpinner => (DrawableSpinner)ParentHitObject;
public DrawableSpinnerTick() public DrawableSpinnerTick()
: this(null) : this(null)
{ {
@ -29,10 +27,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
base.OnApply(); base.OnApply();
// the tick can be theoretically judged at any point in the spinner's duration, // Lifetime will be managed by `DrawableSpinner`.
// so it must be alive throughout the spinner's entire lifetime. LifetimeStart = double.MaxValue;
// this mostly matters for correct sample playback.
LifetimeStart = DrawableSpinner.HitObject.StartTime;
} }
/// <summary> /// <summary>