mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 21:32:57 +08:00
Use a DrawablePool
for mania's beat snap grid
I'm not sure what the cause of the issue is, but I'm also not sure why it wasn't using `DrawablePool` (was it not around back then?). Either way, switching to a proper pool fixes things just fine. Resolves https://github.com/ppy/osu/issues/25009.
This commit is contained in:
parent
b3d3ae87be
commit
1a60d6ade5
@ -8,6 +8,8 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Caching;
|
using osu.Framework.Caching;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Pooling;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
@ -23,7 +25,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A grid which displays coloured beat divisor lines in proximity to the selection or placement cursor.
|
/// A grid which displays coloured beat divisor lines in proximity to the selection or placement cursor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ManiaBeatSnapGrid : Component
|
public partial class ManiaBeatSnapGrid : CompositeComponent
|
||||||
{
|
{
|
||||||
private const double visible_range = 750;
|
private const double visible_range = 750;
|
||||||
|
|
||||||
@ -53,6 +55,8 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
|
|
||||||
private readonly List<ScrollingHitObjectContainer> grids = new List<ScrollingHitObjectContainer>();
|
private readonly List<ScrollingHitObjectContainer> grids = new List<ScrollingHitObjectContainer>();
|
||||||
|
|
||||||
|
private readonly DrawablePool<DrawableGridLine> linesPool = new DrawablePool<DrawableGridLine>(50);
|
||||||
|
|
||||||
private readonly Cached lineCache = new Cached();
|
private readonly Cached lineCache = new Cached();
|
||||||
|
|
||||||
private (double start, double end)? selectionTimeRange;
|
private (double start, double end)? selectionTimeRange;
|
||||||
@ -60,6 +64,8 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(HitObjectComposer composer)
|
private void load(HitObjectComposer composer)
|
||||||
{
|
{
|
||||||
|
AddInternal(linesPool);
|
||||||
|
|
||||||
foreach (var stage in ((ManiaPlayfield)composer.Playfield).Stages)
|
foreach (var stage in ((ManiaPlayfield)composer.Playfield).Stages)
|
||||||
{
|
{
|
||||||
foreach (var column in stage.Columns)
|
foreach (var column in stage.Columns)
|
||||||
@ -85,17 +91,10 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Stack<DrawableGridLine> availableLines = new Stack<DrawableGridLine>();
|
|
||||||
|
|
||||||
private void createLines()
|
private void createLines()
|
||||||
{
|
{
|
||||||
foreach (var grid in grids)
|
foreach (var grid in grids)
|
||||||
{
|
|
||||||
foreach (var line in grid.Objects.OfType<DrawableGridLine>())
|
|
||||||
availableLines.Push(line);
|
|
||||||
|
|
||||||
grid.Clear();
|
grid.Clear();
|
||||||
}
|
|
||||||
|
|
||||||
if (selectionTimeRange == null)
|
if (selectionTimeRange == null)
|
||||||
return;
|
return;
|
||||||
@ -131,10 +130,13 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
|
|
||||||
foreach (var grid in grids)
|
foreach (var grid in grids)
|
||||||
{
|
{
|
||||||
if (!availableLines.TryPop(out var line))
|
var line = linesPool.Get();
|
||||||
line = new DrawableGridLine();
|
|
||||||
|
line.Apply(new HitObject
|
||||||
|
{
|
||||||
|
StartTime = time
|
||||||
|
});
|
||||||
|
|
||||||
line.HitObject.StartTime = time;
|
|
||||||
line.Colour = colour;
|
line.Colour = colour;
|
||||||
|
|
||||||
grid.Add(line);
|
grid.Add(line);
|
||||||
|
Loading…
Reference in New Issue
Block a user