diff --git a/src/libslic3r/GCode/ConflictChecker.cpp b/src/libslic3r/GCode/ConflictChecker.cpp index 3ac65663b..2030399f5 100644 --- a/src/libslic3r/GCode/ConflictChecker.cpp +++ b/src/libslic3r/GCode/ConflictChecker.cpp @@ -206,7 +206,8 @@ ConflictComputeOpt ConflictChecker::find_inter_of_lines(const LineWithIDs &lines ConflictResultOpt ConflictChecker::find_inter_of_lines_in_diff_objs(PrintObjectPtrs objs, std::optional wtdptr) // find the first intersection point of lines in different objects { - if (objs.size() <= 1) { return {}; } + if (objs.empty() || (objs.size() == 1 && objs.front()->instances().size() == 1)) { return {}; } + LinesBucketQueue conflictQueue; if (wtdptr.has_value()) { // wipe tower at 0 by default auto wtpaths = (*wtdptr)->getFakeExtrusionPathsFromWipeTower(); @@ -268,14 +269,15 @@ ConflictResultOpt ConflictChecker::find_inter_of_lines_in_diff_objs(PrintObjectP ConflictComputeOpt ConflictChecker::line_intersect(const LineWithID &l1, const LineWithID &l2) { - if (l1._id == l2._id) { return {}; } // return true if lines are from same object + if (l1._obj_id == l2._obj_id && l1._inst_id == l2._inst_id) { return {}; } // lines are from same instance + Point inter; bool intersect = l1._line.intersection(l2._line, &inter); if (intersect) { auto dist1 = std::min(unscale(Point(l1._line.a - inter)).norm(), unscale(Point(l1._line.b - inter)).norm()); auto dist2 = std::min(unscale(Point(l2._line.a - inter)).norm(), unscale(Point(l2._line.b - inter)).norm()); auto dist = std::min(dist1, dist2); - if (dist > 0.01) { return std::make_optional(l1._id, l2._id); } // the two lines intersects if dist>0.01mm + if (dist > 0.01) { return std::make_optional(l1._obj_id, l2._obj_id); } // the two lines intersects if dist>0.01mm } return {}; } diff --git a/src/libslic3r/GCode/ConflictChecker.hpp b/src/libslic3r/GCode/ConflictChecker.hpp index ce57fdcfb..344018f3d 100644 --- a/src/libslic3r/GCode/ConflictChecker.hpp +++ b/src/libslic3r/GCode/ConflictChecker.hpp @@ -15,10 +15,12 @@ namespace Slic3r { struct LineWithID { Line _line; - int _id; + int _obj_id; + int _inst_id; ExtrusionRole _role; - LineWithID(const Line& line, int id, const ExtrusionRole& role) : _line(line), _id(id), _role(role) {} + LineWithID(const Line& line, int obj_id, int inst_id, const ExtrusionRole& role) : + _line(line), _obj_id(obj_id), _inst_id(inst_id), _role(role) {} }; using LineWithIDs = std::vector; @@ -51,11 +53,11 @@ public: LineWithIDs lines; for (const ExtrusionPath &path : _piles[_curPileIdx]) { Polyline check_polyline; - for (const Point& offset : _offsets) { + for (int i = 0; i < (int)_offsets.size(); ++i) { check_polyline = path.polyline; - check_polyline.translate(offset); + check_polyline.translate(_offsets[i]); Lines tmpLines = check_polyline.lines(); - for (const Line &line : tmpLines) { lines.emplace_back(line, _id, path.role()); } + for (const Line& line : tmpLines) { lines.emplace_back(line, _id, i, path.role()); } } } return lines;