Merge branch 'ys_spe2185'

This commit is contained in:
Lukas Matena 2024-05-02 13:28:19 +02:00
commit 7b7d310f7a
2 changed files with 19 additions and 6 deletions

View File

@ -398,12 +398,17 @@ static void distribute_modifiers_from_object(ModelObject* from_obj, const int in
// Don't add modifiers which are processed connectors // Don't add modifiers which are processed connectors
if (vol->cut_info.is_connector && !vol->cut_info.is_processed) if (vol->cut_info.is_connector && !vol->cut_info.is_processed)
continue; continue;
// Modifiers are not cut, but we still need to add the instance transformation
// to the modifier volume transformation to preserve their shape properly.
const auto modifier_trafo = Transformation(from_obj->instances[instance_idx]->get_transformation().get_matrix_no_offset() * vol->get_matrix());
auto bb = vol->mesh().transformed_bounding_box(inst_matrix * vol->get_matrix()); auto bb = vol->mesh().transformed_bounding_box(inst_matrix * vol->get_matrix());
// Don't add modifiers which are not intersecting with solid parts // Don't add modifiers which are not intersecting with solid parts
if (obj1_bb.intersects(bb)) if (obj1_bb.intersects(bb))
to_obj1->add_volume(*vol); to_obj1->add_volume(*vol)->set_transformation(modifier_trafo);
if (obj2_bb.intersects(bb)) if (obj2_bb.intersects(bb))
to_obj2->add_volume(*vol); to_obj2->add_volume(*vol)->set_transformation(modifier_trafo);
} }
} }
@ -627,8 +632,12 @@ const ModelObjectPtrs& Cut::perform_with_groove(const Groove& groove, const Tran
// add modifiers // add modifiers
for (const ModelVolume* volume : cut_mo->volumes) for (const ModelVolume* volume : cut_mo->volumes)
if (!volume->is_model_part()) if (!volume->is_model_part()) {
upper->add_volume(*volume); // Modifiers are not cut, but we still need to add the instance transformation
// to the modifier volume transformation to preserve their shape properly.
const auto modifier_trafo = Transformation(cut_mo->instances[m_instance]->get_transformation().get_matrix_no_offset() * volume->get_matrix());
upper->add_volume(*volume)->set_transformation(modifier_trafo);
}
cut_object_ptrs.push_back(upper); cut_object_ptrs.push_back(upper);
@ -636,7 +645,11 @@ const ModelObjectPtrs& Cut::perform_with_groove(const Groove& groove, const Tran
cut_object_ptrs.push_back(lower); cut_object_ptrs.push_back(lower);
} }
else { else {
// add modifiers if object has any reset_instance_transformation(upper, m_instance, m_cut_matrix);
reset_instance_transformation(lower, m_instance, m_cut_matrix);
// Add modifiers if object has any
// Note: make it after all transformations are reset for upper/lower object
for (const ModelVolume* volume : cut_mo->volumes) for (const ModelVolume* volume : cut_mo->volumes)
if (!volume->is_model_part()) { if (!volume->is_model_part()) {
distribute_modifiers_from_object(cut_mo, m_instance, upper, lower); distribute_modifiers_from_object(cut_mo, m_instance, upper, lower);

View File

@ -1893,7 +1893,7 @@ GLGizmoCut3D::PartSelection::PartSelection(const ModelObject* mo, const Transfor
// split to parts // split to parts
for (int id = int(volumes.size())-1; id >= 0; id--) for (int id = int(volumes.size())-1; id >= 0; id--)
if (volumes[id]->is_splittable()) if (volumes[id]->is_splittable() && volumes[id]->is_model_part()) // we have to split just solid volumes
volumes[id]->split(1); volumes[id]->split(1);
m_parts.clear(); m_parts.clear();