diff --git a/xs/src/libslic3r/BridgeDetector.cpp b/xs/src/libslic3r/BridgeDetector.cpp index 663b7ceb0..ac20be5c5 100644 --- a/xs/src/libslic3r/BridgeDetector.cpp +++ b/xs/src/libslic3r/BridgeDetector.cpp @@ -115,6 +115,7 @@ bool BridgeDetector::detect_angle(double bridge_direction_override) } double total_length = 0; + uint32_t nbLines = 0; double max_length = 0; { Lines clipped_lines = intersection_ln(lines, clip_area); @@ -125,10 +126,11 @@ bool BridgeDetector::detect_angle(double bridge_direction_override) double len = line.length(); total_length += len; max_length = std::max(max_length, len); + nbLines++; } } } - if (total_length == 0.) + if (total_length == 0. || nbLines == 0) continue; have_coverage = true; @@ -139,6 +141,7 @@ bool BridgeDetector::detect_angle(double bridge_direction_override) // $directions_coverage{$angle} = sum(map $_->area, @{$self->coverage($angle)}) // 0; // max length of bridged lines candidates[i_angle].max_length = max_length; + candidates[i_angle].mean_length = total_length / nbLines; } // if no direction produced coverage, then there's no bridge direction @@ -149,10 +152,12 @@ bool BridgeDetector::detect_angle(double bridge_direction_override) std::sort(candidates.begin(), candidates.end()); // if any other direction is within extrusion width of coverage, prefer it if shorter + // shorter = shorter max length, or if in espilon (10) range, the shorter mean length. // TODO: There are two options here - within width of the angle with most coverage, or within width of the currently perferred? size_t i_best = 0; for (size_t i = 1; i < candidates.size() && candidates[i_best].coverage - candidates[i].coverage < this->spacing; ++ i) - if (candidates[i].max_length < candidates[i_best].max_length) + if (candidates[i].max_length < candidates[i_best].max_length || + (candidates[i].max_length < candidates[i_best].max_length - 10 && candidates[i].mean_length < candidates[i_best].mean_length)) i_best = i; this->angle = candidates[i_best].angle; diff --git a/xs/src/libslic3r/BridgeDetector.hpp b/xs/src/libslic3r/BridgeDetector.hpp index 8c55555e1..0c08546ac 100644 --- a/xs/src/libslic3r/BridgeDetector.hpp +++ b/xs/src/libslic3r/BridgeDetector.hpp @@ -53,6 +53,7 @@ private: double angle; double coverage; double max_length; + double mean_length; }; public: // Get possible briging direction candidates. diff --git a/xs/src/libslic3r/Fill/FillGyroid.hpp b/xs/src/libslic3r/Fill/FillGyroid.hpp index 17924b5ab..9c3cef940 100644 --- a/xs/src/libslic3r/Fill/FillGyroid.hpp +++ b/xs/src/libslic3r/Fill/FillGyroid.hpp @@ -14,7 +14,7 @@ public: virtual Fill* clone() const { return new FillGyroid(*this); } // require bridge flow since most of this pattern hangs in air - virtual bool use_bridge_flow() const { return true; } + virtual bool use_bridge_flow() const { return false; } protected: virtual void _fill_surface_single(