Add travel_slope option (#5873)

* Add travel_slope option

* Merge branch 'main' into travel-slope-pr
This commit is contained in:
Vovodroid 2024-06-29 12:33:22 +03:00 committed by GitHub
parent f5c5f322d2
commit a13152c61f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 30 additions and 12 deletions

View file

@ -17,7 +17,6 @@
namespace Slic3r {
bool GCodeWriter::full_gcode_comment = true;
const double GCodeWriter::slope_threshold = 3 * PI / 180;
bool GCodeWriter::supports_separate_travel_acceleration(GCodeFlavor flavor)
{
@ -458,7 +457,7 @@ std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string &co
//BBS: SpiralLift
if (m_to_lift_type == LiftType::SpiralLift && this->is_current_position_clear()) {
//BBS: todo: check the arc move all in bed area, if not, then use lazy lift
double radius = delta(2) / (2 * PI * atan(GCodeWriter::slope_threshold));
double radius = delta(2) / (2 * PI * atan(this->extruder()->travel_slope()));
Vec2d ij_offset = radius * delta_no_z.normalized();
ij_offset = { -ij_offset(1), ij_offset(0) };
slop_move = this->_spiral_travel_to_z(target(2), ij_offset, "spiral lift Z");
@ -466,11 +465,11 @@ std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string &co
//BBS: LazyLift
else if (m_to_lift_type == LiftType::LazyLift &&
this->is_current_position_clear() &&
atan2(delta(2), delta_no_z.norm()) < GCodeWriter::slope_threshold) {
atan2(delta(2), delta_no_z.norm()) < this->extruder()->travel_slope()) {
//BBS: check whether we can make a travel like
// _____
// / to make the z list early to avoid to hit some warping place when travel is long.
Vec2d temp = delta_no_z.normalized() * delta(2) / tan(GCodeWriter::slope_threshold);
Vec2d temp = delta_no_z.normalized() * delta(2) / tan(this->extruder()->travel_slope());
Vec3d slope_top_point = Vec3d(temp(0), temp(1), delta(2)) + source;
GCodeG1Formatter w0;
w0.emit_xyz(slope_top_point);