mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
Fix an issue that wrong z value was used if a new layer is started with wipe tower extrusions.
This commit is contained in:
parent
5bb42bc0d5
commit
a5d2fa1aed
3 changed files with 11 additions and 12 deletions
|
@ -767,10 +767,10 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||||
toolchange_gcode_str = gcodegen.set_extruder(new_extruder_id, tcr.print_z); // TODO: toolchange_z vs print_z
|
toolchange_gcode_str = gcodegen.set_extruder(new_extruder_id, tcr.print_z); // TODO: toolchange_z vs print_z
|
||||||
if (gcodegen.config().enable_prime_tower) {
|
if (gcodegen.config().enable_prime_tower) {
|
||||||
deretraction_str += gcodegen.writer().travel_to_z(z, "restore layer Z");
|
deretraction_str += gcodegen.writer().travel_to_z(z, "restore layer Z");
|
||||||
Vec3d position{gcodegen.writer().get_position()};
|
Vec3d position{gcodegen.writer().get_position()};
|
||||||
position.z() = z;
|
position.z() = z;
|
||||||
gcodegen.writer().set_position(position);
|
gcodegen.writer().set_position(position);
|
||||||
deretraction_str += gcodegen.unretract();
|
deretraction_str += gcodegen.unretract();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4521,7 +4521,7 @@ std::string GCode::change_layer(coordf_t print_z)
|
||||||
m_need_change_layer_lift_z = true;
|
m_need_change_layer_lift_z = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_nominal_z = z;
|
m_writer.get_position().z() = z;
|
||||||
|
|
||||||
// forget last wiping path as wiping after raising Z is pointless
|
// forget last wiping path as wiping after raising Z is pointless
|
||||||
// BBS. Dont forget wiping path to reduce stringing.
|
// BBS. Dont forget wiping path to reduce stringing.
|
||||||
|
@ -5095,7 +5095,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
||||||
|
|
||||||
const auto get_sloped_z = [&sloped, this](double z_ratio) {
|
const auto get_sloped_z = [&sloped, this](double z_ratio) {
|
||||||
const auto height = sloped->height;
|
const auto height = sloped->height;
|
||||||
return lerp(m_nominal_z - height, m_nominal_z, z_ratio);
|
return lerp(m_writer.get_position().z() - height, m_writer.get_position().z(), z_ratio);
|
||||||
};
|
};
|
||||||
|
|
||||||
// go to first point of extrusion path
|
// go to first point of extrusion path
|
||||||
|
@ -6011,7 +6011,7 @@ std::string GCode::travel_to(const Point& point, ExtrusionRole role, std::string
|
||||||
if (travel.size() == 2) {
|
if (travel.size() == 2) {
|
||||||
// No extra movements emitted by avoid_crossing_perimeters, simply move to the end point with z change
|
// No extra movements emitted by avoid_crossing_perimeters, simply move to the end point with z change
|
||||||
const auto& dest2d = this->point_to_gcode(travel.points.back());
|
const auto& dest2d = this->point_to_gcode(travel.points.back());
|
||||||
Vec3d dest3d(dest2d(0), dest2d(1), z == DBL_MAX ? m_nominal_z : z);
|
Vec3d dest3d(dest2d(0), dest2d(1), z == DBL_MAX ? m_writer.get_position().z() : z);
|
||||||
gcode += m_writer.travel_to_xyz(dest3d, comment + " travel_to_xyz");
|
gcode += m_writer.travel_to_xyz(dest3d, comment + " travel_to_xyz");
|
||||||
} else {
|
} else {
|
||||||
// Extra movements emitted by avoid_crossing_perimeters, lift the z to normal height at the beginning, then apply the z
|
// Extra movements emitted by avoid_crossing_perimeters, lift the z to normal height at the beginning, then apply the z
|
||||||
|
@ -6020,7 +6020,7 @@ std::string GCode::travel_to(const Point& point, ExtrusionRole role, std::string
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
// Lift to normal z at beginning
|
// Lift to normal z at beginning
|
||||||
Vec2d dest2d = this->point_to_gcode(travel.points[i]);
|
Vec2d dest2d = this->point_to_gcode(travel.points[i]);
|
||||||
Vec3d dest3d(dest2d(0), dest2d(1), m_nominal_z);
|
Vec3d dest3d(dest2d(0), dest2d(1), m_writer.get_position().z());
|
||||||
gcode += m_writer.travel_to_xyz(dest3d, comment + " travel_to_xyz");
|
gcode += m_writer.travel_to_xyz(dest3d, comment + " travel_to_xyz");
|
||||||
} else if (z != DBL_MAX && i == travel.size() - 1) {
|
} else if (z != DBL_MAX && i == travel.size() - 1) {
|
||||||
// Apply z_ratio for the very last point
|
// Apply z_ratio for the very last point
|
||||||
|
|
|
@ -184,8 +184,7 @@ public:
|
||||||
m_silent_time_estimator_enabled(false),
|
m_silent_time_estimator_enabled(false),
|
||||||
m_last_obj_copy(nullptr, Point(std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max())),
|
m_last_obj_copy(nullptr, Point(std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max())),
|
||||||
// BBS
|
// BBS
|
||||||
m_toolchange_count(0),
|
m_toolchange_count(0)
|
||||||
m_nominal_z(0.)
|
|
||||||
{}
|
{}
|
||||||
~GCode() = default;
|
~GCode() = default;
|
||||||
|
|
||||||
|
@ -591,7 +590,6 @@ private:
|
||||||
// BBS
|
// BBS
|
||||||
Print* m_curr_print = nullptr;
|
Print* m_curr_print = nullptr;
|
||||||
unsigned int m_toolchange_count;
|
unsigned int m_toolchange_count;
|
||||||
coordf_t m_nominal_z;
|
|
||||||
bool m_need_change_layer_lift_z = false;
|
bool m_need_change_layer_lift_z = false;
|
||||||
int m_start_gcode_filament = -1;
|
int m_start_gcode_filament = -1;
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,8 @@ public:
|
||||||
std::string unretract();
|
std::string unretract();
|
||||||
std::string lift(LiftType lift_type = LiftType::NormalLift, bool spiral_vase = false);
|
std::string lift(LiftType lift_type = LiftType::NormalLift, bool spiral_vase = false);
|
||||||
std::string unlift();
|
std::string unlift();
|
||||||
Vec3d get_position() const { return m_pos; }
|
const Vec3d& get_position() const { return m_pos; }
|
||||||
|
Vec3d& get_position() { return m_pos; }
|
||||||
void set_position(const Vec3d& in) { m_pos = in; }
|
void set_position(const Vec3d& in) { m_pos = in; }
|
||||||
double get_zhop() const { return m_lifted; }
|
double get_zhop() const { return m_lifted; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue