Adjust drawnodes to use the new shared data structure

This commit is contained in:
smoogipoo
2019-03-01 13:01:52 +09:00
parent bfe3d5708d
commit bf8360636a
3 changed files with 33 additions and 37 deletions

View File

@ -180,8 +180,6 @@ namespace osu.Game.Graphics.Backgrounds
protected override DrawNode CreateDrawNode() => new TrianglesDrawNode();
private readonly TrianglesDrawNodeSharedData sharedData = new TrianglesDrawNodeSharedData();
protected override void ApplyDrawNode(DrawNode node)
{
base.ApplyDrawNode(node);
@ -191,27 +189,21 @@ namespace osu.Game.Graphics.Backgrounds
trianglesNode.Shader = shader;
trianglesNode.Texture = texture;
trianglesNode.Size = DrawSize;
trianglesNode.Shared = sharedData;
trianglesNode.Parts.Clear();
trianglesNode.Parts.AddRange(parts);
}
private class TrianglesDrawNodeSharedData
{
public readonly LinearBatch<TexturedVertex2D> VertexBatch = new LinearBatch<TexturedVertex2D>(100 * 3, 10, PrimitiveType.Triangles);
}
private class TrianglesDrawNode : DrawNode
{
public Shader Shader;
public Texture Texture;
public TrianglesDrawNodeSharedData Shared;
public readonly List<TriangleParticle> Parts = new List<TriangleParticle>();
public Vector2 Size;
private readonly LinearBatch<TexturedVertex2D> vertexBatch = new LinearBatch<TexturedVertex2D>(100 * 3, 10, PrimitiveType.Triangles);
public override void Draw(Action<TexturedVertex2D> vertexAction)
{
base.Draw(vertexAction);
@ -239,12 +231,19 @@ namespace osu.Game.Graphics.Backgrounds
triangle,
colourInfo,
null,
Shared.VertexBatch.AddAction,
vertexBatch.AddAction,
Vector2.Divide(localInflationAmount, size));
}
Shader.Unbind();
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
vertexBatch.Dispose();
}
}
protected struct TriangleParticle : IComparable<TriangleParticle>