Add depth buffer support to debug overlays.

This commit is contained in:
Paul Chote
2016-08-22 20:37:55 +01:00
parent 50da18cd22
commit c092c93401
11 changed files with 59 additions and 56 deletions

View File

@@ -63,8 +63,8 @@ namespace OpenRA.Mods.Common.Traits
{
var hc = Color.Orange;
var height = new WVec(0, 0, blockers.Max(b => b.BlockingHeight.Length));
var ha = wr.ScreenPosition(self.CenterPosition);
var hb = wr.ScreenPosition(self.CenterPosition + height);
var ha = wr.Screen3DPosition(self.CenterPosition);
var hb = wr.Screen3DPosition(self.CenterPosition + height);
wcr.DrawLine(ha, hb, iz, hc);
TargetLineRenderable.DrawTargetMarker(wr, hc, ha);
TargetLineRenderable.DrawTargetMarker(wr, hc, hb);
@@ -89,9 +89,9 @@ namespace OpenRA.Mods.Common.Traits
var da = coords.Value.LocalToWorld(new WVec(224, 0, 0).Rotate(WRot.FromYaw(p.Yaw + p.Cone)).Rotate(bodyOrientation));
var db = coords.Value.LocalToWorld(new WVec(224, 0, 0).Rotate(WRot.FromYaw(p.Yaw - p.Cone)).Rotate(bodyOrientation));
var o = wr.ScreenPosition(pos);
var a = wr.ScreenPosition(pos + da * 224 / da.Length);
var b = wr.ScreenPosition(pos + db * 224 / db.Length);
var o = wr.Screen3DPosition(pos);
var a = wr.Screen3DPosition(pos + da * 224 / da.Length);
var b = wr.Screen3DPosition(pos + db * 224 / db.Length);
wcr.DrawLine(o, a, iz, c);
wcr.DrawLine(o, b, iz, c);
}
@@ -106,8 +106,8 @@ namespace OpenRA.Mods.Common.Traits
var muzzle = self.CenterPosition + a.MuzzleOffset(self, b);
var dirOffset = new WVec(0, -224, 0).Rotate(a.MuzzleOrientation(self, b));
var sm = wr.ScreenPosition(muzzle);
var sd = wr.ScreenPosition(muzzle + dirOffset);
var sm = wr.Screen3DPosition(muzzle);
var sd = wr.Screen3DPosition(muzzle + dirOffset);
wcr.DrawLine(sm, sd, iz, c);
TargetLineRenderable.DrawTargetMarker(wr, c, sm);
}

View File

@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
continue;
var exitCellCenter = self.World.Map.CenterOfCell(exitCells[i]);
rgbaRenderer.DrawLine(wr.ScreenPosition(spawnPos), wr.ScreenPosition(exitCellCenter), 1f, self.Owner.Color.RGB);
rgbaRenderer.DrawLine(wr.Screen3DPosition(spawnPos), wr.Screen3DPosition(exitCellCenter), 1f, self.Owner.Color.RGB);
}
}
}

View File

@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits
var corners = map.Grid.CellCorners[ramp];
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 screen = corners.Select(c => wr.Screen3DPxPosition(pos + c)).ToArray();
var width = (uv == mouseCell ? 3 : 1) / wr.Viewport.Zoom;
// Colors change between points, so render separately
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var puv in map.ProjectedCellsCovering(mouseCell))
{
var pos = map.CenterOfCell(((MPos)puv).ToCPos(map));
var screen = projectedCorners.Select(c => wr.ScreenPxPosition(pos + c - new WVec(0, 0, pos.Z)).ToFloat2()).ToArray();
var screen = projectedCorners.Select(c => wr.Screen3DPxPosition(pos + c - new WVec(0, 0, pos.Z))).ToArray();
for (var i = 0; i < 4; i++)
{
var j = (i + 1) % 4;

View File

@@ -73,8 +73,9 @@ namespace OpenRA.Mods.Common.Traits
foreach (var r in i.Range)
{
var tl = wr.ScreenPosition(i.CenterPosition - new WVec(r.Length, r.Length, 0));
var br = wr.ScreenPosition(i.CenterPosition + new WVec(r.Length, r.Length, 0));
var tl = wr.Screen3DPosition(i.CenterPosition - new WVec(r.Length, r.Length, 0));
var br = wr.Screen3DPosition(i.CenterPosition + new WVec(r.Length, r.Length, 0));
Game.Renderer.WorldRgbaColorRenderer.FillEllipse(tl, br, Color.FromArgb((int)alpha, i.Color));
alpha -= rangeStep;