Skip to content

Commit fc62106

Browse files
committed
Increase and standardize turret z offset to counter depth errors due to float imprecision
1 parent 7f7d5fc commit fc62106

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/TSMapEditor/Rendering/ObjectRenderers/BuildingRenderer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ private void DrawVoxelTurret(Structure gameObject, Point2D drawPoint, in CommonD
528528

529529
DrawVoxelModel(gameObject, drawParams.BarrelVoxel,
530530
gameObject.Facing, RampType.None, nonRemapColor, true, gameObject.GetRemapColor(),
531-
affectedByLighting, turretDrawPoint, Constants.DepthEpsilon * 3); // appears to need a 3x multiplier due to float imprecision
531+
affectedByLighting, turretDrawPoint, Constants.DepthEpsilon * ObjectDepthAdjustments.Turret); // appears to need a 3x multiplier due to float imprecision
532532
}
533533
else
534534
{
@@ -538,15 +538,15 @@ private void DrawVoxelTurret(Structure gameObject, Point2D drawPoint, in CommonD
538538

539539
DrawVoxelModel(gameObject, drawParams.TurretVoxel,
540540
gameObject.Facing, RampType.None, nonRemapColor, true, gameObject.GetRemapColor(),
541-
affectedByLighting, turretDrawPoint, Constants.DepthEpsilon * 2); // Turret is always drawn above building
541+
affectedByLighting, turretDrawPoint, Constants.DepthEpsilon * ObjectDepthAdjustments.Turret); // Turret is always drawn above building
542542
}
543543
}
544544
else if (gameObject.ObjectType.Turret && !gameObject.ObjectType.TurretAnimIsVoxel &&
545545
gameObject.ObjectType.BarrelAnimIsVoxel)
546546
{
547547
DrawVoxelModel(gameObject, drawParams.BarrelVoxel,
548548
gameObject.Facing, RampType.None, nonRemapColor, true, gameObject.GetRemapColor(),
549-
affectedByLighting, drawPoint, Constants.DepthEpsilon);
549+
affectedByLighting, drawPoint, Constants.DepthEpsilon * ObjectDepthAdjustments.Turret);
550550
}
551551
}
552552

src/TSMapEditor/Rendering/ObjectRenderers/ObjectDepthAdjustments.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ public static class ObjectDepthAdjustments
1111
public const int Terrain = 300;
1212
public const int Vehicle = 150;
1313
public const int Shadow = 0;
14+
public const int Turret = 3;
1415
}
1516
}

src/TSMapEditor/Rendering/ObjectRenderers/UnitRenderer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ protected override void Render(Unit gameObject, Point2D drawPoint, in CommonDraw
8888
else
8989
RenderTurretShape(gameObject, drawPoint, drawParams, Constants.DepthEpsilon);
9090

91-
RenderVoxelModel(gameObject, drawPoint + turretOffset, drawParams.BarrelVoxel, affectedByLighting, Constants.DepthEpsilon * 2);
91+
RenderVoxelModel(gameObject, drawPoint + turretOffset, drawParams.BarrelVoxel, affectedByLighting, Constants.DepthEpsilon * ObjectDepthAdjustments.Turret);
9292
}
9393
else
9494
{
9595
RenderVoxelModel(gameObject, drawPoint + turretOffset, drawParams.BarrelVoxel, affectedByLighting, Constants.DepthEpsilon);
9696

9797
if (gameObject.UnitType.ArtConfig.Voxel)
98-
RenderVoxelModel(gameObject, drawPoint + turretOffset, drawParams.TurretVoxel, affectedByLighting, Constants.DepthEpsilon * 2);
98+
RenderVoxelModel(gameObject, drawPoint + turretOffset, drawParams.TurretVoxel, affectedByLighting, Constants.DepthEpsilon * ObjectDepthAdjustments.Turret);
9999
else
100-
RenderTurretShape(gameObject, drawPoint, drawParams, Constants.DepthEpsilon * 2);
100+
RenderTurretShape(gameObject, drawPoint, drawParams, Constants.DepthEpsilon * ObjectDepthAdjustments.Turret);
101101
}
102102
}
103103
}

0 commit comments

Comments
 (0)