From 4a846438949368bc1e008efaafcd1d9f518f5eeb Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 22 Nov 2016 22:26:08 +0100 Subject: [PATCH] Fixed regression causing slowdown_below_layer_time to be ignored. #3515 #3443 --- lib/Slic3r/GCode/CoolingBuffer.pm | 2 +- t/cooling.t | 3 ++- xs/src/libslic3r/GCode.cpp | 16 ++++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/Slic3r/GCode/CoolingBuffer.pm b/lib/Slic3r/GCode/CoolingBuffer.pm index d960eae1e..bbb9af472 100644 --- a/lib/Slic3r/GCode/CoolingBuffer.pm +++ b/lib/Slic3r/GCode/CoolingBuffer.pm @@ -63,7 +63,7 @@ sub flush { * ($elapsed - $self->config->slowdown_below_layer_time) / ($self->config->fan_below_layer_time - $self->config->slowdown_below_layer_time); #/ } - Slic3r::debugf " fan = %d%%, speed = %d%%\n", $fan_speed, $speed_factor * 100; + Slic3r::debugf " fan = %d%%, speed = %f%%\n", $fan_speed, $speed_factor * 100; if ($speed_factor < 1) { # Adjust feed rate of G1 commands marked with an _EXTRUDE_SET_SPEED diff --git a/t/cooling.t b/t/cooling.t index 2d76bf747..aa9936276 100644 --- a/t/cooling.t +++ b/t/cooling.t @@ -2,13 +2,14 @@ use Test::More; use strict; use warnings; -plan tests => 11; +plan tests => 12; BEGIN { use FindBin; use lib "$FindBin::Bin/../lib"; } +use List::Util qw(first); use Slic3r; use Slic3r::Test; diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index 40d2ce8f0..ae49f1d9e 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -986,16 +986,16 @@ GCode::travel_to(const Point &point, ExtrusionRole role, std::string comment) // use G1 because we rely on paths being straight (G0 may make round paths) Lines lines = travel.lines(); - double path_length = 0; - for (Lines::const_iterator line = lines.begin(); line != lines.end(); ++line) { - const double line_length = line->length() * SCALING_FACTOR; - path_length += line_length; - + for (Lines::const_iterator line = lines.begin(); line != lines.end(); ++line) gcode += this->writer.travel_to_xy(this->point_to_gcode(line->b), comment); - } - + + /* While this makes the estimate more accurate, CoolingBuffer calculates the slowdown + factor on the whole elapsed time but only alters non-travel moves, thus the resulting + time is still shorter than the configured threshold. We could create a new + elapsed_travel_time but we would still need to account for bridges, retractions, wipe etc. if (this->config.cooling) - this->elapsed_time += path_length / this->config.get_abs_value("travel_speed"); + this->elapsed_time += unscale(travel.length()) / this->config.get_abs_value("travel_speed"); + */ return gcode; }