mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-04 07:19:24 -05:00
fix(simulator): update the heat message at most once a second while playing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
af999ba5d6
commit
9a5feb6fbc
1 file changed
+12
-4
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user