Blender  V2.93
editmesh_mask_extract.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2019 by Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "DNA_mesh_types.h"
25 #include "DNA_modifier_types.h"
26 #include "DNA_object_types.h"
27 
28 #include "BLI_math.h"
29 
30 #include "BLT_translation.h"
31 
32 #include "BKE_context.h"
33 #include "BKE_editmesh.h"
34 #include "BKE_layer.h"
35 #include "BKE_lib_id.h"
36 #include "BKE_mesh.h"
37 #include "BKE_modifier.h"
38 #include "BKE_paint.h"
39 #include "BKE_report.h"
40 #include "BKE_screen.h"
41 #include "BKE_shrinkwrap.h"
42 
43 #include "DEG_depsgraph.h"
44 #include "DEG_depsgraph_build.h"
45 
46 #include "RNA_access.h"
47 #include "RNA_define.h"
48 
49 #include "WM_api.h"
50 #include "WM_types.h"
51 
52 #include "ED_mesh.h"
53 #include "ED_object.h"
54 #include "ED_screen.h"
55 #include "ED_sculpt.h"
56 #include "ED_view3d.h"
57 
58 #include "bmesh_tools.h"
59 
60 #include "MEM_guardedalloc.h"
61 
62 #include "mesh_intern.h" /* own include */
63 
65 {
67  if (ob != NULL && ob->mode == OB_MODE_SCULPT) {
68  if (ob->sculpt->bm) {
69  CTX_wm_operator_poll_msg_set(C, "The geometry can not be extracted with dyntopo activated");
70  return false;
71  }
73  }
74  return false;
75 }
76 
77 typedef struct GeometryExtactParams {
78  /* For extracting Face Sets. */
80 
81  /* For extracting Mask. */
83 
84  /* Common parameters. */
90 
91 /* Function that tags in BMesh the faces that should be deleted in the extracted object. */
93 
95  wmOperator *op,
98 {
99  struct Main *bmain = CTX_data_main(C);
101  View3D *v3d = CTX_wm_view3d(C);
104 
106 
108 
109  /* Ensures that deformation from sculpt mode is taken into account before duplicating the mesh to
110  * extract the geometry. */
112 
113  Mesh *mesh = ob->data;
114  Mesh *new_mesh = (Mesh *)BKE_id_copy(bmain, &mesh->id);
115 
116  const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(new_mesh);
117  BMesh *bm;
118  bm = BM_mesh_create(&allocsize,
119  &((struct BMeshCreateParams){
120  .use_toolflags = true,
121  }));
122 
124  new_mesh,
125  (&(struct BMeshFromMeshParams){
126  .calc_face_normal = true,
127  }));
128 
129  BMEditMesh *em = BKE_editmesh_create(bm, false);
130 
131  /* Generate the tags for deleting geometry in the extracted object. */
132  tag_fn(bm, params);
133 
134  /* Delete all tagged faces. */
137 
138  BMVert *v;
139  BMEdge *ed;
140  BMIter iter;
141  BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
142  mul_v3_v3(v->co, ob->scale);
143  }
144 
145  if (params->add_boundary_loop) {
146  BM_ITER_MESH (ed, &iter, bm, BM_EDGES_OF_MESH) {
148  }
149  edbm_extrude_edges_indiv(em, op, BM_ELEM_TAG, false);
150 
151  for (int repeat = 0; repeat < params->num_smooth_iterations; repeat++) {
153  BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
155  }
156  for (int i = 0; i < 3; i++) {
157  if (!EDBM_op_callf(em,
158  op,
159  "smooth_vert verts=%hv factor=%f mirror_clip_x=%b mirror_clip_y=%b "
160  "mirror_clip_z=%b "
161  "clip_dist=%f use_axis_x=%b use_axis_y=%b use_axis_z=%b",
162  BM_ELEM_TAG,
163  1.0,
164  false,
165  false,
166  false,
167  0.1,
168  true,
169  true,
170  true)) {
171  continue;
172  }
173  }
174 
176  BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
178  }
179  for (int i = 0; i < 1; i++) {
180  if (!EDBM_op_callf(em,
181  op,
182  "smooth_vert verts=%hv factor=%f mirror_clip_x=%b mirror_clip_y=%b "
183  "mirror_clip_z=%b "
184  "clip_dist=%f use_axis_x=%b use_axis_y=%b use_axis_z=%b",
185  BM_ELEM_TAG,
186  0.5,
187  false,
188  false,
189  false,
190  0.1,
191  true,
192  true,
193  true)) {
194  continue;
195  }
196  }
197  }
198  }
199 
201 
202  BKE_id_free(bmain, new_mesh);
203  new_mesh = BKE_mesh_from_bmesh_nomain(bm,
204  (&(struct BMeshToMeshParams){
205  .calc_object_remap = false,
206  }),
207  mesh);
208 
209  BKE_editmesh_free(em);
210  MEM_freeN(em);
211 
212  if (new_mesh->totvert == 0) {
213  BKE_id_free(bmain, new_mesh);
214  return OPERATOR_FINISHED;
215  }
216 
217  ushort local_view_bits = 0;
218  if (v3d && v3d->localvd) {
219  local_view_bits = v3d->local_view_uuid;
220  }
221  Object *new_ob = ED_object_add_type(C, OB_MESH, NULL, ob->loc, ob->rot, false, local_view_bits);
222  BKE_mesh_nomain_to_mesh(new_mesh, new_ob->data, new_ob, &CD_MASK_EVERYTHING, true);
223 
224  /* Remove the Face Sets as they need to be recreated when entering Sculpt Mode in the new object.
225  * TODO(pablodobarro): In the future we can try to preserve them from the original mesh. */
226  Mesh *new_ob_mesh = new_ob->data;
227  CustomData_free_layers(&new_ob_mesh->pdata, CD_SCULPT_FACE_SETS, new_ob_mesh->totpoly);
228 
229  /* Remove the mask from the new object so it can be sculpted directly after extracting. */
230  CustomData_free_layers(&new_ob_mesh->vdata, CD_PAINT_MASK, new_ob_mesh->totvert);
231 
232  BKE_mesh_copy_settings(new_ob_mesh, mesh);
233 
234  if (params->apply_shrinkwrap) {
236  }
237 
238  if (params->add_solidify) {
240  op->reports, bmain, scene, new_ob, "geometry_extract_solidify", eModifierType_Solidify);
242  new_ob, "mask_extract_solidify");
243  if (sfmd) {
244  sfmd->offset = -0.05f;
245  }
246  }
247 
248  BKE_mesh_calc_normals(new_ob->data);
249 
255 
256  return OPERATOR_FINISHED;
257 }
258 
260 {
261  const float threshold = params->mask_threshold;
262 
264  const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
265 
266  BMFace *f;
267  BMIter iter;
268  BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
269  bool keep_face = true;
270  BMVert *v;
271  BMIter face_iter;
272  BM_ITER_ELEM (v, &face_iter, f, BM_VERTS_OF_FACE) {
273  const float mask = BM_ELEM_CD_GET_FLOAT(v, cd_vert_mask_offset);
274  if (mask < threshold) {
275  keep_face = false;
276  break;
277  }
278  }
279  BM_elem_flag_set(f, BM_ELEM_TAG, !keep_face);
280  }
281 }
282 
284 {
285  const int tag_face_set_id = params->active_face_set;
286 
288  const int cd_face_sets_offset = CustomData_get_offset(&bm->pdata, CD_SCULPT_FACE_SETS);
289 
290  BMFace *f;
291  BMIter iter;
292  BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
293  const int face_set_id = abs(BM_ELEM_CD_GET_INT(f, cd_face_sets_offset));
294  BM_elem_flag_set(f, BM_ELEM_TAG, face_set_id != tag_face_set_id);
295  }
296 }
297 
299 {
301  params.mask_threshold = RNA_float_get(op->ptr, "mask_threshold");
302  params.num_smooth_iterations = RNA_int_get(op->ptr, "smooth_iterations");
303  params.add_boundary_loop = RNA_boolean_get(op->ptr, "add_boundary_loop");
304  params.apply_shrinkwrap = RNA_boolean_get(op->ptr, "apply_shrinkwrap");
305  params.add_solidify = RNA_boolean_get(op->ptr, "add_solidify");
307 }
308 
310 {
311  return WM_operator_props_popup_confirm(C, op, e);
312 }
313 
315 {
316  RNA_def_boolean(srna,
317  "add_boundary_loop",
318  true,
319  "Add Boundary Loop",
320  "Add an extra edge loop to better preserve the shape when applying a "
321  "subdivision surface modifier");
322  RNA_def_int(srna,
323  "smooth_iterations",
324  4,
325  0,
326  INT_MAX,
327  "Smooth Iterations",
328  "Smooth iterations applied to the extracted mesh",
329  0,
330  20);
331  RNA_def_boolean(srna,
332  "apply_shrinkwrap",
333  true,
334  "Project to Sculpt",
335  "Project the extracted mesh into the original sculpt");
336  RNA_def_boolean(srna,
337  "add_solidify",
338  true,
339  "Extract as Solid",
340  "Extract the mask as a solid object with a solidify modifier");
341 }
342 
344 {
345  /* identifiers */
346  ot->name = "Mask Extract";
347  ot->description = "Create a new mesh object from the current paint mask";
348  ot->idname = "MESH_OT_paint_mask_extract";
349 
350  /* api callbacks */
354 
356 
358  ot->srna,
359  "mask_threshold",
360  0.5f,
361  0.0f,
362  1.0f,
363  "Threshold",
364  "Minimum mask value to consider the vertex valid to extract a face from the original mesh",
365  0.0f,
366  1.0f);
367 
369 }
370 
372 {
373  ED_workspace_status_text(C, TIP_("Click on the mesh to select a Face Set"));
376  return OPERATOR_RUNNING_MODAL;
377 }
378 
379 static int face_set_extract_modal(bContext *C, wmOperator *op, const wmEvent *event)
380 {
381  switch (event->type) {
382  case LEFTMOUSE:
383  if (event->val == KM_PRESS) {
386 
387  /* This modal operator uses and eyedropper to pick a Face Set from the mesh. This ensures
388  * that the mouse clicked in a viewport region and its coordinates can be used to ray-cast
389  * the PBVH and update the active Face Set ID. */
390  bScreen *screen = CTX_wm_screen(C);
392  screen, SPACE_VIEW3D, event->x, event->y);
393 
394  if (!region) {
395  return OPERATOR_CANCELLED;
396  }
397 
398  const float mval[2] = {event->x - region->winrct.xmin, event->y - region->winrct.ymin};
399 
401  const int face_set_id = ED_sculpt_face_sets_active_update_and_get(C, ob, mval);
402  if (face_set_id == SCULPT_FACE_SET_NONE) {
403  return OPERATOR_CANCELLED;
404  }
405 
407  params.active_face_set = face_set_id;
408  params.num_smooth_iterations = 0;
409  params.add_boundary_loop = false;
410  params.apply_shrinkwrap = true;
411  params.add_solidify = true;
413  }
414  break;
415  case EVT_ESCKEY:
416  case RIGHTMOUSE: {
419 
420  return OPERATOR_CANCELLED;
421  }
422  }
423 
424  return OPERATOR_RUNNING_MODAL;
425 }
426 
428 {
429  /* identifiers */
430  ot->name = "Face Set Extract";
431  ot->description = "Create a new mesh object from the selected Face Set";
432  ot->idname = "MESH_OT_face_set_extract";
433 
434  /* api callbacks */
438 
440 
442 }
443 
444 static void slice_paint_mask(BMesh *bm, bool invert, bool fill_holes, float mask_threshold)
445 {
446  BMVert *v;
447  BMFace *f;
448  BMIter iter;
449  BMIter face_iter;
450 
451  /* Delete all masked faces */
452  const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
453  BLI_assert(cd_vert_mask_offset != -1);
455 
456  BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
457  bool keep_face = true;
458  BM_ITER_ELEM (v, &face_iter, f, BM_VERTS_OF_FACE) {
459  const float mask = BM_ELEM_CD_GET_FLOAT(v, cd_vert_mask_offset);
460  if (mask < mask_threshold) {
461  keep_face = false;
462  break;
463  }
464  }
465  if (invert) {
466  keep_face = !keep_face;
467  }
468  BM_elem_flag_set(f, BM_ELEM_TAG, keep_face);
469  }
470 
474 
475  if (fill_holes) {
476  BM_mesh_edgenet(bm, false, true);
480  "triangulate faces=%hf quad_method=%i ngon_method=%i",
481  BM_ELEM_TAG,
482  0,
483  0);
484 
488  "recalc_face_normals faces=%hf",
489  BM_ELEM_TAG);
491  }
492 }
493 
495 {
496  struct Main *bmain = CTX_data_main(C);
498  View3D *v3d = CTX_wm_view3d(C);
499 
501 
502  Mesh *mesh = ob->data;
503  Mesh *new_mesh = (Mesh *)BKE_id_copy(bmain, &mesh->id);
504 
505  if (ob->mode == OB_MODE_SCULPT) {
506  ED_sculpt_undo_geometry_begin(ob, "mask slice");
507  }
508 
509  BMesh *bm;
510  const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(new_mesh);
511  bm = BM_mesh_create(&allocsize,
512  &((struct BMeshCreateParams){
513  .use_toolflags = true,
514  }));
515 
517  new_mesh,
518  (&(struct BMeshFromMeshParams){
519  .calc_face_normal = true,
520  }));
521 
523  bm, false, RNA_boolean_get(op->ptr, "fill_holes"), RNA_float_get(op->ptr, "mask_threshold"));
524  BKE_id_free(bmain, new_mesh);
525  new_mesh = BKE_mesh_from_bmesh_nomain(bm,
526  (&(struct BMeshToMeshParams){
527  .calc_object_remap = false,
528  }),
529  mesh);
530  BM_mesh_free(bm);
531 
532  if (RNA_boolean_get(op->ptr, "new_object")) {
533  ushort local_view_bits = 0;
534  if (v3d && v3d->localvd) {
535  local_view_bits = v3d->local_view_uuid;
536  }
537  Object *new_ob = ED_object_add_type(
538  C, OB_MESH, NULL, ob->loc, ob->rot, false, local_view_bits);
539  Mesh *new_ob_mesh = (Mesh *)BKE_id_copy(bmain, &mesh->id);
540 
541  const BMAllocTemplate allocsize_new_ob = BMALLOC_TEMPLATE_FROM_ME(new_ob_mesh);
542  bm = BM_mesh_create(&allocsize_new_ob,
543  &((struct BMeshCreateParams){
544  .use_toolflags = true,
545  }));
546 
548  new_ob_mesh,
549  (&(struct BMeshFromMeshParams){
550  .calc_face_normal = true,
551  }));
552 
554  true,
555  RNA_boolean_get(op->ptr, "fill_holes"),
556  RNA_float_get(op->ptr, "mask_threshold"));
557  BKE_id_free(bmain, new_ob_mesh);
558  new_ob_mesh = BKE_mesh_from_bmesh_nomain(bm,
559  (&(struct BMeshToMeshParams){
560  .calc_object_remap = false,
561  }),
562  mesh);
563  BM_mesh_free(bm);
564 
565  /* Remove the mask from the new object so it can be sculpted directly after slicing. */
566  CustomData_free_layers(&new_ob_mesh->vdata, CD_PAINT_MASK, new_ob_mesh->totvert);
567 
568  BKE_mesh_nomain_to_mesh(new_ob_mesh, new_ob->data, new_ob, &CD_MASK_MESH, true);
569  BKE_mesh_calc_normals(new_ob->data);
570  BKE_mesh_copy_settings(new_ob->data, mesh);
576  }
577 
578  BKE_mesh_nomain_to_mesh(new_mesh, ob->data, ob, &CD_MASK_MESH, true);
580 
581  if (ob->mode == OB_MODE_SCULPT) {
582  SculptSession *ss = ob->sculpt;
584  if (ss->face_sets) {
585  /* Assign a new Face Set ID to the new faces created by the slice operation. */
586  const int next_face_set_id = ED_sculpt_face_sets_find_next_available_id(ob->data);
587  ED_sculpt_face_sets_initialize_none_to_id(ob->data, next_face_set_id);
588  }
590  }
591 
595 
596  return OPERATOR_FINISHED;
597 }
598 
600 {
601  PropertyRNA *prop;
602  /* identifiers */
603  ot->name = "Mask Slice";
604  ot->description = "Slices the paint mask from the mesh";
605  ot->idname = "MESH_OT_paint_mask_slice";
606 
607  /* api callbacks */
610 
612 
614  ot->srna,
615  "mask_threshold",
616  0.5f,
617  0.0f,
618  1.0f,
619  "Threshold",
620  "Minimum mask value to consider the vertex valid to extract a face from the original mesh",
621  0.0f,
622  1.0f);
623  prop = RNA_def_boolean(
624  ot->srna, "fill_holes", true, "Fill Holes", "Fill holes after slicing the mask");
626  prop = RNA_def_boolean(ot->srna,
627  "new_object",
628  true,
629  "Slice to New Object",
630  "Create a new object from the sliced mask");
632 }
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Definition: context.c:1424
struct Depsgraph * CTX_data_depsgraph_on_load(const bContext *C)
Definition: context.c:1432
struct Object * CTX_data_active_object(const bContext *C)
Definition: context.c:1279
struct View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:760
struct bScreen * CTX_wm_screen(const bContext *C)
Definition: context.c:709
void CTX_wm_operator_poll_msg_set(struct bContext *C, const char *msg)
Definition: context.c:1006
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
const CustomData_MeshMasks CD_MASK_EVERYTHING
Definition: customdata.c:1986
void CustomData_free_layers(struct CustomData *data, int type, int totelem)
Definition: customdata.c:2716
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.c:1933
void BKE_editmesh_free(BMEditMesh *em)
Definition: editmesh.c:165
BMEditMesh * BKE_editmesh_create(BMesh *bm, const bool do_tessellate)
Definition: editmesh.c:42
struct ID * BKE_id_copy(struct Main *bmain, const struct ID *id)
void BKE_id_free(struct Main *bmain, void *idv)
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_calc_normals(struct Mesh *me)
void BKE_mesh_batch_cache_dirty_tag(struct Mesh *me, eMeshBatchDirtyMode mode)
Definition: mesh_runtime.c:251
void BKE_mesh_copy_settings(struct Mesh *me_dst, const struct Mesh *me_src)
@ 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:230
int BKE_sculpt_mask_layers_ensure(struct Object *ob, struct MultiresModifierData *mmd)
Definition: paint.c:1829
struct ARegion * BKE_screen_find_main_region_at_xy(struct bScreen *screen, const int space_type, const int x, const int y)
Definition: screen.c:1060
void BKE_shrinkwrap_mesh_nearest_surface_deform(struct bContext *C, struct Object *ob_source, struct Object *ob_target)
Definition: shrinkwrap.c:1516
#define BLI_assert(a)
Definition: BLI_assert.h:58
MINLINE void mul_v3_v3(float r[3], const float a[3])
unsigned short ushort
Definition: BLI_sys_types.h:84
#define UNUSED(x)
#define TIP_(msgid)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
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:611
@ 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.c:8531
struct Object * ED_object_add_type(struct bContext *C, const int type, const char *name, const float loc[3], const float rot[3], const bool enter_editmode, const unsigned short local_view_bits) ATTR_NONNULL(1) ATTR_RETURNS_NONNULL
Definition: object_add.c:659
bool ED_operator_object_active_editable_mesh(struct bContext *C)
Definition: screen_ops.c:384
void ED_workspace_status_text(struct bContext *C, const char *str)
Definition: area.c:840
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:1591
void ED_sculpt_undo_geometry_end(struct Object *ob)
Definition: sculpt_undo.c:1597
void ED_sculpt_face_sets_initialize_none_to_id(struct Mesh *mesh, const int new_id)
int ED_sculpt_face_sets_active_update_and_get(struct bContext *C, struct Object *ob, const float mval[2])
Read Guarded memory(de)allocation.
@ PROP_SKIP_SAVE
Definition: RNA_types.h:204
#define C
Definition: RandGen.cpp:39
#define NC_GEOM
Definition: WM_types.h:294
@ OPTYPE_UNDO
Definition: WM_types.h:155
@ OPTYPE_REGISTER
Definition: WM_types.h:153
#define ND_DATA
Definition: WM_types.h:408
#define ND_MODIFIER
Definition: WM_types.h:363
#define KM_PRESS
Definition: WM_types.h:242
#define NC_OBJECT
Definition: WM_types.h:280
#define BM_ELEM_CD_GET_FLOAT(ele, offset)
Definition: bmesh_class.h:542
#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:282
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:30
#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.c:307
BMesh * BM_mesh_create(const BMAllocTemplate *allocsize, const struct BMeshCreateParams *params)
BMesh Make Mesh.
Definition: bmesh_mesh.c:157
void BM_mesh_normals_update(BMesh *bm)
BMesh Compute Normals.
Definition: bmesh_mesh.c:500
#define BMALLOC_TEMPLATE_FROM_ME(...)
Definition: bmesh_mesh.h:163
void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshParams *params)
Mesh -> BMesh.
@ DEL_FACES
#define BMO_FLAG_DEFAULTS
@ BMO_FLAG_RESPECT_HIDE
bool BMO_op_callf(BMesh *bm, const int flag, const char *fmt,...)
bool BM_vert_is_boundary(const BMVert *v)
Definition: bmesh_query.c:1168
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
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]
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6308
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6355
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6261
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:3825
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
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:3585
float co[3]
Definition: bmesh_class.h:99
CustomData vdata
Definition: bmesh_class.h:337
CustomData pdata
Definition: bmesh_class.h:337
Definition: BKE_main.h:116
int totvert
int totpoly
float loc[3]
float scale[3]
float rot[3]
struct SculptSession * sculpt
void * data
int * face_sets
Definition: BKE_paint.h:490
struct BMesh * bm
Definition: BKE_paint.h:493
unsigned short local_view_uuid
struct View3D * localvd
int ymin
Definition: DNA_vec_types.h:80
int xmin
Definition: DNA_vec_types.h:79
int y
Definition: WM_types.h:581
short val
Definition: WM_types.h:579
int x
Definition: WM_types.h:581
short type
Definition: WM_types.h:577
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:752
const char * name
Definition: WM_types.h:721
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:768
const char * idname
Definition: WM_types.h:723
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
struct StructRNA * srna
Definition: WM_types.h:802
const char * description
Definition: WM_types.h:726
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:736
struct ReportList * reports
struct PointerRNA * ptr
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
Definition: svm_invert.h:19
__forceinline const avxi abs(const avxi &a)
Definition: util_avxi.h:186
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
void WM_cursor_modal_set(wmWindow *win, int val)
Definition: wm_cursors.c:207
void WM_cursor_modal_restore(wmWindow *win)
Definition: wm_cursors.c:216
@ WM_CURSOR_EYEDROPPER
Definition: wm_cursors.h:51
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:3156
int WM_operator_props_popup_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))