From 9a5feb6fbce2bd441bbed072231a78aa7a03bb5d Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Tue, 1 Dec 2026 15:16:49 -0500 Subject: [PATCH] fix(simulator): update the heat message at most once a second while playing Co-Authored-By: Claude Opus 5.5 --- OpenNest/Forms/CutSimulatorForm.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/OpenNest/Forms/CutSimulatorForm.cs b/OpenNest/Forms/CutSimulatorForm.cs index 2e12ab3f..c53d249b 100644 --- a/OpenNest/Forms/CutSimulatorForm.cs +++ b/OpenNest/Forms/CutSimulatorForm.cs @@ -403,21 +403,29 @@ namespace OpenNest.Forms var cooling = !heat.UsesSupportBed ? "cooled by air only (no support bed)" : plate.SupportBed is SupportSlats ? "cooled by air and slats" : "cooled by air and the support grid"; heatScaleText = $"{material.Name}, {cooling}; red is {scale:0} °C above ambient"; - UpdateHeatLabel(); + UpdateHeatLabel(force: true); } private string heatScaleText = ""; - private void UpdateHeatLabel() + // While playing, the hottest temperature would change every frame, too fast to read. + private const long HeatLabelIntervalMs = 1000; + private long heatLabelUpdatedAt; + + private void UpdateHeatLabel(bool force = false) { var heat = overlay.Heat; if (heat == null || heatBox.SelectedIndex == 0) return; + var now = Environment.TickCount64; + if (!force && overlay.IsPlaying && now - heatLabelUpdatedAt < HeatLabelIntervalMs) + return; + heatLabelUpdatedAt = now; heat.AdvanceTo(overlay.Time); var values = heatBox.SelectedIndex == 2 ? heat.Peaks : heat.Temperatures; var hottest = PlateHeatSimulation.IndexOfMax(values); - var now = hottest < 0 ? 0 : values[hottest]; - heatLabel.Text = $"Hottest {now:0} °C (estimated)\n{heatScaleText}"; + var hottestNow = hottest < 0 ? 0 : values[hottest]; + heatLabel.Text = $"Hottest {hottestNow:0} °C (estimated)\n{heatScaleText}"; } private void AttachPlate(Plate value)