Fixed duplication of auxiliary volumes when GLCanvas3D::reload_scene() is called for SLA printers

This commit is contained in:
enricoturri1966 2023-03-23 10:16:13 +01:00
parent 760f74ce6a
commit e585fd2221
2 changed files with 19 additions and 15 deletions

View File

@ -603,24 +603,28 @@ void GLVolumeCollection::load_object_auxiliary(
}; };
// Get the support mesh. // Get the support mesh.
TriangleMesh supports_mesh = print_object->support_mesh(); if (milestone == SLAPrintObjectStep::slaposSupportTree) {
if (!supports_mesh.empty()) { TriangleMesh supports_mesh = print_object->support_mesh();
supports_mesh.transform(mesh_trafo_inv); if (!supports_mesh.empty()) {
TriangleMesh convex_hull = supports_mesh.convex_hull_3d(); supports_mesh.transform(mesh_trafo_inv);
for (const std::pair<size_t, size_t>& instance_idx : instances) { TriangleMesh convex_hull = supports_mesh.convex_hull_3d();
const ModelInstance& model_instance = *print_object->model_object()->instances[instance_idx.first]; for (const std::pair<size_t, size_t>& instance_idx : instances) {
add_volume(obj_idx, (int)instance_idx.first, model_instance, slaposSupportTree, supports_mesh, GLVolume::SLA_SUPPORT_COLOR, convex_hull); const ModelInstance& model_instance = *print_object->model_object()->instances[instance_idx.first];
add_volume(obj_idx, (int)instance_idx.first, model_instance, slaposSupportTree, supports_mesh, GLVolume::SLA_SUPPORT_COLOR, convex_hull);
}
} }
} }
// Get the pad mesh. // Get the pad mesh.
TriangleMesh pad_mesh = print_object->pad_mesh(); if (milestone == SLAPrintObjectStep::slaposPad) {
if (!pad_mesh.empty()) { TriangleMesh pad_mesh = print_object->pad_mesh();
pad_mesh.transform(mesh_trafo_inv); if (!pad_mesh.empty()) {
TriangleMesh convex_hull = pad_mesh.convex_hull_3d(); pad_mesh.transform(mesh_trafo_inv);
for (const std::pair<size_t, size_t>& instance_idx : instances) { TriangleMesh convex_hull = pad_mesh.convex_hull_3d();
const ModelInstance& model_instance = *print_object->model_object()->instances[instance_idx.first]; for (const std::pair<size_t, size_t>& instance_idx : instances) {
add_volume(obj_idx, (int)instance_idx.first, model_instance, slaposPad, pad_mesh, GLVolume::SLA_PAD_COLOR, convex_hull); const ModelInstance& model_instance = *print_object->model_object()->instances[instance_idx.first];
add_volume(obj_idx, (int)instance_idx.first, model_instance, slaposPad, pad_mesh, GLVolume::SLA_PAD_COLOR, convex_hull);
}
} }
} }
} }

View File

@ -2162,7 +2162,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
} }
update_volumes_colors_by_extruder(); update_volumes_colors_by_extruder();
// Update selection indices based on the old/new GLVolumeCollection. // Update selection indices based on the old/new GLVolumeCollection.
if (m_selection.get_mode() == Selection::Instance) if (m_selection.get_mode() == Selection::Instance)
m_selection.instances_changed(instance_ids_selected); m_selection.instances_changed(instance_ids_selected);
else else