# HG changeset patch # User alys # Date 2021-04-18 03:25:20 # Node ID d06f5425f7df9f30ce4ad78c19a98364f8d5da47 # Parent f687e82000f059e7f08b8e53e02733fa7ea897b9 Add culling for trees. diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -478,7 +478,11 @@ return ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10; } - protected Boolean cull(int gridX, int gridY) + protected Boolean cull(int gridX, int gridY) + { + return cull(gridX, gridY, 0); + } + protected Boolean cull(int gridX, int gridY, int margin) { int screenX = (gridX - gridY) * Tile.TileSpriteWidth / 2; int screenY = (gridX + gridY) * Tile.TileSpriteHeight / 2; @@ -486,8 +490,8 @@ Vector2 original = Vector2.Transform(new Vector2(screenX, screenY), camera.get_transformation(GraphicsDevice)); return (!FNAGame.enableCulling || - (MathUtils.Between(original.X, -Tile.TileSpriteWidth, FNAGame.width) - && MathUtils.Between(original.Y, -Tile.TileSpriteHeight, FNAGame.height))); + (MathUtils.Between(original.X, -Tile.TileSpriteWidth - margin, FNAGame.width) + && MathUtils.Between(original.Y, -Tile.TileSpriteHeight - margin, FNAGame.height))); } //Convenience method I'm not super sure about anymore. @@ -743,7 +747,8 @@ for (int j = 0; j < this.simulation.map.MapWidth; j += 1) { - if (this.simulation.map.cells[i][j].hasTree) + if (this.simulation.map.cells[i][j].hasTree + && this.cull(i, j)) { //until we actually simulate: drawTileAt(i, j, 142, 2); // if ((i + j) % 8 == 0) @@ -756,7 +761,9 @@ // } this.treesDrawn++; } - else if (this.simulation.map.cells[i][j].status == CellStatus.DeadTree) { + else if (this.simulation.map.cells[i][j].status == CellStatus.DeadTree + && this.cull(i, j)) + { drawTileAt(i, j, 141, 2); // System.Console.WriteLine(String.Format("Drew Dead Tree at {0},{1}", i, j)); this.treesDrawn++;