From e83320d066369a1546c608997909527f60e996e6 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Wed, 13 Nov 2024 12:52:03 +0100 Subject: [PATCH 1/3] Avoid division-by-zero; set tip-layers always at least to 1. should fix sentry#CURAENGINE-Q2 --- include/TreeSupportSettings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/TreeSupportSettings.h b/include/TreeSupportSettings.h index f74b9cffe3..1c4cab4fc6 100644 --- a/include/TreeSupportSettings.h +++ b/include/TreeSupportSettings.h @@ -39,7 +39,7 @@ struct TreeSupportSettings , maximum_move_distance((angle < TAU / 4) ? std::llround(tan(angle) * layer_height) : std::numeric_limits::max()) , maximum_move_distance_slow((angle_slow < TAU / 4) ? std::llround(tan(angle_slow) * layer_height) : std::numeric_limits::max()) , support_bottom_layers(mesh_group_settings.get("support_bottom_enable") ? round_divide(mesh_group_settings.get("support_bottom_height"), layer_height) : 0) - , tip_layers(std::max((branch_radius - min_radius) / (support_line_width / 3), branch_radius / layer_height)) + , tip_layers(std::max(std::max((branch_radius - min_radius) / (support_line_width / 3), branch_radius / layer_height), 1LL)) , // Ensure lines always stack nicely even if layer height is large diameter_angle_scale_factor(sin(mesh_group_settings.get("support_tree_branch_diameter_angle")) * layer_height / branch_radius) , max_to_model_radius_increase(mesh_group_settings.get("support_tree_max_diameter_increase_by_merges_when_support_to_model") / 2) From 65518201e4a540ab04f76afe810d4a10d30e3402 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Wed, 13 Nov 2024 12:54:09 +0100 Subject: [PATCH 2/3] Avoid division-by-zero; make sure max-overhang-speed is divisable. should fix sentry#CURAENGINE-4R --- src/TreeSupportTipGenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TreeSupportTipGenerator.cpp b/src/TreeSupportTipGenerator.cpp index 0a2af0e233..79ac54a51f 100644 --- a/src/TreeSupportTipGenerator.cpp +++ b/src/TreeSupportTipGenerator.cpp @@ -64,7 +64,7 @@ TreeSupportTipGenerator::TreeSupportTipGenerator(const SliceMeshStorage& mesh, T const double support_overhang_angle = mesh.settings.get("support_angle"); const coord_t max_overhang_speed = (support_overhang_angle < TAU / 4) ? (coord_t)(tan(support_overhang_angle) * config_.layer_height) : std::numeric_limits::max(); - if (max_overhang_speed == 0) + if (max_overhang_speed < 2) { max_overhang_insert_lag_ = std::numeric_limits::max(); } From 880114df5f2f9e2e5d000d4e9ea7f0257ca7a36c Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Wed, 13 Nov 2024 12:57:30 +0100 Subject: [PATCH 3/3] Avoid division-by-zero; pretend length is 1 if too small. should fix sentry#CURAENGINE-G8 --- src/utils/polygonUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/polygonUtils.cpp b/src/utils/polygonUtils.cpp index 4b961d2bec..870fda7e0b 100644 --- a/src/utils/polygonUtils.cpp +++ b/src/utils/polygonUtils.cpp @@ -1420,7 +1420,7 @@ void PolygonUtils::fixSelfIntersections(const coord_t epsilon, Shape& polygon) { const Point2LL& other = polygon[poly_idx][(point_idx + 1) % pathlen]; const Point2LL vec = LinearAlg2D::pointIsLeftOfLine(other, a, b) > 0 ? b - a : a - b; - const coord_t len = vSize(vec); + const coord_t len = std::max(vSize(vec), 1LL); pt.X += (-vec.Y * move_dist) / len; pt.Y += (vec.X * move_dist) / len; }