Drop Redundant Belt Checks in BeltGCode

BeltGCode is only created for belt printers, so its hooks no longer re-check belt_printer, and the BBL-machine flag is set once on whichever writer survives init_belt_writer instead of on one about to be discarded.
This commit is contained in:
Hanif Koh
2026-09-11 16:03:14 +08:00
parent 330d8b1d06
commit f2fd3b4bd6
4 changed files with 6 additions and 14 deletions

View File

@@ -5,13 +5,9 @@
namespace Slic3r {
void BeltGCode::init_belt_writer(Print &print, bool is_bbl_printers)
void BeltGCode::init_belt_writer(Print &print)
{
if (!print.config().belt_printer.value)
return;
auto belt_writer = std::make_unique<BeltGCodeWriter>();
belt_writer->set_is_bbl_machine(is_bbl_printers);
// Axis remap and build volume max are set by base GCode after init_belt_writer returns.
belt_writer->set_belt_back_transform(print.config());
belt_writer->set_machine_frame_transform(print.config());
@@ -21,9 +17,6 @@ void BeltGCode::init_belt_writer(Print &print, bool is_bbl_printers)
void BeltGCode::write_belt_header(GCodeOutputStream &file, const Print &print)
{
if (!print.config().belt_printer.value)
return;
const auto &full_cfg = print.full_print_config();
// Slicing rotation: the belt tilt (axis + angle) and the single source of truth
// for the physical tilt the G-code viewer uses to enable belt view.
@@ -62,7 +55,7 @@ void BeltGCode::on_set_origin(const PrintObject * /*obj*/, const Point & /*inst_
|| (m_config.belt_slice_rotation_global.value
&& m_config.belt_slice_rotation.value != BeltRotationAxis::None
&& std::abs(m_config.belt_slice_rotation_angle.value) > EPSILON);
if (!use_global || !m_config.belt_printer.value)
if (!use_global)
return;
// Adjust origin: transform through belt forward pipeline so that

View File

@@ -14,7 +14,7 @@ namespace Slic3r {
class BeltGCode : public GCode
{
protected:
void init_belt_writer(Print &print, bool is_bbl_printers) override;
void init_belt_writer(Print &print) override;
void write_belt_header(GCodeOutputStream &file, const Print &print) override;
void on_set_origin(const PrintObject *obj, const Point &inst_shift) override;
bool should_disable_arc_fitting() const override { return true; }

View File

@@ -2961,10 +2961,9 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
m_fan_mover.release();
m_ordering_cache.clear();
m_writer->set_is_bbl_machine(is_bbl_printers);
// Belt printer: initialize belt-specific writer via virtual hook.
this->init_belt_writer(print, is_bbl_printers);
this->init_belt_writer(print);
m_writer->set_is_bbl_machine(is_bbl_printers);
// Standalone axis remap (works with or without belt mode).
// Sync the writer's remap state to the current export UNCONDITIONALLY — even at

View File

@@ -376,7 +376,7 @@ protected:
// Virtual hooks for belt printer subclass (BeltGCode).
// No-ops in base GCode; overridden in BeltGCode.
virtual void init_belt_writer(Print &print, bool is_bbl_printers) {}
virtual void init_belt_writer(Print &print) {}
virtual void write_belt_header(GCodeOutputStream &file, const Print &print) {}
virtual void on_set_origin(const PrintObject *obj, const Point &inst_shift) {}
virtual bool should_disable_arc_fitting() const { return false; }