diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index 0d86abd3ec..051e88ea6b 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -291,6 +291,25 @@ public: return extrude_explicit(end_point, y(), loading_dist, x_speed * 60.f, false, false); } + // Loads filament while also moving towards given point in x-axis. Unlike the previous function, this one respects + // both the loading_speed and x_speed. Can shorten the move. + WipeTowerWriter& load_move_x_advanced_there_and_back(float farthest_x, float e_dist, float e_speed, float x_speed) + { + float old_x = x(); + float time = std::abs(e_dist / e_speed); // time that the whole move must take + float x_max_dist = std::abs(farthest_x - x()); // max x-distance that we can travel + float x_dist = x_speed * time; // totel x-distance to travel during the move + int n = int(x_dist / (2*x_max_dist) + 1.f); // how many there and back moves should we do + float r = 2*n*x_max_dist / x_dist; // actual/required dist if the move is not shortened + + float end_point = x() + (farthest_x > x() ? 1.f : -1.f) * x_max_dist / r; + for (int i=0; i 5) { + //writer.load_move_x_advanced_there_and_back(turning_point, dist_e-5, m_filpar[m_current_tool].filament_skinnydip_loading_speed, 50); + float cent = writer.x(); + writer.load_move_x_advanced(turning_point, 0.5*(dist_e - 5), m_filpar[m_current_tool].filament_skinnydip_loading_speed, 200); + writer.load_move_x_advanced(cent, 0.5*(dist_e - 5), m_filpar[m_current_tool].filament_skinnydip_loading_speed, 200); + writer.travel(cent, writer.y()); + writer.load_move_x_advanced_there_and_back(turning_point, 5, m_filpar[m_current_tool].filament_skinnydip_loading_speed, m_travel_speed); + } else + writer.load_move_x_advanced_there_and_back(turning_point, dist_e, m_filpar[m_current_tool].filament_skinnydip_loading_speed, m_travel_speed); + writer.load_move_x_advanced_there_and_back(turning_point, -dist_e, m_filpar[m_current_tool].filament_skinnydip_unloading_speed, 50); } skinnydip_done = true; }