From 80d35831faec3706c1047cdeaffbb6557bc0def2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0ach?= Date: Fri, 10 May 2024 17:04:36 +0200 Subject: [PATCH] Fix SPE-2297 - slowdown after overhang. The bug lies in the fact that SmoothPathCache comapare path attributes in `resolve_or_fit_split_with_seam`. For some paths it does the following: If attributes of paths are the same it merges the paths. Since the == operator of ExtrusionAttributes did not consider overhang_attributes in the comparison, some paths were merged even though they had different overhang_attributes. This led to the wrong overhang attributes being applied to some paths. Now the == operator of ExtrusionAttributes takes overhang_attributes into account and it fixes the issue. --- src/libslic3r/ExtrusionEntity.hpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/ExtrusionEntity.hpp b/src/libslic3r/ExtrusionEntity.hpp index 6238447c2c..a42fae5677 100644 --- a/src/libslic3r/ExtrusionEntity.hpp +++ b/src/libslic3r/ExtrusionEntity.hpp @@ -115,6 +115,19 @@ struct OverhangAttributes { float proximity_to_curled_lines; //value between 0 and 1 }; +inline bool operator==(const OverhangAttributes &lhs, const OverhangAttributes &rhs) { + if (std::abs(lhs.start_distance_from_prev_layer - rhs.start_distance_from_prev_layer) > std::numeric_limits::epsilon()) { + return false; + } + if (std::abs(lhs.end_distance_from_prev_layer - rhs.end_distance_from_prev_layer) > std::numeric_limits::epsilon()) { + return false; + } + if (std::abs(lhs.proximity_to_curled_lines - rhs.proximity_to_curled_lines) > std::numeric_limits::epsilon()) { + return false; + } + return true; +} + struct ExtrusionAttributes : ExtrusionFlow { ExtrusionAttributes() = default; @@ -132,7 +145,7 @@ struct ExtrusionAttributes : ExtrusionFlow inline bool operator==(const ExtrusionAttributes &lhs, const ExtrusionAttributes &rhs) { return static_cast(lhs) == static_cast(rhs) && - lhs.role == rhs.role; + lhs.role == rhs.role && lhs.overhang_attributes == rhs.overhang_attributes; } class ExtrusionPath : public ExtrusionEntity