Description:
Add culling for trees.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r212:d06f5425f7df -

@@ -478,7 +478,11
478 478 return ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10;
479 479 }
480 480
481 protected Boolean cull(int gridX, int gridY)
481 protected Boolean cull(int gridX, int gridY)
482 {
483 return cull(gridX, gridY, 0);
484 }
485 protected Boolean cull(int gridX, int gridY, int margin)
482 486 {
483 487 int screenX = (gridX - gridY) * Tile.TileSpriteWidth / 2;
484 488 int screenY = (gridX + gridY) * Tile.TileSpriteHeight / 2;
@@ -486,8 +490,8
486 490 Vector2 original = Vector2.Transform(new Vector2(screenX, screenY), camera.get_transformation(GraphicsDevice));
487 491
488 492 return (!FNAGame.enableCulling ||
489 (MathUtils.Between(original.X, -Tile.TileSpriteWidth, FNAGame.width)
490 && MathUtils.Between(original.Y, -Tile.TileSpriteHeight, FNAGame.height)));
493 (MathUtils.Between(original.X, -Tile.TileSpriteWidth - margin, FNAGame.width)
494 && MathUtils.Between(original.Y, -Tile.TileSpriteHeight - margin, FNAGame.height)));
491 495 }
492 496
493 497 //Convenience method I'm not super sure about anymore.
@@ -743,7 +747,8
743 747 for (int j = 0; j < this.simulation.map.MapWidth; j += 1)
744 748 {
745 749
746 if (this.simulation.map.cells[i][j].hasTree)
750 if (this.simulation.map.cells[i][j].hasTree
751 && this.cull(i, j))
747 752 { //until we actually simulate:
748 753 drawTileAt(i, j, 142, 2);
749 754 // if ((i + j) % 8 == 0)
@@ -756,7 +761,9
756 761 // }
757 762 this.treesDrawn++;
758 763 }
759 else if (this.simulation.map.cells[i][j].status == CellStatus.DeadTree) {
764 else if (this.simulation.map.cells[i][j].status == CellStatus.DeadTree
765 && this.cull(i, j))
766 {
760 767 drawTileAt(i, j, 141, 2);
761 768 // System.Console.WriteLine(String.Format("Drew Dead Tree at {0},{1}", i, j));
762 769 this.treesDrawn++;
You need to be logged in to leave comments. Login now