diff --git a/src/libslic3r/GCode/SpiralVase.cpp b/src/libslic3r/GCode/SpiralVase.cpp index 5f0e77300..cb3e01d72 100644 --- a/src/libslic3r/GCode/SpiralVase.cpp +++ b/src/libslic3r/GCode/SpiralVase.cpp @@ -173,13 +173,19 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer) if (found && dist < max_xy_dist_for_smoothing) { // Interpolate between the point on this layer and the point on the previous layer SpiralVase::SpiralPoint target = SpiralVaseHelpers::add(SpiralVaseHelpers::scale(nearestp, 1 - factor), SpiralVaseHelpers::scale(p, factor)); - line.set(reader, X, target.x); - line.set(reader, Y, target.y); + + // BBS: remove too short movement // We need to figure out the distance of this new line! float modified_dist_XY = SpiralVaseHelpers::distance(last_point, target); - // Scale the extrusion amount according to change in length - line.set(reader, E, line.e() * modified_dist_XY / dist_XY, 5 /*decimal_digits*/); - last_point = target; + if (modified_dist_XY < 0.001) + line.clear(); + else { + line.set(reader, X, target.x); + line.set(reader, Y, target.y); + // Scale the extrusion amount according to change in length + line.set(reader, E, line.e() * modified_dist_XY / dist_XY, 5 /*decimal_digits*/); + last_point = target; + } } else { last_point = p; } diff --git a/src/libslic3r/GCodeReader.hpp b/src/libslic3r/GCodeReader.hpp index ea0df3dd7..52a37dde5 100644 --- a/src/libslic3r/GCodeReader.hpp +++ b/src/libslic3r/GCodeReader.hpp @@ -26,6 +26,7 @@ public: const std::string_view comment() const { size_t pos = m_raw.find(';'); return (pos == std::string::npos) ? std::string_view() : std::string_view(m_raw).substr(pos + 1); } + void clear() { m_raw.clear(); } bool has(Axis axis) const { return (m_mask & (1 << int(axis))) != 0; } float value(Axis axis) const { return m_axis[axis]; } bool has(char axis) const;