diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs
index 911ea6ede4..130edcf178 100644
--- a/OpenRA.Game/Graphics/Viewport.cs
+++ b/OpenRA.Game/Graphics/Viewport.cs
@@ -45,7 +45,7 @@ namespace OpenRA.Graphics
// Viewport geometry (world-px)
public int2 CenterLocation { get; private set; }
- public WPos CenterPosition { get { return worldRenderer.Position(CenterLocation); } }
+ public WPos CenterPosition { get { return worldRenderer.ProjectedPosition(CenterLocation); } }
public int2 TopLeft { get { return CenterLocation - viewportSize / 2; } }
public int2 BottomRight { get { return CenterLocation + viewportSize / 2; } }
@@ -158,14 +158,14 @@ namespace OpenRA.Graphics
}
// Something is very wrong, but lets return something that isn't completely bogus and hope the caller can recover
- return worldRenderer.World.Map.CellContaining(worldRenderer.Position(ViewToWorldPx(view)));
+ return worldRenderer.World.Map.CellContaining(worldRenderer.ProjectedPosition(ViewToWorldPx(view)));
}
/// Returns an unfiltered list of all cells that could potentially contain the mouse cursor
IEnumerable CandidateMouseoverCells(int2 world)
{
var map = worldRenderer.World.Map;
- var minPos = worldRenderer.Position(world);
+ var minPos = worldRenderer.ProjectedPosition(world);
// Find all the cells that could potentially have been clicked
var a = map.CellContaining(minPos - new WVec(1024, 0, 0)).ToMPos(map.TileShape);
@@ -230,8 +230,8 @@ namespace OpenRA.Graphics
// Calculate the viewport corners in "projected wpos" (at ground level), and
// this to an equivalent projected cell for the two corners
- var tl = map.CellContaining(worldRenderer.Position(TopLeft)).ToMPos(map);
- var br = map.CellContaining(worldRenderer.Position(BottomRight)).ToMPos(map);
+ var tl = map.CellContaining(worldRenderer.ProjectedPosition(TopLeft)).ToMPos(map);
+ var br = map.CellContaining(worldRenderer.ProjectedPosition(BottomRight)).ToMPos(map);
// Diamond tile shapes don't have straight edges, and so we need
// an additional cell margin to include the cells that are half
diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs
index 3a3668f918..4b256be4da 100644
--- a/OpenRA.Game/Graphics/WorldRenderer.cs
+++ b/OpenRA.Game/Graphics/WorldRenderer.cs
@@ -264,7 +264,11 @@ namespace OpenRA.Graphics
return pos.Y + pos.Z + offset;
}
- public WPos Position(int2 screenPx)
+ ///
+ /// Returns a position in the world that is projected to the given screen position.
+ /// There are many possible world positions, and the returned value chooses the value with no elevation.
+ ///
+ public WPos ProjectedPosition(int2 screenPx)
{
var ts = Game.ModData.Manifest.TileSize;
return new WPos(1024 * screenPx.X / ts.Width, 1024 * screenPx.Y / ts.Height, 0);
diff --git a/OpenRA.Mods.Common/Traits/Render/RenderNameTag.cs b/OpenRA.Mods.Common/Traits/Render/RenderNameTag.cs
index 6c87e936f7..2683c5744c 100644
--- a/OpenRA.Mods.Common/Traits/Render/RenderNameTag.cs
+++ b/OpenRA.Mods.Common/Traits/Render/RenderNameTag.cs
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits
var bounds = self.Bounds;
bounds.Offset(pos.X, pos.Y);
var spaceBuffer = (int)(10 / wr.Viewport.Zoom);
- var effectPos = wr.Position(new int2(pos.X, bounds.Y - spaceBuffer));
+ var effectPos = wr.ProjectedPosition(new int2(pos.X, bounds.Y - spaceBuffer));
yield return new TextRenderable(font, effectPos, 0, color, name);
}
diff --git a/OpenRA.Mods.Common/Traits/Render/WithDecoration.cs b/OpenRA.Mods.Common/Traits/Render/WithDecoration.cs
index e6531c008f..850ac087c1 100644
--- a/OpenRA.Mods.Common/Traits/Render/WithDecoration.cs
+++ b/OpenRA.Mods.Common/Traits/Render/WithDecoration.cs
@@ -145,7 +145,7 @@ namespace OpenRA.Mods.Common.Traits
pxPos += info.Offset;
// HACK: Because WorldRenderer.Position() does not care about terrain height at the location
- var renderPos = wr.Position(pxPos);
+ var renderPos = wr.ProjectedPosition(pxPos);
renderPos = new WPos(renderPos.X, renderPos.Y + self.CenterPosition.Z, self.CenterPosition.Z);
anim.Tick();
diff --git a/OpenRA.Mods.Common/Widgets/RadarWidget.cs b/OpenRA.Mods.Common/Widgets/RadarWidget.cs
index d2a77b1d76..615eda1977 100644
--- a/OpenRA.Mods.Common/Widgets/RadarWidget.cs
+++ b/OpenRA.Mods.Common/Widgets/RadarWidget.cs
@@ -237,8 +237,8 @@ namespace OpenRA.Mods.Common.Widgets
// Draw viewport rect
if (hasRadar)
{
- var tl = CellToMinimapPixel(world.Map.CellContaining(worldRenderer.Position(worldRenderer.Viewport.TopLeft)));
- var br = CellToMinimapPixel(world.Map.CellContaining(worldRenderer.Position(worldRenderer.Viewport.BottomRight)));
+ var tl = CellToMinimapPixel(world.Map.CellContaining(worldRenderer.ProjectedPosition(worldRenderer.Viewport.TopLeft)));
+ var br = CellToMinimapPixel(world.Map.CellContaining(worldRenderer.ProjectedPosition(worldRenderer.Viewport.BottomRight)));
Game.Renderer.EnableScissor(mapRect);
DrawRadarPings();
diff --git a/OpenRA.Mods.RA/Graphics/TeslaZapRenderable.cs b/OpenRA.Mods.RA/Graphics/TeslaZapRenderable.cs
index 06baa89c90..5c4155f696 100644
--- a/OpenRA.Mods.RA/Graphics/TeslaZapRenderable.cs
+++ b/OpenRA.Mods.RA/Graphics/TeslaZapRenderable.cs
@@ -139,7 +139,7 @@ namespace OpenRA.Mods.RA.Graphics
var step = steps.Where(t => (to - (z + new float2(t[0], t[1]))).LengthSquared < (to - z).LengthSquared)
.MinBy(t => Math.Abs(float2.Dot(z + new float2(t[0], t[1]), q) + c));
- var pos = wr.Position((z + new float2(step[2], step[3])).ToInt2());
+ var pos = wr.ProjectedPosition((z + new float2(step[2], step[3])).ToInt2());
rs.Add(new SpriteRenderable(s.GetSprite(step[4]), pos, WVec.Zero, 0, pal, 1f, true).PrepareRender(wr));
z += new float2(step[0], step[1]);