Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/editmesh_mask_extract.c
| Show First 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | if (new_mesh->totvert == 0) { | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| ushort local_view_bits = 0; | ushort local_view_bits = 0; | ||||
| if (v3d && v3d->localvd) { | if (v3d && v3d->localvd) { | ||||
| local_view_bits = v3d->local_view_uuid; | local_view_bits = v3d->local_view_uuid; | ||||
| } | } | ||||
| Object *new_ob = ED_object_add_type(C, OB_MESH, NULL, ob->loc, ob->rot, false, local_view_bits); | Object *new_ob = ED_object_add_type(C, OB_MESH, NULL, ob->loc, ob->rot, false, local_view_bits); | ||||
| BKE_mesh_nomain_to_mesh(new_mesh, new_ob->data, new_ob, &CD_MASK_EVERYTHING, true); | BKE_mesh_nomain_to_mesh(new_mesh, new_ob->data, new_ob); | ||||
| /* Remove the Face Sets as they need to be recreated when entering Sculpt Mode in the new object. | /* 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. */ | * TODO(pablodobarro): In the future we can try to preserve them from the original mesh. */ | ||||
| Mesh *new_ob_mesh = new_ob->data; | Mesh *new_ob_mesh = new_ob->data; | ||||
| CustomData_free_layers(&new_ob_mesh->pdata, CD_SCULPT_FACE_SETS, new_ob_mesh->totpoly); | CustomData_free_layers(&new_ob_mesh->pdata, CD_SCULPT_FACE_SETS, new_ob_mesh->totpoly); | ||||
| /* Remove the mask from the new object so it can be sculpted directly after extracting. */ | /* Remove the mask from the new object so it can be sculpted directly after extracting. */ | ||||
| CustomData_free_layers(&new_ob_mesh->vdata, CD_PAINT_MASK, new_ob_mesh->totvert); | CustomData_free_layers(&new_ob_mesh->vdata, CD_PAINT_MASK, new_ob_mesh->totvert); | ||||
| ▲ Show 20 Lines • Show All 327 Lines • ▼ Show 20 Lines | new_ob_mesh = BKE_mesh_from_bmesh_nomain(bm, | ||||
| .calc_object_remap = false, | .calc_object_remap = false, | ||||
| }), | }), | ||||
| mesh); | mesh); | ||||
| BM_mesh_free(bm); | BM_mesh_free(bm); | ||||
| /* Remove the mask from the new object so it can be sculpted directly after slicing. */ | /* Remove the mask from the new object so it can be sculpted directly after slicing. */ | ||||
| CustomData_free_layers(&new_ob_mesh->vdata, CD_PAINT_MASK, new_ob_mesh->totvert); | CustomData_free_layers(&new_ob_mesh->vdata, CD_PAINT_MASK, new_ob_mesh->totvert); | ||||
| BKE_mesh_nomain_to_mesh(new_ob_mesh, new_ob->data, new_ob, &CD_MASK_MESH, true); | BKE_mesh_nomain_to_mesh(new_ob_mesh, new_ob->data, new_ob); | ||||
| BKE_mesh_copy_parameters_for_eval(new_ob->data, mesh); | BKE_mesh_copy_parameters_for_eval(new_ob->data, mesh); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, new_ob); | WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, new_ob); | ||||
| BKE_mesh_batch_cache_dirty_tag(new_ob->data, BKE_MESH_BATCH_DIRTY_ALL); | BKE_mesh_batch_cache_dirty_tag(new_ob->data, BKE_MESH_BATCH_DIRTY_ALL); | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| DEG_id_tag_update(&new_ob->id, ID_RECALC_GEOMETRY); | DEG_id_tag_update(&new_ob->id, ID_RECALC_GEOMETRY); | ||||
| WM_event_add_notifier(C, NC_GEOM | ND_DATA, new_ob->data); | WM_event_add_notifier(C, NC_GEOM | ND_DATA, new_ob->data); | ||||
| } | } | ||||
| BKE_mesh_nomain_to_mesh(new_mesh, ob->data, ob, &CD_MASK_MESH, true); | BKE_mesh_nomain_to_mesh(new_mesh, ob->data, ob); | ||||
| if (ob->mode == OB_MODE_SCULPT) { | if (ob->mode == OB_MODE_SCULPT) { | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| ss->face_sets = CustomData_get_layer(&((Mesh *)ob->data)->pdata, CD_SCULPT_FACE_SETS); | ss->face_sets = CustomData_get_layer(&((Mesh *)ob->data)->pdata, CD_SCULPT_FACE_SETS); | ||||
| if (ss->face_sets) { | if (ss->face_sets) { | ||||
| /* Assign a new Face Set ID to the new faces created by the slice operation. */ | /* Assign a new Face Set ID to the new faces created by the slice operation. */ | ||||
| const int next_face_set_id = ED_sculpt_face_sets_find_next_available_id(ob->data); | const int next_face_set_id = ED_sculpt_face_sets_find_next_available_id(ob->data); | ||||
| ED_sculpt_face_sets_initialize_none_to_id(ob->data, next_face_set_id); | ED_sculpt_face_sets_initialize_none_to_id(ob->data, next_face_set_id); | ||||
| ▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines | |||||