Skip to content

Commit

Permalink
Fix cliffs not always getting completely rendered
Browse files Browse the repository at this point in the history
  • Loading branch information
Rampastring committed Jan 17, 2024
1 parent dfab332 commit bc26f31
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/TSMapEditor/Rendering/MapView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,9 @@ private void DoForVisibleCells(Action<MapTile> action)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int GetCameraBottomYCoord() => Math.Min(Camera.TopLeftPoint.Y + GetCameraHeight(), Map.Size.Y * Constants.CellSizeY);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Rectangle GetCameraRectangle() => new Rectangle(Camera.TopLeftPoint.X, Camera.TopLeftPoint.Y, GetCameraWidth(), GetCameraHeight());

public void DrawTerrainTileAndRegisterObjects(MapTile tile)
{
DrawTerrainTile(tile);
Expand Down Expand Up @@ -802,15 +805,23 @@ public void DrawTerrainTile(MapTile tile)
else
SetEffectParams(colorDrawEffect, depthBottom, depthTop, worldTextureCoordinates, spriteSizeToWorldSizeRatio, depthRenderTarget);

DrawTexture(tmpImage.ExtraTexture,
new Rectangle(exDrawPointX,
var exDrawRectangle = new Rectangle(exDrawPointX,
exDrawPointY,
tmpImage.ExtraTexture.Width,
tmpImage.ExtraTexture.Height),
tmpImage.ExtraTexture.Height);

DrawTexture(tmpImage.ExtraTexture,
exDrawRectangle,
null,
Color.White,
0f,
Vector2.Zero, SpriteEffects.None, 0f);

var cameraRectangle = GetCameraRectangle();

// If this tile was only rendered partially, then we need to redraw it properly later
if (!cameraRectangle.Contains(exDrawRectangle))
tile.LastRefreshIndex = 0;
}
}

Expand Down

0 comments on commit bc26f31

Please sign in to comment.