From 3895e1f17dbf3feb79608a975672969c9614d107 Mon Sep 17 00:00:00 2001 From: Asriel Camora Date: Mon, 13 Nov 2023 20:29:19 -0800 Subject: [PATCH] Minor optimizations --- Craftimizer/ImGuiUtils.cs | 8 ++++---- Craftimizer/Windows/MacroEditor.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Craftimizer/ImGuiUtils.cs b/Craftimizer/ImGuiUtils.cs index 7f223c9..de749c9 100644 --- a/Craftimizer/ImGuiUtils.cs +++ b/Craftimizer/ImGuiUtils.cs @@ -253,7 +253,7 @@ public ViolinData(IEnumerable samples, float min, float max, int resolution var samplesList = samples.AsParallel().Select(s => (double)s).ToArray(); _ = Task.Run(() => { var s = Stopwatch.StartNew(); - var data = ParallelEnumerable.Range(0, resolution) + var data = ParallelEnumerable.Range(0, resolution + 1) .Select(n => Lerp(min, max, n / (float)resolution)) .Select(n => (n, (float)KernelDensity.EstimateGaussian(n, bandwidth, samplesList))) .Select(n => new Point(n.n, n.Item2, -n.Item2)); @@ -268,10 +268,9 @@ public static void ViolinPlot(in ViolinData data, Vector2 size) { using var padding = ImRaii2.PushStyle(ImPlotStyleVar.PlotPadding, Vector2.Zero); using var plotBg = ImRaii2.PushColor(ImPlotCol.PlotBg, Vector4.Zero); - using var frameBg = ImRaii2.PushColor(ImPlotCol.FrameBg, Vector4.Zero); using var fill = ImRaii2.PushColor(ImPlotCol.Fill, Vector4.One.WithAlpha(.5f)); - using var plot = ImRaii2.Plot("##violin", size, ImPlotFlags.CanvasOnly); + using var plot = ImRaii2.Plot("##violin", size, ImPlotFlags.CanvasOnly | ImPlotFlags.NoInputs | ImPlotFlags.NoChild | ImPlotFlags.NoFrame); if (plot) { ImPlot.SetupAxes(null, null, ImPlotAxisFlags.NoDecorations, ImPlotAxisFlags.NoDecorations | ImPlotAxisFlags.AutoFit); @@ -280,7 +279,8 @@ public static void ViolinPlot(in ViolinData data, Vector2 size) if (data.Data is { } points && !points.IsEmpty) { - unsafe { + unsafe + { var label_id = stackalloc byte[] { (byte)'\0' }; fixed (ViolinData.Point* p = points) { diff --git a/Craftimizer/Windows/MacroEditor.cs b/Craftimizer/Windows/MacroEditor.cs index 1983c8a..801970d 100644 --- a/Craftimizer/Windows/MacroEditor.cs +++ b/Craftimizer/Windows/MacroEditor.cs @@ -1180,7 +1180,7 @@ private void DrawBars(IEnumerable bars) { if (bar.Reliability is { } reliability) { - if (reliability.GetViolinData(bar.Max, (int)(barSize / 2), 0.02) is { } violinData) + if (reliability.GetViolinData(bar.Max, (int)(barSize / 5), 0.02) is { } violinData) { ImGui.SetCursorPos(pos); ImGuiUtils.ViolinPlot(violinData, new(barSize, ImGui.GetFrameHeight()));