Skip to content

Commit bc26f31

Browse files
committed
Fix cliffs not always getting completely rendered
1 parent dfab332 commit bc26f31

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/TSMapEditor/Rendering/MapView.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,9 @@ private void DoForVisibleCells(Action<MapTile> action)
641641
[MethodImpl(MethodImplOptions.AggressiveInlining)]
642642
public int GetCameraBottomYCoord() => Math.Min(Camera.TopLeftPoint.Y + GetCameraHeight(), Map.Size.Y * Constants.CellSizeY);
643643

644+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
645+
public Rectangle GetCameraRectangle() => new Rectangle(Camera.TopLeftPoint.X, Camera.TopLeftPoint.Y, GetCameraWidth(), GetCameraHeight());
646+
644647
public void DrawTerrainTileAndRegisterObjects(MapTile tile)
645648
{
646649
DrawTerrainTile(tile);
@@ -802,15 +805,23 @@ public void DrawTerrainTile(MapTile tile)
802805
else
803806
SetEffectParams(colorDrawEffect, depthBottom, depthTop, worldTextureCoordinates, spriteSizeToWorldSizeRatio, depthRenderTarget);
804807

805-
DrawTexture(tmpImage.ExtraTexture,
806-
new Rectangle(exDrawPointX,
808+
var exDrawRectangle = new Rectangle(exDrawPointX,
807809
exDrawPointY,
808810
tmpImage.ExtraTexture.Width,
809-
tmpImage.ExtraTexture.Height),
811+
tmpImage.ExtraTexture.Height);
812+
813+
DrawTexture(tmpImage.ExtraTexture,
814+
exDrawRectangle,
810815
null,
811816
Color.White,
812817
0f,
813818
Vector2.Zero, SpriteEffects.None, 0f);
819+
820+
var cameraRectangle = GetCameraRectangle();
821+
822+
// If this tile was only rendered partially, then we need to redraw it properly later
823+
if (!cameraRectangle.Contains(exDrawRectangle))
824+
tile.LastRefreshIndex = 0;
814825
}
815826
}
816827

0 commit comments

Comments
 (0)