From 5fe8c2cd4e38d8cea72169d2a71da2f8284cb101 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Wed, 10 Jul 2024 08:59:39 +0200 Subject: [PATCH 1/2] Fix fan speed could be (-)NAN. CURA-12017 (related to CURA-6410) --- src/LayerPlan.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LayerPlan.cpp b/src/LayerPlan.cpp index a72c5b6110..56d7514509 100644 --- a/src/LayerPlan.cpp +++ b/src/LayerPlan.cpp @@ -1897,7 +1897,7 @@ void ExtruderPlan::processFanSpeedForMinimalLayerTime(Duration minTime, double t const double total_layer_time = estimates_.getTotalTime() + time_other_extr_plans; const double layer_time_diff = fan_speed_layer_time_settings_.cool_min_layer_time_fan_speed_max - minTime; - const double fraction_of_slope = std::clamp((total_layer_time - minTime) / layer_time_diff, 0.0, 1.0); + const double fraction_of_slope = (layer_time_diff != 0.0) ? std::clamp((total_layer_time - minTime) / layer_time_diff, 0.0, 1.0) : 1.0; fan_speed = std::lerp(fan_speed_layer_time_settings_.cool_fan_speed_max, fan_speed, fraction_of_slope); } From 9b610fe951366b35c4908cd0f8d42fa39fd436a4 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Wed, 10 Jul 2024 09:01:47 +0200 Subject: [PATCH 2/2] Put variable definition before use. Though it's technically possible to do it the other way around because of the constexpr, it doesn't make much 'aestetic' sense. done as part of CURA-12017 --- include/GCodePathConfig.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/GCodePathConfig.h b/include/GCodePathConfig.h index 4531b650aa..82a2ea78dd 100644 --- a/include/GCodePathConfig.h +++ b/include/GCodePathConfig.h @@ -18,6 +18,8 @@ namespace cura */ struct GCodePathConfig { + static constexpr double FAN_SPEED_DEFAULT = -1.0; + coord_t z_offset{}; //(const GCodePathConfig& other) const = default;