mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 22:05:56 +08:00
Merge branch 'ms_fix_xyz_travel_speed' (SPE-2493)
This commit is contained in:
commit
6d19776942
@ -2258,12 +2258,10 @@ std::string GCodeGenerator::generate_ramping_layer_change_gcode(
|
|||||||
)};
|
)};
|
||||||
|
|
||||||
std::string travel_gcode;
|
std::string travel_gcode;
|
||||||
Vec3d previous_point{this->point_to_gcode(travel.front())};
|
|
||||||
for (const Vec3crd &point : travel) {
|
for (const Vec3crd &point : travel) {
|
||||||
const Vec3d gcode_point{this->point_to_gcode(point)};
|
const Vec3d gcode_point{this->point_to_gcode(point)};
|
||||||
travel_gcode += this->m_writer
|
travel_gcode += this->m_writer
|
||||||
.get_travel_to_xyz_gcode(previous_point, gcode_point, "layer change");
|
.get_travel_to_xyz_gcode(gcode_point, "layer change");
|
||||||
previous_point = gcode_point;
|
|
||||||
}
|
}
|
||||||
return travel_gcode;
|
return travel_gcode;
|
||||||
}
|
}
|
||||||
@ -3194,9 +3192,6 @@ std::string GCodeGenerator::travel_to_first_position(const Vec3crd& point, const
|
|||||||
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()));
|
||||||
|
|
||||||
if (!EXTRUDER_CONFIG(travel_ramping_lift) && this->last_position) {
|
if (!EXTRUDER_CONFIG(travel_ramping_lift) && this->last_position) {
|
||||||
Vec3d writer_position{this->writer().get_position()};
|
|
||||||
writer_position.z() = 0.0; // Endofrce z generation!
|
|
||||||
this->writer().update_position(writer_position);
|
|
||||||
const Vec3crd from{to_3d(*this->last_position, scaled(from_z))};
|
const Vec3crd from{to_3d(*this->last_position, scaled(from_z))};
|
||||||
gcode = this->travel_to(
|
gcode = this->travel_to(
|
||||||
from, point, role, "travel to first layer point", insert_gcode
|
from, point, role, "travel to first layer point", insert_gcode
|
||||||
@ -3546,7 +3541,6 @@ std::string GCodeGenerator::generate_travel_gcode(
|
|||||||
// use G1 because we rely on paths being straight (G0 may make round paths)
|
// use G1 because we rely on paths being straight (G0 may make round paths)
|
||||||
gcode += this->m_writer.set_travel_acceleration(acceleration);
|
gcode += this->m_writer.set_travel_acceleration(acceleration);
|
||||||
|
|
||||||
Vec3d previous_point{this->point_to_gcode(travel.front())};
|
|
||||||
bool already_inserted{false};
|
bool already_inserted{false};
|
||||||
for (std::size_t i{0}; i < travel.size(); ++i) {
|
for (std::size_t i{0}; i < travel.size(); ++i) {
|
||||||
const Vec3crd& point{travel[i]};
|
const Vec3crd& point{travel[i]};
|
||||||
@ -3557,9 +3551,8 @@ std::string GCodeGenerator::generate_travel_gcode(
|
|||||||
already_inserted = true;
|
already_inserted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
gcode += this->m_writer.travel_to_xyz(previous_point, gcode_point, comment);
|
gcode += this->m_writer.travel_to_xyz(gcode_point, comment);
|
||||||
this->last_position = point.head<2>();
|
this->last_position = point.head<2>();
|
||||||
previous_point = gcode_point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! GCodeWriter::supports_separate_travel_acceleration(config().gcode_flavor)) {
|
if (! GCodeWriter::supports_separate_travel_acceleration(config().gcode_flavor)) {
|
||||||
|
@ -327,19 +327,20 @@ std::string GCodeWriter::travel_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &ij
|
|||||||
return w.string();
|
return w.string();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GCodeWriter::travel_to_xyz(const Vec3d& from, const Vec3d &to, const std::string_view comment)
|
std::string GCodeWriter::travel_to_xyz(const Vec3d &to, const std::string_view comment)
|
||||||
{
|
{
|
||||||
if (std::abs(to.x() - m_pos.x()) < EPSILON && std::abs(to.y() - m_pos.y()) < EPSILON) {
|
if (std::abs(to.x() - m_pos.x()) < EPSILON && std::abs(to.y() - m_pos.y()) < EPSILON) {
|
||||||
return this->travel_to_z(to.z(), comment);
|
return this->travel_to_z(to.z(), comment);
|
||||||
} else if (std::abs(to.z() - m_pos.z()) < EPSILON) {
|
} else if (std::abs(to.z() - m_pos.z()) < EPSILON) {
|
||||||
return this->travel_to_xy(to.head<2>(), comment);
|
return this->travel_to_xy(to.head<2>(), comment);
|
||||||
} else {
|
} else {
|
||||||
|
std::string result{this->get_travel_to_xyz_gcode(to, comment)};
|
||||||
m_pos = to;
|
m_pos = to;
|
||||||
return this->get_travel_to_xyz_gcode(from, to, comment);
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GCodeWriter::get_travel_to_xyz_gcode(const Vec3d &from, const Vec3d &to, const std::string_view comment) const {
|
std::string GCodeWriter::get_travel_to_xyz_gcode(const Vec3d &to, const std::string_view comment) const {
|
||||||
GCodeG1Formatter w;
|
GCodeG1Formatter w;
|
||||||
w.emit_xyz(to);
|
w.emit_xyz(to);
|
||||||
|
|
||||||
@ -347,13 +348,13 @@ std::string GCodeWriter::get_travel_to_xyz_gcode(const Vec3d &from, const Vec3d
|
|||||||
if (speed_z == 0.)
|
if (speed_z == 0.)
|
||||||
speed_z = this->config.travel_speed.value;
|
speed_z = this->config.travel_speed.value;
|
||||||
|
|
||||||
const double distance_xy{(to.head<2>() - from.head<2>()).norm()};
|
const double distance_xy{(to.head<2>() - m_pos.head<2>()).norm()};
|
||||||
const double distnace_z{std::abs(to.z() - from.z())};
|
const double distnace_z{std::abs(to.z() - m_pos.z())};
|
||||||
const double time_z = distnace_z / speed_z;
|
const double time_z = distnace_z / speed_z;
|
||||||
const double time_xy = distance_xy / this->config.travel_speed.value;
|
const double time_xy = distance_xy / this->config.travel_speed.value;
|
||||||
const double factor = time_z > 0 ? time_xy / time_z : 1;
|
const double factor = time_z > 0 ? time_xy / time_z : 1;
|
||||||
if (factor < 1) {
|
if (factor < 1) {
|
||||||
w.emit_f((this->config.travel_speed.value * factor + (1 - factor) * speed_z) * 60.0);
|
w.emit_f(std::floor((this->config.travel_speed.value * factor + (1 - factor) * speed_z) * 60.0));
|
||||||
} else {
|
} else {
|
||||||
w.emit_f(this->config.travel_speed.value * 60.0);
|
w.emit_f(this->config.travel_speed.value * 60.0);
|
||||||
}
|
}
|
||||||
|
@ -87,8 +87,8 @@ public:
|
|||||||
* @param to Where to travel to.
|
* @param to Where to travel to.
|
||||||
* @param comment Description of the travel purpose.
|
* @param comment Description of the travel purpose.
|
||||||
*/
|
*/
|
||||||
std::string get_travel_to_xyz_gcode(const Vec3d &from, const Vec3d &to, const std::string_view comment) const;
|
std::string get_travel_to_xyz_gcode(const Vec3d &to, const std::string_view comment) const;
|
||||||
std::string travel_to_xyz(const Vec3d &from, const Vec3d &to, const std::string_view comment = {});
|
std::string travel_to_xyz(const Vec3d &to, const std::string_view comment = {});
|
||||||
std::string get_travel_to_z_gcode(double z, const std::string_view comment) const;
|
std::string get_travel_to_z_gcode(double z, const std::string_view comment) const;
|
||||||
std::string travel_to_z(double z, const std::string_view comment = {});
|
std::string travel_to_z(double z, const std::string_view comment = {});
|
||||||
std::string extrude_to_xy(const Vec2d &point, double dE, const std::string_view comment = {});
|
std::string extrude_to_xy(const Vec2d &point, double dE, const std::string_view comment = {});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user