From b61ba98183041234405decc3e08d4b0d4550ad55 Mon Sep 17 00:00:00 2001 From: harrierpigeon Date: Sun, 2 Aug 2026 16:20:22 -0500 Subject: [PATCH] belt: adapt BeltGCodeWriter to upstream's per-extruder speed options Upstream retyped travel_speed and travel_speed_z to ConfigOptionFloatsNullable and initial_layer_travel_speed to ConfigOptionFloatsOrPercentsNullable, so the scalar .value / get_abs_value() accessors no longer compile. BeltGCodeWriter.cpp is belt-only and merged without conflict, so this only surfaced at build time. Index them the way the base GCodeWriter does -- .get_at(m_cached_extruder_idx) and get_abs_value_at(..., m_cached_extruder_idx) -- keeping belt's per-point first_layer_for_point test rather than the base class's m_is_first_layer. m_cached_extruder_idx moves from private to the existing protected block that already exposes writer state to subclasses, so the belt writer resolves the per-extruder index identically to the base writer instead of guessing one. --- src/libslic3r/BeltGCodeWriter.cpp | 15 ++++++++------- src/libslic3r/GCodeWriter.hpp | 7 +++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/libslic3r/BeltGCodeWriter.cpp b/src/libslic3r/BeltGCodeWriter.cpp index 7c645edf43..f46b1f2c35 100644 --- a/src/libslic3r/BeltGCodeWriter.cpp +++ b/src/libslic3r/BeltGCodeWriter.cpp @@ -87,7 +87,8 @@ std::string BeltGCodeWriter::travel_to_xy(const Vec2d &point, const std::string m_first_layer_plane, m_first_layer_thickness_mm, m_is_first_layer, Vec3d(point.x(), point.y(), m_pos.z())); auto speed = first_layer_for_point - ? this->config.get_abs_value("initial_layer_travel_speed") : this->config.travel_speed.value; + ? this->config.get_abs_value_at("initial_layer_travel_speed", m_cached_extruder_idx) + : this->config.travel_speed.get_at(m_cached_extruder_idx); w.emit_f(speed * 60.0); w.emit_comment(GCodeWriter::full_gcode_comment, comment); return w.string(); @@ -110,13 +111,13 @@ std::string BeltGCodeWriter::_travel_to_z(double z, const std::string &comment) { m_pos(2) = z; - double speed = this->config.travel_speed_z.value; + double speed = this->config.travel_speed_z.get_at(m_cached_extruder_idx); if (speed == 0.) { const bool first_layer_for_point = belt_point_on_first_layer( m_first_layer_plane, m_first_layer_thickness_mm, m_is_first_layer, Vec3d(m_pos.x(), m_pos.y(), z)); - speed = first_layer_for_point ? this->config.get_abs_value("initial_layer_travel_speed") - : this->config.travel_speed.value; + speed = first_layer_for_point ? this->config.get_abs_value_at("initial_layer_travel_speed", m_cached_extruder_idx) + : this->config.travel_speed.get_at(m_cached_extruder_idx); } // Belt printer: a Z-only move in slicing frame needs to emit both Y and Z in machine coords. @@ -182,8 +183,8 @@ std::string BeltGCodeWriter::travel_to_xyz(const Vec3d &point, const std::string const bool first_layer_for_point = belt_point_on_first_layer( m_first_layer_plane, m_first_layer_thickness_mm, m_is_first_layer, point); auto travel_speed = - first_layer_for_point ? this->config.get_abs_value("initial_layer_travel_speed") - : this->config.travel_speed.value; + first_layer_for_point ? this->config.get_abs_value_at("initial_layer_travel_speed", m_cached_extruder_idx) + : this->config.travel_speed.get_at(m_cached_extruder_idx); // Handle pending z_hop if (std::abs(m_to_lift) > EPSILON) { @@ -253,7 +254,7 @@ std::string BeltGCodeWriter::travel_to_xyz(const Vec3d &point, const std::string // Belt mode: always emit full XYZ GCodeG1Formatter w; w.emit_xyz(point_on_plate); - w.emit_f(this->config.travel_speed.value * 60.0); + w.emit_f(this->config.travel_speed.get_at(m_cached_extruder_idx) * 60.0); w.emit_comment(GCodeWriter::full_gcode_comment, comment); m_pos = dest_point; diff --git a/src/libslic3r/GCodeWriter.hpp b/src/libslic3r/GCodeWriter.hpp index 2671851f53..da2ce35cd6 100644 --- a/src/libslic3r/GCodeWriter.hpp +++ b/src/libslic3r/GCodeWriter.hpp @@ -167,14 +167,17 @@ protected: // Apply axis remap to a point. Returns pos unchanged if remap is identity. Vec3d apply_axis_remap(const Vec3d &pos) const; + // Motion uses the global/base process variant until a filament becomes active. + // Protected so BeltGCodeWriter indexes the per-extruder speed options (travel_speed, + // travel_speed_z, initial_layer_travel_speed) exactly as the base writer does. + size_t m_cached_extruder_idx; + private: // Extruders are sorted by their ID, so that binary search is possible. std::vector m_filament_extruders; bool m_single_extruder_multi_material; std::vector m_curr_filament_extruder; int m_curr_extruder_id; - // Motion uses the global/base process variant until a filament becomes active. - size_t m_cached_extruder_idx; unsigned int m_last_acceleration; unsigned int m_last_travel_acceleration; std::vector m_max_travel_acceleration;