mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 07:42:57 +08:00
Remove cursortrail drawnode allocs
This commit is contained in:
parent
5537c4f183
commit
b0415dc30a
@ -162,7 +162,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
private readonly TrailPart[] parts = new TrailPart[max_sprites];
|
private readonly TrailPart[] parts = new TrailPart[max_sprites];
|
||||||
private Vector2 size;
|
private Vector2 size;
|
||||||
|
|
||||||
private readonly VertexBatch<TexturedTrailVertex> vertexBatch = new QuadBatch<TexturedTrailVertex>(max_sprites, 1);
|
private readonly CustomBatch vertexBatch = new CustomBatch(max_sprites, 1);
|
||||||
|
|
||||||
public TrailDrawNode(CursorTrail source)
|
public TrailDrawNode(CursorTrail source)
|
||||||
: base(source)
|
: base(source)
|
||||||
@ -197,20 +197,14 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
for (int i = 0; i < parts.Length; ++i)
|
for (int i = 0; i < parts.Length; ++i)
|
||||||
{
|
{
|
||||||
Vector2 pos = parts[i].Position;
|
Vector2 pos = parts[i].Position;
|
||||||
float localTime = parts[i].Time;
|
vertexBatch.DrawTime = parts[i].Time;
|
||||||
|
|
||||||
DrawQuad(
|
DrawQuad(
|
||||||
texture,
|
texture,
|
||||||
new Quad(pos.X - size.X / 2, pos.Y - size.Y / 2, size.X, size.Y),
|
new Quad(pos.X - size.X / 2, pos.Y - size.Y / 2, size.X, size.Y),
|
||||||
DrawColourInfo.Colour,
|
DrawColourInfo.Colour,
|
||||||
null,
|
null,
|
||||||
v => vertexBatch.Add(new TexturedTrailVertex
|
vertexBatch.AddAction);
|
||||||
{
|
|
||||||
Position = v.Position,
|
|
||||||
TexturePosition = v.TexturePosition,
|
|
||||||
Time = localTime + 1,
|
|
||||||
Colour = v.Colour,
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shader.Unbind();
|
shader.Unbind();
|
||||||
@ -222,6 +216,27 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
|
|
||||||
vertexBatch.Dispose();
|
vertexBatch.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class CustomBatch : QuadBatch<TexturedTrailVertex>
|
||||||
|
{
|
||||||
|
public new readonly Action<TexturedVertex2D> AddAction;
|
||||||
|
|
||||||
|
public float DrawTime;
|
||||||
|
|
||||||
|
public CustomBatch(int size, int maxBuffers)
|
||||||
|
: base(size, maxBuffers)
|
||||||
|
{
|
||||||
|
AddAction = add;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void add(TexturedVertex2D vertex) => Add(new TexturedTrailVertex
|
||||||
|
{
|
||||||
|
Position = vertex.Position,
|
||||||
|
TexturePosition = vertex.TexturePosition,
|
||||||
|
Time = DrawTime + 1,
|
||||||
|
Colour = vertex.Colour,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
Loading…
Reference in New Issue
Block a user