diff --git a/src/libslic3r/MultiMaterialSegmentation.cpp b/src/libslic3r/MultiMaterialSegmentation.cpp index 3fd60de3fd..add29c4e38 100644 --- a/src/libslic3r/MultiMaterialSegmentation.cpp +++ b/src/libslic3r/MultiMaterialSegmentation.cpp @@ -1602,6 +1602,15 @@ static void update_color_changes_using_color_projection_ranges(std::vector= 0) { + const TriangleMesh &mesh = volume.mesh(); + return {mesh.its.indices, mesh.its.vertices, std::vector(mesh.its.indices.size(), uint8_t(volume_extruder_id))}; + } + + return volume.mm_segmentation_facets.get_all_facets_strict_with_colors(volume); +} + std::vector> multi_material_segmentation_by_painting(const PrintObject &print_object, const std::function &throw_on_cancel_callback) { const size_t num_extruders = print_object.print()->config().nozzle_diameter.size(); @@ -1650,7 +1659,7 @@ std::vector> multi_material_segmentation_by_painting(con BOOST_LOG_TRIVIAL(debug) << "MM segmentation - Slicing painted triangles - Begin"; const std::vector layer_zs = get_print_object_layers_zs(layers); for (const ModelVolume *mv : print_object.model_object()->volumes) { - const indexed_triangle_set_with_color mesh_with_color = mv->mm_segmentation_facets.get_all_facets_strict_with_colors(*mv); + const indexed_triangle_set_with_color mesh_with_color = extract_mesh_with_color(*mv); const Transform3d trafo = print_object.trafo_centered() * mv->get_matrix(); const MeshSlicingParams slicing_params{trafo}; diff --git a/src/libslic3r/PrintApply.cpp b/src/libslic3r/PrintApply.cpp index f30d811457..6cce84d5cc 100644 --- a/src/libslic3r/PrintApply.cpp +++ b/src/libslic3r/PrintApply.cpp @@ -1403,17 +1403,19 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ print_object_regions->ref_cnt_inc(); } std::vector painting_extruders; - if (const auto &volumes = print_object.model_object()->volumes; - num_extruders > 1 && - std::find_if(volumes.begin(), volumes.end(), [](const ModelVolume *v) { return ! v->mm_segmentation_facets.empty(); }) != volumes.end()) { - + if (const auto &volumes = print_object.model_object()->volumes; num_extruders > 1 && print_object.model_object()->is_mm_painted()) { std::array(TriangleStateType::Count)> used_facet_states{}; for (const ModelVolume *volume : volumes) { - const std::vector &volume_used_facet_states = volume->mm_segmentation_facets.get_data().used_states; + if (volume->is_mm_painted()) { + const std::vector &volume_used_facet_states = volume->mm_segmentation_facets.get_data().used_states; - assert(volume_used_facet_states.size() == used_facet_states.size()); - for (size_t state_idx = 0; state_idx < std::min(volume_used_facet_states.size(), used_facet_states.size()); ++state_idx) - used_facet_states[state_idx] |= volume_used_facet_states[state_idx]; + assert(volume_used_facet_states.size() == used_facet_states.size()); + for (size_t state_idx = 0; state_idx < std::min(volume_used_facet_states.size(), used_facet_states.size()); ++state_idx) { + used_facet_states[state_idx] |= volume_used_facet_states[state_idx]; + } + } else if (const int volume_extruder_id = volume->extruder_id(); volume_extruder_id >= 0) { + used_facet_states[volume_extruder_id] |= true; + } } for (size_t state_idx = static_cast(TriangleStateType::Extruder1); state_idx < used_facet_states.size(); ++state_idx) { diff --git a/src/libslic3r/PrintObjectSlice.cpp b/src/libslic3r/PrintObjectSlice.cpp index 04fcde0152..754a2d1ef0 100644 --- a/src/libslic3r/PrintObjectSlice.cpp +++ b/src/libslic3r/PrintObjectSlice.cpp @@ -753,10 +753,7 @@ void PrintObject::slice_volumes() m_print->throw_if_canceled(); // Is any ModelVolume MMU painted? - if (const auto& volumes = this->model_object()->volumes; - m_print->config().nozzle_diameter.size() > 1 && - std::find_if(volumes.begin(), volumes.end(), [](const ModelVolume* v) { return !v->mm_segmentation_facets.empty(); }) != volumes.end()) { - + if (m_print->config().nozzle_diameter.size() > 1 && this->model_object()->is_mm_painted()) { // If XY Size compensation is also enabled, notify the user that XY Size compensation // would not be used because the object is multi-material painted. if (m_config.xy_size_compensation.value != 0.f) {