Rename WorldRenderer.Position -> ProjectedPosition.
This commit is contained in:
@@ -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)));
|
||||
}
|
||||
|
||||
/// <summary> Returns an unfiltered list of all cells that could potentially contain the mouse cursor</summary>
|
||||
IEnumerable<MPos> 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
|
||||
|
||||
@@ -264,7 +264,11 @@ namespace OpenRA.Graphics
|
||||
return pos.Y + pos.Z + offset;
|
||||
}
|
||||
|
||||
public WPos Position(int2 screenPx)
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user