diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 26ca933f63f..9eb51456396 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -5440,7 +5440,7 @@ double_t GCode::_compute_speed_mm_per_sec(const ExtrusionPath& path, double spee void GCode::cooldown_marker_init() { - if (!_cooldown_marker_speed[ExtrusionRole::erExternalPerimeter].empty()) { + if (_cooldown_marker_speed[ExtrusionRole::erExternalPerimeter].empty()) { std::string allow_speed_change = ";CM_extrude_speed;_EXTRUDE_SET_SPEED"; //only change speed on external perimeter (and similar) speed if really necessary. std::string maybe_allow_speed_change = ";CM_extrude_speed_external;_EXTRUDE_SET_SPEED_MAYBE"; diff --git a/src/libslic3r/GCode/CoolingBuffer.cpp b/src/libslic3r/GCode/CoolingBuffer.cpp index 07d4e02c467..9445f98ed7c 100644 --- a/src/libslic3r/GCode/CoolingBuffer.cpp +++ b/src/libslic3r/GCode/CoolingBuffer.cpp @@ -45,6 +45,7 @@ void CoolingBuffer::reset(const Vec3d &position) struct CoolingLine { enum Type : uint32_t { + TYPE_NONE = 0, //first 5 bits are for the extrusiontype (not a flag) TYPE_SET_TOOL = 1 << 7, @@ -79,6 +80,12 @@ struct CoolingLine length(0.f), has_move(false), feedrate(0.f), time(0.f), time_max(0.f), slowdown(false) {} bool adjustable(bool slowdown_external_perimeters) const { + std::cout << (this->type & TYPE_ADJUSTABLE) << "=" << (int) this->type << "&" << (int) TYPE_ADJUSTABLE + << " && " + << (slowdown_external_perimeters || + (!(this->type & TYPE_ADJUSTABLE_MAYBE))) << "=" + << slowdown_external_perimeters << "||" << (int) TYPE_ADJUSTABLE_MAYBE + << " && "<<(this->time < this->time_max) << "\n"; return (this->type & TYPE_ADJUSTABLE) && (slowdown_external_perimeters || (!(this->type & TYPE_ADJUSTABLE_MAYBE))) && this->time < this->time_max; @@ -401,6 +408,8 @@ std::vector CoolingBuffer::parse_layer_gcode(const std:: // Index of an existing CoolingLine of the current adjustment, which holds the feedrate setting command // for a sequence of extrusion moves. size_t active_speed_modifier = size_t(-1); + // type to add to each next G1 (just for adjustable for now) + size_t current_stamp = CoolingLine::TYPE_NONE; for (; *line_start != 0; line_start = line_end) { @@ -460,10 +469,13 @@ std::vector CoolingBuffer::parse_layer_gcode(const std:: if (wipe) line.type |= CoolingLine::TYPE_WIPE; if (boost::contains(sline, ";_EXTRUDE_SET_SPEED") && ! wipe) { - line.type |= CoolingLine::TYPE_ADJUSTABLE; active_speed_modifier = adjustment->lines.size(); - if (boost::contains(sline, ";_EXTRUDE_SET_SPEED_MAYBE")) + line.type |= CoolingLine::TYPE_ADJUSTABLE; + current_stamp |= CoolingLine::TYPE_ADJUSTABLE; + if (boost::contains(sline, ";_EXTRUDE_SET_SPEED_MAYBE")) { line.type |= CoolingLine::TYPE_ADJUSTABLE_MAYBE; + current_stamp |= CoolingLine::TYPE_ADJUSTABLE_MAYBE; + } } if ((line.type & CoolingLine::TYPE_G92) == 0) { // G0 or G1. Calculate the duration. @@ -494,6 +506,11 @@ std::vector CoolingBuffer::parse_layer_gcode(const std:: line.length = std::abs(dif[3]); } line.feedrate = new_pos[4]; + if (line.feedrate > 0.f && line.length > 0.f) { + assert((line.type & CoolingLine::TYPE_ADJUSTABLE) == 0); + assert(active_speed_modifier != size_t(-1)); + line.type |= current_stamp; + } assert((line.type & CoolingLine::TYPE_ADJUSTABLE) == 0 || line.feedrate > 0.f); if (line.length > 0) { assert(line.feedrate > 0); @@ -546,6 +563,7 @@ std::vector CoolingBuffer::parse_layer_gcode(const std:: } } active_speed_modifier = size_t(-1); + current_stamp = CoolingLine::TYPE_NONE; } else if (boost::starts_with(sline, ";_TOOLCHANGE")) { //not using m_toolchange_prefix anymore because there is no use case for it, there is always a _TOOLCHANGE for when a fan change is needed. int prefix = 13;