From a4962843fd4aa9f3c4ed20fbec3f0434e0376c67 Mon Sep 17 00:00:00 2001 From: leroy ketelaars Date: Sat, 5 Dec 2026 11:38:58 +0100 Subject: [PATCH 01/10] Add filament first-layer flow and automatic fin supports --- README.md | 2 + doc/Fins supports.md | 11 + src/libslic3r/CMakeLists.txt | 2 + src/libslic3r/GCode.cpp | 3 +- src/libslic3r/GCode/WipeTower.cpp | 16 +- src/libslic3r/GCode/WipeTower.hpp | 5 +- src/libslic3r/ModelArrange.cpp | 2 +- src/libslic3r/Preset.cpp | 3 +- src/libslic3r/Print.cpp | 2 + src/libslic3r/PrintApply.cpp | 14 + src/libslic3r/PrintConfig.cpp | 30 +- src/libslic3r/PrintConfig.hpp | 12 +- src/libslic3r/PrintObject.cpp | 13 +- src/libslic3r/Support/FinSupport.cpp | 349 ++++++++++++++++++++++ src/libslic3r/Support/FinSupport.hpp | 20 ++ src/libslic3r/Support/SupportMaterial.cpp | 49 ++- src/libslic3r/Support/SupportMaterial.hpp | 6 +- src/slic3r/GUI/ConfigManipulation.cpp | 17 +- src/slic3r/GUI/Tab.cpp | 1 + 19 files changed, 525 insertions(+), 32 deletions(-) create mode 100644 doc/Fins supports.md create mode 100644 src/libslic3r/Support/FinSupport.cpp create mode 100644 src/libslic3r/Support/FinSupport.hpp diff --git a/README.md b/README.md index b13674db41..30de1ef547 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ Bambu Studio is based on [PrusaSlicer](https://github.com/prusa3d/PrusaSlicer) b See the [wiki](https://github.com/bambulab/BambuStudio/wiki) and the [documentation directory](https://github.com/bambulab/BambuStudio/tree/master/doc) for more information. +See [Fins supports](doc/Fins%20supports.md) for automatic breakaway fin supports in this fork. + # What are Bambu Studio's main features? Key features are: - Basic slicing features & GCode viewer diff --git a/doc/Fins supports.md b/doc/Fins supports.md new file mode 100644 index 0000000000..78649348da --- /dev/null +++ b/doc/Fins supports.md @@ -0,0 +1,11 @@ +# Fins supports + +Enable supports in **Process → Support** and select **fins(auto)** under **Type**. Fins are thin walls with widened feet. Where a wall can reach a nearby edge, a short horizontal tine touches the part on a single print layer. The clearance around the wall makes the support easier to break away. + +Fins are placed automatically. They use the **Support/raft base** filament selected for the object, including its process default. The existing overhang threshold, painted enforcers and blockers guide placement. Inspect the result in **Preview** before printing. + +Fins need room to stand on the build plate and reach the overhang. A raft, obstructed footing, narrow opening or a nearby object can prevent placement. If Bambu Studio cannot cover all required overhangs for an object, it discards that object's fins and asks you to select another support type. Choose Normal or Tree and slice again. + +## Credit + +The design is based on [Support Fins](https://github.com/gittrahan/support-fins) by **Matthew Trahan** ([gittrahan](https://github.com/gittrahan)), released under the [MIT License](https://github.com/gittrahan/support-fins/blob/a47cf47b5b0dc42a50ea3e42771c16636ca6b168/LICENSE). The Bambu Studio generator uses Trahan's [fin geometry specification](https://github.com/gittrahan/support-fins/blob/a47cf47b5b0dc42a50ea3e42771c16636ca6b168/docs/FIN-SPEC.md) as its reference for the foot, clearance and single-layer tines. The specification credits Slant3D for the underlying breakaway fin technique. diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt index 7a9483a472..818321cf44 100644 --- a/src/libslic3r/CMakeLists.txt +++ b/src/libslic3r/CMakeLists.txt @@ -318,6 +318,8 @@ set(lisbslic3r_sources SlicingAdaptive.hpp Support/SupportCommon.cpp Support/SupportCommon.hpp + Support/FinSupport.cpp + Support/FinSupport.hpp Support/SupportMaterial.cpp Support/SupportMaterial.hpp Support/TreeSupport.hpp diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 1f5cb6edd9..ebfa259664 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -6074,7 +6074,8 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, if( path.role() == erTopSolidInfill ) _mm3_per_mm *= NOZZLE_CONFIG(top_solid_infill_flow_ratio); else if (this->on_first_layer()) - _mm3_per_mm *= m_config.initial_layer_flow_ratio.value; + _mm3_per_mm *= resolve_initial_layer_flow_ratio(m_config.initial_layer_flow_ratio.value, + FILAMENT_CONFIG(filament_initial_layer_flow_ratio)); double e_per_mm = m_writer.filament()->e_per_mm3() * _mm3_per_mm; diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index d4f2e8a26c..5f6e15d420 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -1810,6 +1810,7 @@ void WipeTower::set_extruder(size_t idx, const PrintConfig& config) m_filpar.push_back(FilamentParameters()); m_filpar[idx].material = config.filament_type.get_at(idx); + m_filpar[idx].initial_layer_flow_ratio = config.filament_initial_layer_flow_ratio.get_at(idx); m_filpar[idx].is_soluble = config.filament_soluble.get_at(idx); // BBS m_filpar[idx].is_support = config.filament_is_support.get_at(idx); @@ -2490,13 +2491,14 @@ void WipeTower::toolchange_Wipe( const box_coordinates &cleaning_box, float wipe_length) { - // Increase flow on first layer, slow down print. - writer.set_extrusion_flow(m_extrusion_flow * (is_first_layer() ? m_first_layer_flow_ratio : 1.f)) + const float flow_ratio = is_first_layer() ? float(resolve_initial_layer_flow_ratio( + m_first_layer_flow_ratio, m_filpar[m_current_tool].initial_layer_flow_ratio)) : 1.f; + writer.set_extrusion_flow(m_extrusion_flow * flow_ratio) .append("; CP TOOLCHANGE WIPE\n"); // BBS: add the note for gcode-check, when the flow changed, the width should follow the change if (is_first_layer()) { - writer.append(";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Width) + std::to_string(m_first_layer_flow_ratio * m_perimeter_width) + "\n"); + writer.append(";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Width) + std::to_string(flow_ratio * m_perimeter_width) + "\n"); } const float& xl = cleaning_box.ld.x(); @@ -3889,14 +3891,16 @@ WipeTower::ToolChangeResult WipeTower::finish_block_solid(const WipeTowerBlock & void WipeTower::toolchange_wipe_new(WipeTowerWriter &writer, const box_coordinates &cleaning_box, float wipe_length,bool solid_tool_toolchange) { - writer.set_extrusion_flow(m_extrusion_flow * (is_first_layer() ? m_first_layer_flow_ratio : 1.f)) + const float flow_ratio = is_first_layer() ? float(resolve_initial_layer_flow_ratio( + m_first_layer_flow_ratio, m_filpar[m_current_tool].initial_layer_flow_ratio)) : 1.f; + writer.set_extrusion_flow(m_extrusion_flow * flow_ratio) .append(";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::CP_TOOLCHANGE_WIPE) + " CT" + std::to_string(solid_tool_toolchange) + "\n"); if (!m_nozzle_change_result.gcode.empty()) writer.change_analyzer_line_width(m_perimeter_width); // BBS: add the note for gcode-check, when the flow changed, the width should follow the change if (is_first_layer()) { - writer.append(";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Width) + std::to_string(m_first_layer_flow_ratio * m_perimeter_width) + "\n"); + writer.append(";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Width) + std::to_string(flow_ratio * m_perimeter_width) + "\n"); } //if (solid_tool_toolchange && m_filpar[m_current_tool].filament_tower_interface_print_temp != m_filpar[m_current_tool].nozzle_temperature) @@ -4169,7 +4173,7 @@ void WipeTower::set_nozzle_last_layer_id() } } -void WipeTower::set_first_layer_flow_ratio(const float flow_ratio) +void WipeTower::set_first_layer_flow_ratio(double flow_ratio) { m_first_layer_flow_ratio = flow_ratio; } diff --git a/src/libslic3r/GCode/WipeTower.hpp b/src/libslic3r/GCode/WipeTower.hpp index b32341ad0a..a6f135febd 100644 --- a/src/libslic3r/GCode/WipeTower.hpp +++ b/src/libslic3r/GCode/WipeTower.hpp @@ -309,6 +309,7 @@ class WipeTower bool has_tpu_filament() const { return m_has_tpu_filament; } struct FilamentParameters { + double initial_layer_flow_ratio = default_initial_layer_flow_ratio; std::string material = "PLA"; int category; bool is_soluble = false; @@ -398,7 +399,7 @@ class WipeTower void generate_wipe_tower_blocks(bool add_solid_flag); void update_all_layer_depth(float wipe_tower_depth); void set_nozzle_last_layer_id(); - void set_first_layer_flow_ratio(const float flow_ratio); + void set_first_layer_flow_ratio(double flow_ratio); void calc_block_infill_gap(); ToolChangeResult tool_change_new(size_t new_tool, bool solid_change = false, bool solid_nozzlechange=false); NozzleChangeResult ramming(int old_filament_id, int new_filament_id, bool solid_change = false, bool extruder_change = true); // extruder_chang means nozzle_change @@ -498,7 +499,7 @@ class WipeTower float m_bed_width; // width of the bed bounding box Vec2f m_bed_bottom_left; // bottom-left corner coordinates (for rectangular beds) - float m_first_layer_flow_ratio; + double m_first_layer_flow_ratio = default_initial_layer_flow_ratio; float m_perimeter_width = 0.4f * Width_To_Nozzle_Ratio; // Width of an extrusion line, also a perimeter spacing for 100% infill. float m_nozzle_change_perimeter_width = 0.4f * Width_To_Nozzle_Ratio; float m_extrusion_flow = 0.038f; //0.029f;// Extrusion flow is derived from m_perimeter_width, layer height and filament diameter. diff --git a/src/libslic3r/ModelArrange.cpp b/src/libslic3r/ModelArrange.cpp index f5ccc72608..c88e0a482d 100644 --- a/src/libslic3r/ModelArrange.cpp +++ b/src/libslic3r/ModelArrange.cpp @@ -169,7 +169,7 @@ ArrangePolygon get_instance_arrange_poly(ModelInstance* instance, const Slic3r:: auto raft_first_layer_expansion_ptr = obj->get_config_value(config, "raft_first_layer_expansion"); float raft_expansion = raft_first_layer_expansion_ptr ? raft_first_layer_expansion_ptr->getFloat() : 0.0; - if (enable_support && (support_type == stNormalAuto || support_type == stNormal)) + if (enable_support && !is_tree(support_type)) ap.brim_width = 6.0; else if (enable_support) { ap.brim_width = std::max(24.0f, raft_expansion); // 2*MAX_BRANCH_RADIUS_FIRST_LAYER diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index d803a49dff..53986b25c4 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -1006,7 +1006,8 @@ static std::vector s_Preset_filament_options{/*"filament_colour", * "filament_soluble", "filament_is_support", "filament_printable", "filament_scarf_seam_type", "filament_scarf_height", "filament_scarf_gap", "filament_scarf_length", "filament_max_volumetric_speed", "impact_strength_z", "filament_ramming_volumetric_speed","filament_ramming_volumetric_speed_nc", "filament_adaptive_volumetric_speed", - "filament_flow_ratio", "filament_density", "filament_adhesiveness_category", "filament_cost", "filament_minimal_purge_on_wipe_tower", + "filament_flow_ratio", "filament_initial_layer_flow_ratio", "filament_density", "filament_adhesiveness_category", "filament_cost", + "filament_minimal_purge_on_wipe_tower", "nozzle_temperature", "nozzle_temperature_initial_layer", // BBS "cool_plate_temp", "eng_plate_temp", "hot_plate_temp", "textured_plate_temp", "cool_plate_temp_initial_layer", "eng_plate_temp_initial_layer", "hot_plate_temp_initial_layer","textured_plate_temp_initial_layer", diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 69ad19e7ec..77276a5517 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -334,6 +334,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n //|| opt_key == "z_offset") { steps.emplace_back(psWipeTower); steps.emplace_back(psSkirtBrim); + } else if (opt_key == "filament_initial_layer_flow_ratio") { + steps.emplace_back(psWipeTower); } else if (opt_key == "filament_soluble" || opt_key == "filament_is_support" || opt_key == "filament_printable" diff --git a/src/libslic3r/PrintApply.cpp b/src/libslic3r/PrintApply.cpp index 2b60d90372..a80d68e2e4 100644 --- a/src/libslic3r/PrintApply.cpp +++ b/src/libslic3r/PrintApply.cpp @@ -1376,6 +1376,8 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ // The following call may stop the background processing. if (! print_diff.empty()) update_apply_status(this->invalidate_state_by_config_options(new_full_config, print_diff)); + if (std::find(region_diff.begin(), region_diff.end(), "initial_layer_flow_ratio") != region_diff.end()) + update_apply_status(this->invalidate_step(psWipeTower)); // Apply variables to placeholder parser. The placeholder parser is used by G-code export, // which should be stopped if print_diff is not empty. @@ -1650,6 +1652,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ PrintObjectPtrs print_objects_new; print_objects_new.reserve(std::max(m_objects.size(), m_model.objects.size())); bool new_objects = false; + bool instance_layout_changed = false; // Walk over all new model objects and check, whether there are matching PrintObjects. for (ModelObject *model_object : m_model.objects) { ModelObjectStatus &model_object_status = const_cast(model_object_status_db.reuse(*model_object)); @@ -1701,6 +1704,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ if (status != PrintBase::APPLY_STATUS_UNCHANGED) { size_t extruder_num = new_full_config.option("nozzle_diameter")->size(); update_apply_status(status == PrintBase::APPLY_STATUS_INVALIDATED); + instance_layout_changed = true; } print_objects_new.emplace_back((*it_old)->print_object); const_cast(*it_old)->status = PrintObjectStatus::Reused; @@ -1708,6 +1712,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ } } if (m_objects != print_objects_new) { + instance_layout_changed = true; //BBS: add more logs BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" %1%: found print object changed.")%__LINE__; this->call_cancel_callback(); @@ -1729,6 +1734,15 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ } print_object_status_db.clear(); + const bool fin_bed_changed = instance_layout_changed || + print_diff_set.count("printable_area") || print_diff_set.count("printable_height") || + print_diff_set.count("bed_exclude_area") || print_diff_set.count("extruder_printable_area") || + print_diff_set.count("extruder_printable_height"); + if (fin_bed_changed) + for (PrintObject *object : m_objects) + if (object->config().support_type.value == stFinsAuto) + update_apply_status(object->invalidate_step(posSupportMaterial)); + // BBS for (PrintObject* object : m_objects) { auto ept_iter = std::find(print_diff.begin(), print_diff.end(), "enable_prime_tower"); diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 8340f2c1e8..c9f8832aea 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -295,7 +295,8 @@ static t_config_enum_values s_keys_map_SupportType{ { "normal(auto)", stNormalAuto }, { "tree(auto)", stTreeAuto }, { "normal(manual)", stNormal }, - { "tree(manual)", stTree } + { "tree(manual)", stTree }, + { "fins(auto)", stFinsAuto } }; CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(SupportType) @@ -1147,11 +1148,12 @@ void PrintConfigDef::init_fff_params() def = this->add("initial_layer_flow_ratio", coFloat); def->label = L("Initial layer flow ratio"); - def->tooltip = L("This factor affects the amount of material for the initial layer"); + def->tooltip = L("Overrides the filament's initial layer flow ratio when set to a value other than 1. " + "At 1, each filament uses its own initial layer flow ratio."); def->min = 0; def->max = 2; def->mode = comDevelop; - def->set_default_value(new ConfigOptionFloat(1)); + def->set_default_value(new ConfigOptionFloat(default_initial_layer_flow_ratio)); def = this->add("top_one_wall_type", coEnum); def->label = L("Only one wall on top surfaces"); @@ -1903,6 +1905,15 @@ void PrintConfigDef::init_fff_params() def->nullable = true; def->set_default_value(new ConfigOptionFloatsNullable { 1. }); + def = this->add("filament_initial_layer_flow_ratio", coFloats); + def->label = L("Initial layer flow ratio"); + def->tooltip = L("Scales this filament's extrusion on the initial layer in addition to its regular flow ratio. " + "A process initial layer flow ratio other than 1 overrides this value."); + def->min = 0.01; + def->max = 2; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionFloats{default_initial_layer_flow_ratio}); + def = this->add("print_flow_ratio", coFloat); def->label = L("Object flow ratio"); def->tooltip = L("The flow ratio set by object, the meaning is the same as flow ratio."); @@ -4665,17 +4676,20 @@ void PrintConfigDef::init_fff_params() def = this->add("support_type", coEnum); def->label = L("Type"); def->category = L("Support"); - def->tooltip = L("normal(auto) and tree(auto) is used to generate support automatically. " - "If normal(manual) or tree(manual) is selected, only support enforcers are generated"); + def->tooltip = L("Normal, tree and fins can be generated automatically. Normal (manual) and tree (manual) " + "generate supports only in enforced areas. Fins are thin breakaway walls printed with the " + "configured support base filament."); def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); def->enum_values.push_back("normal(auto)"); def->enum_values.push_back("tree(auto)"); def->enum_values.push_back("normal(manual)"); def->enum_values.push_back("tree(manual)"); + def->enum_values.push_back("fins(auto)"); def->enum_labels.push_back(L("normal(auto)")); def->enum_labels.push_back(L("tree(auto)")); def->enum_labels.push_back(L("normal(manual)")); def->enum_labels.push_back(L("tree(manual)")); + def->enum_labels.push_back(L("fins(auto)")); def->mode = comSimple; def->set_default_value(new ConfigOptionEnum(stNormalAuto)); @@ -6702,6 +6716,7 @@ std::set print_options_with_variant = { std::set filament_options_with_variant = { "filament_flow_ratio", + "filament_initial_layer_flow_ratio", "filament_max_volumetric_speed", "filament_ramming_volumetric_speed", "filament_pre_cooling_temperature", @@ -8602,6 +8617,11 @@ std::map validate(const FullPrintConfig &cfg, bool und break; } + if (std::any_of(cfg.filament_initial_layer_flow_ratio.values.begin(), + cfg.filament_initial_layer_flow_ratio.values.end(), + [](double ratio) { return !std::isfinite(ratio); })) + error_message.emplace("filament_initial_layer_flow_ratio", L("Invalid initial layer flow ratio.")); + // The following test was commented out after 482841b, see also https://github.com/prusa3d/PrusaSlicer/pull/6743. // The backend should now handle this case correctly. I.e., zero default_acceleration behaves as if all others // were zero too. This is now consistent with what the UI said would happen. diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 601a774aa3..3a6ae384a3 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -122,6 +122,13 @@ enum SupportMaterialPattern { smpNone, }; +constexpr double default_initial_layer_flow_ratio = 1.0; + +inline double resolve_initial_layer_flow_ratio(double process_ratio, double filament_ratio) +{ + return process_ratio == default_initial_layer_flow_ratio ? filament_ratio : process_ratio; +} + enum SupportMaterialStyle { smsDefault, smsGrid, smsSnug, smsTreeSlim, smsTreeStrong, smsTreeHybrid, smsTreeOrganic }; @@ -139,7 +146,7 @@ enum SupportMaterialInterfacePattern { // BBS enum SupportType { - stNormalAuto, stTreeAuto, stNormal, stTree + stNormalAuto, stTreeAuto, stNormal, stTree, stFinsAuto }; inline bool is_tree(SupportType stype) { @@ -151,7 +158,7 @@ inline bool is_tree_slim(SupportType type, SupportMaterialStyle style) }; inline bool is_auto(SupportType stype) { - return std::set{stNormalAuto, stTreeAuto}.count(stype) != 0; + return stype == stNormalAuto || stype == stTreeAuto || stype == stFinsAuto; }; enum SeamPosition { @@ -1092,6 +1099,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionString, machine_end_gcode)) ((ConfigOptionStrings, filament_end_gcode)) ((ConfigOptionFloatsNullable, filament_flow_ratio)) + ((ConfigOptionFloats, filament_initial_layer_flow_ratio)) ((ConfigOptionBools, enable_pressure_advance)) ((ConfigOptionFloats, pressure_advance)) ((ConfigOptionFloats, filament_diameter)) diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index f7f16984b4..7e2f16da6b 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -3683,7 +3683,18 @@ void PrintObject::combine_infill() void PrintObject::_generate_support_material() { - if (is_tree(m_config.support_type.value)) { + if (m_config.support_type.value == stFinsAuto) { + PrintObjectSupportMaterial support_material(this, m_slicing_params); + if (has_support() && !support_material.generate_fins(*this)) { + const std::string warning = Slic3r::format( + L("Fin supports could not be generated for all required overhangs on %s. Choose another support type for this print."), + this->model_object()->name); + BOOST_LOG_TRIVIAL(warning) << warning; + this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, warning); + } + if (has_raft()) + support_material.generate(*this); + } else if (is_tree(m_config.support_type.value)) { TreeSupport tree_support(*this, m_slicing_params); tree_support.throw_on_cancel = [this]() { this->throw_if_canceled(); }; tree_support.generate(); diff --git a/src/libslic3r/Support/FinSupport.cpp b/src/libslic3r/Support/FinSupport.cpp new file mode 100644 index 0000000000..507c538fb5 --- /dev/null +++ b/src/libslic3r/Support/FinSupport.cpp @@ -0,0 +1,349 @@ +#include "FinSupport.hpp" + +#include "ClipperUtils.hpp" +#include "Flow.hpp" +#include "Layer.hpp" +#include "Print.hpp" + +#include +#include + +namespace Slic3r { +namespace { + +// Geometry reference (MIT): https://github.com/gittrahan/support-fins/tree/a47cf47 +// Seated thin walls, a widened foot and one-layer tines at reachable edges. +constexpr double fin_pitch = 4.; +constexpr double wall_clearance = 0.2; +constexpr double foot_height = 0.8; +constexpr double tine_pitch = 3.; + +struct WallLayer { + Polylines paths; + Polygons footprint; +}; + +struct FinWall { + std::vector layers; + Polygons coverage; +}; + +void check_cancellation(const PrintObject &object) +{ + if (object.print()->canceled()) + throw CanceledException(); +} + +Point displaced(const Point &point, const Vec2d &direction, double distance) +{ + return (point.cast() + direction * distance).array().round().cast().matrix(); +} + +Polygons stroke(const Polyline &line, double radius) +{ + return offset(line, float(radius), ClipperLib::jtRound, DefaultLineMiterLimit, ClipperLib::etOpenRound); +} + +void append_stroke(Polygons &polygons, const Polyline &line, double radius) +{ + polygons_append(polygons, stroke(line, radius)); +} + +// Each copy shares toolpaths, so a wall must fit under every instance's +// transform. Leave breathing room around neighboring objects and their fins. +ExPolygons available_bed(const PrintObject &object) +{ + const Print &print = *object.print(); + const PrintConfig &config = print.config(); + Polygons bed{Polygon::new_scale(config.printable_area.values)}; + for (const auto &area : config.extruder_printable_area.values) + if (area.size() >= 3) + bed = intersection(bed, Polygons{Polygon::new_scale(area)}); + + const auto &excluded = config.bed_exclude_area.values; + for (size_t i = 0; i + 3 < excluded.size(); i += 4) { + Polygon keepout = Polygon::new_scale({excluded[i], excluded[i + 1], excluded[i + 2], excluded[i + 3]}); + keepout.make_counter_clockwise(); + bed = diff(bed, Polygons{std::move(keepout)}); + } + + ExPolygons common; + bool first = true; + const Point margin(scale_(fin_pitch), scale_(fin_pitch)); + for (const PrintInstance &instance : object.instances()) { + const Point shift = instance.shift_without_plate_offset(); + Polygons local_bed = bed; + for (Polygon &poly : local_bed) + poly.translate(-shift); + Polygons neighbors; + for (const PrintObject *other : print.objects()) { + for (const PrintInstance &neighbor : other->instances()) { + if (&neighbor == &instance) + continue; + const Point delta = neighbor.shift_without_plate_offset() - shift; + const BoundingBox bbox = other->bounding_box(); + BoundingBox padded(bbox.min + delta - margin, bbox.max + delta + margin); + neighbors.push_back(padded.polygon()); + } + } + ExPolygons local = diff_ex(local_bed, union_(neighbors)); + common = first ? std::move(local) : intersection_ex(common, local); + first = false; + } + return common; +} + +Polylines wall_paths(const Line &run, const Vec2d &normal, const Flow &flow, const Layer &layer, bool tip) +{ + if (tip) + return {Polyline(run.a, run.b)}; + + const bool foot = layer.print_z <= foot_height + EPSILON || layer.id() == 0; + const double spacing = scale_(flow.spacing()); + Polylines paths; + if (foot) + paths.emplace_back(run.a, run.b); + const double lateral = foot ? spacing : 0.5 * spacing; + const double inset = foot ? std::min(0.2, spacing / run.length()) : 0.; + const Point start = lerp(run.a, run.b, inset); + const Point end = lerp(run.b, run.a, inset); + for (double side : {-1., 1.}) + paths.emplace_back(displaced(start, normal, side * lateral), displaced(end, normal, side * lateral)); + return paths; +} + +// Find the first side surface in reach of the bead. The centerline stays +// outside the part, with only the round end of the bead touching the surface. +void add_tines(WallLayer &wall, const Vec2d &normal, double width, double spacing, + const Layer &layer, const Polygons &blockers, const ExPolygons &bed, const Polygons &occupied) +{ + const auto add_side = [&](Point a, Point b, const Vec2d &outward) { + const double length = (b - a).cast().norm(); + for (double pos = 0.5 * scale_(tine_pitch); pos < length; pos += scale_(tine_pitch)) { + const Point edge = lerp(a, b, pos / length); + const auto contacts = intersection_pl( + Polyline(edge, displaced(edge, outward, scale_(wall_clearance) + 2. * width)), layer.lslices); + double distance = scale_(wall_clearance) + 2. * width; + for (const Polyline &contact : contacts) + for (const Point &point : contact.points) + distance = std::min(distance, (point - edge).cast().dot(outward)); + if (contacts.empty() || distance <= 0.5 * width) + continue; + + const Point root = displaced(edge, outward, 0.35 * width); + const Point tip = displaced(edge, outward, distance - 0.45 * width); + if ((tip - root).cast().dot(outward) < 0.35 * spacing) + continue; + Polyline tine(root, tip); + Polygons footprint = stroke(tine, 0.5 * width); + if (!diff(footprint, bed).empty() || overlaps(footprint, blockers) || overlaps(footprint, occupied) || + area(intersection(layer.lslices, footprint)) > 0.18 * width * width) + continue; + wall.paths.push_back(std::move(tine)); + polygons_append(wall.footprint, std::move(footprint)); + } + }; + const Line left(wall.paths[wall.paths.size() - 2].front(), wall.paths[wall.paths.size() - 2].back()); + const Line right(wall.paths.back().front(), wall.paths.back().back()); + add_side(left.a, left.b, -normal); + add_side(right.a, right.b, normal); +} + +FinWall build_wall(const PrintObject &object, const Line &run, size_t top, const std::vector &flows, + const ExPolygons &bed, const FinSupportRegions ®ions, const std::vector &accepted, + const std::vector &in_region) +{ + const Vec2d heading = (run.b - run.a).cast().normalized(); + const Vec2d normal(-heading.y(), heading.x()); + const double clearance = scale_(std::max(wall_clearance, object.config().support_object_xy_distance.value)); + const Polygons no_blockers; + FinWall wall; + wall.layers.reserve(top + 1); + double next_tine_z = foot_height; + for (size_t i = 0; i <= top; ++i) { + if (i % 32 == 0) + check_cancellation(object); + const Layer &layer = *object.layers()[i]; + const Flow &flow = flows[i]; + const double width = flow.scaled_width(); + const bool tip = i == top && i > 0; + WallLayer plan; + plan.paths = wall_paths(run, normal, flow, layer, tip); + Polygons occupied = accepted[i].footprint; + for (const FinWall &neighbor : in_region) + if (i < neighbor.layers.size()) + polygons_append(occupied, neighbor.layers[i].footprint); + const Polygons &blockers = i < regions.blockers.size() ? regions.blockers[i] : no_blockers; + + Polygons clearance_shape; + for (const Polyline &line : plan.paths) { + append_stroke(plan.footprint, line, 0.5 * width); + append_stroke(clearance_shape, line, 0.5 * width + clearance); + } + plan.footprint = union_(plan.footprint); + if (!intersection(layer.lslices, union_(clearance_shape)).empty() || + !diff(plan.footprint, bed).empty() || overlaps(plan.footprint, occupied) || + overlaps(plan.footprint, blockers)) + return {}; + + if (!tip && layer.print_z + EPSILON >= next_tine_z) { + add_tines(plan, normal, width, scale_(flow.spacing()), layer, blockers, bed, occupied); + next_tine_z = layer.print_z + tine_pitch; + } + wall.layers.push_back(std::move(plan)); + } + wall.coverage = stroke(Polyline(run.a, run.b), scale_(0.5 * fin_pitch) + flows[top].scaled_width()); + return wall; +} + +bool sufficiently_covered(const ExPolygon ®ion, const Polygons &covered, double bead_width) +{ + // Do not reject a wall for the sub-bead slivers left by rounded ends. + const ExPolygons missed = diff_ex(region, union_ex(covered)); + return area(missed) <= 0.1 * region.area() && offset_ex(missed, -0.5 * bead_width).empty(); +} + +} // namespace + +bool generate_fin_support_walls(PrintObject &object, const FinSupportRegions ®ions) +{ + if (std::all_of(regions.overhangs.begin(), regions.overhangs.end(), [](const Polygons &p) { return p.empty(); })) + return true; + const auto layers = object.layers(); + // This generator seats the walls on the build plate, so it needs an + // object layer grid starting at the bed. + if (layers.empty() || layers.front()->bottom_z() > EPSILON) + return false; + const ExPolygons bed = available_bed(object); + if (bed.empty()) + return false; + + std::vector flows; + flows.reserve(layers.size()); + for (size_t i = 0; i < layers.size(); ++i) + flows.push_back(i == 0 ? support_material_1st_layer_flow(&object, float(layers[i]->height)) : + support_material_flow(&object, float(layers[i]->height))); + std::vector accepted(layers.size()); + std::vector coverage_by_layer(layers.size()); + size_t projected_layers = 0; + Polygons lower_keepout; + double seat_margin = 0.; + const double xy_gap = scale_(std::max(wall_clearance, object.config().support_object_xy_distance.value)); + const double z_gap = std::max(0., object.config().support_top_z_distance.value); + const auto &print_config = object.print()->config(); + const auto &height_limits = print_config.extruder_printable_height.values; + double height_limit = print_config.printable_height.value; + for (const double limit : height_limits) + if (limit > 0.) + height_limit = std::min(height_limit, limit); + + for (size_t i = 1; i < regions.overhangs.size(); ++i) { + check_cancellation(object); + if (regions.overhangs[i].empty()) + continue; + const double contact_z = layers[i]->bottom_z(); + const double top_limit = contact_z - z_gap; + size_t end = i; + while (end > 0 && layers[end - 1]->print_z > top_limit + EPSILON) + --end; + if (end == 0 || layers[end - 1]->print_z > height_limit || + contact_z - layers[end - 1]->print_z > z_gap + layers[end]->height + EPSILON) + return false; + const size_t top = end - 1; + + for (; projected_layers < end; ++projected_layers) { + const size_t z = projected_layers; + const double wall_radius = flows[z].scaled_width() * 0.5 + scale_(flows[z].spacing()) + xy_gap + scale_(0.02); + seat_margin = std::max(seat_margin, wall_radius); + polygons_append(lower_keepout, offset(layers[z]->lslices, wall_radius)); + lower_keepout = union_(lower_keepout); + } + + for (const ExPolygon ®ion : union_ex(regions.overhangs[i])) { + const double width = flows[top].scaled_width(); + Polygons &covered = coverage_by_layer[top]; + if (sufficiently_covered(region, covered, width)) + continue; + const ExPolygons remaining = diff_ex(region, union_ex(covered)); + const Lines edges = region.contour.lines(); + const auto longest = std::max_element(edges.begin(), edges.end(), [](const Line &a, const Line &b) { + return a.length() < b.length(); + }); + if (longest == edges.end()) + return false; + const Vec2d direction = (longest->b - longest->a).cast(); + const double heading = std::atan2(direction.y(), direction.x()); + + std::vector walls; + Polygons trial_coverage; + bool fits = false; + for (int attempt = 0; attempt < 4; ++attempt) { + const double angle = attempt < 2 ? heading : heading + PI * 0.5; + walls.clear(); + trial_coverage = covered; + ExPolygons rotated = remaining; + for (ExPolygon &patch : rotated) + patch.rotate(-angle); + const BoundingBox bounds = get_extents(rotated); + const double span = double(bounds.size().y()); + const double pitch = scale_(fin_pitch); + // Try a row just beyond the foot clearance so its tines can + // reach the overhang's side. Fall back to the centered grid. + const double inset = std::min(0.5 * span, seat_margin + scale_(0.06)); + const bool edge_rows = attempt % 2 == 0 && span > 2. * inset; + const int rows = edge_rows ? 1 + int(std::ceil((span - 2. * inset) / pitch)) : + std::max(1, int(std::ceil(span / pitch))); + for (int row = 0; row < rows; ++row) { + check_cancellation(object); + const double offset = edge_rows ? inset + row * (span - 2. * inset) / (rows - 1) : + (row + 0.5) * span / rows; + const coord_t y = bounds.min.y() + coord_t(offset); + const Polyline scan(Point(bounds.min.x() - 1, y), Point(bounds.max.x() + 1, y)); + for (Polyline segment : intersection_pl(scan, rotated)) { + segment.rotate(angle); + for (const Polyline &clear : diff_pl(segment, lower_keepout)) { + if (clear.length() < std::max(scale_(1.2), 3. * width)) + continue; + FinWall wall = build_wall(object, Line(clear.front(), clear.back()), top, flows, + bed, regions, accepted, walls); + if (wall.layers.empty()) + continue; + polygons_append(trial_coverage, wall.coverage); + walls.push_back(std::move(wall)); + } + } + } + if ((fits = sufficiently_covered(region, trial_coverage, width))) + break; + } + if (!fits) + return false; + + covered = union_(trial_coverage); + for (FinWall &wall : walls) + for (size_t z = 0; z < wall.layers.size(); ++z) { + polygons_append(accepted[z].footprint, std::move(wall.layers[z].footprint)); + for (Polyline &path : wall.layers[z].paths) + accepted[z].paths.push_back(std::move(path)); + } + } + } + + check_cancellation(object); + int support_layer_id = 0; + for (size_t i = 0; i < accepted.size(); ++i) { + if (accepted[i].paths.empty()) + continue; + SupportLayer *support = object.add_support_layer(support_layer_id++, 0, layers[i]->height, layers[i]->print_z); + support->support_islands = union_ex(accepted[i].footprint); + const Flow &flow = flows[i]; + for (Polyline &polyline : accepted[i].paths) { + ExtrusionPath path(erSupportMaterial, flow.mm3_per_mm(), flow.width(), flow.height()); + path.polyline = std::move(polyline); + support->support_fills.append(std::move(path)); + } + } + return true; +} + +} // namespace Slic3r diff --git a/src/libslic3r/Support/FinSupport.hpp b/src/libslic3r/Support/FinSupport.hpp new file mode 100644 index 0000000000..6338c521ea --- /dev/null +++ b/src/libslic3r/Support/FinSupport.hpp @@ -0,0 +1,20 @@ +#ifndef slic3r_FinSupport_hpp_ +#define slic3r_FinSupport_hpp_ + +#include "libslic3r/Polygon.hpp" + +namespace Slic3r { + +class PrintObject; + +struct FinSupportRegions { + std::vector overhangs; + std::vector blockers; +}; + +// Install fin paths only after all meaningful overhangs have support. +bool generate_fin_support_walls(PrintObject &object, const FinSupportRegions ®ions); + +} // namespace Slic3r + +#endif diff --git a/src/libslic3r/Support/SupportMaterial.cpp b/src/libslic3r/Support/SupportMaterial.cpp index 510a3cd0e2..a940c61dd8 100644 --- a/src/libslic3r/Support/SupportMaterial.cpp +++ b/src/libslic3r/Support/SupportMaterial.cpp @@ -4,6 +4,7 @@ #include "Layer.hpp" #include "Print.hpp" #include "SupportMaterial.hpp" +#include "FinSupport.hpp" #include "SupportCommon.hpp" #include "Geometry.hpp" #include "Point.hpp" @@ -1373,7 +1374,8 @@ static inline ExPolygons detect_overhangs( Polygons overhang_polygons; // BBS. - const bool auto_normal_support = object_config.support_type.value == stNormalAuto; + const bool auto_normal_support = object_config.support_type.value == stNormalAuto || + object_config.support_type.value == stFinsAuto; const bool buildplate_only = ! annotations.buildplate_covered.empty(); // If user specified a custom angle threshold, convert it to radians. // Zero means automatic overhang detection. @@ -2087,8 +2089,19 @@ static OverhangCluster* add_overhang(std::vector& clusters, ExP // Generate top contact layers supporting overhangs. // For a soluble interface material synchronize the layer heights with the object, otherwise leave the layer height undefined. // If supports over bed surface only are requested, don't generate contact layers over an object. +bool PrintObjectSupportMaterial::generate_fins(PrintObject &object) const +{ + FinSupportRegions regions; + SupportGeneratorLayerStorage unused_storage; + this->top_contact_layers(object, this->buildplate_covered(object), unused_storage, ®ions); + if (object.print()->canceled()) + throw CanceledException(); + return generate_fin_support_walls(object, regions); +} + SupportGeneratorLayersPtr PrintObjectSupportMaterial::top_contact_layers( - const PrintObject &object, const std::vector &buildplate_covered, SupportGeneratorLayerStorage &layer_storage) const + const PrintObject &object, const std::vector &buildplate_covered, SupportGeneratorLayerStorage &layer_storage, + FinSupportRegions *fin_regions) const { #ifdef SLIC3R_DEBUG static int iRun = 0; @@ -2098,7 +2111,8 @@ SupportGeneratorLayersPtr PrintObjectSupportMaterial::top_contact_layers( // BBS: tree support is selected so normal supports need not be generated. // Note we still need to go through the following steps if support is disabled but raft is enabled. - if (m_object_config->enable_support.value && (m_object_config->support_type.value != stNormalAuto && m_object_config->support_type.value != stNormal)) { + const bool fins = m_object_config->support_type.value == stFinsAuto; + if (m_object_config->enable_support.value && is_tree(m_object_config->support_type.value)) { return SupportGeneratorLayersPtr(); } @@ -2114,13 +2128,20 @@ SupportGeneratorLayersPtr PrintObjectSupportMaterial::top_contact_layers( // If having a raft, start with 0th layer, otherwise with 1st layer. // Note that layer_id < layer->id when raft_layers > 0 as the layer->id incorporates the raft layers. // So layer_id == 0 means first object layer and layer->id == 0 means first print layer if there are no explicit raft layers. - size_t num_layers = this->has_support() ? object.layer_count() : 1; + // A normal generation pass on an object using Fins only generates a requested raft. + size_t num_layers = this->has_support() && (!fins || fin_regions) ? object.layer_count() : 1; + if (fin_regions) + for (const Layer *layer : object.layers()) { + layer->sharp_tails.clear(); + layer->sharp_tails_height.clear(); + layer->cantilevers.clear(); + } // For each overhang layer, two supporting layers may be generated: One for the overhangs extruded with a bridging flow, // and the other for the overhangs extruded with a normal flow. contact_out.assign(num_layers * 2, nullptr); std::vector overhangs_per_layers(num_layers); - size_t layer_id_start = this->has_raft() ? 0 : 1; + size_t layer_id_start = this->has_raft() && !fin_regions ? 0 : 1; // main part of overhang detection can be parallel tbb::parallel_for(tbb::blocked_range(layer_id_start, num_layers), [&](const tbb::blocked_range& range) { @@ -2302,6 +2323,9 @@ SupportGeneratorLayersPtr PrintObjectSupportMaterial::top_contact_layers( if (object.print()->canceled()) return SupportGeneratorLayersPtr(); + if (fin_regions) + fin_regions->overhangs.resize(num_layers); + for (size_t layer_id = layer_id_start; layer_id < num_layers; layer_id++) { const Layer& layer = *object.layers()[layer_id]; Polygons overhang_polygons = to_polygons(overhangs_per_layers[layer_id]); @@ -2315,6 +2339,14 @@ SupportGeneratorLayersPtr PrintObjectSupportMaterial::top_contact_layers( #endif // SLIC3R_DEBUG ); + if (fin_regions) { + overhang_polygons = intersection(layer.lslices, overhang_polygons); + if (!annotations.blockers_layers.empty()) + overhang_polygons = diff(overhang_polygons, annotations.blockers_layers[layer_id]); + fin_regions->overhangs[layer_id] = std::move(overhang_polygons); + continue; + } + // Now apply the contact areas to the layer where they need to be made. if (!contact_polygons.empty() || !overhang_polygons.empty()) { // Allocate the two empty layers. @@ -2344,6 +2376,11 @@ SupportGeneratorLayersPtr PrintObjectSupportMaterial::top_contact_layers( } } + if (fin_regions) { + fin_regions->blockers = std::move(annotations.blockers_layers); + return {}; + } + // Compress contact_out, remove the nullptr items. remove_nulls(contact_out); @@ -3147,7 +3184,7 @@ void PrintObjectSupportMaterial::trim_support_layers_by_object( bool is_overlap = is_layers_overlap(support_layer, object_layer); for (const ExPolygon& expoly : object_layer.lslices) { - // BBS + // BBS bool is_sharptail = overlaps({ expoly }, object_layer.sharp_tails); coordf_t trimming_offset = is_sharptail ? scale_(sharp_tail_xy_gap) : is_overlap ? gap_xy_scaled : diff --git a/src/libslic3r/Support/SupportMaterial.hpp b/src/libslic3r/Support/SupportMaterial.hpp index af09238fda..baa08da0f2 100644 --- a/src/libslic3r/Support/SupportMaterial.hpp +++ b/src/libslic3r/Support/SupportMaterial.hpp @@ -9,6 +9,8 @@ #include "SupportParameters.hpp" namespace Slic3r { +struct FinSupportRegions; + class PrintObject; class PrintConfig; class PrintObjectConfig; @@ -70,6 +72,7 @@ class PrintObjectSupportMaterial // New support layers will be added to the object, // with extrusion paths and islands filled in for each support layer. void generate(PrintObject &object); + bool generate_fins(PrintObject &object) const; private: std::vector buildplate_covered(const PrintObject &object) const; @@ -77,7 +80,8 @@ class PrintObjectSupportMaterial // Generate top contact layers supporting overhangs. // For a soluble interface material synchronize the layer heights with the object, otherwise leave the layer height undefined. // If supports over bed surface only are requested, don't generate contact layers over an object. - SupportGeneratorLayersPtr top_contact_layers(const PrintObject &object, const std::vector &buildplate_covered, SupportGeneratorLayerStorage &layer_storage) const; + SupportGeneratorLayersPtr top_contact_layers(const PrintObject &object, const std::vector &buildplate_covered, + SupportGeneratorLayerStorage &layer_storage, FinSupportRegions *fin_regions = nullptr) const; // Generate bottom contact layers supporting the top contact layers. // For a soluble interface material synchronize the layer heights with the object, diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index 45eccce500..1df1079078 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -818,18 +818,23 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, in bool have_support_material = config->opt_bool("enable_support") || have_raft; // BBS SupportType support_type = config->opt_enum("support_type"); - bool have_support_interface = config->opt_int("support_interface_top_layers") > 0 || config->opt_int("support_interface_bottom_layers") > 0; + const bool fins = support_type == stFinsAuto; + const bool have_support_interface = (!fins || have_raft) && + (config->opt_int("support_interface_top_layers") > 0 || config->opt_int("support_interface_bottom_layers") > 0); bool have_support_soluble = have_support_material && config->opt_float("support_top_z_distance") == 0; auto support_style = config->opt_enum("support_style"); - for (auto el : { "support_style", "support_base_pattern", - "support_base_pattern_spacing", "support_expansion", "support_angle", - "support_interface_pattern", "support_interface_top_layers", - "bridge_no_support", "max_bridge_length", "support_top_z_distance", "support_bottom_z_distance", + for (auto el : { "support_expansion", + "bridge_no_support", "max_bridge_length", "support_top_z_distance", //BBS: add more support params to dependent of enable_support "support_type", "support_on_build_plate_only", - "support_remove_small_overhang","support_interface_not_for_body", + "support_remove_small_overhang", "support_object_xy_distance","support_object_first_layer_gap"/*, "independent_support_layer_height"*/}) toggle_field(el, have_support_material); + toggle_field("support_style", have_support_material && !fins); + for (auto el : { "support_base_pattern", "support_base_pattern_spacing", "support_angle", + "support_interface_pattern", "support_interface_top_layers", "support_interface_bottom_layers", + "support_bottom_interface_spacing", "support_bottom_z_distance", "support_interface_not_for_body" }) + toggle_field(el, have_support_material && (!fins || have_raft)); toggle_field("support_threshold_angle", have_support_material && is_auto(support_type)); //toggle_field("support_closing_radius", have_support_material && support_style == smsSnug); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 6dbc23f062..d9ee330b3c 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3920,6 +3920,7 @@ void TabFilament::build() optgroup->append_single_option_line("filament_diameter"); optgroup->append_single_option_line("filament_adhesiveness_category", "parameter/prime-tower#adhesiveness"); optgroup->append_single_option_line("filament_flow_ratio", "", 0); + optgroup->append_single_option_line("filament_initial_layer_flow_ratio", "", 0); optgroup->append_single_option_line("enable_pressure_advance"); optgroup->append_single_option_line("pressure_advance"); optgroup->append_single_option_line("filament_density"); From 7669b7ea976244e9deb30e8d65b5325088d58942 Mon Sep 17 00:00:00 2001 From: leroy ketelaars Date: Sat, 5 Dec 2026 12:00:14 +0100 Subject: [PATCH 02/10] Point the Boost patch at the source archive layout --- deps/Boost/Boost.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/deps/Boost/Boost.cmake b/deps/Boost/Boost.cmake index 8b217e32a3..b14ab965c7 100644 --- a/deps/Boost/Boost.cmake +++ b/deps/Boost/Boost.cmake @@ -11,11 +11,16 @@ if (APPLE AND CMAKE_OSX_ARCHITECTURES) message(STATUS "BOOST param: ${_context_abi_line} ${_context_arch_line}") endif () +set(_boost_process_dir "libs/process") +if (BINARY_DIR_REL) + set(_boost_process_dir "${BINARY_DIR_REL}/dep_Boost-prefix/src/dep_Boost/libs/process") +endif () + bambustudio_add_cmake_project(Boost URL "https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.gz" URL_HASH SHA256=4d27e9efed0f6f152dc28db6430b9d3dfb40c0345da7342eaa5a987dde57bd95 LIST_SEPARATOR | - PATCH_COMMAND git apply --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-FIX-OBS-cannot-start-streaming-on-MAC.patch + PATCH_COMMAND git apply -p3 --directory "${_boost_process_dir}" --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-FIX-OBS-cannot-start-streaming-on-MAC.patch CMAKE_ARGS -DBOOST_EXCLUDE_LIBRARIES:STRING=contract|fiber|numpy|wave|test -DBOOST_LOCALE_ENABLE_ICU:BOOL=OFF # do not link to libicu, breaks compatibility between distros @@ -24,4 +29,4 @@ bambustudio_add_cmake_project(Boost "${_context_arch_line}" ) -set(DEP_Boost_DEPENDS ZLIB) \ No newline at end of file +set(DEP_Boost_DEPENDS ZLIB) From acee69f049b656389e785dd899e66b5abf18c70f Mon Sep 17 00:00:00 2001 From: leroy ketelaars Date: Sat, 5 Dec 2026 12:01:56 +0100 Subject: [PATCH 03/10] Fix issues found in independent flow and Fins reviews --- src/BambuStudio.cpp | 46 +++++++-- src/libslic3r/Config.cpp | 6 ++ src/libslic3r/GCode.cpp | 13 ++- src/libslic3r/GCode.hpp | 2 +- src/libslic3r/Print.cpp | 16 ++- src/libslic3r/PrintApply.cpp | 13 ++- src/libslic3r/PrintBase.hpp | 3 +- src/libslic3r/PrintConfig.cpp | 4 + src/libslic3r/PrintObject.cpp | 3 +- src/libslic3r/ShortestPath.cpp | 4 +- src/libslic3r/Support/FinSupport.cpp | 141 ++++++++++++++++++++------ src/slic3r/GUI/ConfigManipulation.cpp | 14 ++- src/slic3r/GUI/Field.cpp | 20 +++- 13 files changed, 230 insertions(+), 55 deletions(-) diff --git a/src/BambuStudio.cpp b/src/BambuStudio.cpp index d106f1d666..654da7f672 100644 --- a/src/BambuStudio.cpp +++ b/src/BambuStudio.cpp @@ -22,10 +22,10 @@ #include #include #include +#include #if defined(__linux__) || defined(__LINUX__) #include -#include #include //add json logic #include "nlohmann/json.hpp" @@ -209,6 +209,13 @@ typedef struct _sliced_info { std::vector upward_compatibility_taint; }sliced_info_t; std::vector g_slicing_warnings; +static std::mutex slicing_warnings_mutex; + +static void collect_slicing_warning(const PrintBase::SlicingStatus &status) +{ + std::lock_guard lock(slicing_warnings_mutex); + g_slicing_warnings.push_back(status); +} #if defined(__linux__) || defined(__LINUX__) #define PIPE_BUFFER_SIZE 512 @@ -396,7 +403,7 @@ cli_callback_mgr_t g_cli_callback_mgr; void cli_status_callback(const PrintBase::SlicingStatus& slicing_status) { if (slicing_status.warning_step != -1) { - g_slicing_warnings.push_back(slicing_status); + collect_slicing_warning(slicing_status); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": percent=%1%, warning_step=%2%, message=%3%, message_type=%4%, flag=%5%") %slicing_status.percent %slicing_status.warning_step %slicing_status.text %(int)(slicing_status.message_type) %slicing_status.flags; } @@ -408,7 +415,7 @@ void cli_status_callback(const PrintBase::SlicingStatus& slicing_status) void default_status_callback(const PrintBase::SlicingStatus& slicing_status) { if (slicing_status.warning_step != -1) { - g_slicing_warnings.push_back(slicing_status); + collect_slicing_warning(slicing_status); } BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(": percent=%1%, warning_step=%2%, message=%3%, message_type=%4%")%slicing_status.percent %slicing_status.warning_step %slicing_status.text %(int)(slicing_status.message_type); @@ -3311,6 +3318,14 @@ int CLI::run(int argc, char **argv) } std::vector old_self_indice= filament_self_index_opt->values; + // The project can predate this option. Fill its missing variants before + // applying individual profiles so an omitted slot never borrows slot one's ratio. + constexpr auto initial_layer_flow_key = "filament_initial_layer_flow_ratio"; + auto &project_initial_layer_ratios = + m_print_config.option(initial_layer_flow_key, true)->values; + if (project_initial_layer_ratios.size() < old_self_indice.size()) + project_initial_layer_ratios.resize(old_self_indice.size(), default_initial_layer_flow_ratio); + int old_self_indice_size = old_self_indice.size(); int k = -1, current_filament = 0; for (size_t i = 0; i < old_self_indice_size; i++) { @@ -3384,6 +3399,10 @@ int CLI::run(int argc, char **argv) std::vector new_variant_indice; int new_variant_count = new_variant_opt->size(), old_variant_count = old_variant_counts[filament_index - 1]; new_variant_indice.resize(new_variant_count, -1); + auto &initial_layer_ratios = config.option(initial_layer_flow_key, true)->values; + const double profile_ratio = initial_layer_ratios.empty() ? + default_initial_layer_flow_ratio : initial_layer_ratios.front(); + initial_layer_ratios.resize(new_variant_count, profile_ratio); for (int i = 0; i < new_variant_count; i++) { @@ -6749,14 +6768,26 @@ int CLI::run(int argc, char **argv) } //check the warnings - if (!g_slicing_warnings.empty()) { - for (unsigned int i = 0; i < g_slicing_warnings.size(); i++) + std::vector slicing_warnings; + { + std::lock_guard lock(slicing_warnings_mutex); + slicing_warnings.swap(g_slicing_warnings); + } + bool has_fins_warning = false; + for (const PrintBase::SlicingStatus &status : slicing_warnings) { - PrintBase::SlicingStatus& status = g_slicing_warnings[i]; if ((status.warning_step != -1) && (status.message_type != PrintStateBase::SlicingDefaultNotification)) { - sliced_plate_info.warning_message = status.text; + if (status.message_type == PrintStateBase::SlicingFinsCoverageIncomplete) { + if (!has_fins_warning) + sliced_plate_info.warning_message = status.text; + else + sliced_plate_info.warning_message += "\n" + status.text; + has_fins_warning = true; + } else if (!has_fins_warning) { + sliced_plate_info.warning_message = status.text; + } if (status.warning_level == PrintStateBase::WarningLevel::NON_CRITICAL) { BOOST_LOG_TRIVIAL(warning) << "plate "<< index+1<< ": found NON_CRITICAL slicing warnings: "<option(opt_key, true); assert(opt != nullptr); + // Older input may omit this setting or provide an empty array. Preserve + // the neutral default so variant mapping can always read a value. + if (!append && value.empty() && opt_key == "filament_initial_layer_flow_ratio") { + opt->set(optdef->default_value.get()); + return true; + } bool success = false; bool substituted = false; if (optdef->type == coBools && substitutions_ctxt.rule != ForwardCompatibilitySubstitutionRule::Disable) { diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index ebfa259664..9835b288dc 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -4651,7 +4651,11 @@ GCode::LayerResult GCode::process_layer( bool is_overridden = support_extrusion_role == erSupportMaterialInterface ? support_intf_overridden : support_overridden; if (is_overridden == (print_wipe_extrusions != 0)) { // support_extrusion_role is erSupportMaterial, erSupportTransition, erSupportMaterialInterface or erMixed for all extrusion paths. - gcode += this->extrude_support(instance_to_print.object_by_extruder.support->chained_path_from(m_last_pos, support_extrusion_role)); + const bool preserve_fin_order = instance_to_print.print_object.config().support_type.value == stFinsAuto && + !instance_to_print.print_object.has_raft(); + gcode += this->extrude_support( + instance_to_print.object_by_extruder.support->chained_path_from(m_last_pos, support_extrusion_role), + preserve_fin_order); if (support_extrusion_role == erSupportMaterialInterface) { // erSupportMaterialInterface may be mixed with erSupportIroning, thus, should also make ironing here gcode += this->extrude_support(instance_to_print.object_by_extruder.support->chained_path_from(m_last_pos, erSupportIroning)); @@ -5411,7 +5415,7 @@ std::string GCode::extrude_infill(const Print &print, const std::vectorextrude_loop(*loop, label, speed); } else if (collection) { - gcode += extrude_support(*collection); + gcode += extrude_support(*collection, preserve_fin_order); } else { throw Slic3r::InvalidArgument("Unknown extrusion type"); } diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index 156c43768f..ad2c2f09d8 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -478,7 +478,7 @@ class GCode { std::string extrude_perimeters(const Print &print, const std::vector &by_region); std::string extrude_infill(const Print &print, const std::vector &by_region, bool ironing); - std::string extrude_support(const ExtrusionEntityCollection &support_fills); + std::string extrude_support(const ExtrusionEntityCollection &support_fills, bool preserve_fin_order = false); std::string travel_to(const Point &point, ExtrusionRole role, std::string comment, double z = DBL_MAX); diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 77276a5517..b841efb3d0 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1804,8 +1804,13 @@ void Print::process(std::unordered_map* slice_time, bool for (PrintObject *obj : m_objects) obj->clear_shared_object(); - //add the print_object share check logic - auto is_print_object_the_same = [this](const PrintObject* object1, const PrintObject* object2) -> bool{ + const auto uses_fins = [](const PrintObject *object) { + return object->has_support() && object->config().support_type.value == stFinsAuto; + }; + // Fins depend on bed and neighboring object clearance at each placement. + auto is_print_object_the_same = [uses_fins](const PrintObject* object1, const PrintObject* object2) -> bool{ + if (uses_fins(object1) || uses_fins(object2)) + return false; if (object1->trafo().matrix() != object2->trafo().matrix()) return false; const ModelObject* model_obj1 = object1->model_object(); @@ -1880,12 +1885,17 @@ void Print::process(std::unordered_map* slice_time, bool for (int index = 0; index < object_count; index++) { PrintObject *obj = m_objects[index]; - if (obj->layer_count() > 0) + if (obj->layer_count() > 0 && !uses_fins(obj)) need_slicing_objects.insert(obj); } for (int index = 0; index < object_count; index++) { PrintObject *obj = m_objects[index]; + if (uses_fins(obj)) { + need_slicing_objects.insert(obj); + m_reslicing_objects.insert(obj); + continue; + } bool found_shared = false; if (need_slicing_objects.find(obj) == need_slicing_objects.end()) { for (PrintObject *slicing_obj : need_slicing_objects) diff --git a/src/libslic3r/PrintApply.cpp b/src/libslic3r/PrintApply.cpp index a80d68e2e4..b591cf10d9 100644 --- a/src/libslic3r/PrintApply.cpp +++ b/src/libslic3r/PrintApply.cpp @@ -1417,6 +1417,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ // 1) Synchronize model objects. bool print_regions_reshuffled = false; + bool fin_neighbors_changed = false; if (model.id() != m_model.id()) { // Kill everything, initialize from scratch. // Stop background processing. @@ -1499,6 +1500,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ // Do not delete this ModelObject instance. model_object = nullptr; if (deleted_any) { + fin_neighbors_changed = true; // Delete PrintObjects of the deleted ModelObjects. PrintObjectPtrs print_objects_old = std::move(m_objects); m_objects.clear(); @@ -1603,6 +1605,11 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ for (const PrintObjectStatus &print_object_status : print_object_status_db.get_range(model_object)) { t_config_option_keys diff = print_object_status.print_object->config().diff(new_config); if (! diff.empty()) { + fin_neighbors_changed |= std::any_of(diff.begin(), diff.end(), [](const t_config_option_key &key) { + return key == "brim_type" || key == "brim_width" || key == "brim_object_gap" || + key == "raft_layers" || key == "raft_expansion" || key == "raft_first_layer_expansion" || + key == "enable_support" || key == "enforce_support_layers" || key == "support_type"; + }); update_apply_status(print_object_status.print_object->invalidate_state_by_config_options(print_object_status.print_object->config(), new_config, diff)); print_object_status.print_object->config_apply_only(new_config, diff, true); } @@ -1734,10 +1741,12 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ } print_object_status_db.clear(); - const bool fin_bed_changed = instance_layout_changed || + const bool fin_bed_changed = instance_layout_changed || fin_neighbors_changed || print_diff_set.count("printable_area") || print_diff_set.count("printable_height") || print_diff_set.count("bed_exclude_area") || print_diff_set.count("extruder_printable_area") || - print_diff_set.count("extruder_printable_height"); + print_diff_set.count("extruder_printable_height") || print_diff_set.count("filament_map") || + print_diff_set.count("filament_map_mode") || print_diff_set.count("nozzle_diameter") || + print_diff_set.count("initial_layer_line_width"); if (fin_bed_changed) for (PrintObject *object : m_objects) if (object->config().support_type.value == stFinsAuto) diff --git a/src/libslic3r/PrintBase.hpp b/src/libslic3r/PrintBase.hpp index f7039fd374..38ea130eb9 100644 --- a/src/libslic3r/PrintBase.hpp +++ b/src/libslic3r/PrintBase.hpp @@ -63,7 +63,8 @@ class PrintStateBase { SlicingReplaceInitEmptyLayers, SlicingNeedSupportOn, SlicingEmptyGcodeLayers, - SlicingGcodeOverlap + SlicingGcodeOverlap, + SlicingFinsCoverageIncomplete }; typedef size_t TimeStamp; diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index c9f8832aea..e1091dee1c 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -6927,6 +6927,10 @@ void DynamicPrintConfig::normalize_fdm() //BBS:divide normalize_fdm to 2 steps and call them one by one in Print::Apply void DynamicPrintConfig::normalize_fdm_1() { + if (auto *ratios = this->opt("filament_initial_layer_flow_ratio", false); + ratios && ratios->values.empty()) + ratios->values.push_back(default_initial_layer_flow_ratio); + if (this->has("extruder")) { int extruder = this->option("extruder")->getInt(); this->erase("extruder"); diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 7e2f16da6b..b23562ebdc 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -3690,7 +3690,8 @@ void PrintObject::_generate_support_material() L("Fin supports could not be generated for all required overhangs on %s. Choose another support type for this print."), this->model_object()->name); BOOST_LOG_TRIVIAL(warning) << warning; - this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, warning); + this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, warning, + PrintStateBase::SlicingFinsCoverageIncomplete); } if (has_raft()) support_material.generate(*this); diff --git a/src/libslic3r/ShortestPath.cpp b/src/libslic3r/ShortestPath.cpp index ce45376757..4ded06f77c 100644 --- a/src/libslic3r/ShortestPath.cpp +++ b/src/libslic3r/ShortestPath.cpp @@ -1031,7 +1031,9 @@ void reorder_extrusion_entities(std::vector &entities, const s void chain_and_reorder_extrusion_entities(std::vector &entities, const Point *start_near) { // this function crashes if there are empty elements in entities - entities.erase(std::remove_if(entities.begin(), entities.end(), [](ExtrusionEntity *entity) { return static_cast(entity)->empty(); }), + entities.erase(std::remove_if(entities.begin(), entities.end(), [](ExtrusionEntity *entity) { + return entity->is_collection() && static_cast(entity)->empty(); + }), entities.end()); reorder_extrusion_entities(entities, chain_extrusion_entities(entities, start_near)); } diff --git a/src/libslic3r/Support/FinSupport.cpp b/src/libslic3r/Support/FinSupport.cpp index 507c538fb5..6f9353e9eb 100644 --- a/src/libslic3r/Support/FinSupport.cpp +++ b/src/libslic3r/Support/FinSupport.cpp @@ -7,6 +7,7 @@ #include #include +#include namespace Slic3r { namespace { @@ -21,6 +22,12 @@ constexpr double tine_pitch = 3.; struct WallLayer { Polylines paths; Polygons footprint; + size_t body_path_count = 0; +}; + +struct AcceptedLayer { + ExtrusionEntityCollection fills; + Polygons footprint; }; struct FinWall { @@ -41,7 +48,9 @@ Point displaced(const Point &point, const Vec2d &direction, double distance) Polygons stroke(const Polyline &line, double radius) { - return offset(line, float(radius), ClipperLib::jtRound, DefaultLineMiterLimit, ClipperLib::etOpenRound); + // Keep round ends accurate at print scale without sub-micron vertices. + const double arc_tolerance = std::min(scale_(0.005), 0.02 * radius); + return offset(line, float(radius), ClipperLib::jtRound, arc_tolerance, ClipperLib::etOpenRound); } void append_stroke(Polygons &polygons, const Polyline &line, double radius) @@ -49,16 +58,52 @@ void append_stroke(Polygons &polygons, const Polyline &line, double radius) polygons_append(polygons, stroke(line, radius)); } +std::optional fin_support_extruder(const PrintObject &object) +{ + const Print &print = *object.print(); + const auto &config = print.config(); + const size_t extruder_count = config.nozzle_diameter.size(); + if (extruder_count == 1) + return 0; + + // Automatic mapping is resolved after support generation. + const FilamentMapMode mode = print.get_filament_map_mode(); + const int filament = object.config().support_filament.value; + if (filament > 0 && size_t(filament) <= config.filament_map.size() && + (mode == fmmManual || mode == fmmNozzleManual)) { + const size_t extruder = print.get_extruder_id(filament - 1); + if (extruder < extruder_count) + return extruder; + } + return std::nullopt; +} + +double neighbor_margin(const PrintObject &neighbor) +{ + const auto &config = neighbor.config(); + const BrimType brim_type = config.brim_type.value; + const double brim = brim_type == btNoBrim || brim_type == btInnerOnly ? 0. : + std::max(0., config.brim_width.value) + std::max(0., config.brim_object_gap.value); + const double raft = neighbor.has_raft() ? std::max(0., config.raft_expansion.value) : 0.; + const double base = neighbor.has_raft() || (neighbor.has_support() && config.support_type.value != stFinsAuto) ? + std::max(0., config.raft_first_layer_expansion.value) : 0.; + return std::max(fin_pitch, brim + raft + base + wall_clearance); +} + // Each copy shares toolpaths, so a wall must fit under every instance's // transform. Leave breathing room around neighboring objects and their fins. -ExPolygons available_bed(const PrintObject &object) +ExPolygons available_bed(const PrintObject &object, std::optional extruder) { const Print &print = *object.print(); const PrintConfig &config = print.config(); Polygons bed{Polygon::new_scale(config.printable_area.values)}; - for (const auto &area : config.extruder_printable_area.values) - if (area.size() >= 3) + const auto &reach = config.extruder_printable_area.values; + const bool known_reach = extruder && *extruder < reach.size(); + for (size_t i = 0; i < reach.size(); ++i) { + const auto &area = reach[i]; + if ((!known_reach || i == *extruder) && area.size() >= 3) bed = intersection(bed, Polygons{Polygon::new_scale(area)}); + } const auto &excluded = config.bed_exclude_area.values; for (size_t i = 0; i + 3 < excluded.size(); i += 4) { @@ -69,7 +114,6 @@ ExPolygons available_bed(const PrintObject &object) ExPolygons common; bool first = true; - const Point margin(scale_(fin_pitch), scale_(fin_pitch)); for (const PrintInstance &instance : object.instances()) { const Point shift = instance.shift_without_plate_offset(); Polygons local_bed = bed; @@ -77,6 +121,8 @@ ExPolygons available_bed(const PrintObject &object) poly.translate(-shift); Polygons neighbors; for (const PrintObject *other : print.objects()) { + const coord_t clearance = scale_(neighbor_margin(*other)); + const Point margin(clearance, clearance); for (const PrintInstance &neighbor : other->instances()) { if (&neighbor == &instance) continue; @@ -93,6 +139,26 @@ ExPolygons available_bed(const PrintObject &object) return common; } +double layer_clearance(const PrintObjectConfig &config, bool first_layer) +{ + const double requested = first_layer ? config.support_object_first_layer_gap.value : + config.support_object_xy_distance.value; + return scale_(std::max(wall_clearance, requested)); +} + +Flow fin_layer_flow(const PrintObject &object, const Layer &layer, bool first_layer, std::optional extruder) +{ + if (!extruder) + return first_layer ? support_material_1st_layer_flow(&object, float(layer.height)) : + support_material_flow(&object, float(layer.height)); + + const PrintConfig &print_config = object.print()->config(); + const auto &support_width = first_layer && print_config.initial_layer_line_width.value > 0 ? + print_config.initial_layer_line_width : object.config().support_line_width; + return Flow::new_from_config_width(frSupportMaterial, support_width.value > 0 ? support_width : object.config().line_width, + float(print_config.nozzle_diameter.get_at(*extruder)), float(layer.height)); +} + Polylines wall_paths(const Line &run, const Vec2d &normal, const Flow &flow, const Layer &layer, bool tip) { if (tip) @@ -150,12 +216,11 @@ void add_tines(WallLayer &wall, const Vec2d &normal, double width, double spacin } FinWall build_wall(const PrintObject &object, const Line &run, size_t top, const std::vector &flows, - const ExPolygons &bed, const FinSupportRegions ®ions, const std::vector &accepted, + const ExPolygons &bed, const FinSupportRegions ®ions, const std::vector &accepted, const std::vector &in_region) { const Vec2d heading = (run.b - run.a).cast().normalized(); const Vec2d normal(-heading.y(), heading.x()); - const double clearance = scale_(std::max(wall_clearance, object.config().support_object_xy_distance.value)); const Polygons no_blockers; FinWall wall; wall.layers.reserve(top + 1); @@ -166,9 +231,11 @@ FinWall build_wall(const PrintObject &object, const Line &run, size_t top, const const Layer &layer = *object.layers()[i]; const Flow &flow = flows[i]; const double width = flow.scaled_width(); + const double clearance = layer_clearance(object.config(), i == 0); const bool tip = i == top && i > 0; WallLayer plan; plan.paths = wall_paths(run, normal, flow, layer, tip); + plan.body_path_count = plan.paths.size(); Polygons occupied = accepted[i].footprint; for (const FinWall &neighbor : in_region) if (i < neighbor.layers.size()) @@ -186,7 +253,7 @@ FinWall build_wall(const PrintObject &object, const Line &run, size_t top, const overlaps(plan.footprint, blockers)) return {}; - if (!tip && layer.print_z + EPSILON >= next_tine_z) { + if (i > 0 && !tip && layer.print_z + EPSILON >= next_tine_z) { add_tines(plan, normal, width, scale_(flow.spacing()), layer, blockers, bed, occupied); next_tine_z = layer.print_z + tine_pitch; } @@ -203,6 +270,29 @@ bool sufficiently_covered(const ExPolygon ®ion, const Polygons &covered, doub return area(missed) <= 0.1 * region.area() && offset_ex(missed, -0.5 * bead_width).empty(); } +void append_wall(AcceptedLayer &accepted, WallLayer &&wall, const Flow &flow) +{ + polygons_append(accepted.footprint, std::move(wall.footprint)); + const bool has_tines = wall.body_path_count < wall.paths.size(); + ExtrusionEntityCollection ordered_wall; + ordered_wall.no_sort = true; + ExtrusionEntityCollection &fills = has_tines ? ordered_wall : accepted.fills; + for (size_t i = 0; i < wall.paths.size(); ++i) { + if (i < wall.body_path_count) { + ExtrusionPath path(erSupportMaterial, flow.mm3_per_mm(), flow.width(), flow.height()); + path.polyline = std::move(wall.paths[i]); + fills.append(std::move(path)); + } else { + ExtrusionPathOriented tine(erSupportMaterial, flow.mm3_per_mm(), flow.width(), flow.height()); + tine.polyline = std::move(wall.paths[i]); + fills.append(std::move(tine)); + } + } + // Lay the wall before its tines, then print the tines root to tip. + if (has_tines) + accepted.fills.append(std::move(ordered_wall)); +} + } // namespace bool generate_fin_support_walls(PrintObject &object, const FinSupportRegions ®ions) @@ -214,28 +304,28 @@ bool generate_fin_support_walls(PrintObject &object, const FinSupportRegions &re // object layer grid starting at the bed. if (layers.empty() || layers.front()->bottom_z() > EPSILON) return false; - const ExPolygons bed = available_bed(object); + const auto extruder = fin_support_extruder(object); + const ExPolygons bed = available_bed(object, extruder); if (bed.empty()) return false; std::vector flows; flows.reserve(layers.size()); for (size_t i = 0; i < layers.size(); ++i) - flows.push_back(i == 0 ? support_material_1st_layer_flow(&object, float(layers[i]->height)) : - support_material_flow(&object, float(layers[i]->height))); - std::vector accepted(layers.size()); + flows.push_back(fin_layer_flow(object, *layers[i], i == 0, extruder)); + std::vector accepted(layers.size()); std::vector coverage_by_layer(layers.size()); size_t projected_layers = 0; Polygons lower_keepout; double seat_margin = 0.; - const double xy_gap = scale_(std::max(wall_clearance, object.config().support_object_xy_distance.value)); const double z_gap = std::max(0., object.config().support_top_z_distance.value); const auto &print_config = object.print()->config(); const auto &height_limits = print_config.extruder_printable_height.values; double height_limit = print_config.printable_height.value; - for (const double limit : height_limits) - if (limit > 0.) - height_limit = std::min(height_limit, limit); + const bool known_limit = extruder && *extruder < height_limits.size(); + for (size_t i = 0; i < height_limits.size(); ++i) + if ((!known_limit || i == *extruder) && height_limits[i] > 0.) + height_limit = std::min(height_limit, height_limits[i]); for (size_t i = 1; i < regions.overhangs.size(); ++i) { check_cancellation(object); @@ -253,7 +343,8 @@ bool generate_fin_support_walls(PrintObject &object, const FinSupportRegions &re for (; projected_layers < end; ++projected_layers) { const size_t z = projected_layers; - const double wall_radius = flows[z].scaled_width() * 0.5 + scale_(flows[z].spacing()) + xy_gap + scale_(0.02); + const double wall_radius = flows[z].scaled_width() * 0.5 + scale_(flows[z].spacing()) + + layer_clearance(object.config(), z == 0) + scale_(0.02); seat_margin = std::max(seat_margin, wall_radius); polygons_append(lower_keepout, offset(layers[z]->lslices, wall_radius)); lower_keepout = union_(lower_keepout); @@ -321,27 +412,19 @@ bool generate_fin_support_walls(PrintObject &object, const FinSupportRegions &re covered = union_(trial_coverage); for (FinWall &wall : walls) - for (size_t z = 0; z < wall.layers.size(); ++z) { - polygons_append(accepted[z].footprint, std::move(wall.layers[z].footprint)); - for (Polyline &path : wall.layers[z].paths) - accepted[z].paths.push_back(std::move(path)); - } + for (size_t z = 0; z < wall.layers.size(); ++z) + append_wall(accepted[z], std::move(wall.layers[z]), flows[z]); } } check_cancellation(object); int support_layer_id = 0; for (size_t i = 0; i < accepted.size(); ++i) { - if (accepted[i].paths.empty()) + if (accepted[i].fills.empty()) continue; SupportLayer *support = object.add_support_layer(support_layer_id++, 0, layers[i]->height, layers[i]->print_z); support->support_islands = union_ex(accepted[i].footprint); - const Flow &flow = flows[i]; - for (Polyline &polyline : accepted[i].paths) { - ExtrusionPath path(erSupportMaterial, flow.mm3_per_mm(), flow.width(), flow.height()); - path.polyline = std::move(polyline); - support->support_fills.append(std::move(path)); - } + support->support_fills = std::move(accepted[i].fills); } return true; } diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index 1df1079078..91fe76cbc9 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -12,6 +12,13 @@ namespace Slic3r { namespace GUI { +static bool has_support_ironing_interface(const DynamicPrintConfig &config) +{ + return config.opt_int("raft_layers") > 1 || + (config.opt_enum("support_type") != stFinsAuto && + config.opt_bool("enable_support") && config.opt_int("support_interface_top_layers") > 0); +} + void ConfigManipulation::apply(DynamicPrintConfig* config, DynamicPrintConfig* new_config) { bool modified = false; @@ -283,7 +290,9 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con apply(config, &new_conf); is_msg_dlg_already_exist = false; } - if (config->opt_float("support_ironing_spacing") < 0.05) { + const bool has_ironing_support = has_support_ironing_interface(*config); + if ((config->opt_enum("support_type") != stFinsAuto || has_ironing_support) && + config->opt_float("support_ironing_spacing") < 0.05) { const wxString msg_text = _(L("Too small support ironing spacing.\nReset to 0.1")); MessageDialog dialog(nullptr, msg_text, "", wxICON_WARNING | wxOK); DynamicPrintConfig new_conf = *config; @@ -295,7 +304,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con } // the ironing only works with solid interface - bool has_ironing_support = config->opt_int("raft_layers") > 1 || (config->opt_bool("enable_support") && config->opt_int("support_interface_top_layers") > 0); bool can_ironing_support = config->opt_float("support_interface_spacing") < EPSILON; can_ironing_support &= // where the grid alwasy was sparse, not works with ironing! config->opt_enum("support_interface_pattern") @@ -879,7 +887,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, in toggle_line(el, has_ironing); // has ironingable support interface - bool has_ironing_support = config->opt_int("raft_layers") > 1 || (config->opt_bool("enable_support") && config->opt_int("support_interface_top_layers") > 0); + const bool has_ironing_support = has_support_ironing_interface(*config); toggle_field("enable_support_ironing", has_ironing_support); for (auto el : {"support_ironing_pattern", "support_ironing_speed", "support_ironing_flow", "support_ironing_spacing", "support_ironing_direction", "support_ironing_inset"}) toggle_line(el, config->opt_bool("enable_support_ironing") && has_ironing_support); diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 123cb4e7fc..55ce4aa9ca 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -9,6 +9,8 @@ #include "libslic3r/PrintConfig.hpp" +#include +#include #include #include #include @@ -264,6 +266,9 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true } double val; + const auto *previous = boost::any_cast(&m_value); + const bool had_previous_value = previous != nullptr; + const double previous_value = previous ? *previous : std::numeric_limits::quiet_NaN(); bool is_na_value = m_opt.nullable && str == na_value(); const char dec_sep = is_decimal_separator_point() ? '.' : ','; @@ -279,14 +284,25 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true { if (is_na_value) val = ConfigOptionFloatsNullable::nil_value(); - else if (!str.ToDouble(&val)) + else if (!str.ToDouble(&val) || !std::isfinite(val)) { if (!check_value) { m_value.clear(); break; } show_error(m_parent, _(L("Invalid numeric."))); - set_value(double_to_string(val), true); + val = previous_value; + if (!had_previous_value || (!std::isfinite(val) && !(m_opt.nullable && std::isnan(val)))) { + if (m_opt.default_value->is_scalar()) { + val = m_opt.default_value->getFloat(); + } else { + const auto *defaults = static_cast *>(m_opt.default_value.get()); + val = defaults->empty() ? std::clamp(0., m_opt.min, m_opt.max) : defaults->get_at(m_opt_idx); + } + } + set_value(m_opt.nullable && std::isnan(val) ? na_value() : double_to_string(val), false); + m_value = val; + break; } if (m_opt.min > val || val > m_opt.max) { From ec60756a5e6beb3e6842c061e37a2ecf16c1d93e Mon Sep 17 00:00:00 2001 From: leroy ketelaars Date: Sat, 5 Dec 2026 12:57:34 +0100 Subject: [PATCH 04/10] Handle missing filament metadata when opening sliced projects --- src/slic3r/GUI/GCodeRenderer/BaseRenderer.cpp | 6 ++++++ src/slic3r/GUI/Plater.cpp | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GCodeRenderer/BaseRenderer.cpp b/src/slic3r/GUI/GCodeRenderer/BaseRenderer.cpp index 4ccd394bc0..f258691280 100644 --- a/src/slic3r/GUI/GCodeRenderer/BaseRenderer.cpp +++ b/src/slic3r/GUI/GCodeRenderer/BaseRenderer.cpp @@ -7,6 +7,7 @@ #include "slic3r/GUI/GLToolbar.hpp" #include "libslic3r/Print.hpp" #include "../Utils/HelioDragon.hpp" +#include #include #include namespace @@ -532,7 +533,12 @@ namespace Slic3r std::vector color_opt = print.config().option("filament_colour")->values; std::vector type_opt = print.config().option("filament_type")->values; std::vector support_filament_opt = print.config().option("filament_is_support")->values; + const size_t filament_metadata_count = std::min({ + filament_maps.size(), color_opt.size(), type_opt.size(), support_filament_opt.size() }); for (auto extruder_id : m_extruder_ids) { + // A loaded toolpath may use filaments outside the current print configuration. + if (extruder_id >= filament_metadata_count) + continue; if (filament_maps[extruder_id] == 1) { m_left_extruder_filament.push_back({ type_opt[extruder_id], color_opt[extruder_id], extruder_id, (bool)(support_filament_opt[extruder_id]) }); } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 81b1947a76..c1db22ff83 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -18342,7 +18342,9 @@ void Plater::record_slice_preset(std::string action) } auto filament_presets = wxGetApp().preset_bundle->filament_presets; for (int i = 0; i < filament_presets.size(); ++i) { - auto filament_preset = wxGetApp().preset_bundle->filaments.find_preset(filament_presets[i]); + const Preset *filament_preset = wxGetApp().preset_bundle->filaments.find_preset(filament_presets[i]); + if (filament_preset == nullptr) + continue; if (filament_preset->is_system) { j["filament_preset_" + std::to_string(i)] = filament_preset->name; } From d4f584fb5232a45081e391cf8e9dfea6414821bb Mon Sep 17 00:00:00 2001 From: leroy ketelaars Date: Sat, 5 Dec 2026 13:04:03 +0100 Subject: [PATCH 05/10] Expand legacy flow defaults to match filament variants --- src/libslic3r/Preset.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 53986b25c4..c304c6c7a4 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -399,6 +399,14 @@ void Preset::normalize(DynamicPrintConfig &config) // BBS size_t n = (filament_diameter == nullptr) ? 1 : filament_diameter->values.size(); const auto &defaults = FullPrintConfig::defaults(); + + // Older presets can list several variants while inheriting only one default flow ratio. + constexpr auto initial_layer_flow_key = "filament_initial_layer_flow_ratio"; + const auto *variants = config.option("filament_extruder_variant", false); + if (auto *ratios = config.option(initial_layer_flow_key, false); + ratios && variants && ratios->size() < variants->size()) + ratios->resize(variants->size(), defaults.option(initial_layer_flow_key)); + for (const std::string &key : Preset::filament_options()) { if (key == "compatible_prints" || key == "compatible_printers") continue; From c86f80897bcf050686124ce1918bfdc4c8ddf638 Mon Sep 17 00:00:00 2001 From: leroy ketelaars Date: Sat, 5 Dec 2026 15:42:29 +0100 Subject: [PATCH 06/10] Add automatic sway braces for Fins supports --- doc/Fins supports.md | 14 ++ src/libslic3r/Preset.cpp | 1 + src/libslic3r/PrintApply.cpp | 3 +- src/libslic3r/PrintConfig.cpp | 43 ++++ src/libslic3r/PrintConfig.hpp | 4 + src/libslic3r/PrintObject.cpp | 4 + src/libslic3r/Support/FinSupport.cpp | 284 +++++++++++++++++++++++++- src/slic3r/GUI/ConfigManipulation.cpp | 9 + src/slic3r/GUI/Tab.cpp | 4 + 9 files changed, 361 insertions(+), 5 deletions(-) diff --git a/doc/Fins supports.md b/doc/Fins supports.md index 78649348da..1266b9d534 100644 --- a/doc/Fins supports.md +++ b/doc/Fins supports.md @@ -6,6 +6,20 @@ Fins are placed automatically. They use the **Support/raft base** filament selec Fins need room to stand on the build plate and reach the overhang. A raft, obstructed footing, narrow opening or a nearby object can prevent placement. If Bambu Studio cannot cover all required overhangs for an object, it discards that object's fins and asks you to select another support type. Choose Normal or Tree and slice again. +## Sway braces + +In Advanced mode, enable **Sway braces** under **Process → Support** while using **fins(auto)**. Studio places tapered, plate-seated ribs beside suitable upright faces of tall parts, including parts that have no overhangs. Each rib grips its face at intervals with single-layer tines. The ribs use the object's **Support/raft base** filament. + +| Setting | Default | Effect | +| --- | ---: | --- | +| Brace grip from | 0 mm | Height above the plate where tines can start gripping. At zero, the first contact can start above the brace foot. | +| Brace tine spacing | 6 mm | Vertical distance between tines. Shorter spacing adds more contact points and can leave more marks. | +| Brace depth | 15% | Depth at the bed as a share of rib height. The rib tapers upward and has a 60 mm depth cap before the foot flange. | + +Sway braces start off. Studio skips candidate ribs that cannot get a clear seat and enough contacts. Inspect the toolpaths in **Preview** after slicing. + ## Credit The design is based on [Support Fins](https://github.com/gittrahan/support-fins) by **Matthew Trahan** ([gittrahan](https://github.com/gittrahan)), released under the [MIT License](https://github.com/gittrahan/support-fins/blob/a47cf47b5b0dc42a50ea3e42771c16636ca6b168/LICENSE). The Bambu Studio generator uses Trahan's [fin geometry specification](https://github.com/gittrahan/support-fins/blob/a47cf47b5b0dc42a50ea3e42771c16636ca6b168/docs/FIN-SPEC.md) as its reference for the foot, clearance and single-layer tines. The specification credits Slant3D for the underlying breakaway fin technique. + +Sway brace placement, taper and grip rules are based on Trahan's [Sway braces design](https://github.com/gittrahan/support-fins/blob/a47cf47b5b0dc42a50ea3e42771c16636ca6b168/docs/FIN-SPEC.md#sway-braces-tall-parts--webswayjs). diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index c304c6c7a4..4feaeff8aa 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -973,6 +973,7 @@ static std::vector s_Preset_print_options { "support_angle", "support_interface_top_layers", "support_interface_bottom_layers", "support_interface_pattern", "support_interface_spacing", "support_interface_loop_pattern", "support_top_z_distance", "support_on_build_plate_only","support_critical_regions_only", "support_remove_small_overhang", + "support_sway_braces", "support_sway_brace_grip_from", "support_sway_brace_tine_spacing", "support_sway_brace_depth", "bridge_no_support", "thick_bridges", "max_bridge_length", "print_sequence", "filename_format", "wall_filament", "support_bottom_z_distance", "sparse_infill_filament", "solid_infill_filament", "support_filament", "support_interface_filament","support_interface_not_for_body", diff --git a/src/libslic3r/PrintApply.cpp b/src/libslic3r/PrintApply.cpp index b591cf10d9..87c3aefaba 100644 --- a/src/libslic3r/PrintApply.cpp +++ b/src/libslic3r/PrintApply.cpp @@ -1608,7 +1608,8 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ fin_neighbors_changed |= std::any_of(diff.begin(), diff.end(), [](const t_config_option_key &key) { return key == "brim_type" || key == "brim_width" || key == "brim_object_gap" || key == "raft_layers" || key == "raft_expansion" || key == "raft_first_layer_expansion" || - key == "enable_support" || key == "enforce_support_layers" || key == "support_type"; + key == "enable_support" || key == "enforce_support_layers" || key == "support_type" || + key == "support_sway_braces"; }); update_apply_status(print_object_status.print_object->invalidate_state_by_config_options(print_object_status.print_object->config(), new_config, diff)); print_object_status.print_object->config_apply_only(new_config, diff, true); diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index e1091dee1c..4afadb2bfb 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -633,6 +633,45 @@ PrintConfigDef::PrintConfigDef() assign_printer_technology_to_unknown(this->options, ptFFF); this->init_sla_params(); assign_printer_technology_to_unknown(this->options, ptSLA); + + // Keep new options after the existing definitions to preserve serialized option IDs. + auto *def = this->add("support_sway_braces", coBool); + def->label = L("Sway braces"); + def->category = L("Support"); + def->tooltip = L("Automatically brace tall parts along upright sides with tapered ribs and breakaway tines."); + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionBool(false)); + + def = this->add("support_sway_brace_grip_from", coFloat); + def->label = L("Brace grip from"); + def->category = L("Support"); + def->tooltip = L("Height above the build plate where brace tines can start touching the part. At zero, tines can start just above the brace foot."); + def->sidetext = L("mm"); + def->min = 0; + def->max = 2000; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionFloat(0.)); + + def = this->add("support_sway_brace_tine_spacing", coFloat); + def->label = L("Brace tine spacing"); + def->category = L("Support"); + def->tooltip = L("Vertical spacing between brace tines. Closer tines hold the part at more points and can leave more marks."); + def->sidetext = L("mm"); + def->min = 2; + def->max = 30; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionFloat(6.)); + + def = this->add("support_sway_brace_depth", coPercent); + def->label = L("Brace depth"); + def->category = L("Support"); + def->tooltip = L("How far the brace extends outward at the build plate as a percentage of its height. Clearance limits placement, and the rib depth is capped at 60 mm."); + def->sidetext = "%"; + def->min = 5; + def->max = 50; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionPercent(15.)); + assign_printer_technology_to_unknown(this->options, ptFFF); } void PrintConfigDef::init_common_params() @@ -8626,6 +8665,10 @@ std::map validate(const FullPrintConfig &cfg, bool und [](double ratio) { return !std::isfinite(ratio); })) error_message.emplace("filament_initial_layer_flow_ratio", L("Invalid initial layer flow ratio.")); + for (const char *key : { "support_sway_brace_grip_from", "support_sway_brace_tine_spacing", "support_sway_brace_depth" }) + if (!std::isfinite(cfg.option(key)->getFloat())) + error_message.emplace(key, L("Invalid sway brace value.")); + // The following test was commented out after 482841b, see also https://github.com/prusa3d/PrusaSlicer/pull/6743. // The backend should now handle this case correctly. I.e., zero default_acceleration behaves as if all others // were zero too. This is now consistent with what the UI said would happen. diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 3a6ae384a3..89e42899ad 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -858,6 +858,10 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionBool, support_on_build_plate_only)) ((ConfigOptionBool, support_critical_regions_only)) ((ConfigOptionBool, support_remove_small_overhang)) + ((ConfigOptionBool, support_sway_braces)) + ((ConfigOptionFloat, support_sway_brace_grip_from)) + ((ConfigOptionFloat, support_sway_brace_tine_spacing)) + ((ConfigOptionPercent, support_sway_brace_depth)) ((ConfigOptionFloat, support_top_z_distance)) ((ConfigOptionFloat, support_bottom_z_distance)) ((ConfigOptionInt, enforce_support_layers)) diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index b23562ebdc..e0a22f2616 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1169,6 +1169,10 @@ bool PrintObject::invalidate_state_by_config_options( || opt_key == "support_on_build_plate_only" || opt_key == "support_critical_regions_only" || opt_key == "support_remove_small_overhang" + || opt_key == "support_sway_braces" + || opt_key == "support_sway_brace_grip_from" + || opt_key == "support_sway_brace_tine_spacing" + || opt_key == "support_sway_brace_depth" || opt_key == "enforce_support_layers" || opt_key == "support_filament" || opt_key == "support_line_width" diff --git a/src/libslic3r/Support/FinSupport.cpp b/src/libslic3r/Support/FinSupport.cpp index 6f9353e9eb..4c9f0feffa 100644 --- a/src/libslic3r/Support/FinSupport.cpp +++ b/src/libslic3r/Support/FinSupport.cpp @@ -19,6 +19,16 @@ constexpr double wall_clearance = 0.2; constexpr double foot_height = 0.8; constexpr double tine_pitch = 3.; +// Gridfins Sway braces use different faces and clearances from the overhang walls. +constexpr double sway_min_face_height = 30.; +constexpr double sway_top_gap = 1.; +constexpr double sway_clearance = 1.; +constexpr double sway_foot_height = 0.6; +constexpr double sway_foot_margin = 3.; +constexpr double sway_max_lean = 0.5773502692; // Tangent of 30 degrees. +constexpr double sway_face_alignment = 0.8660254038; // Cosine of 30 degrees. +constexpr double sway_max_tine_span = 1.5; + struct WallLayer { Polylines paths; Polygons footprint; @@ -90,9 +100,34 @@ double neighbor_margin(const PrintObject &neighbor) return std::max(fin_pitch, brim + raft + base + wall_clearance); } +bool uses_sway_braces(const PrintObject &object) +{ + return object.config().support_sway_braces.value && object.config().support_type.value == stFinsAuto && + object.config().enable_support.value && !object.has_raft() && object.height() >= scale_(sway_min_face_height); +} + +Polygons limit_sway_bed(const Polygons &bed, const Point &neighbor) +{ + if (bed.empty() || neighbor == Point(0, 0)) + return {}; + + // Print objects can generate supports concurrently. Leave air at a shared + // dividing line so two neighboring copies cannot place intersecting ribs. + const Vec2d outward = neighbor.cast().normalized(); + const Vec2d across(-outward.y(), outward.x()); + const Point center = displaced(lerp(Point(0, 0), neighbor, 0.5), outward, -scale_(0.5 * sway_clearance)); + const BoundingBox bounds = get_extents(bed); + const double extent = bounds.size().cast().norm() + (bounds.center() - center).cast().norm() + 1.; + const Point left = displaced(center, across, extent); + const Point right = displaced(center, across, -extent); + Polygon partition({left, right, displaced(right, outward, -extent), displaced(left, outward, -extent)}); + partition.make_counter_clockwise(); + return intersection(bed, Polygons{std::move(partition)}); +} + // Each copy shares toolpaths, so a wall must fit under every instance's // transform. Leave breathing room around neighboring objects and their fins. -ExPolygons available_bed(const PrintObject &object, std::optional extruder) +ExPolygons available_bed(const PrintObject &object, std::optional extruder, bool for_sway_braces = false) { const Print &print = *object.print(); const PrintConfig &config = print.config(); @@ -130,6 +165,8 @@ ExPolygons available_bed(const PrintObject &object, std::optional extrud const BoundingBox bbox = other->bounding_box(); BoundingBox padded(bbox.min + delta - margin, bbox.max + delta + margin); neighbors.push_back(padded.polygon()); + if (for_sway_braces && uses_sway_braces(*other)) + local_bed = limit_sway_bed(local_bed, delta); } } ExPolygons local = diff_ex(local_bed, union_(neighbors)); @@ -293,21 +330,258 @@ void append_wall(AcceptedLayer &accepted, WallLayer &&wall, const Flow &flow) accepted.fills.append(std::move(ordered_wall)); } +struct SwaySettings { + double grip_from; + double tine_spacing; + double depth_ratio; +}; + +struct SwaySite { + Point face; + Vec2d outward; + size_t face_top; +}; + +Vec2d contour_normal(const Line &edge, bool counterclockwise) +{ + const Vec2d normal = edge.normal().cast(); + return counterclockwise ? normal : -normal; +} + +std::optional find_sway_face(const Layer &layer, const Point &position, const Vec2d &outward, double reach) +{ + const Line probe(displaced(position, outward, -reach), displaced(position, outward, reach)); + std::optional closest; + for (const ExPolygon &slice : layer.lslices) { + const Polygon &contour = slice.contour; + const bool counterclockwise = contour.is_counter_clockwise(); + const Points &points = contour.points; + for (size_t i = 0; i < points.size(); ++i) { + const Line edge(points[i], points[(i + 1) % points.size()]); + const Vec2d normal = contour_normal(edge, counterclockwise); + Point crossing; + if (normal.dot(outward) < sway_face_alignment * normal.norm() || !probe.intersection(edge, &crossing)) + continue; + const double distance = (crossing - position).cast().norm(); + if (!closest || distance < reach) { + closest = crossing; + reach = distance; + } + } + } + return closest; +} + +Polygon sway_outline(const Line &rail, const Vec2d &outward, double half_width, double end_clearance) +{ + const Vec2d across(-outward.y(), outward.x()); + const Point start = displaced(rail.a, outward, -end_clearance); + const Point end = displaced(rail.b, outward, end_clearance); + return Polygon({displaced(start, across, -half_width), displaced(end, across, -half_width), + displaced(end, across, half_width), displaced(start, across, half_width)}); +} + +bool add_sway_tine(WallLayer §ion, const Point &surface, const Point &root, const Vec2d &outward, double width, + const Layer &layer, const ExPolygons &bed, const Polygons &blockers, const Polygons &occupied) +{ + Polyline tine(root, displaced(surface, outward, 0.45 * width)); + Polygons footprint = stroke(tine, 0.5 * width); + if (!diff(footprint, bed).empty() || overlaps(footprint, blockers) || overlaps(footprint, occupied) || + area(intersection(layer.lslices, footprint)) > 0.18 * width * width) + return false; + + section.paths.push_back(std::move(tine)); + polygons_append(section.footprint, std::move(footprint)); + return true; +} + +std::vector build_sway_rib(const PrintObject &object, const SwaySite &site, const SwaySettings &settings, + const std::vector &flows, const ExPolygons &bed, const FinSupportRegions ®ions, + const std::vector &accepted, double height_limit) +{ + const auto layers = object.layers(); + size_t top = site.face_top; + const double top_limit = std::min(height_limit, layers[top]->print_z - sway_top_gap); + while (top > 0 && layers[top]->print_z > top_limit + EPSILON) + --top; + const double height = layers[top]->print_z; + if (height < sway_min_face_height - sway_top_gap - EPSILON || settings.grip_from >= height) + return {}; + const double clearance = std::max(layer_clearance(object.config(), false), layer_clearance(object.config(), true)); + if (clearance + scale_(0.01) > scale_(sway_max_tine_span)) + return {}; + + // Trace an upright face from the top down. If the part recedes, keep the + // brace standing on the plate and count only rows with a real contact. + std::vector edge_positions(top + 1); + std::vector face_aligned(top + 1); + Point position = site.face; + double face_height = 0.; + for (size_t i = site.face_top + 1; i-- > 0;) { + if (i % 32 == 0) + check_cancellation(object); + const double rise = i < site.face_top ? layers[i + 1]->slice_z - layers[i]->slice_z : layers[i]->height; + const double reach = scale_(std::min(sway_max_lean * rise + 0.01, 0.45 * flows[i].spacing())); + const auto surface = find_sway_face(*layers[i], position, site.outward, reach); + if (surface) { + position = *surface; + face_height += layers[i]->height; + } + if (i <= top) { + edge_positions[i] = position; + face_aligned[i] = surface.has_value(); + } + } + if (face_height + EPSILON < sway_min_face_height) + return {}; + + const Vec2d across(-site.outward.y(), site.outward.x()); + const double depth_at_bed = std::clamp(height * settings.depth_ratio, 8., 60.); + const double thickness = scale_(std::min(2.4, 1.2 + 0.004 * height)); + const Polygons no_blockers; + std::vector rib; + rib.reserve(top + 1); + double next_tine = std::max(settings.grip_from, sway_foot_height + 0.5); + double first_grip = height; + size_t planned_tines = 0; + size_t placed_tines = 0; + for (size_t i = 0; i <= top; ++i) { + if (i % 32 == 0) + check_cancellation(object); + const Layer &layer = *layers[i]; + const double width = flows[i].scaled_width(); + const double spacing = scale_(flows[i].spacing()); + const bool foot = i == 0 || layer.print_z <= sway_foot_height + EPSILON; + const double margin = foot ? sway_foot_margin : 0.; + const double taper = layer.bottom_z() / height; + const double depth = scale_(depth_at_bed + taper * (4. - depth_at_bed) + margin); + const double face_offset = 0.5 * width + clearance + scale_(0.01); + const Point start = displaced(edge_positions[i], site.outward, face_offset); + const Line rail(start, displaced(start, site.outward, depth)); + const int paths = std::max(2, int(std::round((thickness + 2. * scale_(margin)) / spacing))); + const double outer_rail = 0.5 * (paths - 1) * spacing; + const double half_width = outer_rail + 0.5 * width; + const Polygons &blockers = i < regions.blockers.size() ? regions.blockers[i] : no_blockers; + const Polygons &occupied = accepted[i].footprint; + WallLayer section; + section.footprint = {sway_outline(rail, site.outward, half_width, 0.5 * width)}; + if (!diff(section.footprint, bed).empty() || overlaps(section.footprint, blockers) || + !intersection(layer.lslices, Polygons{sway_outline(rail, site.outward, half_width + clearance, 0.5 * width + clearance)}).empty() || + overlaps(occupied, Polygons{sway_outline(rail, site.outward, half_width + scale_(sway_clearance), + 0.5 * width + scale_(sway_clearance))})) + return {}; + + section.paths.reserve(paths + 1); + for (int j = 0; j < paths; ++j) { + const double offset = j * spacing - outer_rail; + section.paths.emplace_back(displaced(rail.a, across, offset), displaced(rail.b, across, offset)); + } + section.body_path_count = section.paths.size(); + if (!foot && layer.print_z + EPSILON >= next_tine) { + ++planned_tines; + next_tine += settings.tine_spacing; + const Point root = displaced(start, site.outward, 0.3 * width); + if (face_aligned[i] && add_sway_tine(section, edge_positions[i], root, site.outward, width, + layer, bed, blockers, occupied)) { + ++placed_tines; + first_grip = std::min(first_grip, layer.print_z); + } + } + rib.push_back(std::move(section)); + } + + // Reject a largely unattached rib even when its base fits on the plate. + const double stilt = first_grip - std::max(sway_foot_height, settings.grip_from); + if (placed_tines < 3 || placed_tines < 0.3 * planned_tines || stilt > std::min(40., 0.4 * height) + EPSILON) + return {}; + return rib; +} + +void add_sway_braces(const PrintObject &object, const std::vector &flows, const ExPolygons &bed, + const FinSupportRegions ®ions, std::vector &accepted, double height_limit) +{ + const auto &config = object.config(); + const SwaySettings settings{config.support_sway_brace_grip_from.value, config.support_sway_brace_tine_spacing.value, + config.support_sway_brace_depth.value / 100.}; + if (!(settings.grip_from >= 0. && settings.grip_from <= 2000. && + settings.tine_spacing >= 2. && settings.tine_spacing <= 30. && + settings.depth_ratio >= 0.05 && settings.depth_ratio <= 0.5) || bed.empty()) + return; + + const auto layers = object.layers(); + const double min_face_top = std::max(sway_min_face_height, 0.4 * layers.back()->print_z); + double next_face_height = std::min(height_limit + sway_top_gap, layers.back()->print_z); + const double sample_step = std::max(5., (next_face_height - min_face_top) / 8.); + std::vector directions; + for (size_t i = layers.size(); i-- > 0 && directions.size() < 4;) { + const Layer &layer = *layers[i]; + if (layer.print_z + EPSILON < min_face_top) + break; + if (layer.print_z > next_face_height + EPSILON) + continue; + check_cancellation(object); + next_face_height = layer.print_z - sample_step; + + Lines faces; + for (const ExPolygon &slice : layer.lslices) { + const bool counterclockwise = slice.contour.is_counter_clockwise(); + for (Line edge : slice.contour.lines()) { + if (edge.length() < std::max(scale_(2.), 3. * flows[i].scaled_width())) + continue; + if (!counterclockwise) + edge.reverse(); + faces.push_back(edge); + } + } + const auto widest = faces.begin() + std::min(32, faces.size()); + std::partial_sort(faces.begin(), widest, faces.end(), [](const Line &a, const Line &b) { return a.length() > b.length(); }); + for (auto face = faces.begin(); face != widest && directions.size() < 4; ++face) { + const Vec2d outward = face->normal().cast().normalized(); + if (std::any_of(directions.begin(), directions.end(), [&](const Vec2d &direction) { return direction.dot(outward) > 0.5 + EPSILON; })) + continue; + + const double length = face->length(); + const int columns = std::clamp(int(std::round(length / scale_(100.))), 1, 4); + bool fitted = false; + for (int column = 0; column < columns; ++column) { + const double position = (column + 0.5) / columns; + for (double nudge : {0., 3., -3., 6., -6.}) { + const double offset = position + scale_(nudge) / length; + if (offset <= 0. || offset >= 1.) + continue; + const SwaySite site{lerp(face->a, face->b, offset), outward, i}; + auto rib = build_sway_rib(object, site, settings, flows, bed, regions, accepted, height_limit); + if (rib.empty()) + continue; + for (size_t z = 0; z < rib.size(); ++z) + append_wall(accepted[z], std::move(rib[z]), flows[z]); + fitted = true; + break; + } + } + if (fitted) + directions.push_back(outward); + } + } +} + } // namespace bool generate_fin_support_walls(PrintObject &object, const FinSupportRegions ®ions) { - if (std::all_of(regions.overhangs.begin(), regions.overhangs.end(), [](const Polygons &p) { return p.empty(); })) + const bool overhangs = std::any_of(regions.overhangs.begin(), regions.overhangs.end(), [](const Polygons &p) { return !p.empty(); }); + const bool sway_braces = uses_sway_braces(object); + if (!overhangs && !sway_braces) return true; const auto layers = object.layers(); // This generator seats the walls on the build plate, so it needs an // object layer grid starting at the bed. if (layers.empty() || layers.front()->bottom_z() > EPSILON) - return false; + return !overhangs; const auto extruder = fin_support_extruder(object); const ExPolygons bed = available_bed(object, extruder); if (bed.empty()) - return false; + return !overhangs; std::vector flows; flows.reserve(layers.size()); @@ -417,6 +691,8 @@ bool generate_fin_support_walls(PrintObject &object, const FinSupportRegions &re } } + if (sway_braces) + add_sway_braces(object, flows, available_bed(object, extruder, true), regions, accepted, height_limit); check_cancellation(object); int support_layer_id = 0; for (size_t i = 0; i < accepted.size(); ++i) { diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index 91fe76cbc9..6d7bfd5bf2 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -846,6 +846,15 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, in toggle_field("support_threshold_angle", have_support_material && is_auto(support_type)); //toggle_field("support_closing_radius", have_support_material && support_style == smsSnug); + const bool sway_braces_available = fins && config->opt_bool("enable_support"); + toggle_line("support_sway_braces", fins); + toggle_field("support_sway_braces", sway_braces_available); + const bool sway_braces_enabled = sway_braces_available && config->opt_bool("support_sway_braces"); + for (const char *key : { "support_sway_brace_grip_from", "support_sway_brace_tine_spacing", "support_sway_brace_depth" }) { + toggle_line(key, fins); + toggle_field(key, sway_braces_enabled); + } + bool support_is_tree = config->opt_bool("enable_support") && is_tree(support_type); for (auto el : {"tree_support_branch_angle", "tree_support_branch_distance", "tree_support_branch_diameter", "tree_support_branch_diameter_angle"}) toggle_field(el, support_is_tree); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index d9ee330b3c..3d78b321d8 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2832,6 +2832,10 @@ void TabPrint::build() optgroup->append_single_option_line("support_on_build_plate_only"); optgroup->append_single_option_line("support_critical_regions_only"); optgroup->append_single_option_line("support_remove_small_overhang"); + optgroup->append_single_option_line("support_sway_braces"); + optgroup->append_single_option_line("support_sway_brace_grip_from"); + optgroup->append_single_option_line("support_sway_brace_tine_spacing"); + optgroup->append_single_option_line("support_sway_brace_depth"); //optgroup->append_single_option_line("enforce_support_layers"); optgroup = page->new_optgroup(L("Raft"), L"param_raft"); From d0e103674ef6f08c7b6acc9b9108ed18893051aa Mon Sep 17 00:00:00 2001 From: leroy ketelaars Date: Sat, 5 Dec 2026 16:24:03 +0100 Subject: [PATCH 07/10] Use support interface filament for Fins tines --- doc/Fins supports.md | 4 +- src/libslic3r/Support/FinSupport.cpp | 170 +++++++++++++++++---------- 2 files changed, 108 insertions(+), 66 deletions(-) diff --git a/doc/Fins supports.md b/doc/Fins supports.md index 1266b9d534..df01c49248 100644 --- a/doc/Fins supports.md +++ b/doc/Fins supports.md @@ -2,13 +2,13 @@ Enable supports in **Process → Support** and select **fins(auto)** under **Type**. Fins are thin walls with widened feet. Where a wall can reach a nearby edge, a short horizontal tine touches the part on a single print layer. The clearance around the wall makes the support easier to break away. -Fins are placed automatically. They use the **Support/raft base** filament selected for the object, including its process default. The existing overhang threshold, painted enforcers and blockers guide placement. Inspect the result in **Preview** before printing. +Fins are placed automatically. Fin bodies use the object's **Support/raft base** filament. Tines use the configured **Support/raft interface** filament and fall back to the base filament when the interface is set to **Default**. The existing overhang threshold, painted enforcers and blockers guide placement. Inspect the result in **Preview** before printing. Fins need room to stand on the build plate and reach the overhang. A raft, obstructed footing, narrow opening or a nearby object can prevent placement. If Bambu Studio cannot cover all required overhangs for an object, it discards that object's fins and asks you to select another support type. Choose Normal or Tree and slice again. ## Sway braces -In Advanced mode, enable **Sway braces** under **Process → Support** while using **fins(auto)**. Studio places tapered, plate-seated ribs beside suitable upright faces of tall parts, including parts that have no overhangs. Each rib grips its face at intervals with single-layer tines. The ribs use the object's **Support/raft base** filament. +In Advanced mode, enable **Sway braces** under **Process → Support** while using **fins(auto)**. Studio places tapered, plate-seated ribs beside suitable upright faces of tall parts, including parts that have no overhangs. The ribs use the object's **Support/raft base** filament and grip the part with single-layer tines. These tines follow the same interface filament setting as overhang tines. | Setting | Default | Effect | | --- | ---: | --- | diff --git a/src/libslic3r/Support/FinSupport.cpp b/src/libslic3r/Support/FinSupport.cpp index 4c9f0feffa..af67e463e9 100644 --- a/src/libslic3r/Support/FinSupport.cpp +++ b/src/libslic3r/Support/FinSupport.cpp @@ -45,6 +45,17 @@ struct FinWall { Polygons coverage; }; +struct TineMaterial { + std::vector interface_flows; + ExPolygons interface_bed; + double interface_height = 0.; + + bool uses_interface() const { return !interface_flows.empty(); } + bool printable_at(double print_z) const { return !uses_interface() || print_z <= interface_height + EPSILON; } + const Flow &flow(size_t i, const Flow &base_flow) const { return uses_interface() ? interface_flows[i] : base_flow; } + const ExPolygons &bed(const ExPolygons &base_bed) const { return uses_interface() ? interface_bed : base_bed; } +}; + void check_cancellation(const PrintObject &object) { if (object.print()->canceled()) @@ -68,7 +79,7 @@ void append_stroke(Polygons &polygons, const Polyline &line, double radius) polygons_append(polygons, stroke(line, radius)); } -std::optional fin_support_extruder(const PrintObject &object) +std::optional fin_support_extruder(const PrintObject &object, int filament) { const Print &print = *object.print(); const auto &config = print.config(); @@ -78,7 +89,6 @@ std::optional fin_support_extruder(const PrintObject &object) // Automatic mapping is resolved after support generation. const FilamentMapMode mode = print.get_filament_map_mode(); - const int filament = object.config().support_filament.value; if (filament > 0 && size_t(filament) <= config.filament_map.size() && (mode == fmmManual || mode == fmmNozzleManual)) { const size_t extruder = print.get_extruder_id(filament - 1); @@ -88,6 +98,17 @@ std::optional fin_support_extruder(const PrintObject &object) return std::nullopt; } +double fin_printable_height(const PrintConfig &config, std::optional extruder) +{ + double height = config.printable_height.value; + const auto &limits = config.extruder_printable_height.values; + const bool known_limit = extruder && *extruder < limits.size(); + for (size_t i = 0; i < limits.size(); ++i) + if ((!known_limit || i == *extruder) && limits[i] > 0.) + height = std::min(height, limits[i]); + return height; +} + double neighbor_margin(const PrintObject &neighbor) { const auto &config = neighbor.config(); @@ -183,16 +204,20 @@ double layer_clearance(const PrintObjectConfig &config, bool first_layer) return scale_(std::max(wall_clearance, requested)); } -Flow fin_layer_flow(const PrintObject &object, const Layer &layer, bool first_layer, std::optional extruder) +Flow fin_layer_flow(const PrintObject &object, const Layer &layer, bool first_layer, + std::optional extruder, FlowRole role) { - if (!extruder) + if (!extruder) { + if (role == frSupportMaterialInterface) + return support_material_interface_flow(&object, float(layer.height)); return first_layer ? support_material_1st_layer_flow(&object, float(layer.height)) : support_material_flow(&object, float(layer.height)); + } const PrintConfig &print_config = object.print()->config(); const auto &support_width = first_layer && print_config.initial_layer_line_width.value > 0 ? print_config.initial_layer_line_width : object.config().support_line_width; - return Flow::new_from_config_width(frSupportMaterial, support_width.value > 0 ? support_width : object.config().line_width, + return Flow::new_from_config_width(role, support_width.value > 0 ? support_width : object.config().line_width, float(print_config.nozzle_diameter.get_at(*extruder)), float(layer.height)); } @@ -215,11 +240,28 @@ Polylines wall_paths(const Line &run, const Vec2d &normal, const Flow &flow, con return paths; } -// Find the first side surface in reach of the bead. The centerline stays -// outside the part, with only the round end of the bead touching the surface. -void add_tines(WallLayer &wall, const Vec2d &normal, double width, double spacing, - const Layer &layer, const Polygons &blockers, const ExPolygons &bed, const Polygons &occupied) +bool add_tine(WallLayer &wall, Polyline tine, double width, const Layer &layer, const ExPolygons &bed, + const Polygons &blockers, const Polygons &occupied, const Polygons *previous_support) +{ + // A separate interface tool may print first on this layer. Anchor its + // starting point to support already printed on the layer below. + if (previous_support && !contains(*previous_support, tine.front())) + return false; + Polygons footprint = stroke(tine, 0.5 * width); + if (!diff(footprint, bed).empty() || overlaps(footprint, blockers) || overlaps(footprint, occupied) || + area(intersection(layer.lslices, footprint)) > 0.18 * width * width) + return false; + wall.paths.push_back(std::move(tine)); + polygons_append(wall.footprint, std::move(footprint)); + return true; +} + +// The centerline stays outside the part and the round end touches the surface. +void add_tines(WallLayer &wall, const Vec2d &normal, double body_width, const Flow &tine_flow, + const Layer &layer, const Polygons &blockers, const ExPolygons &bed, const Polygons &occupied, const Polygons *previous_support) { + const double width = tine_flow.scaled_width(); + const double min_length = 0.35 * scale_(tine_flow.spacing()); const auto add_side = [&](Point a, Point b, const Vec2d &outward) { const double length = (b - a).cast().norm(); for (double pos = 0.5 * scale_(tine_pitch); pos < length; pos += scale_(tine_pitch)) { @@ -233,17 +275,11 @@ void add_tines(WallLayer &wall, const Vec2d &normal, double width, double spacin if (contacts.empty() || distance <= 0.5 * width) continue; - const Point root = displaced(edge, outward, 0.35 * width); + const Point root = displaced(edge, outward, 0.35 * body_width); const Point tip = displaced(edge, outward, distance - 0.45 * width); - if ((tip - root).cast().dot(outward) < 0.35 * spacing) - continue; - Polyline tine(root, tip); - Polygons footprint = stroke(tine, 0.5 * width); - if (!diff(footprint, bed).empty() || overlaps(footprint, blockers) || overlaps(footprint, occupied) || - area(intersection(layer.lslices, footprint)) > 0.18 * width * width) + if ((tip - root).cast().dot(outward) < min_length) continue; - wall.paths.push_back(std::move(tine)); - polygons_append(wall.footprint, std::move(footprint)); + add_tine(wall, Polyline(root, tip), width, layer, bed, blockers, occupied, previous_support); } }; const Line left(wall.paths[wall.paths.size() - 2].front(), wall.paths[wall.paths.size() - 2].back()); @@ -254,7 +290,7 @@ void add_tines(WallLayer &wall, const Vec2d &normal, double width, double spacin FinWall build_wall(const PrintObject &object, const Line &run, size_t top, const std::vector &flows, const ExPolygons &bed, const FinSupportRegions ®ions, const std::vector &accepted, - const std::vector &in_region) + const std::vector &in_region, const TineMaterial &tines) { const Vec2d heading = (run.b - run.a).cast().normalized(); const Vec2d normal(-heading.y(), heading.x()); @@ -290,8 +326,9 @@ FinWall build_wall(const PrintObject &object, const Line &run, size_t top, const overlaps(plan.footprint, blockers)) return {}; - if (i > 0 && !tip && layer.print_z + EPSILON >= next_tine_z) { - add_tines(plan, normal, width, scale_(flow.spacing()), layer, blockers, bed, occupied); + if (i > 0 && !tip && layer.print_z + EPSILON >= next_tine_z && tines.printable_at(layer.print_z)) { + const Polygons *previous_support = tines.uses_interface() ? &wall.layers.back().footprint : nullptr; + add_tines(plan, normal, width, tines.flow(i, flow), layer, blockers, tines.bed(bed), occupied, previous_support); next_tine_z = layer.print_z + tine_pitch; } wall.layers.push_back(std::move(plan)); @@ -307,26 +344,28 @@ bool sufficiently_covered(const ExPolygon ®ion, const Polygons &covered, doub return area(missed) <= 0.1 * region.area() && offset_ex(missed, -0.5 * bead_width).empty(); } -void append_wall(AcceptedLayer &accepted, WallLayer &&wall, const Flow &flow) +void append_wall(AcceptedLayer &accepted, WallLayer &&wall, const Flow &flow, const TineMaterial &tines, size_t layer) { polygons_append(accepted.footprint, std::move(wall.footprint)); - const bool has_tines = wall.body_path_count < wall.paths.size(); + const bool ordered = wall.body_path_count < wall.paths.size() && !tines.uses_interface(); ExtrusionEntityCollection ordered_wall; ordered_wall.no_sort = true; - ExtrusionEntityCollection &fills = has_tines ? ordered_wall : accepted.fills; + ExtrusionEntityCollection &fills = ordered ? ordered_wall : accepted.fills; + const auto tine_role = tines.uses_interface() ? erSupportMaterialInterface : erSupportMaterial; + const auto &tine_flow = tines.flow(layer, flow); for (size_t i = 0; i < wall.paths.size(); ++i) { if (i < wall.body_path_count) { ExtrusionPath path(erSupportMaterial, flow.mm3_per_mm(), flow.width(), flow.height()); path.polyline = std::move(wall.paths[i]); fills.append(std::move(path)); } else { - ExtrusionPathOriented tine(erSupportMaterial, flow.mm3_per_mm(), flow.width(), flow.height()); + ExtrusionPathOriented tine(tine_role, tine_flow.mm3_per_mm(), tine_flow.width(), tine_flow.height()); tine.polyline = std::move(wall.paths[i]); fills.append(std::move(tine)); } } - // Lay the wall before its tines, then print the tines root to tip. - if (has_tines) + // Keep a single-material wall and its tines together in printing order. + if (ordered) accepted.fills.append(std::move(ordered_wall)); } @@ -381,23 +420,9 @@ Polygon sway_outline(const Line &rail, const Vec2d &outward, double half_width, displaced(end, across, half_width), displaced(start, across, half_width)}); } -bool add_sway_tine(WallLayer §ion, const Point &surface, const Point &root, const Vec2d &outward, double width, - const Layer &layer, const ExPolygons &bed, const Polygons &blockers, const Polygons &occupied) -{ - Polyline tine(root, displaced(surface, outward, 0.45 * width)); - Polygons footprint = stroke(tine, 0.5 * width); - if (!diff(footprint, bed).empty() || overlaps(footprint, blockers) || overlaps(footprint, occupied) || - area(intersection(layer.lslices, footprint)) > 0.18 * width * width) - return false; - - section.paths.push_back(std::move(tine)); - polygons_append(section.footprint, std::move(footprint)); - return true; -} - std::vector build_sway_rib(const PrintObject &object, const SwaySite &site, const SwaySettings &settings, const std::vector &flows, const ExPolygons &bed, const FinSupportRegions ®ions, - const std::vector &accepted, double height_limit) + const std::vector &accepted, double height_limit, const TineMaterial &tines) { const auto layers = object.layers(); size_t top = site.face_top; @@ -480,11 +505,16 @@ std::vector build_sway_rib(const PrintObject &object, const SwaySite if (!foot && layer.print_z + EPSILON >= next_tine) { ++planned_tines; next_tine += settings.tine_spacing; - const Point root = displaced(start, site.outward, 0.3 * width); - if (face_aligned[i] && add_sway_tine(section, edge_positions[i], root, site.outward, width, - layer, bed, blockers, occupied)) { - ++placed_tines; - first_grip = std::min(first_grip, layer.print_z); + if (face_aligned[i] && tines.printable_at(layer.print_z)) { + const double tine_width = tines.flow(i, flows[i]).scaled_width(); + const Point root = displaced(start, site.outward, 0.3 * width); + const Point tip = displaced(edge_positions[i], site.outward, 0.45 * tine_width); + const Polygons *previous_support = tines.uses_interface() ? &rib.back().footprint : nullptr; + if ((root - tip).cast().dot(site.outward) > 0. && + add_tine(section, Polyline(root, tip), tine_width, layer, tines.bed(bed), blockers, occupied, previous_support)) { + ++placed_tines; + first_grip = std::min(first_grip, layer.print_z); + } } } rib.push_back(std::move(section)); @@ -498,7 +528,8 @@ std::vector build_sway_rib(const PrintObject &object, const SwaySite } void add_sway_braces(const PrintObject &object, const std::vector &flows, const ExPolygons &bed, - const FinSupportRegions ®ions, std::vector &accepted, double height_limit) + const FinSupportRegions ®ions, std::vector &accepted, double height_limit, + const TineMaterial &tines) { const auto &config = object.config(); const SwaySettings settings{config.support_sway_brace_grip_from.value, config.support_sway_brace_tine_spacing.value, @@ -550,11 +581,11 @@ void add_sway_braces(const PrintObject &object, const std::vector &flows, if (offset <= 0. || offset >= 1.) continue; const SwaySite site{lerp(face->a, face->b, offset), outward, i}; - auto rib = build_sway_rib(object, site, settings, flows, bed, regions, accepted, height_limit); + auto rib = build_sway_rib(object, site, settings, flows, bed, regions, accepted, height_limit, tines); if (rib.empty()) continue; for (size_t z = 0; z < rib.size(); ++z) - append_wall(accepted[z], std::move(rib[z]), flows[z]); + append_wall(accepted[z], std::move(rib[z]), flows[z], tines, z); fitted = true; break; } @@ -578,7 +609,10 @@ bool generate_fin_support_walls(PrintObject &object, const FinSupportRegions &re // object layer grid starting at the bed. if (layers.empty() || layers.front()->bottom_z() > EPSILON) return !overhangs; - const auto extruder = fin_support_extruder(object); + const auto &config = object.config(); + const int base_filament = config.support_filament.value; + const int interface_filament = config.support_interface_filament.value; + const auto extruder = fin_support_extruder(object, base_filament); const ExPolygons bed = available_bed(object, extruder); if (bed.empty()) return !overhangs; @@ -586,20 +620,25 @@ bool generate_fin_support_walls(PrintObject &object, const FinSupportRegions &re std::vector flows; flows.reserve(layers.size()); for (size_t i = 0; i < layers.size(); ++i) - flows.push_back(fin_layer_flow(object, *layers[i], i == 0, extruder)); + flows.push_back(fin_layer_flow(object, *layers[i], i == 0, extruder, frSupportMaterial)); + const auto &print_config = object.print()->config(); + const double height_limit = fin_printable_height(print_config, extruder); + TineMaterial tines; + std::optional interface_extruder; + if (interface_filament > 0 && interface_filament != base_filament) { + interface_extruder = fin_support_extruder(object, interface_filament); + tines.interface_bed = available_bed(object, interface_extruder); + tines.interface_height = fin_printable_height(print_config, interface_extruder); + tines.interface_flows.reserve(layers.size()); + for (const Layer *layer : layers) + tines.interface_flows.push_back(fin_layer_flow(object, *layer, false, interface_extruder, frSupportMaterialInterface)); + } std::vector accepted(layers.size()); std::vector coverage_by_layer(layers.size()); size_t projected_layers = 0; Polygons lower_keepout; double seat_margin = 0.; - const double z_gap = std::max(0., object.config().support_top_z_distance.value); - const auto &print_config = object.print()->config(); - const auto &height_limits = print_config.extruder_printable_height.values; - double height_limit = print_config.printable_height.value; - const bool known_limit = extruder && *extruder < height_limits.size(); - for (size_t i = 0; i < height_limits.size(); ++i) - if ((!known_limit || i == *extruder) && height_limits[i] > 0.) - height_limit = std::min(height_limit, height_limits[i]); + const double z_gap = std::max(0., config.support_top_z_distance.value); for (size_t i = 1; i < regions.overhangs.size(); ++i) { check_cancellation(object); @@ -670,7 +709,7 @@ bool generate_fin_support_walls(PrintObject &object, const FinSupportRegions &re if (clear.length() < std::max(scale_(1.2), 3. * width)) continue; FinWall wall = build_wall(object, Line(clear.front(), clear.back()), top, flows, - bed, regions, accepted, walls); + bed, regions, accepted, walls, tines); if (wall.layers.empty()) continue; polygons_append(trial_coverage, wall.coverage); @@ -687,12 +726,15 @@ bool generate_fin_support_walls(PrintObject &object, const FinSupportRegions &re covered = union_(trial_coverage); for (FinWall &wall : walls) for (size_t z = 0; z < wall.layers.size(); ++z) - append_wall(accepted[z], std::move(wall.layers[z]), flows[z]); + append_wall(accepted[z], std::move(wall.layers[z]), flows[z], tines, z); } } - if (sway_braces) - add_sway_braces(object, flows, available_bed(object, extruder, true), regions, accepted, height_limit); + if (sway_braces) { + if (tines.uses_interface()) + tines.interface_bed = available_bed(object, interface_extruder, true); + add_sway_braces(object, flows, available_bed(object, extruder, true), regions, accepted, height_limit, tines); + } check_cancellation(object); int support_layer_id = 0; for (size_t i = 0; i < accepted.size(); ++i) { From 7d3dc76a84dc07fd71b65793ec070be934a88f36 Mon Sep 17 00:00:00 2001 From: leroy ketelaars Date: Sat, 5 Dec 2026 16:54:23 +0100 Subject: [PATCH 08/10] Publish native release binaries after pull request merges --- .github/actions/setup-cmake/action.yml | 34 ++++++ .github/workflows/build_all.yml | 147 +++++++++++++++++++---- .github/workflows/build_bambu.yml | 153 +++++++++--------------- .github/workflows/build_check_cache.yml | 12 +- .github/workflows/build_deps.yml | 107 ++++++----------- .github/workflows/build_ubuntu.yml | 46 +------ deps/Boost/Boost.cmake | 9 +- 7 files changed, 267 insertions(+), 241 deletions(-) create mode 100644 .github/actions/setup-cmake/action.yml diff --git a/.github/actions/setup-cmake/action.yml b/.github/actions/setup-cmake/action.yml new file mode 100644 index 0000000000..71546dbcf0 --- /dev/null +++ b/.github/actions/setup-cmake/action.yml @@ -0,0 +1,34 @@ +name: Set up CMake +description: Install the pinned CMake release used by the macOS and Windows builds + +runs: + using: composite + steps: + - name: Install CMake on macOS + if: runner.os == 'macOS' + shell: bash + run: | + version=3.31.0 + archive="cmake-$version-macos-universal.tar.gz" + cd "$RUNNER_TEMP" + curl --fail --show-error --silent --location --retry 3 \ + "https://github.com/Kitware/CMake/releases/download/v$version/$archive" -o "$archive" + echo "50d5b9f370e71c8eee87c123b7fb9272caf2bf2b372ea7c9423f10f1cd52813b $archive" | shasum -a 256 -c - + tar -xzf "$archive" + echo "$RUNNER_TEMP/cmake-$version-macos-universal/CMake.app/Contents/bin" >> "$GITHUB_PATH" + + - name: Install CMake on Windows + if: runner.os == 'Windows' + shell: pwsh + run: | + $version = '3.31.0' + $archive = "cmake-$version-windows-x86_64.zip" + $archivePath = Join-Path $env:RUNNER_TEMP $archive + Invoke-WebRequest "https://github.com/Kitware/CMake/releases/download/v$version/$archive" ` + -OutFile $archivePath -MaximumRetryCount 3 + $checksum = (Get-FileHash -Algorithm SHA256 $archivePath).Hash + if ($checksum -ne 'f4b499f71cf44115a1d711d4867da3c6bd2f3f4d7121c213ace979757640385c') { + throw 'CMake archive checksum did not match' + } + Expand-Archive -LiteralPath $archivePath -DestinationPath $env:RUNNER_TEMP + Join-Path $env:RUNNER_TEMP "cmake-$version-windows-x86_64\bin" | Add-Content -Path $env:GITHUB_PATH -Encoding utf8 diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index 83b6e0465f..ff978dc3a1 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -1,9 +1,8 @@ name: Build all on: - push: - branches: - - main + pull_request: + branches: [master, main] paths: - 'deps/**' - 'src/**' @@ -11,41 +10,78 @@ on: - 'version.inc' - 'bbl/**' - 'resources/**' - - ".github/workflows/build_*.yml" - - pull_request: - branches: - - master - paths: - - 'deps/**' - - 'src/**' - - '**/CMakeLists.txt' - - 'version.inc' + - '.github/actions/**' - ".github/workflows/build_*.yml" - 'BuildLinux.sh' + - 'BuildMac.sh' - 'build_win.bat' - - workflow_dispatch: # manual dispatch - inputs: - build-deps-only: - description: 'Only build dependencies (bypasses caching)' - type: boolean - default: false + + pull_request_target: + branches: [master, main] + types: [closed] + + workflow_dispatch: + inputs: + build-deps-only: + description: 'Only build dependencies (bypasses caching)' + type: boolean + default: false + +permissions: + contents: read concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name != 'pull_request_target' }} jobs: + release_metadata: + name: Read merged release version + if: >- + github.event_name == 'pull_request_target' && + github.event.pull_request.merged && + github.event.pull_request.base.ref == github.event.repository.default_branch + runs-on: ubuntu-latest + outputs: + commit: ${{ steps.version.outputs.commit }} + version: ${{ steps.version.outputs.version }} + tag: ${{ steps.version.outputs.tag }} + steps: + # Use the commit accepted by the base branch, including squash and rebase merges. + - uses: actions/checkout@v6 + with: + ref: ${{ github.event.pull_request.merge_commit_sha }} + sparse-checkout: version.inc + sparse-checkout-cone-mode: false + persist-credentials: false + - name: Read version.inc + id: version + shell: bash + env: + MERGE_COMMIT: ${{ github.event.pull_request.merge_commit_sha }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + test "$(git rev-parse HEAD)" = "$MERGE_COMMIT" + version=$(sed -nE 's/^set\(SLIC3R_VERSION "([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)"\)$/\1/p' version.inc) + if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo 'Expected a four-component SLIC3R_VERSION in version.inc' >&2 + exit 1 + fi + echo "commit=$MERGE_COMMIT" >> "$GITHUB_OUTPUT" + echo "version=$version-c" >> "$GITHUB_OUTPUT" + echo "tag=v$version-pr$PR_NUMBER-c" >> "$GITHUB_OUTPUT" + build_all: name: Build All + needs: release_metadata + if: ${{ !cancelled() && (github.event_name != 'pull_request_target' || needs.release_metadata.result == 'success') }} strategy: fail-fast: false matrix: include: - os: ubuntu-22.04 - os: ubuntu-24.04 - - os: windows-latest + - os: windows-2022 - os: macos-15-intel arch: x86_64 - os: macos-15 @@ -55,4 +91,67 @@ jobs: os: ${{ matrix.os }} arch: ${{ matrix.arch }} build-deps-only: ${{ inputs.build-deps-only || false }} - secrets: inherit + source-ref: ${{ needs.release_metadata.outputs.commit }} + release-version: ${{ needs.release_metadata.outputs.version }} + + publish_release: + name: Publish release binaries + needs: [release_metadata, build_all] + if: ${{ needs.release_metadata.result == 'success' && needs.build_all.result == 'success' }} + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/download-artifact@v7 + with: + pattern: release-* + path: release-assets + merge-multiple: true + - name: Publish the complete release + shell: bash + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + RELEASE_TAG: ${{ needs.release_metadata.outputs.tag }} + RELEASE_VERSION: ${{ needs.release_metadata.outputs.version }} + MERGE_COMMIT: ${{ needs.release_metadata.outputs.commit }} + PR_URL: ${{ github.event.pull_request.html_url }} + run: | + assets=( + "BambuStudio_Windows_V${RELEASE_VERSION}_portable.zip" + "BambuStudio_Mac_x86_64_V${RELEASE_VERSION}.zip" + "BambuStudio_Mac_arm64_V${RELEASE_VERSION}.zip" + "Bambu_Studio_ubuntu-22.04_V${RELEASE_VERSION}.AppImage" + "Bambu_Studio_ubuntu-24.04_V${RELEASE_VERSION}.AppImage" + ) + for asset in "${assets[@]}"; do + if [[ ! -s "release-assets/$asset" ]]; then + echo "Missing release binary $asset" >&2 + exit 1 + fi + done + + if ! target=$(gh api "repos/$GH_REPO/git/ref/tags/$RELEASE_TAG" --jq '.object.sha' 2>/dev/null); then + target=$(gh api --method POST "repos/$GH_REPO/git/refs" \ + -f "ref=refs/tags/$RELEASE_TAG" -f "sha=$MERGE_COMMIT" --jq '.object.sha') + fi + test "$target" = "$MERGE_COMMIT" + + if ! release=$(gh release view "$RELEASE_TAG" --json isDraft,assets); then + gh release create "$RELEASE_TAG" --verify-tag --draft \ + --title "Bambu Studio $RELEASE_VERSION" --notes "Built from $PR_URL at $MERGE_COMMIT." + release=$(gh release view "$RELEASE_TAG" --json isDraft,assets) + fi + + # A rerun may resume a draft, or verify a release that already finished. + if [[ $(jq -r '.isDraft' <<< "$release") == true ]]; then + paths=("${assets[@]/#/release-assets/}") + gh release upload "$RELEASE_TAG" "${paths[@]}" --clobber + release=$(gh release view "$RELEASE_TAG" --json isDraft,assets) + fi + for asset in "${assets[@]}"; do + jq -e --arg asset "$asset" 'any(.assets[]; .name == $asset and .size > 0)' <<< "$release" > /dev/null + done + if [[ $(jq -r '.isDraft' <<< "$release") == true ]]; then + gh release edit "$RELEASE_TAG" --draft=false + fi diff --git a/.github/workflows/build_bambu.yml b/.github/workflows/build_bambu.yml index 079973b6ea..b4c5bcdf39 100644 --- a/.github/workflows/build_bambu.yml +++ b/.github/workflows/build_bambu.yml @@ -13,20 +13,20 @@ on: arch: required: false type: string + source-ref: + type: string + release-version: + type: string jobs: build_bambu: name: Build BambuStudio runs-on: ${{ inputs.os }} - env: - date: - ver: - ver_pure: - steps: - name: Checkout uses: actions/checkout@v6 with: + ref: ${{ inputs.source-ref }} lfs: 'true' - name: load cached deps @@ -36,96 +36,57 @@ jobs: key: ${{ inputs.cache-key }} fail-on-cache-miss: true - - name: Get the version and date on Ubuntu and macOS - if: inputs.os != 'windows-latest' + - name: Set the package version + env: + RELEASE_VERSION: ${{ inputs.release-version }} + PR_NUMBER: ${{ github.event.pull_request.number }} run: | - ver_pure=$(grep 'set(SLIC3R_VERSION' version.inc | cut -d '"' -f2) - if [[ "${{ github.event_name }}" == "pull_request" ]]; then - ver="PR-${{ github.event.number }}" + if [[ -n "$RELEASE_VERSION" ]]; then + ver="V$RELEASE_VERSION" + elif [[ "$GITHUB_EVENT_NAME" == pull_request ]]; then + if [[ "$RUNNER_OS" == Windows ]]; then + ver="PR$PR_NUMBER" + else + ver="PR-$PR_NUMBER" + fi else - ver=V$ver_pure + ver="V$(grep '^set(SLIC3R_VERSION ' version.inc | cut -d '"' -f2)" fi - echo "ver=$ver" >> $GITHUB_ENV - echo "ver_pure=$ver_pure" >> $GITHUB_ENV - echo "date=$(date +'%Y%m%d')" >> $GITHUB_ENV + echo "ver=$ver" >> "$GITHUB_ENV" shell: bash - - name: Get the version and date on Windows - if: inputs.os == 'windows-latest' - run: | - $date = Get-Date -Format 'yyyyMMdd' - $ref = "${{ github.ref }}" - $eventName = "${{ github.event_name }}" - $prNumber = "${{ github.event.number }}" - - if ($eventName -eq 'pull_request') { - $ver = "PR" + $prNumber - } else { - $versionContent = Get-Content version.inc -Raw - if ($versionContent -match 'set\(SLIC3R_VERSION "(.*?)"\)') { - $ver = $matches[1] - } - $ver = "V$ver" - } - - echo "ver=$ver" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 - echo "date=$date" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 - echo "date: ${{ env.date }} version: ${{ env.ver }}" - shell: pwsh - - # Mac - - name: Build slicer mac - if: inputs.os == 'macos-15-intel' - working-directory: ${{ github.workspace }} - run: | - brew install automake texinfo - brew unlink cmake || true - brew tap-new $USER/old-cmake - brew extract --version=3.31.0 cmake $USER/old-cmake - brew install $USER/old-cmake/cmake@3.31.0 - brew link --overwrite cmake@3.31.0 - brew pin cmake@3.31.0 - ./BuildMac.sh -s -x -a x86_64 -t 10.15 -1 - - - name: Build slicer mac - if: inputs.os == 'macos-15' + - name: Set up CMake for the native application + if: runner.os != 'Linux' + uses: ./.github/actions/setup-cmake + + - name: Build and pack the macOS app + if: runner.os == 'macOS' + env: + BUILD_ARCH: ${{ inputs.arch }} working-directory: ${{ github.workspace }} run: | brew install automake texinfo - brew unlink cmake || true - brew tap-new $USER/old-cmake - brew extract --version=3.31.0 cmake $USER/old-cmake - brew install $USER/old-cmake/cmake@3.31.0 - brew link --overwrite cmake@3.31.0 - brew pin cmake@3.31.0 - ./BuildMac.sh -s -x -a universal -t 10.15 -1 - - - name: pack mac app - if: github.ref != 'refs/heads/main' && (inputs.os == 'macos-15-intel' || inputs.os == 'macos-15') - working-directory: ${{ github.workspace }} - run: zip -r BambuStudio_Mac_${{inputs.arch}}_${{ env.ver }}.zip ${{ github.workspace }}/build + ./BuildMac.sh -s -x -a "$BUILD_ARCH" -t 10.15 -1 + bundle="build/$BUILD_ARCH/BambuStudio/BambuStudio.app" + test -x "$bundle/Contents/MacOS/BambuStudio" + ditto -c -k --sequesterRsrc --keepParent "$bundle" "BambuStudio_Mac_${BUILD_ARCH}_${ver}.zip" - name: Upload artifacts mac - if: inputs.os == 'macos-15-intel' || inputs.os == 'macos-15' + if: runner.os == 'macOS' uses: actions/upload-artifact@v6 with: - name: BambuStudio_Mac_${{inputs.arch}}_${{ env.ver }} - path: ${{ github.workspace }}/BambuStudio_Mac_${{inputs.arch}}_${{ env.ver }}.zip + name: ${{ inputs.release-version && 'release-' || '' }}BambuStudio_Mac_${{ inputs.arch }}_${{ env.ver }} + path: BambuStudio_Mac_${{ inputs.arch }}_${{ env.ver }}.zip + if-no-files-found: error + overwrite: ${{ inputs.release-version != '' }} # Windows - - name: setup MSVC - if: inputs.os == 'windows-latest' - uses: microsoft/setup-msbuild@v2 - - - name: Install nsis and pkgconfig - if: inputs.os == 'windows-latest' - run: | - dir "C:/Program Files (x86)/Windows Kits/10/Include" - choco install nsis - choco install pkgconfiglite + - name: Install pkgconfig + if: runner.os == 'Windows' + run: choco install pkgconfiglite - name: Build slicer Win - if: inputs.os == 'windows-latest' + if: runner.os == 'Windows' working-directory: ${{ github.workspace }} run: | mkdir build @@ -133,30 +94,22 @@ jobs: cmake .. -G "Visual Studio 17 2022" -A X64 -DBBL_RELEASE_TO_PUBLIC=1 -DBBL_INTERNAL_TESTING=0 -DCMAKE_PREFIX_PATH="${{ github.workspace }}\deps\build\BambuStudio_dep\usr\local" -DCMAKE_INSTALL_PREFIX="../install-dir" -DCMAKE_BUILD_TYPE=Release -DWIN10SDK_PATH="C:/Program Files (x86)/Windows Kits/10/Include/10.0.22000.0" cmake --build . --target install --config Release -- -m - # - name: Create installer Win - # if: inputs.os == 'windows-latest' - # working-directory: ${{ github.workspace }}/build - # run: | - # cpack -G NSIS - - name: Pack app - if: inputs.os == 'windows-latest' + if: runner.os == 'Windows' working-directory: ${{ github.workspace }} shell: cmd - run: '"C:/Program Files/7-Zip/7z.exe" a -tzip BambuStudio_Windows_${{ env.ver }}_portable.zip ${{ github.workspace }}/install-dir' - - # - name: Pack PDB - # if: inputs.os == 'windows-latest' - # working-directory: ${{ github.workspace }}/build/src/Release - # shell: cmd - # run: '"C:/Program Files/7-Zip/7z.exe" a -m0=lzma2 -mx9 Debug_PDB_${{ env.ver }}_for_developers_only.7z *.pdb' + run: | + if not exist "install-dir\bambu-studio.exe" exit /b 1 + "C:/Program Files/7-Zip/7z.exe" a -tzip "BambuStudio_Windows_%ver%_portable.zip" "install-dir" - name: Upload artifacts Win zip - if: inputs.os == 'windows-latest' + if: runner.os == 'Windows' uses: actions/upload-artifact@v6 with: - name: BambuStudio_Windows_${{ env.ver }}_portable - path: ${{ github.workspace }}/BambuStudio_Windows_${{ env.ver }}_portable.zip + name: ${{ inputs.release-version && 'release-' || '' }}BambuStudio_Windows_${{ env.ver }}_portable + path: BambuStudio_Windows_${{ env.ver }}_portable.zip + if-no-files-found: error + overwrite: ${{ inputs.release-version != '' }} # Ubuntu @@ -175,7 +128,7 @@ jobs: shell: bash run: | ./BuildLinux.sh -isfr - mv -n ./build/BambuStudio_ubu64.AppImage ./build/Bambu_Studio_${{inputs.os}}_${{ env.ver }}.AppImage + mv ./build/BambuStudio_ubu64.AppImage ./build/Bambu_Studio_${{ inputs.os }}_${{ env.ver }}.AppImage # - name: Build orca_custom_preset_tests # if: github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-22.04' @@ -190,8 +143,10 @@ jobs: if: ${{ ! env.ACT && (inputs.os == 'ubuntu-22.04' || inputs.os == 'ubuntu-24.04') }} uses: actions/upload-artifact@v6 with: - name: BambuStudio_${{inputs.os}}_${{ env.ver }} - path: './build/Bambu_Studio_${{inputs.os}}_${{ env.ver }}.AppImage' + name: ${{ inputs.release-version && 'release-' || '' }}BambuStudio_${{ inputs.os }}_${{ env.ver }} + path: build/Bambu_Studio_${{ inputs.os }}_${{ env.ver }}.AppImage + if-no-files-found: error + overwrite: ${{ inputs.release-version != '' }} # - name: Deploy Ubuntu release # if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-22.04' }} diff --git a/.github/workflows/build_check_cache.yml b/.github/workflows/build_check_cache.yml index ca52f7afc6..003d962fb9 100644 --- a/.github/workflows/build_check_cache.yml +++ b/.github/workflows/build_check_cache.yml @@ -12,6 +12,10 @@ on: build-deps-only: required: false type: boolean + source-ref: + type: string + release-version: + type: string jobs: check_cache: # determines if there is a cache and outputs variables used in caching process @@ -25,13 +29,14 @@ jobs: - name: Checkout uses: actions/checkout@v6 with: + ref: ${{ inputs.source-ref }} lfs: 'true' - name: set outputs id: set_outputs env: - dep-folder-name: ${{ inputs.os == 'windows-latest' && '/BambuStudio_dep' || ((inputs.os == 'macos-15-intel' || inputs.os == 'macos-15') && '') || (inputs.os != 'macos-15-intel' && inputs.os != 'macos-15') && '/destdir' || '' }} - output-cmd: ${{ inputs.os == 'windows-latest' && '$env:GITHUB_OUTPUT' || '"$GITHUB_OUTPUT"'}} + dep-folder-name: ${{ runner.os == 'Windows' && '/BambuStudio_dep' || runner.os == 'Linux' && '/destdir' || '' }} + output-cmd: ${{ runner.os == 'Windows' && '$env:GITHUB_OUTPUT' || '"$GITHUB_OUTPUT"' }} run: | echo cache-key=${{ inputs.os }}-cache-bambustudio_deps-build-${{ hashFiles('deps/**') }} >> ${{ env.output-cmd }} echo cache-path=${{ github.workspace }}/deps/build${{ env.dep-folder-name }} >> ${{ env.output-cmd }} @@ -55,4 +60,5 @@ jobs: os: ${{ inputs.os }} arch: ${{ inputs.arch }} build-deps-only: ${{ inputs.build-deps-only }} - secrets: inherit \ No newline at end of file + source-ref: ${{ inputs.source-ref }} + release-version: ${{ inputs.release-version }} diff --git a/.github/workflows/build_deps.yml b/.github/workflows/build_deps.yml index dc14611315..2996aaec71 100644 --- a/.github/workflows/build_deps.yml +++ b/.github/workflows/build_deps.yml @@ -19,6 +19,10 @@ on: build-deps-only: required: false type: boolean + source-ref: + type: string + release-version: + type: string jobs: build_deps: @@ -33,6 +37,7 @@ jobs: - name: Checkout uses: actions/checkout@v6 with: + ref: ${{ inputs.source-ref }} lfs: 'true' - name: load cached deps @@ -41,24 +46,24 @@ jobs: path: ${{ inputs.cache-path }} key: ${{ inputs.cache-key }} - - name: setup dev on Windows - if: inputs.os == 'windows-latest' - uses: microsoft/setup-msbuild@v2 + - name: Set up CMake for the native dependencies + if: runner.os != 'Linux' + uses: ./.github/actions/setup-cmake - name: Get the date on Ubuntu and macOS - if: inputs.os != 'windows-latest' + if: runner.os != 'Windows' run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_ENV shell: bash - name: Get the date on Windows - if: inputs.os == 'windows-latest' + if: runner.os == 'Windows' run: echo "date=$(Get-Date -Format 'yyyyMMdd')" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 shell: pwsh # Build Dependencies - name: Build on Windows - if: inputs.os == 'windows-latest' + if: runner.os == 'Windows' working-directory: ${{ github.workspace }} run: | choco install strawberryperl @@ -67,70 +72,30 @@ jobs: mkdir ${{ github.workspace }}\deps\build\BambuStudio_dep cd "${{ github.workspace }}\deps\build" cmake ../ -G "Visual Studio 17 2022" -A x64 -DDESTDIR="./BambuStudio_dep" -DCMAKE_BUILD_TYPE=Release -DDEP_DEBUG=OFF - msbuild /m ALL_BUILD.vcxproj + cmake --build . --parallel --config Release --target deps - name: pack deps on Windows - if: inputs.os == 'windows-latest' + if: runner.os == 'Windows' && !inputs.release-version working-directory: ${{ github.workspace }} run: Compress-Archive -Path "${{ github.workspace }}\deps\build\BambuStudio_dep\*" -DestinationPath "${{ github.workspace }}\deps\build\BambuStudio_dep_win64_${{ env.date }}_vs2022.zip" shell: pwsh - - name: Fix python install error on mac - if: inputs.os == 'macos-15-intel' - working-directory: ${{ github.workspace }} - run: | - find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete - sudo rm -rf /Library/Frameworks/Python.framework/ - brew install --force python3 && brew unlink python3 && brew unlink python3 && brew link --overwrite python3 - - - name: Free disk space - if: inputs.os == 'macos-15' - run: | - df -h - sudo find /Applications -maxdepth 1 -type d -name "Xcode_*.app" ! -name "Xcode_15.4.app" -exec rm -rf {} + - sudo rm -rf ~/Library/Developer/CoreSimulator/Caches/* - df -h - - name: Build on Mac ${{ inputs.arch }} - if: inputs.os == 'macos-15-intel' + if: runner.os == 'macOS' + env: + BUILD_ARCH: ${{ inputs.arch }} working-directory: ${{ github.workspace }} run: | brew install automake texinfo nasm yasm x264 - brew uninstall --ignore-dependencies zstd - brew unlink cmake || true - brew tap-new $USER/old-cmake - brew extract --version=3.31.0 cmake $USER/old-cmake - brew install $USER/old-cmake/cmake@3.31.0 - brew link --overwrite cmake@3.31.0 - brew pin cmake@3.31.0 - ./BuildMac.sh -d -x -a x86_64 -t 10.15 -1 - for arch in x86_64; do - (cd "${{ github.workspace }}/deps/build/${arch}" && \ - find . -mindepth 1 -maxdepth 1 ! -name 'BambuStudio_deps' -exec rm -rf {} +) - done - brew install zstd - - - name: Build on Mac ${{ inputs.arch }} - if: inputs.os == 'macos-15' - working-directory: ${{ github.workspace }} - run: | - brew install automake texinfo nasm yasm x264 - brew uninstall --ignore-dependencies zstd - brew unlink cmake || true - brew tap-new $USER/old-cmake - brew extract --version=3.31.0 cmake $USER/old-cmake - brew install $USER/old-cmake/cmake@3.31.0 - brew link --overwrite cmake@3.31.0 - brew pin cmake@3.31.0 - ./BuildMac.sh -d -x -a universal -t 10.15 -1 - for arch in arm64 x86_64; do - (cd "${{ github.workspace }}/deps/build/${arch}" && \ - find . -mindepth 1 -maxdepth 1 ! -name 'BambuStudio_deps' -exec rm -rf {} +) - done - brew install zstd + if brew list --versions zstd >/dev/null; then + brew unlink zstd + fi + ./BuildMac.sh -d -x -a "$BUILD_ARCH" -t 10.15 -1 + cd "deps/build/$BUILD_ARCH" + find . -mindepth 1 -maxdepth 1 ! -name 'BambuStudio_deps' -exec rm -rf {} + - name: pack deps on Macos - if: inputs.os == 'macos-15-intel' || inputs.os == 'macos-15' + if: runner.os == 'macOS' && !inputs.release-version working-directory: ${{ github.workspace }} run: | cd ${{ github.workspace }}/deps @@ -144,31 +109,29 @@ jobs: sudo ./BuildLinux.sh -ur sudo chown $USER -R ./ ./BuildLinux.sh -dfr - cd deps/build - tar -czvf BambuStudio_dep_${{ inputs.os }}_$(date +"%Y%m%d").tar.gz destdir + + - name: Pack Ubuntu dependencies + if: runner.os == 'Linux' && !inputs.release-version + working-directory: ${{ github.workspace }}/deps/build + run: tar -czvf BambuStudio_dep_${{ inputs.os }}_$(date +"%Y%m%d").tar.gz destdir # Upload Artifacts - name: Upload Mac ${{ inputs.arch }} artifacts - if: inputs.os == 'macos-15-intel' || inputs.os == 'macos-15' + if: runner.os == 'macOS' && !inputs.release-version uses: actions/upload-artifact@v6 with: name: BambuStudio_dep_mac_${{ inputs.arch }}_${{ env.date }} path: ${{ github.workspace }}/deps/BambuStudio_dep_mac_${{ inputs.arch }}*.tar.gz - - name: clean artifacts - if: inputs.os == 'macos-15-intel' || inputs.os == 'macos-15' - working-directory: ${{ github.workspace }} - run: rm -rf ${{ github.workspace }}/deps/build/BambuStudio_dep_mac_${{ inputs.arch }}*.tar.gz - - name: Upload Windows artifacts - if: inputs.os == 'windows-latest' + if: runner.os == 'Windows' && !inputs.release-version uses: actions/upload-artifact@v6 with: name: BambuStudio_dep_win64_${{ env.date }} path: ${{ github.workspace }}/deps/build/BambuStudio_dep*.zip - name: Upload Ubuntu artifacts - if: ${{ ! env.ACT && (inputs.os == 'ubuntu-22.04' || inputs.os == 'ubuntu-24.04') }} + if: ${{ !env.ACT && runner.os == 'Linux' && !inputs.release-version }} uses: actions/upload-artifact@v6 with: name: BambuStudio_dep_${{ inputs.os }}_${{ env.date }} @@ -177,11 +140,15 @@ jobs: build_Bambu: name: Build BambuStudio needs: [build_deps] - if: ${{ !cancelled() && !inputs.build-deps-only && (inputs.valid-cache == true && needs.build_deps.result == 'skipped') || (inputs.valid-cache != true && success()) }} + if: >- + ${{ !cancelled() && !inputs.build-deps-only && + ((inputs.valid-cache && needs.build_deps.result == 'skipped') || + (!inputs.valid-cache && needs.build_deps.result == 'success')) }} uses: ./.github/workflows/build_bambu.yml with: cache-key: ${{ inputs.cache-key }} cache-path: ${{ inputs.cache-path }} os: ${{ inputs.os }} arch: ${{ inputs.arch }} - secrets: inherit + source-ref: ${{ inputs.source-ref }} + release-version: ${{ inputs.release-version }} diff --git a/.github/workflows/build_ubuntu.yml b/.github/workflows/build_ubuntu.yml index 0ff0f20f52..ea1f6cc28d 100644 --- a/.github/workflows/build_ubuntu.yml +++ b/.github/workflows/build_ubuntu.yml @@ -1,50 +1,10 @@ -name: Build Linux +name: Build Linux container AppImage -on: [pull_request] +on: [workflow_dispatch] jobs: - appimage-builder: - name: Linux AppImage Build - - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v6 - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install cmake libgl1-mesa-dev libgtk-3-dev libxkbcommon-dev libunwind-dev libfuse2 -y - - name: Install dependencies from BuildLinux.sh - shell: bash - run: sudo ./BuildLinux.sh -ur - - name: Fix permissions - shell: bash - run: sudo chown $USER -R ./ - - name: Build deps - id: cache_deps - uses: actions/cache@v5 - env: - cache-name: ${{ runner.os }}-cache-bambustudio_deps_x64 - with: - path: ${{ github.workspace }}/deps/build/destdir - key: build-${{ env.cache-name }} - - - if: ${{ steps.cache_deps.outputs.cache-hit != 'true' }} - name: Build deps - working-directory: ${{ github.workspace }} - continue-on-error: true - run: ./BuildLinux.sh -dsr - - - name: Build Studio - shell: bash - run: ./BuildLinux.sh -ir - - uses: actions/upload-artifact@v6 - with: - name: BambuStudio_Linux_ubu64_20.04 - path: './build/BambuStudio_ubu64.AppImage' - appimage-builder-using-container: - name: Linux AppImage Build Ubuntu 20.04 using container + name: Build Linux AppImage using container runs-on: ubuntu-latest diff --git a/deps/Boost/Boost.cmake b/deps/Boost/Boost.cmake index 8b217e32a3..b14ab965c7 100644 --- a/deps/Boost/Boost.cmake +++ b/deps/Boost/Boost.cmake @@ -11,11 +11,16 @@ if (APPLE AND CMAKE_OSX_ARCHITECTURES) message(STATUS "BOOST param: ${_context_abi_line} ${_context_arch_line}") endif () +set(_boost_process_dir "libs/process") +if (BINARY_DIR_REL) + set(_boost_process_dir "${BINARY_DIR_REL}/dep_Boost-prefix/src/dep_Boost/libs/process") +endif () + bambustudio_add_cmake_project(Boost URL "https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.gz" URL_HASH SHA256=4d27e9efed0f6f152dc28db6430b9d3dfb40c0345da7342eaa5a987dde57bd95 LIST_SEPARATOR | - PATCH_COMMAND git apply --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-FIX-OBS-cannot-start-streaming-on-MAC.patch + PATCH_COMMAND git apply -p3 --directory "${_boost_process_dir}" --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-FIX-OBS-cannot-start-streaming-on-MAC.patch CMAKE_ARGS -DBOOST_EXCLUDE_LIBRARIES:STRING=contract|fiber|numpy|wave|test -DBOOST_LOCALE_ENABLE_ICU:BOOL=OFF # do not link to libicu, breaks compatibility between distros @@ -24,4 +29,4 @@ bambustudio_add_cmake_project(Boost "${_context_arch_line}" ) -set(DEP_Boost_DEPENDS ZLIB) \ No newline at end of file +set(DEP_Boost_DEPENDS ZLIB) From 908fb65b4ea2b9bf5c6b6a3edaf40f6368edc224 Mon Sep 17 00:00:00 2001 From: leroy ketelaars Date: Sat, 5 Dec 2026 20:12:35 +0100 Subject: [PATCH 09/10] Pass freshly built dependencies to CI as artifacts --- .github/workflows/build_bambu.yml | 39 +++++++++++++++++++++++++++++-- .github/workflows/build_deps.yml | 38 ++++++++++++++++++++++++------ 2 files changed, 68 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_bambu.yml b/.github/workflows/build_bambu.yml index b4c5bcdf39..84b6913fa0 100644 --- a/.github/workflows/build_bambu.yml +++ b/.github/workflows/build_bambu.yml @@ -7,6 +7,8 @@ on: cache-path: required: true type: string + dependency-artifact-id: + type: string os: required: true type: string @@ -29,13 +31,46 @@ jobs: ref: ${{ inputs.source-ref }} lfs: 'true' - - name: load cached deps - uses: actions/cache@v5 + - name: Restore cached dependencies + if: inputs.dependency-artifact-id == '' + uses: actions/cache/restore@v5 with: path: ${{ inputs.cache-path }} key: ${{ inputs.cache-key }} fail-on-cache-miss: true + - name: Download dependencies from this run + if: inputs.dependency-artifact-id != '' + uses: actions/download-artifact@v7 + with: + artifact-ids: ${{ inputs.dependency-artifact-id }} + path: ${{ runner.temp }}/bambu-dependencies + merge-multiple: true + + - name: Unpack Windows dependencies + if: inputs.dependency-artifact-id != '' && runner.os == 'Windows' + shell: pwsh + env: + DEPS_PATH: ${{ inputs.cache-path }} + run: | + $archives = @(Get-ChildItem "$env:RUNNER_TEMP/bambu-dependencies" -Filter '*.zip' -File) + if ($archives.Count -ne 1) { throw 'Expected one Windows dependency archive' } + Expand-Archive -LiteralPath $archives[0].FullName -DestinationPath $env:DEPS_PATH + + - name: Unpack macOS or Linux dependencies + if: inputs.dependency-artifact-id != '' && runner.os != 'Windows' + shell: bash + env: + DEPS_DIR: ${{ runner.os == 'macOS' && 'deps' || 'deps/build' }} + run: | + archives=("$RUNNER_TEMP/bambu-dependencies/"*.tar.gz) + if [[ "${#archives[@]}" != 1 || ! -f "${archives[0]}" ]]; then + echo 'Expected one dependency archive' >&2 + exit 1 + fi + mkdir -p "$DEPS_DIR" + tar -xzf "${archives[0]}" -C "$DEPS_DIR" + - name: Set the package version env: RELEASE_VERSION: ${{ inputs.release-version }} diff --git a/.github/workflows/build_deps.yml b/.github/workflows/build_deps.yml index 2996aaec71..9631639f7f 100644 --- a/.github/workflows/build_deps.yml +++ b/.github/workflows/build_deps.yml @@ -29,6 +29,8 @@ jobs: name: Build Deps if: inputs.build-deps-only || inputs.valid-cache != true runs-on: ${{ inputs.os }} + outputs: + dependency-artifact-id: ${{ steps.upload_mac.outputs.artifact-id || steps.upload_windows.outputs.artifact-id || steps.upload_ubuntu.outputs.artifact-id }} env: date: steps: @@ -75,7 +77,7 @@ jobs: cmake --build . --parallel --config Release --target deps - name: pack deps on Windows - if: runner.os == 'Windows' && !inputs.release-version + if: runner.os == 'Windows' working-directory: ${{ github.workspace }} run: Compress-Archive -Path "${{ github.workspace }}\deps\build\BambuStudio_dep\*" -DestinationPath "${{ github.workspace }}\deps\build\BambuStudio_dep_win64_${{ env.date }}_vs2022.zip" shell: pwsh @@ -90,12 +92,21 @@ jobs: if brew list --versions zstd >/dev/null; then brew unlink zstd fi - ./BuildMac.sh -d -x -a "$BUILD_ARCH" -t 10.15 -1 + for attempt in 1 2 3; do + if ./BuildMac.sh -d -x -a "$BUILD_ARCH" -t 10.15 -1; then + break + fi + if [[ "$attempt" == 3 ]]; then + exit 1 + fi + echo "::warning::macOS dependency build attempt $attempt failed. Retrying in 15 seconds." + sleep 15 + done cd "deps/build/$BUILD_ARCH" find . -mindepth 1 -maxdepth 1 ! -name 'BambuStudio_deps' -exec rm -rf {} + - name: pack deps on Macos - if: runner.os == 'macOS' && !inputs.release-version + if: runner.os == 'macOS' working-directory: ${{ github.workspace }} run: | cd ${{ github.workspace }}/deps @@ -111,31 +122,43 @@ jobs: ./BuildLinux.sh -dfr - name: Pack Ubuntu dependencies - if: runner.os == 'Linux' && !inputs.release-version + if: runner.os == 'Linux' working-directory: ${{ github.workspace }}/deps/build run: tar -czvf BambuStudio_dep_${{ inputs.os }}_$(date +"%Y%m%d").tar.gz destdir # Upload Artifacts - name: Upload Mac ${{ inputs.arch }} artifacts - if: runner.os == 'macOS' && !inputs.release-version + id: upload_mac + if: runner.os == 'macOS' uses: actions/upload-artifact@v6 with: name: BambuStudio_dep_mac_${{ inputs.arch }}_${{ env.date }} path: ${{ github.workspace }}/deps/BambuStudio_dep_mac_${{ inputs.arch }}*.tar.gz + if-no-files-found: error + retention-days: ${{ inputs.release-version && 2 || 0 }} + overwrite: true - name: Upload Windows artifacts - if: runner.os == 'Windows' && !inputs.release-version + id: upload_windows + if: runner.os == 'Windows' uses: actions/upload-artifact@v6 with: name: BambuStudio_dep_win64_${{ env.date }} path: ${{ github.workspace }}/deps/build/BambuStudio_dep*.zip + if-no-files-found: error + retention-days: ${{ inputs.release-version && 2 || 0 }} + overwrite: true - name: Upload Ubuntu artifacts - if: ${{ !env.ACT && runner.os == 'Linux' && !inputs.release-version }} + id: upload_ubuntu + if: ${{ !env.ACT && runner.os == 'Linux' }} uses: actions/upload-artifact@v6 with: name: BambuStudio_dep_${{ inputs.os }}_${{ env.date }} path: ${{ github.workspace }}/deps/build/BambuStudio_dep_${{ inputs.os }}_*.tar.gz + if-no-files-found: error + retention-days: ${{ inputs.release-version && 2 || 0 }} + overwrite: true build_Bambu: name: Build BambuStudio @@ -148,6 +171,7 @@ jobs: with: cache-key: ${{ inputs.cache-key }} cache-path: ${{ inputs.cache-path }} + dependency-artifact-id: ${{ needs.build_deps.outputs.dependency-artifact-id }} os: ${{ inputs.os }} arch: ${{ inputs.arch }} source-ref: ${{ inputs.source-ref }} From be2a7daf83deb9eef62bec94893044f3bb2d93f0 Mon Sep 17 00:00:00 2001 From: leroy ketelaars Date: Sat, 5 Dec 2026 20:15:18 +0100 Subject: [PATCH 10/10] Restore zstd before saving macOS dependency caches --- .github/workflows/build_deps.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_deps.yml b/.github/workflows/build_deps.yml index 9631639f7f..4f0dcbc5f9 100644 --- a/.github/workflows/build_deps.yml +++ b/.github/workflows/build_deps.yml @@ -89,8 +89,10 @@ jobs: working-directory: ${{ github.workspace }} run: | brew install automake texinfo nasm yasm x264 - if brew list --versions zstd >/dev/null; then + if [[ -L "$(brew --prefix)/bin/zstd" ]]; then brew unlink zstd + # Restore the compression tool before the cache save step. + trap 'brew link zstd' EXIT fi for attempt in 1 2 3; do if ./BuildMac.sh -d -x -a "$BUILD_ARCH" -t 10.15 -1; then