-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
384 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using Bang.Contexts; | ||
using Bang.Systems; | ||
using ImGuiNET; | ||
using Murder.Core.Graphics; | ||
using Murder.Diagnostics; | ||
using Murder.Editor.Attributes; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Numerics; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using static Assimp.Metadata; | ||
using static Murder.Editor.Systems.Debug.GraphLogger; | ||
|
||
namespace Murder.Editor.Systems.Debug | ||
{ | ||
[DoNotPause] | ||
[OnlyShowOnDebugView] | ||
[Filter(ContextAccessorFilter.None)] | ||
internal class DebugPlotterSystem : IGuiSystem | ||
{ | ||
private bool _showHierarchy = false; | ||
public void DrawGui(RenderContext render, Context context) | ||
{ | ||
|
||
ImGui.BeginMainMenuBar(); | ||
|
||
if (ImGui.BeginMenu("Show")) | ||
{ | ||
ImGui.MenuItem("Graph Debugger", "", ref _showHierarchy); | ||
ImGui.EndMenu(); | ||
} | ||
|
||
ImGui.EndMainMenuBar(); | ||
|
||
if (_showHierarchy) | ||
{ | ||
ImGui.SetNextWindowSize(new Vector2(350, 150), ImGuiCond.Appearing); | ||
if (ImGui.Begin("Graph", ref _showHierarchy, ImGuiWindowFlags.AlwaysAutoResize)) | ||
{ | ||
GraphLogger logger = ((GraphLogger)Architect.Instance.GraphLogger); | ||
foreach (var entry in logger.Graphs) | ||
{ | ||
if (entry.Value.Values.Length > 0) | ||
{ | ||
ImGui.PlotHistogram("", ref entry.Value.Values[0], entry.Value.Values.Length, 0, entry.Key, 0, 1, new Vector2(310, 75)); | ||
} | ||
else | ||
{ | ||
ImGui.Text($"Graph {entry.Key} is empty"); | ||
} | ||
} | ||
if (logger.Graphs.Count == 0) | ||
{ | ||
ImGui.Text("Use GameLogger.PlotGraph(float value) to start plottting!"); | ||
} | ||
} | ||
ImGui.End(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Murder.Diagnostics; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using static Murder.Editor.Systems.Debug.GraphLogger; | ||
|
||
namespace Murder.Editor.Systems.Debug | ||
{ | ||
internal class GraphLogger : GraphLoggerBase | ||
{ | ||
|
||
public class Graph | ||
{ | ||
private readonly List<float> _values = new List<float>(400); | ||
private float[] _valuesCache = new float[0]; | ||
public void Plot(float point) | ||
{ | ||
_values.Add(point); | ||
_valuesCache = _values.ToArray(); | ||
} | ||
|
||
public float[] Values => _valuesCache; | ||
} | ||
public readonly Dictionary<string, Graph> Graphs = new Dictionary<string, Graph>(); | ||
|
||
public override void PlotGraph(float value, string callerFilePath) | ||
{ | ||
string callerClassName = Path.GetFileNameWithoutExtension(callerFilePath); | ||
if (!Graphs.ContainsKey(callerClassName)) | ||
{ | ||
Graphs[callerClassName] = new Graph(); | ||
} | ||
|
||
var graph = Graphs[callerClassName]; | ||
graph.Plot(value); | ||
} | ||
|
||
public override void ClearGraph(string callerFilePath) | ||
{ | ||
string callerClassName = Path.GetFileNameWithoutExtension(callerFilePath); | ||
Graphs.Remove(callerClassName); | ||
} | ||
|
||
public override void ClearAllGraphs() | ||
{ | ||
Graphs.Clear(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.