Skip to content

Commit 2b2afb7

Browse files
committed
Improve high bridge shadows
1 parent 325453b commit 2b2afb7

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/TSMapEditor/Rendering/ObjectRenderers/ObjectRenderer.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public virtual void DrawShadow(T gameObject)
289289

290290
float textureHeight = (regularFrame != null && regularFrame.Texture != null) ? (float)regularFrame.Texture.Height : shadowFrame.Texture.Height;
291291

292-
float depth = GetDepthFromPosition(gameObject, drawingBounds);
292+
float depth = GetShadowDepthFromPosition(gameObject, drawingBounds);
293293
// depth += GetDepthAddition(gameObject);
294294
depth += textureHeight / Map.HeightInPixelsWithCellHeight;
295295

@@ -330,6 +330,8 @@ protected virtual float GetDepthFromPosition(T gameObject, Rectangle drawingBoun
330330
(height * Constants.DepthRenderStep);
331331
}
332332

333+
protected virtual float GetShadowDepthFromPosition(T gameObject, Rectangle drawingBounds) => GetDepthFromPosition(gameObject, drawingBounds);
334+
333335
protected MapTile GetSouthernmostCell(T gameObject)
334336
{
335337
MapTile tile = null;

src/TSMapEditor/Rendering/ObjectRenderers/OverlayRenderer.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ protected override float GetDepthAddition(Overlay gameObject)
9494
return (Constants.DepthEpsilon * ObjectDepthAdjustments.Overlay) + ((tile.Level + bridgeHeight) * Constants.CellHeight / (float)Map.HeightInPixelsWithCellHeight);
9595
}
9696

97+
protected override float GetShadowDepthFromPosition(Overlay gameObject, Rectangle drawingBounds)
98+
{
99+
// Hack to prevent high bridge shadows from overlapping terrain on higher ground on bridge ends
100+
if (gameObject.OverlayType.HighBridgeDirection != BridgeDirection.None)
101+
{
102+
return base.GetShadowDepthFromPosition(gameObject, new Rectangle(drawingBounds.X, drawingBounds.Y - (Constants.CellSizeY * 4), drawingBounds.Width, drawingBounds.Height));
103+
}
104+
105+
return base.GetShadowDepthFromPosition(gameObject, drawingBounds);
106+
}
107+
97108
protected override void Render(Overlay gameObject, Point2D drawPoint, in CommonDrawParams drawParams)
98109
{
99110
Color remapColor = Color.White;

0 commit comments

Comments
 (0)