diff --git a/src/libslic3r/BuildVolume.cpp b/src/libslic3r/BuildVolume.cpp index 8cb1715a08..0d26d78aa7 100644 --- a/src/libslic3r/BuildVolume.cpp +++ b/src/libslic3r/BuildVolume.cpp @@ -364,20 +364,22 @@ BuildVolume::ObjectState BuildVolume::volume_state_bbox(const BoundingBoxf3 volu build_volume.min.z() = -std::numeric_limits::max(); ObjectState state = ObjectState::Outside; - int bed_id = 0; - for (bed_id = 0; bed_id <= std::min(s_multiple_beds.get_number_of_beds(), s_multiple_beds.get_max_beds() - 1); ++bed_id) { + int obj_bed_id = -1; + for (int bed_id = 0; bed_id <= std::min(s_multiple_beds.get_number_of_beds(), s_multiple_beds.get_max_beds() - 1); ++bed_id) { BoundingBoxf3 volume_bbox = volume_bbox_orig; volume_bbox.translate(-s_multiple_beds.get_bed_translation(bed_id)); state = build_volume.max.z() <= -SceneEpsilon ? ObjectState::Below : build_volume.contains(volume_bbox) ? ObjectState::Inside : build_volume.intersects(volume_bbox) ? ObjectState::Colliding : ObjectState::Outside; - if (state != ObjectState::Outside) + if (state != ObjectState::Outside) { + obj_bed_id = bed_id; break; + } } if (bed_idx) - *bed_idx = bed_id; + *bed_idx = obj_bed_id; return state; } diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 52694e12da..e657796865 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -1660,7 +1660,7 @@ unsigned int ModelObject::update_instances_print_volume_state(const BuildVolume inside_outside == INSIDE ? ModelInstancePVS_Inside : ModelInstancePVS_Fully_Outside; if (inside_outside == INSIDE) ++num_printable; - if (bed_idx != -1 && model_instance->is_printable()) + if (bed_idx != -1) s_multiple_beds.set_instance_bed(model_instance->id(), bed_idx); } return num_printable; diff --git a/src/libslic3r/MultipleBeds.cpp b/src/libslic3r/MultipleBeds.cpp index 389bbea131..6996646289 100644 --- a/src/libslic3r/MultipleBeds.cpp +++ b/src/libslic3r/MultipleBeds.cpp @@ -197,10 +197,11 @@ bool MultipleBeds::is_glvolume_on_thumbnail_bed(const Model& model, int obj_idx, return (m_bed_for_thumbnails_generation < 0 || it->second == m_bed_for_thumbnails_generation); } -void MultipleBeds::update_shown_beds(Model& model, const BuildVolume& build_volume) { +void MultipleBeds::update_shown_beds(Model& model, const BuildVolume& build_volume, bool only_remove /*=false*/) { const int original_number_of_beds = m_number_of_beds; const int stash_active = get_active_bed(); - m_number_of_beds = get_max_beds(); + if (! only_remove) + m_number_of_beds = get_max_beds(); model.update_print_volume_state(build_volume); const int max_bed{std::accumulate( this->m_inst_to_bed.begin(), this->m_inst_to_bed.end(), 0, diff --git a/src/libslic3r/MultipleBeds.hpp b/src/libslic3r/MultipleBeds.hpp index ccc5fbcc66..6daa7ce99a 100644 --- a/src/libslic3r/MultipleBeds.hpp +++ b/src/libslic3r/MultipleBeds.hpp @@ -52,7 +52,7 @@ public: void set_last_hovered_bed(int i) { m_last_hovered_bed = i; } int get_last_hovered_bed() const { return m_last_hovered_bed; } - void update_shown_beds(Model& model, const BuildVolume& build_volume); + void update_shown_beds(Model& model, const BuildVolume& build_volume, bool only_remove = false); bool rearrange_after_load(Model& model, const BuildVolume& build_volume, std::function update_fn); void set_loading_project_flag(bool project) { m_loading_project = project; } bool get_loading_project_flag() const { return m_loading_project; } diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index a7f0bc25b0..9cbf2c8d24 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1563,8 +1563,8 @@ bool GLCanvas3D::check_volumes_outside_state(GLVolumeCollection& volumes, ModelI overall_state = ModelInstancePVS_Partly_Outside; contained_min_one |= !volume->is_outside; - if (! volume->is_outside && bed_idx != -1 && bed_idx == s_multiple_beds.get_number_of_beds()) - s_multiple_beds.request_next_bed(true); + if (bed_idx != -1 && bed_idx == s_multiple_beds.get_number_of_beds()) + s_multiple_beds.request_next_bed(true); } } else if (volume->is_modifier) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 8cab8c17fa..e62d11f55f 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1093,7 +1093,7 @@ void Plater::priv::update(unsigned int flags) // Update the SLAPrint from the current Model, so that the reload_scene() // pulls the correct data. update_status = this->update_background_process(false, flags & (unsigned int)UpdateParams::POSTPONE_VALIDATION_ERROR_MESSAGE); - s_multiple_beds.update_shown_beds(model, q->build_volume()); + s_multiple_beds.update_shown_beds(model, q->build_volume(), true); this->view3D->reload_scene(false, flags & (unsigned int)UpdateParams::FORCE_FULL_SCREEN_REFRESH); this->preview->reload_print(); if (force_background_processing_restart) @@ -1600,11 +1600,12 @@ std::vector Plater::priv::load_files(const std::vector& input_ GLGizmoSimplify::add_simplify_suggestion_notification( obj_idxs, model.objects, *notification_manager); - if (s_multiple_beds.rearrange_after_load(model, q->build_volume(), [this]() { + s_multiple_beds.rearrange_after_load(model, q->build_volume(), [this]() { q->canvas3D()->check_volumes_outside_state(); s_multiple_beds.ensure_wipe_towers_on_beds(model, fff_prints); - })) - update(); + s_multiple_beds.update_shown_beds(model, q->build_volume()); + }); + update(); return obj_idxs; } @@ -4089,6 +4090,7 @@ void Plater::priv::update_after_undo_redo(const UndoRedo::Snapshot& snapshot, bo this->view3D->get_canvas3d()->get_selection().set_deserialized(GUI::Selection::EMode(this->undo_redo_stack().selection_deserialized().mode), this->undo_redo_stack().selection_deserialized().volumes_and_instances); this->view3D->get_canvas3d()->get_gizmos_manager().update_after_undo_redo(snapshot); + s_multiple_beds.update_shown_beds(model, q->build_volume(), false); wxGetApp().obj_list()->update_after_undo_redo(); if (wxGetApp().get_mode() == comSimple && model_has_advanced_features(this->model)) { @@ -6811,6 +6813,7 @@ void Plater::arrange(Worker &w, const ArrangeSelectionMode &mode) concat_strings(names, "\n"))); } + s_multiple_beds.update_shown_beds(model(), build_volume()); canvas3D()->check_volumes_outside_state(); update(static_cast(UpdateParams::FORCE_FULL_SCREEN_REFRESH));