From a9d1d374b8f56ac63c4c89433a690dc9a4146a8a Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Fri, 15 Dec 2017 19:22:20 +0000 Subject: [PATCH] Remove draw line 2D helper method. Callers can provide 3D points easily, and this avoids the need to allocate and slow down enumeration via the points.Select(p => new float3(p, 0)) wrapper. --- OpenRA.Game/Graphics/RgbaColorRenderer.cs | 5 ----- OpenRA.Mods.Common/Graphics/SelectionBoxRenderable.cs | 4 ++-- OpenRA.Mods.Common/Widgets/LineGraphWidget.cs | 2 +- OpenRA.Mods.Common/Widgets/PerfGraphWidget.cs | 8 ++++---- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/OpenRA.Game/Graphics/RgbaColorRenderer.cs b/OpenRA.Game/Graphics/RgbaColorRenderer.cs index 3ca0aa0cf1..497032342d 100644 --- a/OpenRA.Game/Graphics/RgbaColorRenderer.cs +++ b/OpenRA.Game/Graphics/RgbaColorRenderer.cs @@ -204,11 +204,6 @@ namespace OpenRA.Graphics } } - public void DrawLine(IEnumerable points, float width, Color color, bool connectSegments = false) - { - DrawLine(points.Select(p => new float3(p, 0)), width, color, connectSegments); - } - public void DrawLine(IEnumerable points, float width, Color color, bool connectSegments = false) { if (!connectSegments) diff --git a/OpenRA.Mods.Common/Graphics/SelectionBoxRenderable.cs b/OpenRA.Mods.Common/Graphics/SelectionBoxRenderable.cs index 28a745871e..b50b430c84 100644 --- a/OpenRA.Mods.Common/Graphics/SelectionBoxRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/SelectionBoxRenderable.cs @@ -46,8 +46,8 @@ namespace OpenRA.Mods.Common.Graphics { var iz = 1 / wr.Viewport.Zoom; var screenDepth = wr.Screen3DPxPosition(pos).Z; - var tl = new float2(decorationBounds.Left, decorationBounds.Top); - var br = new float2(decorationBounds.Right, decorationBounds.Bottom); + var tl = new float3(decorationBounds.Left, decorationBounds.Top, 0); + var br = new float3(decorationBounds.Right, decorationBounds.Bottom, 0); var tr = new float3(br.X, tl.Y, screenDepth); var bl = new float3(tl.X, br.Y, screenDepth); var u = new float2(4 * iz, 0); diff --git a/OpenRA.Mods.Common/Widgets/LineGraphWidget.cs b/OpenRA.Mods.Common/Widgets/LineGraphWidget.cs index af62439708..bb9ce83889 100644 --- a/OpenRA.Mods.Common/Widgets/LineGraphWidget.cs +++ b/OpenRA.Mods.Common/Widgets/LineGraphWidget.cs @@ -131,7 +131,7 @@ namespace OpenRA.Mods.Common.Widgets { lastX = x; lastPoint = point; - return origin + new float2(x * xStep, -point * scale); + return origin + new float3(x * xStep, -point * scale, 0); }), 1, color); if (lastPoint != 0f) diff --git a/OpenRA.Mods.Common/Widgets/PerfGraphWidget.cs b/OpenRA.Mods.Common/Widgets/PerfGraphWidget.cs index a9ba630e87..fe88573248 100644 --- a/OpenRA.Mods.Common/Widgets/PerfGraphWidget.cs +++ b/OpenRA.Mods.Common/Widgets/PerfGraphWidget.cs @@ -27,9 +27,9 @@ namespace OpenRA.Mods.Common.Widgets cr.DrawLine(new[] { - new float2(rect.Left, rect.Top), - new float2(rect.Left, rect.Bottom), - new float2(rect.Right, rect.Bottom) + new float3(rect.Left, rect.Top, 0), + new float3(rect.Left, rect.Bottom, 0), + new float3(rect.Right, rect.Bottom, 0) }, 1, Color.White); cr.DrawLine(origin + new float2(100, 0) * basis, origin + new float2(100, 100) * basis, 1, Color.White); @@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Widgets foreach (var item in PerfHistory.Items.Values) { cr.DrawLine(item.Samples() - .Select((sample, i) => origin + new float2(i, (float)sample) * basis), + .Select((sample, i) => origin + new float3(i, (float)sample, 0) * basis), 1, item.C); var u = new float2(rect.Left, rect.Top);