Merge pull request #10203 from pchote/widelines2

Rewrite line renderer: Part 2 (remove LineRenderer plus other cleanups)
This commit is contained in:
Matthias Mailänder
2015-12-21 07:36:21 +01:00
27 changed files with 300 additions and 332 deletions

View File

@@ -52,7 +52,8 @@ namespace OpenRA.Mods.Common.Traits
RangeCircleRenderable.DrawRangeCircle(wr, self.CenterPosition, healthInfo.Radius,
1, Color.Red, 0, Color.Red);
var wlr = Game.Renderer.WorldLineRenderer;
var wcr = Game.Renderer.WorldRgbaColorRenderer;
var iz = 1 / wr.Viewport.Zoom;
if (blockInfo != null)
{
@@ -60,9 +61,9 @@ namespace OpenRA.Mods.Common.Traits
var height = new WVec(0, 0, blockInfo.Height.Length);
var ha = wr.ScreenPosition(self.CenterPosition);
var hb = wr.ScreenPosition(self.CenterPosition + height);
wlr.DrawLine(ha, hb, hc);
wr.DrawTargetMarker(hc, ha);
wr.DrawTargetMarker(hc, hb);
wcr.DrawLine(ha, hb, iz, hc);
TargetLineRenderable.DrawTargetMarker(wr, hc, ha);
TargetLineRenderable.DrawTargetMarker(wr, hc, hb);
}
// No armaments to draw
@@ -85,8 +86,8 @@ namespace OpenRA.Mods.Common.Traits
var o = wr.ScreenPosition(pos);
var a = wr.ScreenPosition(pos + da * 224 / da.Length);
var b = wr.ScreenPosition(pos + db * 224 / db.Length);
wlr.DrawLine(o, a, c);
wlr.DrawLine(o, b, c);
wcr.DrawLine(o, a, iz, c);
wcr.DrawLine(o, b, iz, c);
}
return;
@@ -101,8 +102,8 @@ namespace OpenRA.Mods.Common.Traits
var sm = wr.ScreenPosition(muzzle);
var sd = wr.ScreenPosition(muzzle + dirOffset);
wlr.DrawLine(sm, sd, c);
wr.DrawTargetMarker(c, sm);
wcr.DrawLine(sm, sd, iz, c);
TargetLineRenderable.DrawTargetMarker(wr, c, sm);
}
}
}

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
var map = wr.World.Map;
var tileSet = wr.World.TileSet;
var lr = Game.Renderer.WorldLineRenderer;
var wcr = Game.Renderer.WorldRgbaColorRenderer;
var colors = wr.World.TileSet.HeightDebugColors;
var mouseCell = wr.Viewport.ViewToWorld(Viewport.LastMousePos).ToMPos(wr.World.Map);
@@ -71,22 +71,18 @@ namespace OpenRA.Mods.Common.Traits
var color = corners.Select(c => colors[height + c.Z / 512]).ToArray();
var pos = map.CenterOfCell(uv.ToCPos(map));
var screen = corners.Select(c => wr.ScreenPxPosition(pos + c).ToFloat2()).ToArray();
var width = (uv == mouseCell ? 3 : 1) / wr.Viewport.Zoom;
if (uv == mouseCell)
lr.LineWidth = 3;
// Colors change between points, so render separately
for (var i = 0; i < 4; i++)
{
var j = (i + 1) % 4;
lr.DrawLine(screen[i], screen[j], color[i], color[j]);
wcr.DrawLine(screen[i], screen[j], width, color[i], color[j]);
}
lr.LineWidth = 1;
}
// Projected cell coordinates for the current cell
var projectedCorners = map.CellCorners[0];
lr.LineWidth = 3;
foreach (var puv in map.ProjectedCellsCovering(mouseCell))
{
var pos = map.CenterOfCell(((MPos)puv).ToCPos(map));
@@ -94,11 +90,9 @@ namespace OpenRA.Mods.Common.Traits
for (var i = 0; i < 4; i++)
{
var j = (i + 1) % 4;
lr.DrawLine(screen[i], screen[j], Color.Navy);
wcr.DrawLine(screen[i], screen[j], 3 / wr.Viewport.Zoom, Color.Navy);
}
}
lr.LineWidth = 1;
}
}
}

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Particles are drawn in squares when enabled, otherwise with lines.")]
public readonly bool UseSquares = true;
[Desc("Works only with squares enabled. Size min. and max. value in pixels.")]
[Desc("Size / width of the particle in px.")]
public readonly int[] ParticleSize = { 1, 3 };
[Desc("Scatters falling direction on the x-axis. Scatter min. and max. value in px/tick.")]
@@ -294,7 +294,7 @@ namespace OpenRA.Mods.Common.Traits
else
{
var tempPosTail = new float2(topLeft.X + item.PosX - currentWindXOffset, item.PosY - (item.Gravity * 2 / 3) + topLeft.Y);
Game.Renderer.WorldLineRenderer.DrawLine(tempPos, tempPosTail, item.Color, item.TailColor);
Game.Renderer.WorldRgbaColorRenderer.DrawLine(tempPos, tempPosTail, item.Size, item.TailColor);
}
}
}