Change DrawSprite calls to provide scales instead of sizes.

This allows us to remove a hacky workaround for calculating
depth offsets when sprites have size.Z == 0.
This commit is contained in:
Paul Chote
2021-07-24 20:56:51 +01:00
committed by reaperrr
parent 8e94e1d5ec
commit 70892a6661
12 changed files with 46 additions and 64 deletions

View File

@@ -76,10 +76,7 @@ namespace OpenRA.Graphics
float3 ScreenPosition(WorldRenderer wr)
{
var xy = wr.ScreenPxPosition(pos) + wr.ScreenPxOffset(offset) - (0.5f * scale * sprite.Size.XY).ToInt2();
// HACK: The z offset needs to be applied somewhere, but this probably is the wrong place.
return new float3(xy, sprite.Offset.Z + wr.ScreenZPosition(pos, 0) - 0.5f * scale * sprite.Size.Z);
return wr.Screen3DPxPosition(pos) + wr.ScreenPxOffset(offset) - 0.5f * scale * sprite.Size;
}
public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
@@ -95,7 +92,7 @@ namespace OpenRA.Graphics
if ((tintModifiers & TintModifiers.ReplaceColor) != 0)
a *= -1;
wsr.DrawSprite(sprite, ScreenPosition(wr), palette, scale * sprite.Size, t, a);
wsr.DrawSprite(sprite, palette, ScreenPosition(wr), scale, t, a);
}
public void RenderDebugGeometry(WorldRenderer wr)