Skip to content

Commit

Permalink
Fix bug in GCode markers when dynamic overhang speed is enabled
Browse files Browse the repository at this point in the history
Should fix the following issues: #9594, #9485, #9563, #9588, #9610
Also fixed a problem with zero speed when dynamic speed was percentage based and speeds were set to 0 (auto)
  • Loading branch information
Godrak committed Feb 7, 2023
1 parent 8472287 commit a167d43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2946,10 +2946,10 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string_view de
prev = p;
}
} else {
std::string comment;
std::string marked_comment;
if (m_config.gcode_comments) {
comment = description;
comment += description_bridge;
marked_comment = description;
marked_comment += description_bridge;
}
double last_set_speed = new_points[0].speed * 60.0;
gcode += m_writer.set_speed(last_set_speed, "", comment);
Expand All @@ -2958,7 +2958,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string_view de
const ProcessedPoint& processed_point = new_points[i];
Vec2d p = this->point_to_gcode_quantized(processed_point.p);
const double line_length = (p - prev).norm();
gcode += m_writer.extrude_to_xy(p, e_per_mm * line_length, comment);
gcode += m_writer.extrude_to_xy(p, e_per_mm * line_length, marked_comment);
prev = p;
double new_speed = processed_point.speed * 60.0;
if (last_set_speed != new_speed) {
Expand Down
3 changes: 2 additions & 1 deletion src/libslic3r/GCode/ExtrusionProcessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,11 @@ class ExtrusionQualityEstimator
float original_speed)
{
size_t speed_sections_count = std::min(overlaps.values.size(), speeds.values.size());
float speed_base = ext_perimeter_speed > 0 ? ext_perimeter_speed : original_speed;
std::vector<std::pair<float, float>> speed_sections;
for (size_t i = 0; i < speed_sections_count; i++) {
float distance = path.width * (1.0 - (overlaps.get_at(i) / 100.0));
float speed = speeds.get_at(i).percent ? (ext_perimeter_speed * speeds.get_at(i).value / 100.0) : speeds.get_at(i).value;
float speed = speeds.get_at(i).percent ? (speed_base * speeds.get_at(i).value / 100.0) : speeds.get_at(i).value;
speed_sections.push_back({distance, speed});
}
std::sort(speed_sections.begin(), speed_sections.end(),
Expand Down

0 comments on commit a167d43

Please sign in to comment.