mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 11:23:42 +00:00
Scale emulated spiral Z-hop segments based on slicing resolution (#11556)
Spiral Z-Hop resolution Use slicing resolution to determine segment count for emulated spiral Z-hop What’s changed The number of linear segments used to approximate a spiral Z-hop is now derived from the PrintConfig resolution value. The segment count is clamped to a safe range (4–24) to avoid excessive G-code generation or MCU queue overflow. Why Previously a fixed 24 segments were always used, regardless of model resolution. For small-radius spiral lifts this was excessive and could overwhelm some printers. Adapting segment count to resolution ensures smooth motion where needed, but lighter G-code where possible. Details m_resolution is now stored via apply_print_config(). _spiral_travel_to_z() uses this value to compute segment count dynamically. Only the linear-segment fallback path is affected; G2/G3 arc-fitting remains unchanged.
This commit is contained in:
@@ -42,6 +42,7 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config)
|
|||||||
};
|
};
|
||||||
m_max_jerk_z = print_config.machine_max_jerk_z.values.front();
|
m_max_jerk_z = print_config.machine_max_jerk_z.values.front();
|
||||||
m_max_jerk_e = print_config.machine_max_jerk_e.values.front();
|
m_max_jerk_e = print_config.machine_max_jerk_e.values.front();
|
||||||
|
m_resolution = print_config.resolution.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeWriter::set_extruders(std::vector<unsigned int> extruder_ids)
|
void GCodeWriter::set_extruders(std::vector<unsigned int> extruder_ids)
|
||||||
@@ -787,8 +788,18 @@ std::string GCodeWriter::_spiral_travel_to_z(double z, const Vec2d &ij_offset, c
|
|||||||
|
|
||||||
if (!this->config.enable_arc_fitting) { // Orca: if arc fitting is disabled, approximate the arc with small linear segments
|
if (!this->config.enable_arc_fitting) { // Orca: if arc fitting is disabled, approximate the arc with small linear segments
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
const double z_start = m_pos(2); // starting Z height
|
const double z_start = m_pos(2); // starting Z height
|
||||||
const int segments = 24; // number of linear segments to use for approximating the arc
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
// Determine number of segments based on Resolution
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
const double ref_resolution = 0.01; // reference resolution in mm
|
||||||
|
const double ref_segments = 16.0; // reference number of segments at reference resolution
|
||||||
|
|
||||||
|
// number of linear segments to use for approximating the arc, clamp between 4 and 24
|
||||||
|
const int segments = std::clamp(int(std::round(ref_segments * (ref_resolution / m_resolution))), 4, 24);
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
const double px = m_pos(0) - m_x_offset; // take plate offset into consideration
|
const double px = m_pos(0) - m_x_offset; // take plate offset into consideration
|
||||||
const double py = m_pos(1) - m_y_offset; // take plate offset into consideration
|
const double py = m_pos(1) - m_y_offset; // take plate offset into consideration
|
||||||
const double cx = px + ij_offset(0); // center x
|
const double cx = px + ij_offset(0); // center x
|
||||||
|
|||||||
@@ -168,6 +168,9 @@ public:
|
|||||||
//BBS: x, y offset for gcode generated
|
//BBS: x, y offset for gcode generated
|
||||||
double m_x_offset{ 0 };
|
double m_x_offset{ 0 };
|
||||||
double m_y_offset{ 0 };
|
double m_y_offset{ 0 };
|
||||||
|
|
||||||
|
// Orca: slicing resolution in mm
|
||||||
|
double m_resolution = 0.01;
|
||||||
|
|
||||||
std::string m_gcode_label_objects_start;
|
std::string m_gcode_label_objects_start;
|
||||||
std::string m_gcode_label_objects_end;
|
std::string m_gcode_label_objects_end;
|
||||||
|
|||||||
Reference in New Issue
Block a user