Skip to content

Commit

Permalink
Tech ENABLE_Z_OFFSET_CORRECTION - Correction of toolpaths zs when z o…
Browse files Browse the repository at this point in the history
…ffset is set

(cherry picked from commit 537ae6bec3bb5347665e294d02cba4a889221445)
  • Loading branch information
enricoturri1966 authored and SoftFever committed Oct 24, 2023
1 parent 6023f79 commit f1c884a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/libslic3r/GCode/GCodeProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,10 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
const ConfigOptionBool* manual_filament_change = config.option<ConfigOptionBool>("manual_filament_change");
if (manual_filament_change != nullptr)
m_manual_filament_change = manual_filament_change->value;

const ConfigOptionFloat* z_offset = config.option<ConfigOptionFloat>("z_offset");
if (z_offset != nullptr)
m_z_offset = z_offset->value;
}

void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
Expand Down Expand Up @@ -1290,6 +1294,10 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
if (bed_type != nullptr)
m_result.bed_type = (BedType)bed_type->value;


const ConfigOptionFloat* z_offset = config.option<ConfigOptionFloat>("z_offset");
if (z_offset != nullptr)
m_z_offset = z_offset->value;
}

void GCodeProcessor::enable_stealth_time_estimator(bool enabled)
Expand Down Expand Up @@ -1326,6 +1334,7 @@ void GCodeProcessor::reset()
m_forced_height = 0.0f;
m_mm3_per_mm = 0.0f;
m_fan_speed = 0.0f;
m_z_offset = 0.0f;

m_extrusion_role = erNone;
m_extruder_id = 0;
Expand Down Expand Up @@ -3103,7 +3112,7 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
// the threshold value = 0.0625f == 0.25 * 0.25 is arbitrary, we may find some smarter condition later

if ((new_pos - *first_vertex).squaredNorm() < 0.0625f) {
set_end_position(0.5f * (new_pos + *first_vertex));
set_end_position(0.5f * (new_pos + *first_vertex) + m_z_offset * Vec3f::UnitZ());
store_move_vertex(EMoveType::Seam);
set_end_position(curr_pos);
}
Expand Down Expand Up @@ -4110,7 +4119,7 @@ void GCodeProcessor::store_move_vertex(EMoveType type, EMovePathType path_type)
m_extruder_id,
m_cp_color.current,
//BBS: add plate's offset to the rendering vertices
Vec3f(m_end_position[X] + m_x_offset, m_end_position[Y] + m_y_offset, m_processing_start_custom_gcode ? m_first_layer_height : m_end_position[Z]) + m_extruder_offsets[m_extruder_id],
Vec3f(m_end_position[X] + m_x_offset, m_end_position[Y] + m_y_offset, m_processing_start_custom_gcode ? m_first_layer_height : m_end_position[Z]- m_z_offset) + m_extruder_offsets[m_extruder_id],
static_cast<float>(m_end_position[E] - m_start_position[E]),
m_feedrate,
m_width,
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/GCode/GCodeProcessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ namespace Slic3r {
float m_forced_height; // mm
float m_mm3_per_mm;
float m_fan_speed; // percentage
float m_z_offset; // mm
ExtrusionRole m_extrusion_role;
unsigned char m_extruder_id;
unsigned char m_last_extruder_id;
Expand Down

0 comments on commit f1c884a

Please sign in to comment.