diff --git a/TODO.taskpaper b/TODO.taskpaper --- a/TODO.taskpaper +++ b/TODO.taskpaper @@ -186,6 +186,7 @@ Drawing each tile individually is very silly when it's just a (big) square anyway. For edges: Using a dictionary with counts doesn't work either. (~5 fps) Nor using sets. Instead need to do the fill and edge-drawing as large regions. + - Draw slows down after merely leaving it running Structural improvements: - Button to clear/thin debug buffers? Take every nth to reduce counters to past 100 measurements 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 @@ -61,6 +61,7 @@ TimeSpan tileDrawTime = TimeSpan.Zero; TimeSpan gridDrawTime = TimeSpan.Zero; TimeSpan treeDrawTime = TimeSpan.Zero; + TimeSpan rendererDrawTime = TimeSpan.Zero; TimeSpan updateTime = TimeSpan.Zero; TimeSpan worldUpdateTime = TimeSpan.Zero; TimeSpan simulationUpdateTime = TimeSpan.Zero; @@ -763,44 +764,6 @@ this.gridDrawTime = stopWatch2.Elapsed; #endregion draw_gridlines - //Gridlines - //Lines going down and to the right: - /* - for (int x = (int)(-this.squaresAcross/2); x < this.squaresAcross; x++) - { - int rowOffset = 0; - - float startX = (x * Tile.TileStepX) + baseOffsetX - (Tile.TileStepX / 2); - - Vector2 start = new Vector2(startX, -baseOffsetY+4); - Vector2 stop = new Vector2(startX + this.squaresAcross* Tile.TileStepX/2, - this.squaresDown*Tile.TileStepY- baseOffsetY+4); - - - - Line.drawLine(batch, - Line.departurePoint(stop, start, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight), - Line.departurePoint(start, stop, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight), - Color.White, 0.8f); - - } - //Lines going down and to the left: - for (int x = 0; x < (int)(1.5*this.squaresAcross); x++) - { - - float startX = (x * Tile.TileStepX) + baseOffsetX - (Tile.TileStepX / 2); - - Vector2 start_reverse = new Vector2(startX, -baseOffsetY + 4); - Vector2 stop_reverse = new Vector2(startX + -(this.squaresAcross * Tile.TileStepX / 2), - (this.squaresDown * Tile.TileStepY) - baseOffsetY + 4); - - Line.drawLine(batch, - Line.departurePoint(stop_reverse, start_reverse, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight), - Line.departurePoint(start_reverse, stop_reverse, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight), - Color.White, 0.8f); - - } - */ tileBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, @@ -890,9 +853,13 @@ drawTileAt(3, 2, 140, 2); #endif + stopWatch2 = new Stopwatch(); + stopWatch2.Start(); World.Draw(); // _imGuiRenderer.AfterLayout(); tileBatch.End(); + stopWatch2.Stop(); + this.rendererDrawTime = stopWatch2.Elapsed; #region draw_header batch.Begin(SpriteSortMode.BackToFront, @@ -1053,6 +1020,7 @@ treeDrawTime = this.treeDrawTime, gridDrawTime = this.gridDrawTime, tileDrawTime = this.tileDrawTime, + rendererDrawTime = this.rendererDrawTime, updateTime = this.updateTime, worldUpdateTime = this.worldUpdateTime, simulationUpdateTime = this.simulationUpdateTime, diff --git a/isometric-park-fna/UI/DebugWindow.cs b/isometric-park-fna/UI/DebugWindow.cs --- a/isometric-park-fna/UI/DebugWindow.cs +++ b/isometric-park-fna/UI/DebugWindow.cs @@ -19,6 +19,7 @@ public TimeSpan treeDrawTime; public TimeSpan gridDrawTime; public TimeSpan tileDrawTime; + public TimeSpan rendererDrawTime; public Vector2 cameraPosition; public int treeCount; public Vector2 mouseGrid; @@ -226,10 +227,11 @@ ImGui.Text(string.Format("fps: {0:F3}", debugInfo.fps)); ImGui.Text(string.Format("Draw Time: {0:F3}", debugInfo.drawTime.TotalMilliseconds.ToString())); - ImGui.Text(string.Format("\tTree: {0:F3}; Grid: {1:F3}; Tile: {2:F3}", + ImGui.Text(string.Format("\tTree: {0,7:F3}; Grid: {1,7:F3}; Tile: {2,7:F3}\n\t Renderer: {3,7:F3}", debugInfo.treeDrawTime.TotalMilliseconds.ToString(), debugInfo.gridDrawTime.TotalMilliseconds.ToString(), - debugInfo.tileDrawTime.TotalMilliseconds.ToString())); + debugInfo.tileDrawTime.TotalMilliseconds.ToString(), + debugInfo.rendererDrawTime.TotalMilliseconds.ToString())); ImGui.Text(string.Format("Update Time: {0:F3}", debugInfo.updateTime.TotalMilliseconds.ToString())); ImGui.Text(string.Format("\tWorld: {0:F3}; Simulation: {1:F3}", debugInfo.worldUpdateTime.TotalMilliseconds.ToString(),