mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 20:33:08 +08:00
Merge pull request #7967 from peppy/judgement-line-performance
Reduce hit error display performance overhead
This commit is contained in:
commit
d11ec392f4
@ -9,6 +9,7 @@ using osu.Game.Rulesets.Judgements;
|
|||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Rulesets.Catch.Scoring;
|
using osu.Game.Rulesets.Catch.Scoring;
|
||||||
using osu.Game.Rulesets.Mania.Scoring;
|
using osu.Game.Rulesets.Mania.Scoring;
|
||||||
@ -43,6 +44,22 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddRepeatStep("New max negative", () => newJudgement(-hitWindows.WindowFor(HitResult.Meh)), 20);
|
AddRepeatStep("New max negative", () => newJudgement(-hitWindows.WindowFor(HitResult.Meh)), 20);
|
||||||
AddRepeatStep("New max positive", () => newJudgement(hitWindows.WindowFor(HitResult.Meh)), 20);
|
AddRepeatStep("New max positive", () => newJudgement(hitWindows.WindowFor(HitResult.Meh)), 20);
|
||||||
AddStep("New fixed judgement (50ms)", () => newJudgement(50));
|
AddStep("New fixed judgement (50ms)", () => newJudgement(50));
|
||||||
|
|
||||||
|
AddStep("Judgement barrage", () =>
|
||||||
|
{
|
||||||
|
int runCount = 0;
|
||||||
|
|
||||||
|
ScheduledDelegate del = null;
|
||||||
|
|
||||||
|
del = Scheduler.AddDelayed(() =>
|
||||||
|
{
|
||||||
|
newJudgement(runCount++ / 10f);
|
||||||
|
|
||||||
|
if (runCount == 500)
|
||||||
|
// ReSharper disable once AccessToModifiedClosure
|
||||||
|
del?.Cancel();
|
||||||
|
}, 10, true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -207,11 +207,27 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
private double floatingAverage;
|
private double floatingAverage;
|
||||||
private Container colourBars;
|
private Container colourBars;
|
||||||
|
|
||||||
|
private const int max_concurrent_judgements = 50;
|
||||||
|
|
||||||
public override void OnNewJudgement(JudgementResult judgement)
|
public override void OnNewJudgement(JudgementResult judgement)
|
||||||
{
|
{
|
||||||
if (!judgement.IsHit)
|
if (!judgement.IsHit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (judgementsContainer.Count > max_concurrent_judgements)
|
||||||
|
{
|
||||||
|
const double quick_fade_time = 100;
|
||||||
|
|
||||||
|
// check with a bit of lenience to avoid precision error in comparison.
|
||||||
|
var old = judgementsContainer.FirstOrDefault(j => j.LifetimeEnd > Clock.CurrentTime + quick_fade_time * 1.1);
|
||||||
|
|
||||||
|
if (old != null)
|
||||||
|
{
|
||||||
|
old.ClearTransforms();
|
||||||
|
old.FadeOut(quick_fade_time).Expire();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
judgementsContainer.Add(new JudgementLine
|
judgementsContainer.Add(new JudgementLine
|
||||||
{
|
{
|
||||||
Y = getRelativeJudgementPosition(judgement.TimeOffset),
|
Y = getRelativeJudgementPosition(judgement.TimeOffset),
|
||||||
@ -228,7 +244,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
|
|
||||||
private class JudgementLine : CompositeDrawable
|
private class JudgementLine : CompositeDrawable
|
||||||
{
|
{
|
||||||
private const int judgement_fade_duration = 10000;
|
private const int judgement_fade_duration = 5000;
|
||||||
|
|
||||||
public JudgementLine()
|
public JudgementLine()
|
||||||
{
|
{
|
||||||
@ -255,7 +271,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
Width = 0;
|
Width = 0;
|
||||||
|
|
||||||
this.ResizeWidthTo(1, 200, Easing.OutElasticHalf);
|
this.ResizeWidthTo(1, 200, Easing.OutElasticHalf);
|
||||||
this.FadeTo(0.8f, 150).Then().FadeOut(judgement_fade_duration, Easing.OutQuint).Expire();
|
this.FadeTo(0.8f, 150).Then().FadeOut(judgement_fade_duration).Expire();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user