From e1290dca4779a8b7cba952dae9f9f99989ba6a96 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 15 May 2013 21:07:15 +1200 Subject: [PATCH] Round PxPosition to the nearest pixel. --- OpenRA.Game/Graphics/WorldRenderer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index b43d54ccc1..088ef22b6b 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -214,8 +214,11 @@ namespace OpenRA.Graphics public int2 ScreenPxPosition(WPos pos) { - return new int2(Game.CellSize*pos.X/1024, Game.CellSize*(pos.Y - pos.Z)/1024); + // Round to nearest pixel + var px = ScreenPosition(pos); + return new int2((int)Math.Round(px.X), (int)Math.Round(px.Y)); } + public float ScreenZPosition(WPos pos) { return (pos.Y + pos.Z)*Game.CellSize/1024f; } public int2 ScreenPxOffset(WVec vec)