Skip to content

Commit 68a3b17

Browse files
authored
Fix (some) crash-logs divide-by-zero issues (#2173)
2 parents d3a029b + 880114d commit 68a3b17

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

include/TreeSupportSettings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct TreeSupportSettings
3939
, maximum_move_distance((angle < TAU / 4) ? std::llround(tan(angle) * layer_height) : std::numeric_limits<coord_t>::max())
4040
, maximum_move_distance_slow((angle_slow < TAU / 4) ? std::llround(tan(angle_slow) * layer_height) : std::numeric_limits<coord_t>::max())
4141
, support_bottom_layers(mesh_group_settings.get<bool>("support_bottom_enable") ? round_divide(mesh_group_settings.get<coord_t>("support_bottom_height"), layer_height) : 0)
42-
, tip_layers(std::max((branch_radius - min_radius) / (support_line_width / 3), branch_radius / layer_height))
42+
, tip_layers(std::max(std::max((branch_radius - min_radius) / (support_line_width / 3), branch_radius / layer_height), 1LL))
4343
, // Ensure lines always stack nicely even if layer height is large
4444
diameter_angle_scale_factor(sin(mesh_group_settings.get<AngleRadians>("support_tree_branch_diameter_angle")) * layer_height / branch_radius)
4545
, max_to_model_radius_increase(mesh_group_settings.get<coord_t>("support_tree_max_diameter_increase_by_merges_when_support_to_model") / 2)

src/TreeSupportTipGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ TreeSupportTipGenerator::TreeSupportTipGenerator(const SliceMeshStorage& mesh, T
6464
const double support_overhang_angle = mesh.settings.get<AngleRadians>("support_angle");
6565
const coord_t max_overhang_speed = (support_overhang_angle < TAU / 4) ? (coord_t)(tan(support_overhang_angle) * config_.layer_height) : std::numeric_limits<coord_t>::max();
6666

67-
if (max_overhang_speed == 0)
67+
if (max_overhang_speed < 2)
6868
{
6969
max_overhang_insert_lag_ = std::numeric_limits<coord_t>::max();
7070
}

src/utils/polygonUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ void PolygonUtils::fixSelfIntersections(const coord_t epsilon, Shape& polygon)
14201420
{
14211421
const Point2LL& other = polygon[poly_idx][(point_idx + 1) % pathlen];
14221422
const Point2LL vec = LinearAlg2D::pointIsLeftOfLine(other, a, b) > 0 ? b - a : a - b;
1423-
const coord_t len = vSize(vec);
1423+
const coord_t len = std::max(vSize(vec), 1LL);
14241424
pt.X += (-vec.Y * move_dist) / len;
14251425
pt.Y += (vec.X * move_dist) / len;
14261426
}

0 commit comments

Comments
 (0)