Blender  V3.3
editmesh_mask_extract.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2019 Blender Foundation. All rights reserved. */
3 
8 #include "DNA_mesh_types.h"
9 #include "DNA_modifier_types.h"
10 #include "DNA_object_types.h"
11 
12 #include "BLI_math.h"
13 
14 #include "BLT_translation.h"
15 
16 #include "BKE_context.h"
17 #include "BKE_editmesh.h"
18 #include "BKE_layer.h"
19 #include "BKE_lib_id.h"
20 #include "BKE_mesh.h"
21 #include "BKE_modifier.h"
22 #include "BKE_paint.h"
23 #include "BKE_report.h"
24 #include "BKE_screen.h"
25 #include "BKE_shrinkwrap.h"
26 
27 #include "DEG_depsgraph.h"
28 #include "DEG_depsgraph_build.h"
29 
30 #include "RNA_access.h"
31 #include "RNA_define.h"
32 
33 #include "WM_api.h"
34 #include "WM_types.h"
35 
36 #include "ED_mesh.h"
37 #include "ED_object.h"
38 #include "ED_screen.h"
39 #include "ED_sculpt.h"
40 #include "ED_undo.h"
41 #include "ED_view3d.h"
42 
43 #include "bmesh_tools.h"
44 
45 #include "MEM_guardedalloc.h"
46 
47 #include "mesh_intern.h" /* own include */
48 
50 {
52  if (ob != NULL && ob->mode == OB_MODE_SCULPT) {
53  if (ob->sculpt->bm) {
54  CTX_wm_operator_poll_msg_set(C, "The geometry can not be extracted with dyntopo activated");
55  return false;
56  }
58  }
59  return false;
60 }
61 
62 typedef struct GeometryExtactParams {
63  /* For extracting Face Sets. */
65 
66  /* For extracting Mask. */
68 
69  /* Common parameters. */
75 
76 /* Function that tags in BMesh the faces that should be deleted in the extracted object. */
78 
80  wmOperator *op,
83 {
84  struct Main *bmain = CTX_data_main(C);
86  View3D *v3d = CTX_wm_view3d(C);
89 
91 
93 
94  /* Ensures that deformation from sculpt mode is taken into account before duplicating the mesh to
95  * extract the geometry. */
97 
98  Mesh *mesh = ob->data;
99  Mesh *new_mesh = (Mesh *)BKE_id_copy(bmain, &mesh->id);
100 
101  const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(new_mesh);
102  BMesh *bm;
103  bm = BM_mesh_create(&allocsize,
104  &((struct BMeshCreateParams){
105  .use_toolflags = true,
106  }));
107 
109  new_mesh,
110  (&(struct BMeshFromMeshParams){
111  .calc_face_normal = true,
112  .calc_vert_normal = true,
113  }));
114 
116 
117  /* Generate the tags for deleting geometry in the extracted object. */
118  tag_fn(bm, params);
119 
120  /* Delete all tagged faces. */
123 
124  BMVert *v;
125  BMEdge *ed;
126  BMIter iter;
127  BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
128  mul_v3_v3(v->co, ob->scale);
129  }
130 
131  if (params->add_boundary_loop) {
132  BM_ITER_MESH (ed, &iter, bm, BM_EDGES_OF_MESH) {
134  }
135  edbm_extrude_edges_indiv(em, op, BM_ELEM_TAG, false);
136 
137  for (int repeat = 0; repeat < params->num_smooth_iterations; repeat++) {
139  BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
141  }
142  for (int i = 0; i < 3; i++) {
143  if (!EDBM_op_callf(em,
144  op,
145  "smooth_vert verts=%hv factor=%f mirror_clip_x=%b mirror_clip_y=%b "
146  "mirror_clip_z=%b "
147  "clip_dist=%f use_axis_x=%b use_axis_y=%b use_axis_z=%b",
148  BM_ELEM_TAG,
149  1.0,
150  false,
151  false,
152  false,
153  0.1,
154  true,
155  true,
156  true)) {
157  continue;
158  }
159  }
160 
162  BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
164  }
165  for (int i = 0; i < 1; i++) {
166  if (!EDBM_op_callf(em,
167  op,
168  "smooth_vert verts=%hv factor=%f mirror_clip_x=%b mirror_clip_y=%b "
169  "mirror_clip_z=%b "
170  "clip_dist=%f use_axis_x=%b use_axis_y=%b use_axis_z=%b",
171  BM_ELEM_TAG,
172  0.5,
173  false,
174  false,
175  false,
176  0.1,
177  true,
178  true,
179  true)) {
180  continue;
181  }
182  }
183  }
184  }
185 
187 
188  BKE_id_free(bmain, new_mesh);
189  new_mesh = BKE_mesh_from_bmesh_nomain(bm,
190  (&(struct BMeshToMeshParams){
191  .calc_object_remap = false,
192  }),
193  mesh);
194 
196  MEM_freeN(em);
197 
198  if (new_mesh->totvert == 0) {
199  BKE_id_free(bmain, new_mesh);
200  return OPERATOR_FINISHED;
201  }
202 
203  ushort local_view_bits = 0;
204  if (v3d && v3d->localvd) {
205  local_view_bits = v3d->local_view_uuid;
206  }
207  Object *new_ob = ED_object_add_type(C, OB_MESH, NULL, ob->loc, ob->rot, false, local_view_bits);
208  BKE_mesh_nomain_to_mesh(new_mesh, new_ob->data, new_ob, &CD_MASK_EVERYTHING, true);
209 
210  /* Remove the Face Sets as they need to be recreated when entering Sculpt Mode in the new object.
211  * TODO(pablodobarro): In the future we can try to preserve them from the original mesh. */
212  Mesh *new_ob_mesh = new_ob->data;
213  CustomData_free_layers(&new_ob_mesh->pdata, CD_SCULPT_FACE_SETS, new_ob_mesh->totpoly);
214 
215  /* Remove the mask from the new object so it can be sculpted directly after extracting. */
216  CustomData_free_layers(&new_ob_mesh->vdata, CD_PAINT_MASK, new_ob_mesh->totvert);
217 
219 
220  if (params->apply_shrinkwrap) {
222  }
223 
224  if (params->add_solidify) {
226  op->reports, bmain, scene, new_ob, "geometry_extract_solidify", eModifierType_Solidify);
228  new_ob, "mask_extract_solidify");
229  if (sfmd) {
230  sfmd->offset = -0.05f;
231  }
232  }
233 
239 
240  return OPERATOR_FINISHED;
241 }
242 
244 {
245  const float threshold = params->mask_threshold;
246 
248  const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
249 
250  BMFace *f;
251  BMIter iter;
252  BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
253  bool keep_face = true;
254  BMVert *v;
255  BMIter face_iter;
256  BM_ITER_ELEM (v, &face_iter, f, BM_VERTS_OF_FACE) {
257  const float mask = BM_ELEM_CD_GET_FLOAT(v, cd_vert_mask_offset);
258  if (mask < threshold) {
259  keep_face = false;
260  break;
261  }
262  }
263  BM_elem_flag_set(f, BM_ELEM_TAG, !keep_face);
264  }
265 }
266 
268 {
269  const int tag_face_set_id = params->active_face_set;
270 
272  const int cd_face_sets_offset = CustomData_get_offset(&bm->pdata, CD_SCULPT_FACE_SETS);
273 
274  BMFace *f;
275  BMIter iter;
276  BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
277  const int face_set_id = abs(BM_ELEM_CD_GET_INT(f, cd_face_sets_offset));
278  BM_elem_flag_set(f, BM_ELEM_TAG, face_set_id != tag_face_set_id);
279  }
280 }
281 
283 {
285  params.mask_threshold = RNA_float_get(op->ptr, "mask_threshold");
286  params.num_smooth_iterations = RNA_int_get(op->ptr, "smooth_iterations");
287  params.add_boundary_loop = RNA_boolean_get(op->ptr, "add_boundary_loop");
288  params.apply_shrinkwrap = RNA_boolean_get(op->ptr, "apply_shrinkwrap");
289  params.add_solidify = RNA_boolean_get(op->ptr, "add_solidify");
290 
291  /* Push an undo step prior to extraction.
292  * Note: A second push happens after the operator due to
293  * the OPTYPE_UNDO flag; having an initial undo step here
294  * is just needed to preserve the active object pointer.
295  *
296  * Fixes T103261.
297  */
298  ED_undo_push_op(C, op);
299 
301 }
302 
304 {
305  return WM_operator_props_popup_confirm(C, op, e);
306 }
307 
309 {
310  RNA_def_boolean(srna,
311  "add_boundary_loop",
312  true,
313  "Add Boundary Loop",
314  "Add an extra edge loop to better preserve the shape when applying a "
315  "subdivision surface modifier");
316  RNA_def_int(srna,
317  "smooth_iterations",
318  4,
319  0,
320  INT_MAX,
321  "Smooth Iterations",
322  "Smooth iterations applied to the extracted mesh",
323  0,
324  20);
325  RNA_def_boolean(srna,
326  "apply_shrinkwrap",
327  true,
328  "Project to Sculpt",
329  "Project the extracted mesh into the original sculpt");
330  RNA_def_boolean(srna,
331  "add_solidify",
332  true,
333  "Extract as Solid",
334  "Extract the mask as a solid object with a solidify modifier");
335 }
336 
338 {
339  /* identifiers */
340  ot->name = "Mask Extract";
341  ot->description = "Create a new mesh object from the current paint mask";
342  ot->idname = "MESH_OT_paint_mask_extract";
343 
344  /* api callbacks */
348 
350 
352  ot->srna,
353  "mask_threshold",
354  0.5f,
355  0.0f,
356  1.0f,
357  "Threshold",
358  "Minimum mask value to consider the vertex valid to extract a face from the original mesh",
359  0.0f,
360  1.0f);
361 
363 }
364 
366 {
367  ED_workspace_status_text(C, TIP_("Click on the mesh to select a Face Set"));
370  return OPERATOR_RUNNING_MODAL;
371 }
372 
373 static int face_set_extract_modal(bContext *C, wmOperator *op, const wmEvent *event)
374 {
375  switch (event->type) {
376  case LEFTMOUSE:
377  if (event->val == KM_PRESS) {
380 
381  /* This modal operator uses and eyedropper to pick a Face Set from the mesh. This ensures
382  * that the mouse clicked in a viewport region and its coordinates can be used to ray-cast
383  * the PBVH and update the active Face Set ID. */
384  bScreen *screen = CTX_wm_screen(C);
385  ARegion *region = BKE_screen_find_main_region_at_xy(screen, SPACE_VIEW3D, event->xy);
386 
387  if (!region) {
388  return OPERATOR_CANCELLED;
389  }
390 
391  const float mval[2] = {event->xy[0] - region->winrct.xmin,
392  event->xy[1] - region->winrct.ymin};
393 
395  const int face_set_id = ED_sculpt_face_sets_active_update_and_get(C, ob, mval);
396  if (face_set_id == SCULPT_FACE_SET_NONE) {
397  return OPERATOR_CANCELLED;
398  }
399 
401  params.active_face_set = face_set_id;
402  params.num_smooth_iterations = 0;
403  params.add_boundary_loop = false;
404  params.apply_shrinkwrap = true;
405  params.add_solidify = true;
407  }
408  break;
409  case EVT_ESCKEY:
410  case RIGHTMOUSE: {
413 
414  return OPERATOR_CANCELLED;
415  }
416  }
417 
418  return OPERATOR_RUNNING_MODAL;
419 }
420 
422 {
423  /* identifiers */
424  ot->name = "Face Set Extract";
425  ot->description = "Create a new mesh object from the selected Face Set";
426  ot->idname = "MESH_OT_face_set_extract";
427 
428  /* api callbacks */
432 
434 
436 }
437 
438 static void slice_paint_mask(BMesh *bm, bool invert, bool fill_holes, float mask_threshold)
439 {
440  BMVert *v;
441  BMFace *f;
442  BMIter iter;
443  BMIter face_iter;
444 
445  /* Delete all masked faces */
446  const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
447  BLI_assert(cd_vert_mask_offset != -1);
449 
450  BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
451  bool keep_face = true;
452  BM_ITER_ELEM (v, &face_iter, f, BM_VERTS_OF_FACE) {
453  const float mask = BM_ELEM_CD_GET_FLOAT(v, cd_vert_mask_offset);
454  if (mask < mask_threshold) {
455  keep_face = false;
456  break;
457  }
458  }
459  if (invert) {
460  keep_face = !keep_face;
461  }
462  BM_elem_flag_set(f, BM_ELEM_TAG, keep_face);
463  }
464 
468 
469  if (fill_holes) {
470  BM_mesh_edgenet(bm, false, true);
474  "triangulate faces=%hf quad_method=%i ngon_method=%i",
475  BM_ELEM_TAG,
476  0,
477  0);
478 
482  "recalc_face_normals faces=%hf",
483  BM_ELEM_TAG);
485  }
486 }
487 
489 {
490  struct Main *bmain = CTX_data_main(C);
492  View3D *v3d = CTX_wm_view3d(C);
493 
495 
496  Mesh *mesh = ob->data;
497  Mesh *new_mesh = (Mesh *)BKE_id_copy(bmain, &mesh->id);
498 
499  if (ob->mode == OB_MODE_SCULPT) {
500  ED_sculpt_undo_geometry_begin(ob, "mask slice");
501  }
502 
503  BMesh *bm;
504  const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(new_mesh);
505  bm = BM_mesh_create(&allocsize,
506  &((struct BMeshCreateParams){
507  .use_toolflags = true,
508  }));
509 
511  new_mesh,
512  (&(struct BMeshFromMeshParams){
513  .calc_face_normal = true,
514  }));
515 
517  bm, false, RNA_boolean_get(op->ptr, "fill_holes"), RNA_float_get(op->ptr, "mask_threshold"));
518  BKE_id_free(bmain, new_mesh);
519  new_mesh = BKE_mesh_from_bmesh_nomain(bm,
520  (&(struct BMeshToMeshParams){
521  .calc_object_remap = false,
522  }),
523  mesh);
524  BM_mesh_free(bm);
525 
526  if (RNA_boolean_get(op->ptr, "new_object")) {
527  ushort local_view_bits = 0;
528  if (v3d && v3d->localvd) {
529  local_view_bits = v3d->local_view_uuid;
530  }
531  Object *new_ob = ED_object_add_type(
532  C, OB_MESH, NULL, ob->loc, ob->rot, false, local_view_bits);
533  Mesh *new_ob_mesh = (Mesh *)BKE_id_copy(bmain, &mesh->id);
534 
535  const BMAllocTemplate allocsize_new_ob = BMALLOC_TEMPLATE_FROM_ME(new_ob_mesh);
536  bm = BM_mesh_create(&allocsize_new_ob,
537  &((struct BMeshCreateParams){
538  .use_toolflags = true,
539  }));
540 
542  new_ob_mesh,
543  (&(struct BMeshFromMeshParams){
544  .calc_face_normal = true,
545  }));
546 
548  true,
549  RNA_boolean_get(op->ptr, "fill_holes"),
550  RNA_float_get(op->ptr, "mask_threshold"));
551  BKE_id_free(bmain, new_ob_mesh);
552  new_ob_mesh = BKE_mesh_from_bmesh_nomain(bm,
553  (&(struct BMeshToMeshParams){
554  .calc_object_remap = false,
555  }),
556  mesh);
557  BM_mesh_free(bm);
558 
559  /* Remove the mask from the new object so it can be sculpted directly after slicing. */
560  CustomData_free_layers(&new_ob_mesh->vdata, CD_PAINT_MASK, new_ob_mesh->totvert);
561 
562  BKE_mesh_nomain_to_mesh(new_ob_mesh, new_ob->data, new_ob, &CD_MASK_MESH, true);
569  }
570 
571  BKE_mesh_nomain_to_mesh(new_mesh, ob->data, ob, &CD_MASK_MESH, true);
572 
573  if (ob->mode == OB_MODE_SCULPT) {
574  SculptSession *ss = ob->sculpt;
576  if (ss->face_sets) {
577  /* Assign a new Face Set ID to the new faces created by the slice operation. */
578  const int next_face_set_id = ED_sculpt_face_sets_find_next_available_id(ob->data);
579  ED_sculpt_face_sets_initialize_none_to_id(ob->data, next_face_set_id);
580  }
582  }
583 
587 
588  return OPERATOR_FINISHED;
589 }
590 
592 {
593  PropertyRNA *prop;
594  /* identifiers */
595  ot->name = "Mask Slice";
596  ot->description = "Slices the paint mask from the mesh";
597  ot->idname = "MESH_OT_paint_mask_slice";
598 
599  /* api callbacks */
602 
604 
606  ot->srna,
607  "mask_threshold",
608  0.5f,
609  0.0f,
610  1.0f,
611  "Threshold",
612  "Minimum mask value to consider the vertex valid to extract a face from the original mesh",
613  0.0f,
614  1.0f);
615  prop = RNA_def_boolean(
616  ot->srna, "fill_holes", true, "Fill Holes", "Fill holes after slicing the mask");
618  prop = RNA_def_boolean(ot->srna,
619  "new_object",
620  true,
621  "Slice to New Object",
622  "Create a new object from the sliced mask");
624 }
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Definition: context.c:1528
struct Depsgraph * CTX_data_depsgraph_on_load(const bContext *C)
Definition: context.c:1536
struct Object * CTX_data_active_object(const bContext *C)
Definition: context.c:1353
struct View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:784
struct bScreen * CTX_wm_screen(const bContext *C)
Definition: context.c:733
void CTX_wm_operator_poll_msg_set(struct bContext *C, const char *msg)
Definition: context.c:1042
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1074
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:723
const CustomData_MeshMasks CD_MASK_EVERYTHING
Definition: customdata.cc:2101
void CustomData_free_layers(struct CustomData *data, int type, int totelem)
Definition: customdata.cc:2904
void * CustomData_get_layer(const struct CustomData *data, int type)
int CustomData_get_offset(const struct CustomData *data, int type)
const CustomData_MeshMasks CD_MASK_MESH
Definition: customdata.cc:2065
void BKE_editmesh_free_data(BMEditMesh *em)
Definition: editmesh.c:181
BMEditMesh * BKE_editmesh_create(BMesh *bm)
Definition: editmesh.c:29
struct ID * BKE_id_copy(struct Main *bmain, const struct ID *id)
void BKE_id_free(struct Main *bmain, void *idv)
void BKE_mesh_copy_parameters_for_eval(struct Mesh *me_dst, const struct Mesh *me_src)
void BKE_mesh_nomain_to_mesh(struct Mesh *mesh_src, struct Mesh *mesh_dst, struct Object *ob, const struct CustomData_MeshMasks *mask, bool take_ownership)
struct Mesh * BKE_mesh_from_bmesh_nomain(struct BMesh *bm, const struct BMeshToMeshParams *params, const struct Mesh *me_settings)
void BKE_mesh_batch_cache_dirty_tag(struct Mesh *me, eMeshBatchDirtyMode mode)
@ BKE_MESH_BATCH_DIRTY_ALL
struct ModifierData * BKE_modifiers_findby_name(const struct Object *ob, const char *name)
#define SCULPT_FACE_SET_NONE
Definition: BKE_paint.h:267
int BKE_sculpt_mask_layers_ensure(struct Object *ob, struct MultiresModifierData *mmd)
Definition: paint.c:1926
struct ARegion struct ARegion * BKE_screen_find_main_region_at_xy(struct bScreen *screen, int space_type, const int xy[2]) ATTR_NONNULL(1
void BKE_shrinkwrap_mesh_nearest_surface_deform(struct bContext *C, struct Object *ob_source, struct Object *ob_target)
Definition: shrinkwrap.c:1525
#define BLI_assert(a)
Definition: BLI_assert.h:46
MINLINE void mul_v3_v3(float r[3], const float a[3])
unsigned short ushort
Definition: BLI_sys_types.h:68
#define UNUSED(x)
#define TIP_(msgid)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
@ CD_PAINT_MASK
@ CD_SCULPT_FACE_SETS
@ eModifierType_Solidify
@ OB_MODE_SCULPT
Object is a sort of wrapper for general info.
@ OB_MESH
@ SPACE_VIEW3D
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
struct ModifierData * ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, const char *name, int type)
void ED_object_sculptmode_exit(struct bContext *C, struct Depsgraph *depsgraph)
Definition: sculpt_ops.c:466
struct Object * ED_object_add_type(struct bContext *C, int type, const char *name, const float loc[3], const float rot[3], bool enter_editmode, unsigned short local_view_bits) ATTR_NONNULL(1) ATTR_RETURNS_NONNULL
Definition: object_add.cc:668
bool ED_operator_object_active_editable_mesh(struct bContext *C)
Definition: screen_ops.c:413
void ED_workspace_status_text(struct bContext *C, const char *str)
Definition: area.c:816
int ED_sculpt_face_sets_find_next_available_id(struct Mesh *mesh)
void ED_sculpt_undo_geometry_begin(struct Object *ob, const char *name)
Definition: sculpt_undo.c:1833
void ED_sculpt_undo_geometry_end(struct Object *ob)
Definition: sculpt_undo.c:1839
void ED_sculpt_face_sets_initialize_none_to_id(struct Mesh *mesh, int new_id)
int ED_sculpt_face_sets_active_update_and_get(struct bContext *C, struct Object *ob, const float mval_fl[2])
void ED_undo_push_op(struct bContext *C, struct wmOperator *op)
Definition: ed_undo.c:404
Read Guarded memory(de)allocation.
@ PROP_SKIP_SAVE
Definition: RNA_types.h:218
#define C
Definition: RandGen.cpp:25
@ KM_PRESS
Definition: WM_types.h:267
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_REGISTER
Definition: WM_types.h:146
#define NC_GEOM
Definition: WM_types.h:343
#define ND_DATA
Definition: WM_types.h:456
#define ND_MODIFIER
Definition: WM_types.h:411
#define NC_OBJECT
Definition: WM_types.h:329
#define BM_ELEM_CD_GET_FLOAT(ele, offset)
Definition: bmesh_class.h:553
#define BM_ELEM_CD_GET_INT(ele, offset)
Definition: bmesh_class.h:518
@ BM_FACE
Definition: bmesh_class.h:386
@ BM_VERT
Definition: bmesh_class.h:383
@ BM_EDGE
Definition: bmesh_class.h:384
@ BM_ELEM_SELECT
Definition: bmesh_class.h:471
@ BM_ELEM_TAG
Definition: bmesh_class.h:484
void BM_mesh_delete_hflag_context(BMesh *bm, const char hflag, const int type)
Definition: bmesh_delete.c:258
void BM_mesh_edgenet(BMesh *bm, const bool use_edge_tag, const bool use_new_face_tag)
#define BM_elem_flag_set(ele, hflag, val)
Definition: bmesh_inline.h:16
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
@ BM_EDGES_OF_MESH
@ BM_VERTS_OF_MESH
@ BM_VERTS_OF_FACE
@ BM_FACES_OF_MESH
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_elem_hflag_enable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
Definition: bmesh_mesh.cc:258
BMesh * BM_mesh_create(const BMAllocTemplate *allocsize, const struct BMeshCreateParams *params)
Definition: bmesh_mesh.cc:125
#define BMALLOC_TEMPLATE_FROM_ME(...)
Definition: bmesh_mesh.h:197
void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshParams *params)
void BM_mesh_normals_update(BMesh *bm)
@ DEL_FACES
@ BMO_FLAG_RESPECT_HIDE
bool BMO_op_callf(BMesh *bm, int flag, const char *fmt,...)
#define BMO_FLAG_DEFAULTS
bool BM_vert_is_boundary(const BMVert *v)
Definition: bmesh_query.c:916
BLI_INLINE bool BM_edge_is_boundary(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
Scene scene
const Depsgraph * depsgraph
SyclQueue void void size_t num_bytes void
bool edbm_extrude_edges_indiv(BMEditMesh *em, wmOperator *op, const char hflag, const bool use_normal_flip)
void MESH_OT_paint_mask_extract(wmOperatorType *ot)
struct GeometryExtactParams GeometryExtractParams
static int geometry_extract_apply(bContext *C, wmOperator *op, GeometryExtractTagMeshFunc *tag_fn, GeometryExtractParams *params)
static int face_set_extract_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e))
void MESH_OT_paint_mask_slice(wmOperatorType *ot)
static int paint_mask_extract_invoke(bContext *C, wmOperator *op, const wmEvent *e)
static bool geometry_extract_poll(bContext *C)
static void geometry_extract_tag_face_set(BMesh *bm, GeometryExtractParams *params)
static int face_set_extract_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void geometry_extract_props(StructRNA *srna)
static int paint_mask_extract_exec(bContext *C, wmOperator *op)
static void geometry_extract_tag_masked_faces(BMesh *bm, GeometryExtractParams *params)
void() GeometryExtractTagMeshFunc(struct BMesh *, GeometryExtractParams *)
static int paint_mask_slice_exec(bContext *C, wmOperator *op)
static void slice_paint_mask(BMesh *bm, bool invert, bool fill_holes, float mask_threshold)
void MESH_OT_face_set_extract(wmOperatorType *ot)
bool EDBM_op_callf(BMEditMesh *em, wmOperator *op, const char *fmt,...)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
Definition: invert.h:8
ccl_gpu_kernel_postfix ccl_global float int int int int float threshold
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
T abs(const T &a)
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4910
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4957
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4863
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3836
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3597
float co[3]
Definition: bmesh_class.h:87
CustomData vdata
Definition: bmesh_class.h:337
CustomData pdata
Definition: bmesh_class.h:337
Definition: BKE_main.h:121
CustomData vdata
int totvert
CustomData pdata
int totpoly
float loc[3]
float scale[3]
float rot[3]
struct SculptSession * sculpt
void * data
int * face_sets
Definition: BKE_paint.h:536
struct BMesh * bm
Definition: BKE_paint.h:539
unsigned short local_view_uuid
struct View3D * localvd
int ymin
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63
short val
Definition: WM_types.h:680
int xy[2]
Definition: WM_types.h:682
short type
Definition: WM_types.h:678
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:919
const char * name
Definition: WM_types.h:888
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:935
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
struct StructRNA * srna
Definition: WM_types.h:969
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
struct ReportList * reports
struct PointerRNA * ptr
void WM_cursor_modal_set(wmWindow *win, int val)
Definition: wm_cursors.c:191
void WM_cursor_modal_restore(wmWindow *win)
Definition: wm_cursors.c:200
@ WM_CURSOR_EYEDROPPER
Definition: wm_cursors.h:35
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
@ RIGHTMOUSE
@ LEFTMOUSE
@ EVT_ESCKEY
wmOperatorType * ot
Definition: wm_files.c:3479
int WM_operator_props_popup_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))