Browse Source

fix bad support grid
(introduced by fill_aligned_z, caa4a0)
supermerill/SuperSlicer#4306

supermerill 9 months ago
parent
commit
0f7411f2b9

+ 1 - 1
src/libslic3r/Fill/Fill3DHoneycomb.cpp

@@ -170,7 +170,7 @@ void Fill3DHoneycomb::_fill_surface_single(
     if (params.connection == icNotConnected || polylines.size() <= 1)
         append(polylines_out, chain_polylines(std::move(polylines)));
     else
-        this->connect_infill(std::move(polylines), expolygon, polylines_out, this->get_spacing(), params);
+        this->connect_infill(std::move(polylines), expolygon, polylines_out, scale_t(this->get_spacing()), params);
 }
 
 } // namespace Slic3r

+ 1 - 1
src/libslic3r/Fill/FillAdaptive.cpp

@@ -1405,7 +1405,7 @@ void Filler::_fill_surface_single(
     if (params.connection == InfillConnection::icNotConnected || all_polylines_with_hooks.size() <= 1)
         append(polylines_out, chain_polylines(std::move(all_polylines_with_hooks)));
     else
-        connect_infill(std::move(all_polylines_with_hooks), expolygon, polylines_out, this->get_spacing(), params);
+        connect_infill(std::move(all_polylines_with_hooks), expolygon, polylines_out, scale_t(this->get_spacing()), params);
 
 #ifdef ADAPTIVE_CUBIC_INFILL_DEBUG_OUTPUT
     {

+ 39 - 40
src/libslic3r/Fill/FillBase.cpp

@@ -629,13 +629,13 @@ Points getFrontier(Polylines& polylines, const Point& p1, const Point& p2, const
 /// return the connected polylines in polylines_out. Can output polygons (stored as polylines with first_point = last_point).
 /// complexity: worst: N(infill_ordered.points) x N(boundary.points)
 ///             typical: N(infill_ordered) x ( N(boundary.points) + N(infill_ordered.points) )
-void connect_infill(const Polylines& infill_ordered, const ExPolygon& boundary, Polylines& polylines_out, const double spacing, const FillParams& params) {
+void connect_infill(const Polylines& infill_ordered, const ExPolygon& boundary, Polylines& polylines_out, const coord_t spacing, const FillParams& params) {
 
     //TODO: fallback to the quick & dirty old algorithm when n(points) is too high.
     Polylines polylines_frontier = to_polylines(((Polygons)boundary));
 
     Polylines polylines_blocker;
-    coord_t clip_size = scale_(spacing) * 2;
+    coord_t clip_size = (spacing) * 2;
     for (const Polyline& polyline : infill_ordered) {
         if (polyline.length() > 2.01 * clip_size) {
             polylines_blocker.push_back(polyline);
@@ -655,8 +655,8 @@ void connect_infill(const Polylines& infill_ordered, const ExPolygon& boundary,
             Points& pts_end = polylines_connected_first.back().points;
             const Point& last_point = pts_end.back();
             const Point& first_point = polyline.points.front();
-            if (last_point.distance_to(first_point) < scale_(spacing) * 10) {
-                Points pts_frontier = getFrontier(polylines_frontier, last_point, first_point, scale_(spacing), polylines_blocker, scale_(ideal_length) * 2);
+            if (last_point.distance_to(first_point) < (spacing) * 10) {
+                Points pts_frontier = getFrontier(polylines_frontier, last_point, first_point, (spacing), polylines_blocker, (ideal_length) * 2);
                 if (!pts_frontier.empty()) {
                     // The lines can be connected.
                     pts_end.insert(pts_end.end(), pts_frontier.begin(), pts_frontier.end());
@@ -681,7 +681,7 @@ void connect_infill(const Polylines& infill_ordered, const ExPolygon& boundary,
             const Point& first_point = polyline.points.front();
 
             Polylines before = polylines_frontier;
-            Points pts_frontier = getFrontier(polylines_frontier, last_point, first_point, scale_(spacing), polylines_blocker);
+            Points pts_frontier = getFrontier(polylines_frontier, last_point, first_point, (spacing), polylines_blocker);
             if (!pts_frontier.empty()) {
                 // The lines can be connected.
                 pts_end.insert(pts_end.end(), pts_frontier.begin(), pts_frontier.end());
@@ -718,7 +718,7 @@ void connect_infill(const Polylines& infill_ordered, const ExPolygon& boundary,
             Points pts_frontier = getFrontier(polylines_frontier,
                 switch_id1 ? polylines_connected[idx1].first_point() : polylines_connected[idx1].last_point(),
                 switch_id2 ? polylines_connected[min_idx].last_point() : polylines_connected[min_idx].first_point(),
-                scale_(spacing), polylines_blocker);
+                (spacing), polylines_blocker);
             if (!pts_frontier.empty()) {
                 if (switch_id1) polylines_connected[idx1].reverse();
                 if (switch_id2) polylines_connected[min_idx].reverse();
@@ -732,7 +732,7 @@ void connect_infill(const Polylines& infill_ordered, const ExPolygon& boundary,
 
     //try to create some loops if possible
     for (Polyline& polyline : polylines_connected) {
-        Points pts_frontier = getFrontier(polylines_frontier, polyline.last_point(), polyline.first_point(), scale_(spacing), polylines_blocker);
+        Points pts_frontier = getFrontier(polylines_frontier, polyline.last_point(), polyline.first_point(), (spacing), polylines_blocker);
         if (!pts_frontier.empty()) {
             polyline.points.insert(polyline.points.end(), pts_frontier.begin(), pts_frontier.end());
             polyline.points.insert(polyline.points.begin(), polyline.points.back());
@@ -1053,7 +1053,7 @@ namespace PrusaSimpleConnect {
         }
     }
 
-    void connect_infill(Polylines &&infill_ordered, const ExPolygon &boundary_src, Polylines &polylines_out, const double spacing, const FillParams &params)
+    void connect_infill(Polylines &&infill_ordered, const ExPolygon &boundary_src, Polylines &polylines_out, const coord_t spacing, const FillParams &params)
     {
         assert(!infill_ordered.empty());
         assert(!boundary_src.contour.points.empty());
@@ -1132,16 +1132,16 @@ namespace PrusaSimpleConnect {
 
         // Mark the points and segments of split boundary as consumed if they are very close to some of the infill line.
         {
-            // @supermerill used 2. * scale_(spacing)
-            const double clip_distance = 3. * scale_(spacing);
-            const double distance_colliding = 1.1 * scale_(spacing);
+            // @supermerill used 2. * (spacing)
+            const double clip_distance = 3. * (spacing);
+            const double distance_colliding = 1.1 * (spacing);
             mark_boundary_segments_touching_infill(boundary, boundary_data, bbox, infill_ordered, clip_distance, distance_colliding);
         }
 
         // Connection from end of one infill line to the start of another infill line.
-        //const float length_max = scale_(spacing);
-    //	const float length_max = scale_((2. / params.density) * spacing);
-        const coord_t length_max = scale_((1000. / params.density) * spacing);
+        //const float length_max = (spacing);
+    //	const float length_max = ((2. / params.density) * spacing);
+        const coord_t length_max = ((1000. / params.density) * spacing);
         std::vector<size_t> merged_with(infill_ordered.size());
         for (size_t i = 0; i < merged_with.size(); ++i)
             merged_with[i] = i;
@@ -2169,7 +2169,7 @@ void mark_boundary_segments_touching_infill(
     assert(validate_boundary_intersections(boundary_intersections));
 }
 
-void connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary_src, Polylines& polylines_out, const double spacing, const FillParams& params)
+void connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary_src, Polylines& polylines_out, const coord_t spacing, const FillParams& params)
 {
     assert(!boundary_src.contour.points.empty());
     auto polygons_src = reserve_vector<const Polygon*>(boundary_src.holes.size() + 1);
@@ -2182,7 +2182,7 @@ void connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary_src, P
     connect_infill(std::move(infill_ordered), polygons_src, get_extents(boundary_src.contour), polylines_out, spacing, params);
 }
 
-void connect_infill(Polylines&& infill_ordered, const Polygons& boundary_src, const BoundingBox& bbox, Polylines& polylines_out, const double spacing, const FillParams& params)
+void connect_infill(Polylines&& infill_ordered, const Polygons& boundary_src, const BoundingBox& bbox, Polylines& polylines_out, const coord_t spacing, const FillParams& params)
 {
     auto polygons_src = reserve_vector<const Polygon*>(boundary_src.size());
     for (const Polygon& polygon : boundary_src)
@@ -2285,7 +2285,7 @@ static inline void mark_boundary_segments_overlapping_infill(
     // Infill lines, either completely inside the boundary, or touching the boundary.
     const Polylines                                        &infill,
     // Spacing (width) of the infill lines.
-    const double                                            spacing)
+    const coord_t                                            spacing)
 {
     for (ContourIntersectionPoint &cp : graph.map_infill_end_point_to_boundary) {
         const Points                &contour         = graph.boundary[cp.contour_idx];
@@ -2360,7 +2360,7 @@ static inline void mark_boundary_segments_overlapping_infill(
     }
 }
 
-BoundaryInfillGraph create_boundary_infill_graph(const Polylines &infill_ordered, const std::vector<const Polygon*> &boundary_src, const BoundingBox &bbox, const double spacing)
+BoundaryInfillGraph create_boundary_infill_graph(const Polylines &infill_ordered, const std::vector<const Polygon*> &boundary_src, const BoundingBox &bbox, const coord_t spacing)
 {
     BoundaryInfillGraph out;
     out.boundary.assign(boundary_src.size(), Points());
@@ -2484,12 +2484,12 @@ BoundaryInfillGraph create_boundary_infill_graph(const Polylines &infill_ordered
 
         // Mark the points and segments of split out.boundary as consumed if they are very close to some of the infill line.
         {
-            // @supermerill used 2. * scale_(spacing)
-            const double clip_distance = 1.7 * scale_(spacing);
+            // @supermerill used 2. * (spacing)
+            const double clip_distance = 1.7 * (spacing);
             // Allow a bit of overlap. This value must be slightly higher than the overlap of FillAdaptive, otherwise
             // the anchors of the adaptive infill will mask the other side of the perimeter line.
             // (see connect_lines_using_hooks() in FillAdaptive.cpp)
-            const double distance_colliding = 0.8 * scale_(spacing);
+            const double distance_colliding = 0.8 * (spacing);
             mark_boundary_segments_touching_infill(out.boundary, out.boundary_params, boundary_intersection_points, bbox, infill_ordered, clip_distance, distance_colliding);
         }
     }
@@ -2497,7 +2497,7 @@ BoundaryInfillGraph create_boundary_infill_graph(const Polylines &infill_ordered
     return out;
 }
 
-void connect_infill(Polylines &&infill_ordered, const std::vector<const Polygon*> &boundary_src, const BoundingBox &bbox, Polylines &polylines_out, const double spacing, const FillParams &params)
+void connect_infill(Polylines &&infill_ordered, const std::vector<const Polygon*> &boundary_src, const BoundingBox &bbox, Polylines &polylines_out, const coord_t spacing, const FillParams &params)
 {
 	assert(! infill_ordered.empty());
     assert(params.anchor_length     >= 0.);
@@ -2544,13 +2544,13 @@ void connect_infill(Polylines &&infill_ordered, const std::vector<const Polygon*
         return std::numeric_limits<size_t>::max();
     };
 
-    const double line_half_width = 0.5 * scale_(spacing);
+    const double line_half_width = 0.5 * (spacing);
 
 #if 0
     // Connection from end of one infill line to the start of another infill line.
-    //const double length_max = scale_(spacing);
-//  const auto length_max = double(scale_((2. / params.density) * spacing));
-    const auto length_max = double(scale_((1000. / params.density) * spacing));
+    //const double length_max = (spacing);
+//  const auto length_max = double(((2. / params.density) * spacing));
+    const auto length_max = double(((1000. / params.density) * spacing));
     struct ConnectionCost {
         ConnectionCost(size_t idx_first, double cost, bool reversed) : idx_first(idx_first), cost(cost), reversed(reversed) {}
         size_t  idx_first;
@@ -2745,7 +2745,7 @@ void connect_infill(Polylines &&infill_ordered, const std::vector<const Polygon*
 
 // Extend the infill lines along the perimeters, this is mainly useful for grid aligned support, where a perimeter line may be nearly
 // aligned with the infill lines.
-static inline void base_support_extend_infill_lines(Polylines &infill, BoundaryInfillGraph &graph, const double spacing, const FillParams &params)
+static inline void base_support_extend_infill_lines(Polylines &infill, BoundaryInfillGraph &graph, const coord_t line_spacing, const FillParams &params)
 {
 /*
     // Backup the source lines.
@@ -2753,8 +2753,6 @@ static inline void base_support_extend_infill_lines(Polylines &infill, BoundaryI
     lines.reserve(linfill.size());
     std::transform(infill.begin(), infill.end(), std::back_inserter(lines), [](const Polyline &pl) { assert(pl.size() == 2); return Line(pl.points.begin(), pl.points.end()); });
 */
-
-    const double    line_spacing    = scale_(spacing) / params.density;
     // Maximum deviation perpendicular to the infill line to allow merging as a continuation of the same infill line.
     const auto      dist_max_x      = coord_t(line_spacing * 0.33);
     // Minimum length of the arc away from the infill end point to allow merging as a continuation of the same infill line.
@@ -3114,7 +3112,7 @@ static double evaluate_support_arch_cost(const Polyline &pl)
 }
 
 // Costs for prev / next arch of each infill line end point.
-static inline std::vector<SupportArcCost> evaluate_support_arches(Polylines &infill, BoundaryInfillGraph &graph, const double spacing, const FillParams &params)
+static inline std::vector<SupportArcCost> evaluate_support_arches(Polylines &infill, BoundaryInfillGraph &graph, const FillParams &params)
 {
     std::vector<SupportArcCost> arches(graph.map_infill_end_point_to_boundary.size() * 2);
 
@@ -3160,13 +3158,15 @@ static inline std::vector<SupportArcCost> evaluate_support_arches(Polylines &inf
 } // end namespace FakePerimeterConnect
 
 // Both the poly_with_offset and polylines_out are rotated, so the infill lines are strictly vertical.
-void Fill::connect_base_support(Polylines &&infill_ordered, const std::vector<const Polygon*> &boundary_src, const BoundingBox &bbox, Polylines &polylines_out, const double spacing, const FillParams &params)
+void Fill::connect_base_support(Polylines &&infill_ordered, const std::vector<const Polygon*> &boundary_src, const BoundingBox &bbox, Polylines &polylines_out, const coord_t line_spacing, const FillParams &params)
 {
 //    assert(! infill_ordered.empty());
     assert(params.anchor_length     >= 0.);
     assert(params.anchor_length_max >= 0.01f);
     assert(params.anchor_length_max >= params.anchor_length);
 
+    coord_t spacing = line_spacing * params.density;
+
     FakePerimeterConnect::BoundaryInfillGraph graph = FakePerimeterConnect::create_boundary_infill_graph(infill_ordered, boundary_src, bbox, spacing);
 
 #ifdef INFILL_DEBUG_OUTPUT
@@ -3175,15 +3175,14 @@ void Fill::connect_base_support(Polylines &&infill_ordered, const std::vector<co
     export_partial_infill_to_svg(debug_out_path("connect_base_support-initial-%03d.svg", iRun), graph, infill_ordered, polylines_out);
 #endif // INFILL_DEBUG_OUTPUT
 
-    const double        line_half_width = 0.5 * scale_(spacing);
-    const double        line_spacing    = ((params.max_sparse_infill_spacing > 0) ? params.max_sparse_infill_spacing : spacing) / params.density;
+    const double        line_half_width = 0.5 * spacing;
     const double        min_arch_length = 1.3 * line_spacing;
     const double        trim_length     = line_half_width * 0.3;
 
 // After mark_boundary_segments_touching_infill() marks boundary segments overlapping trimmed infill lines,
 // there are possibly some very short boundary segments unmarked, but overlapping the untrimmed infill lines fully.
 // Mark those short boundary segments.
-    mark_boundary_segments_overlapping_infill(graph, infill_ordered, scale_(spacing));
+    mark_boundary_segments_overlapping_infill(graph, infill_ordered, spacing);
 
 #ifdef INFILL_DEBUG_OUTPUT
     export_partial_infill_to_svg(debug_out_path("connect_base_support-marked-%03d.svg", iRun), graph, infill_ordered, polylines_out);
@@ -3239,7 +3238,7 @@ void Fill::connect_base_support(Polylines &&infill_ordered, const std::vector<co
     export_partial_infill_to_svg(debug_out_path("connect_base_support-excess-%03d.svg", iRun), graph, infill_ordered, polylines_out);
 #endif // INFILL_DEBUG_OUTPUT
 
-    base_support_extend_infill_lines(infill_ordered, graph, spacing, params);
+    base_support_extend_infill_lines(infill_ordered, graph, line_spacing, params);
     
 #ifdef INFILL_DEBUG_OUTPUT
     export_partial_infill_to_svg(debug_out_path("connect_base_support-extended-%03d.svg", iRun), graph, infill_ordered, polylines_out);
@@ -3376,7 +3375,7 @@ void Fill::connect_base_support(Polylines &&infill_ordered, const std::vector<co
     export_partial_infill_to_svg(debug_out_path("connect_base_support-vertical-%03d.svg", iRun), graph, infill_ordered, polylines_out);
 #endif // INFILL_DEBUG_OUTPUT
 
-    const std::vector<FakePerimeterConnect::SupportArcCost> arches = FakePerimeterConnect::evaluate_support_arches(infill_ordered, graph, spacing, params);
+    const std::vector<FakePerimeterConnect::SupportArcCost> arches = FakePerimeterConnect::evaluate_support_arches(infill_ordered, graph, params);
     static const double cost_low      = line_spacing * 1.3;
     static const double cost_high     = line_spacing * 2.;
     static const double cost_veryhigh = line_spacing * 3.;
@@ -3615,16 +3614,16 @@ void Fill::connect_base_support(Polylines &&infill_ordered, const std::vector<co
             polylines_out.emplace_back(std::move(pl));
 }
 
-void Fill::connect_base_support(Polylines &&infill_ordered, const Polygons &boundary_src, const BoundingBox &bbox, Polylines &polylines_out, const double spacing, const FillParams &params)
+void Fill::connect_base_support(Polylines &&infill_ordered, const Polygons &boundary_src, const BoundingBox &bbox, Polylines &polylines_out, const coord_t line_spacing, const FillParams &params)
 {
     auto polygons_src = reserve_vector<const Polygon*>(boundary_src.size());
     for (const Polygon &polygon : boundary_src)
         polygons_src.emplace_back(&polygon);
 
-    connect_base_support(std::move(infill_ordered), polygons_src, bbox, polylines_out, spacing, params);
+    connect_base_support(std::move(infill_ordered), polygons_src, bbox, polylines_out, line_spacing, params);
 }
 
-void Fill::connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary, Polylines& polylines_out, const double spacing, const FillParams& params) {
+void Fill::connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary, Polylines& polylines_out, const coord_t spacing, const FillParams& params) {
     if (params.anchor_length_max == 0) {
         PrusaSimpleConnect::connect_infill(std::move(infill_ordered), boundary, polylines_out, spacing, params);
     } else {
@@ -3632,7 +3631,7 @@ void Fill::connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary,
     }
 }
 
-void Fill::connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary, const Polygons& polygons_src, Polylines& polylines_out, const double spacing, const FillParams& params) {
+void Fill::connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary, const Polygons& polygons_src, Polylines& polylines_out, const coord_t spacing, const FillParams& params) {
     if (params.anchor_length_max == 0) {
         PrusaSimpleConnect::connect_infill(std::move(infill_ordered), boundary, polylines_out, spacing, params);
     } else {

+ 9 - 9
src/libslic3r/Fill/FillBase.hpp

@@ -215,26 +215,26 @@ protected:
     }
 
 public:
-    static void connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary, Polylines& polylines_out, const double spacing, const FillParams& params);
+    static void connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary, Polylines& polylines_out, const coord_t spacing, const FillParams& params);
     //for rectilinear
-    static void connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary, const Polygons& polygons_src, Polylines& polylines_out, const double spacing, const FillParams& params);
+    static void connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary, const Polygons& polygons_src, Polylines& polylines_out, const coord_t spacing, const FillParams& params);
 
-    static void connect_base_support(Polylines &&infill_ordered, const std::vector<const Polygon*> &boundary_src, const BoundingBox &bbox, Polylines &polylines_out, const double spacing, const FillParams &params);
-    static void connect_base_support(Polylines &&infill_ordered, const Polygons &boundary_src, const BoundingBox &bbox, Polylines &polylines_out, const double spacing, const FillParams &params);
+    static void connect_base_support(Polylines &&infill_ordered, const std::vector<const Polygon*> &boundary_src, const BoundingBox &bbox, Polylines &polylines_out, const coord_t line_spacing, const FillParams &params);
+    static void connect_base_support(Polylines &&infill_ordered, const Polygons &boundary_src, const BoundingBox &bbox, Polylines &polylines_out, const coord_t line_spacing, const FillParams &params);
 
     static coord_t  _adjust_solid_spacing(const coord_t width, const coord_t distance, const double factor_max = 1.2);
 };
 
 namespace FakePerimeterConnect {
-    void connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary, Polylines& polylines_out, const double spacing, const FillParams& params);
-    void connect_infill(Polylines&& infill_ordered, const Polygons& boundary, const BoundingBox& bbox, Polylines& polylines_out, const double spacing, const FillParams& params);
-    void connect_infill(Polylines&& infill_ordered, const std::vector<const Polygon*>& boundary, const BoundingBox& bbox, Polylines& polylines_out, double spacing, const FillParams& params);
+    void connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary, Polylines& polylines_out, const coord_t spacing, const FillParams& params);
+    void connect_infill(Polylines&& infill_ordered, const Polygons& boundary, const BoundingBox& bbox, Polylines& polylines_out, const coord_t spacing, const FillParams& params);
+    void connect_infill(Polylines&& infill_ordered, const std::vector<const Polygon*>& boundary, const BoundingBox& bbox, Polylines& polylines_out, coord_t spacing, const FillParams& params);
 }
 namespace PrusaSimpleConnect {
-    void connect_infill(Polylines& infill_ordered, const ExPolygon& boundary, Polylines& polylines_out, const double spacing, const FillParams& params);
+    void connect_infill(Polylines& infill_ordered, const ExPolygon& boundary, Polylines& polylines_out, const coord_t spacing, const FillParams& params);
 }
 namespace NaiveConnect {
-    void connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary, Polylines& polylines_out, const double spacing, const FillParams& params);
+    void connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary, Polylines& polylines_out, const coord_t spacing, const FillParams& params);
 }
 
 // composite filler

+ 1 - 1
src/libslic3r/Fill/FillGyroid.cpp

@@ -192,7 +192,7 @@ void FillGyroid::_fill_surface_single(
         if (params.connection == icNotConnected){
             append(polylines_out, chain_polylines(polylines));
         } else {
-            this->connect_infill(chain_polylines(polylines), expolygon, polylines_out, this->get_spacing(), params);
+            this->connect_infill(chain_polylines(polylines), expolygon, polylines_out, scale_t(this->get_spacing()), params);
         }
         // new paths must be rotated back
         if (std::abs(infill_angle) >= EPSILON) {

+ 1 - 1
src/libslic3r/Fill/FillHoneycomb.cpp

@@ -82,7 +82,7 @@ void FillHoneycomb::_fill_surface_single(
     if (params.connection == icNotConnected || all_polylines.size() <= 1)
         append(polylines_out, chain_polylines(std::move(all_polylines)));
     else
-        connect_infill(std::move(all_polylines), expolygon, polylines_out, this->get_spacing(), params);
+        connect_infill(std::move(all_polylines), expolygon, polylines_out, scale_t(this->get_spacing()), params);
 }
 
 } // namespace Slic3r

+ 1 - 1
src/libslic3r/Fill/FillLightning.cpp

@@ -19,7 +19,7 @@ void Filler::_fill_surface_single(
     if (params.dont_connect() || fill_lines.size() <= 1) {
         append(polylines_out, chain_polylines(std::move(fill_lines)));
     } else
-        connect_infill(std::move(fill_lines), expolygon, polylines_out, this->get_spacing(), params);
+        connect_infill(std::move(fill_lines), expolygon, polylines_out, scale_t(this->get_spacing()), params);
 }
 
 void GeneratorDeleter::operator()(Generator *p) {

+ 1 - 1
src/libslic3r/Fill/FillPlanePath.cpp

@@ -67,7 +67,7 @@ void FillPlanePath::_fill_surface_single(
     if (params.dont_connect() || params.density > 0.5 || all_poly.size() <= 1)
         chained = chain_polylines(std::move(all_poly));
     else
-        connect_infill(std::move(all_poly), expolygon, chained, this->get_spacing(), params);
+        connect_infill(std::move(all_poly), expolygon, chained, scale_t(this->get_spacing()), params);
     // paths must be repositioned and rotated back
     for (Polyline &pl : chained) {
         pl.translate(double(shift.x()), double(shift.y()));

+ 3 - 2
src/libslic3r/Fill/FillRectilinear.cpp

@@ -3162,7 +3162,7 @@ bool FillRectilinear::fill_surface_by_multilines(const Surface *surface, FillPar
             fill_lines = chain_polylines(std::move(fill_lines));
         append(polylines_out, std::move(fill_lines));
     } else
-        connect_infill(std::move(fill_lines), surface->expolygon, poly_with_offset_base.polygons_outer, polylines_out, this->get_spacing(), params);
+        connect_infill(std::move(fill_lines), surface->expolygon, poly_with_offset_base.polygons_outer, polylines_out, scale_t(this->get_spacing()), params);
 
     return true;
 }
@@ -3242,8 +3242,9 @@ Polylines FillSupportBase::fill_surface(const Surface *surface, const FillParams
         coord_t line_spacing = _line_spacing_for_density(params);
         // Create infill lines, keep them vertical.
         make_fill_lines(poly_with_offset, rotate_vector.second.rotated(- rotate_vector.first), 0, 0, line_spacing, 0, fill_lines, params);
+
         // Both the poly_with_offset and polylines_out are rotated, so the infill lines are strictly vertical.
-        connect_base_support(std::move(fill_lines), poly_with_offset.polygons_outer, poly_with_offset.bounding_box_outer(), polylines_out, this->get_spacing(), params);
+        connect_base_support(std::move(fill_lines), poly_with_offset.polygons_outer, poly_with_offset.bounding_box_outer(), polylines_out,  _line_spacing_for_density(params), params);
         // Rotate back by rotate_vector.first
         const double cos_a = cos(rotate_vector.first);
         const double sin_a = sin(rotate_vector.first);

+ 1 - 2
src/libslic3r/Print.hpp

@@ -439,8 +439,7 @@ private:
     bool                                    m_typed_slices = false;
 
     //this setting allow fill_aligned_z to get the max sparse spacing spacing.
-    coord_t                                 m_max_sparse_spacing;
-
+    coord_t                                 m_max_sparse_spacing = 0;
 
 };