mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 15:44:04 +09:00
Apply DrawNode batching changes
This commit is contained in:
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Batches;
|
||||
using osu.Framework.Graphics.OpenGL.Vertices;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Rendering;
|
||||
@ -212,17 +211,12 @@ namespace osu.Game.Rulesets.Mods
|
||||
private Vector2 flashlightSize;
|
||||
private float flashlightDim;
|
||||
|
||||
private readonly VertexBatch<PositionAndColourVertex> quadBatch = new QuadBatch<PositionAndColourVertex>(1, 1);
|
||||
private readonly Action<TexturedVertex2D> addAction;
|
||||
private IVertexBatch<PositionAndColourVertex>? quadBatch;
|
||||
private Action<TexturedVertex2D>? addAction;
|
||||
|
||||
public FlashlightDrawNode(Flashlight source)
|
||||
: base(source)
|
||||
{
|
||||
addAction = v => quadBatch.Add(new PositionAndColourVertex
|
||||
{
|
||||
Position = v.Position,
|
||||
Colour = v.Colour
|
||||
});
|
||||
}
|
||||
|
||||
public override void ApplyState()
|
||||
@ -240,6 +234,16 @@ namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
base.Draw(renderer);
|
||||
|
||||
if (quadBatch == null)
|
||||
{
|
||||
quadBatch = renderer.CreateQuadBatch<PositionAndColourVertex>(1, 1);
|
||||
addAction = v => quadBatch.Add(new PositionAndColourVertex
|
||||
{
|
||||
Position = v.Position,
|
||||
Colour = v.Colour
|
||||
});
|
||||
}
|
||||
|
||||
shader.Bind();
|
||||
|
||||
shader.GetUniform<Vector2>("flashlightPos").UpdateValue(ref flashlightPosition);
|
||||
@ -254,7 +258,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
quadBatch.Dispose();
|
||||
quadBatch?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user