Use proper z for no sparse layers travel start - this z is used to calculate lift of the travel (#12330, SPE-2176)

This commit is contained in:
Martin Šach 2024-02-26 10:26:36 +01:00 committed by Lukas Matena
parent 75fafd84f6
commit 3fdd02fff5
3 changed files with 5 additions and 5 deletions

View File

@ -3064,7 +3064,7 @@ void GCodeGenerator::GCodeOutputStream::write_format(const char* format, ...)
va_end(args); va_end(args);
} }
std::string GCodeGenerator::travel_to_first_position(const Vec3crd& point) { std::string GCodeGenerator::travel_to_first_position(const Vec3crd& point, const double from_z) {
std::string gcode; std::string gcode;
const Vec3d gcode_point = to_3d(this->point_to_gcode(point.head<2>()), unscaled(point.z())); const Vec3d gcode_point = to_3d(this->point_to_gcode(point.head<2>()), unscaled(point.z()));
@ -3082,7 +3082,7 @@ std::string GCodeGenerator::travel_to_first_position(const Vec3crd& point) {
if (EXTRUDER_CONFIG(retract_length) > 0 && (!this->last_position || (!EXTRUDER_CONFIG(travel_ramping_lift)))) { if (EXTRUDER_CONFIG(retract_length) > 0 && (!this->last_position || (!EXTRUDER_CONFIG(travel_ramping_lift)))) {
if (!this->last_position || EXTRUDER_CONFIG(retract_before_travel) < (this->point_to_gcode(*this->last_position) - gcode_point.head<2>()).norm()) { if (!this->last_position || EXTRUDER_CONFIG(retract_before_travel) < (this->point_to_gcode(*this->last_position) - gcode_point.head<2>()).norm()) {
gcode += this->writer().retract(); gcode += this->writer().retract();
gcode += this->writer().get_travel_to_z_gcode(gcode_point.z() + lift, "lift"); gcode += this->writer().get_travel_to_z_gcode(from_z + lift, "lift");
} }
} }
this->last_position = point.head<2>(); this->last_position = point.head<2>();
@ -3121,7 +3121,7 @@ std::string GCodeGenerator::_extrude(
if (!m_current_layer_first_position) { if (!m_current_layer_first_position) {
const Vec3crd point = to_3d(path.front().point, scaled(this->m_last_layer_z)); const Vec3crd point = to_3d(path.front().point, scaled(this->m_last_layer_z));
gcode += this->travel_to_first_position(point); gcode += this->travel_to_first_position(point, unscaled(point.z()));
} else { } else {
// go to first point of extrusion path // go to first point of extrusion path
if (!this->last_position) { if (!this->last_position) {

View File

@ -334,7 +334,7 @@ private:
const std::string &comment const std::string &comment
); );
std::string travel_to_first_position(const Vec3crd& point); std::string travel_to_first_position(const Vec3crd& point, const double from_z);
bool needs_retraction(const Polyline &travel, ExtrusionRole role = ExtrusionRole::None); bool needs_retraction(const Polyline &travel, ExtrusionRole role = ExtrusionRole::None);

View File

@ -72,7 +72,7 @@ std::string WipeTowerIntegration::append_tcr(GCodeGenerator &gcodegen, const Wip
} }
} else { } else {
const Vec3crd point = to_3d(xy_point, scaled(z)); const Vec3crd point = to_3d(xy_point, scaled(z));
gcode += gcodegen.travel_to_first_position(point); gcode += gcodegen.travel_to_first_position(point, current_z);
} }
gcode += gcodegen.unretract(); gcode += gcodegen.unretract();
} else { } else {