Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/editmesh_mask_extract.c
| Show First 20 Lines • Show All 342 Lines • ▼ Show 20 Lines | static int paint_mask_slice_exec(bContext *C, wmOperator *op) | ||||
| BKE_sculpt_mask_layers_ensure(ob, NULL); | BKE_sculpt_mask_layers_ensure(ob, NULL); | ||||
| Mesh *mesh = ob->data; | Mesh *mesh = ob->data; | ||||
| Mesh *new_mesh = BKE_mesh_copy(bmain, mesh); | Mesh *new_mesh = BKE_mesh_copy(bmain, mesh); | ||||
| if (ob->mode == OB_MODE_SCULPT) { | if (ob->mode == OB_MODE_SCULPT) { | ||||
| ED_sculpt_undo_geometry_begin(ob, "mask slice"); | ED_sculpt_undo_geometry_begin(ob, "mask slice"); | ||||
| CustomData_free_layers(&mesh->pdata, CD_SCULPT_FACE_SETS, mesh->totpoly); | |||||
| } | } | ||||
| BMesh *bm; | BMesh *bm; | ||||
| const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(new_mesh); | const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(new_mesh); | ||||
| bm = BM_mesh_create(&allocsize, | bm = BM_mesh_create(&allocsize, | ||||
| &((struct BMeshCreateParams){ | &((struct BMeshCreateParams){ | ||||
| .use_toolflags = true, | .use_toolflags = true, | ||||
| })); | })); | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | if (RNA_boolean_get(op->ptr, "new_object")) { | ||||
| 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, &CD_MASK_MESH, true); | ||||
| BKE_mesh_calc_normals(ob->data); | BKE_mesh_calc_normals(ob->data); | ||||
| if (ob->mode == OB_MODE_SCULPT) { | if (ob->mode == OB_MODE_SCULPT) { | ||||
| ED_sculpt_undo_geometry_end(ob); | ED_sculpt_undo_geometry_end(ob); | ||||
| SculptSession *ss = ob->sculpt; | |||||
| /* Rebuild a new valid Face Set layer for the object. */ | |||||
| ss->face_sets = CustomData_add_layer( | |||||
| &mesh->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, mesh->totpoly); | |||||
| for (int i = 0; i < mesh->totpoly; i++) { | |||||
| ss->face_sets[i] = 1; | |||||
| } | |||||
| } | } | ||||
| BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL); | BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL); | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | ||||
| WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); | WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| Show All 35 Lines | |||||