From dccb5766cce91e95975fa6f66bf8ae584a7bef80 Mon Sep 17 00:00:00 2001 From: kaczy Date: Sun, 21 Jan 2024 23:01:30 +0100 Subject: [PATCH] DebugDrawSelectionBuffer --- CentrED/Map/MapManager.cs | 6 +++++- CentrED/UI/UIManager.cs | 1 + CentrED/UI/Windows/DebugWindow.cs | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CentrED/Map/MapManager.cs b/CentrED/Map/MapManager.cs index f5248a6..146291d 100644 --- a/CentrED/Map/MapManager.cs +++ b/CentrED/Map/MapManager.cs @@ -24,6 +24,7 @@ public class MapManager private readonly SpriteBatch _spriteBatch; private readonly Texture2D _background; + public bool DebugDrawSelectionBuffer; private RenderTarget2D _selectionBuffer; internal List Tools = new(); @@ -757,6 +758,9 @@ public void Draw() Metrics.Start("DrawSelection"); DrawSelectionBuffer(); Metrics.Stop("DrawSelection"); + if (DebugDrawSelectionBuffer) + return; + _mapRenderer.SetRenderTarget(null); Metrics.Start("DrawLand"); DrawLand(); @@ -790,7 +794,7 @@ private void DrawSelectionBuffer() { _mapEffect.WorldViewProj = Camera.WorldViewProj; _mapEffect.CurrentTechnique = _mapEffect.Techniques["Selection"]; - _mapRenderer.SetRenderTarget(_selectionBuffer); + _mapRenderer.SetRenderTarget(DebugDrawSelectionBuffer ? null : _selectionBuffer); _mapRenderer.Begin ( _mapEffect, diff --git a/CentrED/UI/UIManager.cs b/CentrED/UI/UIManager.cs index c4dd866..4c139d9 100644 --- a/CentrED/UI/UIManager.cs +++ b/CentrED/UI/UIManager.cs @@ -191,6 +191,7 @@ public void Draw(GameTime gameTime) { Metrics.Start("DrawUI"); FramesPerSecond = 1 / gameTime.ElapsedGameTime.TotalSeconds; + _graphicsDevice.SetRenderTarget(null); ImGui.NewFrame(); DrawUI(); ImGui.Render(); diff --git a/CentrED/UI/Windows/DebugWindow.cs b/CentrED/UI/Windows/DebugWindow.cs index 5a5e0c0..a4964d3 100644 --- a/CentrED/UI/Windows/DebugWindow.cs +++ b/CentrED/UI/Windows/DebugWindow.cs @@ -66,6 +66,7 @@ private void DrawGeneralTab() { mapManager.Reset(); } + ImGui.Checkbox("Draw SelectionBuffer", ref CEDGame.MapManager.DebugDrawSelectionBuffer); ImGui.Separator(); if (ImGui.Button("Server Flush"))