From 9a330c3cdbcf8d275d957216efe43e9bd4e727e8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 Nov 2022 14:56:58 +0900 Subject: [PATCH] Apply nullability and clean up conditionals --- .../TestSceneTriangleBorderShader.cs | 2 -- osu.Game/Graphics/Backgrounds/TrianglesV2.cs | 25 ++++++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneTriangleBorderShader.cs b/osu.Game.Tests/Visual/Background/TestSceneTriangleBorderShader.cs index 470962088e..41a1d9b42e 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneTriangleBorderShader.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneTriangleBorderShader.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Allocation; using osu.Framework.Graphics.Shaders; using osu.Framework.Graphics.Shapes; diff --git a/osu.Game/Graphics/Backgrounds/TrianglesV2.cs b/osu.Game/Graphics/Backgrounds/TrianglesV2.cs index 0c4bf59732..4da227d5d6 100644 --- a/osu.Game/Graphics/Backgrounds/TrianglesV2.cs +++ b/osu.Game/Graphics/Backgrounds/TrianglesV2.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Utils; using osuTK; using System; @@ -71,11 +69,12 @@ namespace osu.Game.Graphics.Backgrounds private readonly List parts = new List(); [Resolved] - private IRenderer renderer { get; set; } + private IRenderer renderer { get; set; } = null!; - private Random stableRandom; - private IShader shader; - private Texture texture; + private Random? stableRandom; + + private IShader shader = null!; + private Texture texture = null!; /// /// Construct a new triangle visualisation. @@ -116,8 +115,7 @@ namespace osu.Game.Graphics.Backgrounds image[i, 0] = new Rgba32( colourBottom.Value.R * ratio + colourTop.Value.R * (1f - ratio), colourBottom.Value.G * ratio + colourTop.Value.G * (1f - ratio), - colourBottom.Value.B * ratio + colourTop.Value.B * (1f - ratio), - 1f + colourBottom.Value.B * ratio + colourTop.Value.B * (1f - ratio) ); } @@ -223,13 +221,13 @@ namespace osu.Game.Graphics.Backgrounds { protected new TrianglesV2 Source => (TrianglesV2)base.Source; - private IShader shader; - private Texture texture; + private IShader shader = null!; + private Texture texture = null!; private readonly List parts = new List(); private Vector2 size; - private IVertexBatch vertexBatch; + private IVertexBatch? vertexBatch; public TrianglesDrawNode(TrianglesV2 source) : base(source) @@ -252,7 +250,10 @@ namespace osu.Game.Graphics.Backgrounds { base.Draw(renderer); - if (Source.AimCount > 0 && (vertexBatch == null || vertexBatch.Size != Source.AimCount)) + if (Source.AimCount == 0) + return; + + if (vertexBatch == null || vertexBatch.Size != Source.AimCount) { vertexBatch?.Dispose(); vertexBatch = renderer.CreateQuadBatch(Source.AimCount, 1);