From 5efb35100d54060dd049f48ed34728fab44eb0fe Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 7 Feb 2024 10:19:37 -0500 Subject: [PATCH] Fix #117929: Extract face set operator crash The problem was calling a "for eval" function on an original mesh in the main data-base. The parameters are already copied anyway, so the call was unnecessary. Also reorder some changes to happen before the geometry is moved to the original mesh. --- .../editors/mesh/editmesh_mask_extract.cc | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_mask_extract.cc b/source/blender/editors/mesh/editmesh_mask_extract.cc index 3527d1cb8fb..59eacec2622 100644 --- a/source/blender/editors/mesh/editmesh_mask_extract.cc +++ b/source/blender/editors/mesh/editmesh_mask_extract.cc @@ -191,6 +191,13 @@ static int geometry_extract_apply(bContext *C, bm_to_mesh_params.calc_object_remap = false; new_mesh = BKE_mesh_from_bmesh_nomain(bm, &bm_to_mesh_params, mesh); + /* Remove the Face Sets as they need to be recreated when entering Sculpt Mode in the new object. + * TODO(pablodobarro): In the future we can try to preserve them from the original mesh. */ + new_mesh->attributes_for_write().remove(".sculpt_face_set"); + + /* Remove the mask from the new object so it can be sculpted directly after extracting. */ + new_mesh->attributes_for_write().remove(".sculpt_mask"); + BKE_editmesh_free_data(em); MEM_freeN(em); @@ -207,17 +214,6 @@ static int geometry_extract_apply(bContext *C, C, OB_MESH, nullptr, ob->loc, ob->rot, false, local_view_bits); BKE_mesh_nomain_to_mesh(new_mesh, static_cast(new_ob->data), new_ob); - Mesh *new_ob_mesh = static_cast(new_ob->data); - - /* Remove the Face Sets as they need to be recreated when entering Sculpt Mode in the new object. - * TODO(pablodobarro): In the future we can try to preserve them from the original mesh. */ - new_ob_mesh->attributes_for_write().remove(".sculpt_face_set"); - - /* Remove the mask from the new object so it can be sculpted directly after extracting. */ - new_ob_mesh->attributes_for_write().remove(".sculpt_mask"); - - BKE_mesh_copy_parameters_for_eval(new_ob_mesh, mesh); - if (params->apply_shrinkwrap) { BKE_shrinkwrap_mesh_nearest_surface_deform(CTX_data_depsgraph_pointer(C), scene, new_ob, ob); }