Blender  V3.3
mesh_data.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2009 Blender Foundation. All rights reserved. */
3 
8 #include "MEM_guardedalloc.h"
9 
10 #include "DNA_mesh_types.h"
11 #include "DNA_meshdata_types.h"
12 #include "DNA_object_types.h"
13 #include "DNA_scene_types.h"
14 #include "DNA_view3d_types.h"
15 
16 #include "BLI_array.hh"
17 #include "BLI_math.h"
18 #include "BLI_utildefines.h"
19 
20 #include "BKE_attribute.h"
21 #include "BKE_context.h"
22 #include "BKE_customdata.h"
23 #include "BKE_editmesh.h"
24 #include "BKE_mesh.h"
25 #include "BKE_mesh_runtime.h"
26 #include "BKE_report.h"
27 
28 #include "DEG_depsgraph.h"
29 
30 #include "RNA_access.h"
31 #include "RNA_define.h"
32 #include "RNA_prototypes.h"
33 
34 #include "WM_api.h"
35 #include "WM_types.h"
36 
37 #include "ED_mesh.h"
38 #include "ED_object.h"
39 #include "ED_paint.h"
40 #include "ED_screen.h"
41 #include "ED_uvedit.h"
42 #include "ED_view3d.h"
43 
44 #include "mesh_intern.h" /* own include */
45 
46 using blender::Array;
47 
48 static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_tot)
49 {
51  BMesh *bm = (me->edit_mesh) ? me->edit_mesh->bm : nullptr;
52  int tot;
53 
54  switch (htype) {
55  case BM_VERT:
56  if (bm) {
57  data = &bm->vdata;
58  tot = bm->totvert;
59  }
60  else {
61  data = &me->vdata;
62  tot = me->totvert;
63  }
64  break;
65  case BM_EDGE:
66  if (bm) {
67  data = &bm->edata;
68  tot = bm->totedge;
69  }
70  else {
71  data = &me->edata;
72  tot = me->totedge;
73  }
74  break;
75  case BM_LOOP:
76  if (bm) {
77  data = &bm->ldata;
78  tot = bm->totloop;
79  }
80  else {
81  data = &me->ldata;
82  tot = me->totloop;
83  }
84  break;
85  case BM_FACE:
86  if (bm) {
87  data = &bm->pdata;
88  tot = bm->totface;
89  }
90  else {
91  data = &me->pdata;
92  tot = me->totpoly;
93  }
94  break;
95  default:
96  BLI_assert(0);
97  tot = 0;
98  data = nullptr;
99  break;
100  }
101 
102  *r_tot = tot;
103  return data;
104 }
105 
106 #define GET_CD_DATA(me, data) ((me)->edit_mesh ? &(me)->edit_mesh->bm->data : &(me)->data)
108 {
109  const int type = layer->type;
110  CustomData *data;
111  int layer_index, tot, n;
112 
113  char htype = BM_FACE;
115  htype = BM_LOOP;
116  }
117  else if (ELEM(type, CD_PROP_COLOR)) {
118  htype = BM_VERT;
119  }
120 
121  data = mesh_customdata_get_type(me, htype, &tot);
122  layer_index = CustomData_get_layer_index(data, type);
123  n = (layer - &data->layers[layer_index]);
124  BLI_assert(n >= 0 && (n + layer_index) < data->totlayer);
125 
126  if (me->edit_mesh) {
128  }
129  else {
130  CustomData_free_layer(data, type, tot, layer_index + n);
132  }
133 }
134 
135 static void mesh_uv_reset_array(float **fuv, const int len)
136 {
137  if (len == 3) {
138  fuv[0][0] = 0.0;
139  fuv[0][1] = 0.0;
140 
141  fuv[1][0] = 1.0;
142  fuv[1][1] = 0.0;
143 
144  fuv[2][0] = 1.0;
145  fuv[2][1] = 1.0;
146  }
147  else if (len == 4) {
148  fuv[0][0] = 0.0;
149  fuv[0][1] = 0.0;
150 
151  fuv[1][0] = 1.0;
152  fuv[1][1] = 0.0;
153 
154  fuv[2][0] = 1.0;
155  fuv[2][1] = 1.0;
156 
157  fuv[3][0] = 0.0;
158  fuv[3][1] = 1.0;
159  /* Make sure we ignore 2-sided faces. */
160  }
161  else if (len > 2) {
162  float fac = 0.0f, dfac = 1.0f / (float)len;
163 
164  dfac *= (float)M_PI * 2.0f;
165 
166  for (int i = 0; i < len; i++) {
167  fuv[i][0] = 0.5f * sinf(fac) + 0.5f;
168  fuv[i][1] = 0.5f * cosf(fac) + 0.5f;
169 
170  fac += dfac;
171  }
172  }
173 }
174 
175 static void mesh_uv_reset_bmface(BMFace *f, const int cd_loop_uv_offset)
176 {
178  BMIter liter;
179  BMLoop *l;
180  int i;
181 
182  BM_ITER_ELEM_INDEX (l, &liter, f, BM_LOOPS_OF_FACE, i) {
183  fuv[i] = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset))->uv;
184  }
185 
186  mesh_uv_reset_array(fuv.data(), f->len);
187 }
188 
189 static void mesh_uv_reset_mface(MPoly *mp, MLoopUV *mloopuv)
190 {
192 
193  for (int i = 0; i < mp->totloop; i++) {
194  fuv[i] = mloopuv[mp->loopstart + i].uv;
195  }
196 
197  mesh_uv_reset_array(fuv.data(), mp->totloop);
198 }
199 
200 void ED_mesh_uv_loop_reset_ex(Mesh *me, const int layernum)
201 {
202  BMEditMesh *em = me->edit_mesh;
203 
204  if (em) {
205  /* Collect BMesh UVs */
206  const int cd_loop_uv_offset = CustomData_get_n_offset(&em->bm->ldata, CD_MLOOPUV, layernum);
207 
208  BMFace *efa;
209  BMIter iter;
210 
211  BLI_assert(cd_loop_uv_offset != -1);
212 
213  BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
214  if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
215  continue;
216  }
217 
218  mesh_uv_reset_bmface(efa, cd_loop_uv_offset);
219  }
220  }
221  else {
222  /* Collect Mesh UVs */
224  MLoopUV *mloopuv = (MLoopUV *)CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, layernum);
225 
226  for (int i = 0; i < me->totpoly; i++) {
227  mesh_uv_reset_mface(&me->mpoly[i], mloopuv);
228  }
229  }
230 
231  DEG_id_tag_update(&me->id, 0);
232 }
233 
235 {
236  /* could be ldata or pdata */
237  CustomData *ldata = GET_CD_DATA(me, ldata);
238  const int layernum = CustomData_get_active_layer(ldata, CD_MLOOPUV);
239  ED_mesh_uv_loop_reset_ex(me, layernum);
240 
242 }
243 
245  Mesh *me, const char *name, const bool active_set, const bool do_init, ReportList *reports)
246 {
247  /* NOTE: keep in sync with #ED_mesh_color_add. */
248 
249  BMEditMesh *em;
250  int layernum_dst;
251 
252  bool is_init = false;
253 
254  if (me->edit_mesh) {
255  em = me->edit_mesh;
256 
257  layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV);
258  if (layernum_dst >= MAX_MTFACE) {
259  BKE_reportf(reports, RPT_WARNING, "Cannot add more than %i UV maps", MAX_MTFACE);
260  return -1;
261  }
262 
263  /* CD_MLOOPUV */
264  BM_data_layer_add_named(em->bm, &em->bm->ldata, CD_MLOOPUV, name);
265  /* copy data from active UV */
266  if (layernum_dst && do_init) {
267  const int layernum_src = CustomData_get_active_layer(&em->bm->ldata, CD_MLOOPUV);
268  BM_data_layer_copy(em->bm, &em->bm->ldata, CD_MLOOPUV, layernum_src, layernum_dst);
269 
270  is_init = true;
271  }
272  if (active_set || layernum_dst == 0) {
273  CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum_dst);
274  }
275  }
276  else {
277  layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
278  if (layernum_dst >= MAX_MTFACE) {
279  BKE_reportf(reports, RPT_WARNING, "Cannot add more than %i UV maps", MAX_MTFACE);
280  return -1;
281  }
282 
283  if (me->mloopuv && do_init) {
285  &me->ldata, CD_MLOOPUV, CD_DUPLICATE, me->mloopuv, me->totloop, name);
286  is_init = true;
287  }
288  else {
289  CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, nullptr, me->totloop, name);
290  }
291 
292  if (active_set || layernum_dst == 0) {
293  CustomData_set_layer_active(&me->ldata, CD_MLOOPUV, layernum_dst);
294  }
295 
297  }
298 
299  /* don't overwrite our copied coords */
300  if (!is_init && do_init) {
301  ED_mesh_uv_loop_reset_ex(me, layernum_dst);
302  }
303 
304  DEG_id_tag_update(&me->id, 0);
306 
307  return layernum_dst;
308 }
309 
310 void ED_mesh_uv_ensure(Mesh *me, const char *name)
311 {
312  BMEditMesh *em;
313  int layernum_dst;
314 
315  if (me->edit_mesh) {
316  em = me->edit_mesh;
317 
318  layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV);
319  if (layernum_dst == 0) {
320  ED_mesh_uv_add(me, name, true, true, nullptr);
321  }
322  }
323  else {
324  layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
325  if (layernum_dst == 0) {
326  ED_mesh_uv_add(me, name, true, true, nullptr);
327  }
328  }
329 }
330 
331 bool ED_mesh_uv_remove_index(Mesh *me, const int n)
332 {
333  CustomData *ldata = GET_CD_DATA(me, ldata);
334  CustomDataLayer *cdlu;
335  int index;
336 
337  index = CustomData_get_layer_index_n(ldata, CD_MLOOPUV, n);
338  cdlu = (index == -1) ? nullptr : &ldata->layers[index];
339 
340  if (!cdlu) {
341  return false;
342  }
343 
344  delete_customdata_layer(me, cdlu);
345 
346  DEG_id_tag_update(&me->id, 0);
348 
349  return true;
350 }
352 {
353  CustomData *ldata = GET_CD_DATA(me, ldata);
354  const int n = CustomData_get_active_layer(ldata, CD_MLOOPUV);
355 
356  if (n != -1) {
357  return ED_mesh_uv_remove_index(me, n);
358  }
359  return false;
360 }
361 bool ED_mesh_uv_remove_named(Mesh *me, const char *name)
362 {
363  CustomData *ldata = GET_CD_DATA(me, ldata);
364  const int n = CustomData_get_named_layer(ldata, CD_MLOOPUV, name);
365  if (n != -1) {
366  return ED_mesh_uv_remove_index(me, n);
367  }
368  return false;
369 }
370 
372  const char *name,
373  const bool active_set,
374  const bool do_init,
375  ReportList *UNUSED(reports))
376 {
377  /* NOTE: keep in sync with #ED_mesh_uv_add. */
378 
379  BMEditMesh *em;
380  int layernum;
381 
382  if (me->edit_mesh) {
383  em = me->edit_mesh;
384 
386 
387  /* CD_PROP_BYTE_COLOR */
389  /* copy data from active vertex color layer */
390  if (layernum && do_init) {
391  const int layernum_dst = CustomData_get_active_layer(&em->bm->ldata, CD_PROP_BYTE_COLOR);
392  BM_data_layer_copy(em->bm, &em->bm->ldata, CD_PROP_BYTE_COLOR, layernum_dst, layernum);
393  }
394  if (active_set || layernum == 0) {
396  }
397  }
398  else {
400 
401  if (me->mloopcol && do_init) {
403  &me->ldata, CD_PROP_BYTE_COLOR, CD_DUPLICATE, me->mloopcol, me->totloop, name);
404  }
405  else {
407  &me->ldata, CD_PROP_BYTE_COLOR, CD_DEFAULT, nullptr, me->totloop, name);
408  }
409 
410  if (active_set || layernum == 0) {
412  }
413 
415  }
416 
417  DEG_id_tag_update(&me->id, 0);
419 
420  return layernum;
421 }
422 
423 bool ED_mesh_color_ensure(Mesh *me, const char *name)
424 {
425  BLI_assert(me->edit_mesh == nullptr);
427 
428  if (!layer) {
430  &me->ldata, CD_PROP_BYTE_COLOR, CD_DEFAULT, nullptr, me->totloop, name);
432 
435  }
436 
437  DEG_id_tag_update(&me->id, 0);
438 
439  return (layer != nullptr);
440 }
441 
442 bool ED_mesh_color_remove_index(Mesh *me, const int n)
443 {
444  CustomData *ldata = GET_CD_DATA(me, ldata);
445  CustomDataLayer *cdl;
446  int index;
447 
449  cdl = (index == -1) ? nullptr : &ldata->layers[index];
450 
451  if (!cdl) {
452  return false;
453  }
454 
455  delete_customdata_layer(me, cdl);
456  DEG_id_tag_update(&me->id, 0);
458 
459  return true;
460 }
462 {
463  CustomData *ldata = GET_CD_DATA(me, ldata);
464  const int n = CustomData_get_active_layer(ldata, CD_PROP_BYTE_COLOR);
465  if (n != -1) {
466  return ED_mesh_color_remove_index(me, n);
467  }
468  return false;
469 }
470 bool ED_mesh_color_remove_named(Mesh *me, const char *name)
471 {
472  CustomData *ldata = GET_CD_DATA(me, ldata);
473  const int n = CustomData_get_named_layer(ldata, CD_PROP_BYTE_COLOR, name);
474  if (n != -1) {
475  return ED_mesh_color_remove_index(me, n);
476  }
477  return false;
478 }
479 
480 /*********************** General poll ************************/
481 
482 static bool layers_poll(bContext *C)
483 {
484  Object *ob = ED_object_context(C);
485  ID *data = (ob) ? static_cast<ID *>(ob->data) : nullptr;
486  return (ob && !ID_IS_LINKED(ob) && !ID_IS_OVERRIDE_LIBRARY(ob) && ob->type == OB_MESH && data &&
488 }
489 
490 /*********************** Sculpt Vertex colors operators ************************/
491 
493 {
494  if (!layers_poll(C)) {
495  return false;
496  }
497 
498  Object *ob = ED_object_context(C);
499  Mesh *me = static_cast<Mesh *>(ob->data);
500  CustomData *vdata = GET_CD_DATA(me, vdata);
502  if (active != -1) {
503  return true;
504  }
505 
506  return false;
507 }
508 
510  const char *name,
511  const bool active_set,
512  const bool do_init,
513  ReportList *UNUSED(reports))
514 {
515  /* NOTE: keep in sync with #ED_mesh_uv_add. */
516 
517  BMEditMesh *em;
518  int layernum;
519 
520  if (me->edit_mesh) {
521  em = me->edit_mesh;
522 
524 
525  /* CD_PROP_COLOR */
526  BM_data_layer_add_named(em->bm, &em->bm->vdata, CD_PROP_COLOR, name);
527  /* copy data from active vertex color layer */
528  if (layernum && do_init) {
529  const int layernum_dst = CustomData_get_active_layer(&em->bm->vdata, CD_PROP_COLOR);
530  BM_data_layer_copy(em->bm, &em->bm->vdata, CD_PROP_COLOR, layernum_dst, layernum);
531  }
532  if (active_set || layernum == 0) {
534  }
535  }
536  else {
538 
539  if (CustomData_has_layer(&me->vdata, CD_PROP_COLOR) && do_init) {
540  const MPropCol *color_data = (const MPropCol *)CustomData_get_layer(&me->vdata,
541  CD_PROP_COLOR);
543  &me->vdata, CD_PROP_COLOR, CD_DUPLICATE, (MPropCol *)color_data, me->totvert, name);
544  }
545  else {
547  &me->vdata, CD_PROP_COLOR, CD_DEFAULT, nullptr, me->totvert, name);
548  }
549 
550  if (active_set || layernum == 0) {
552  }
553 
555  }
556 
557  DEG_id_tag_update(&me->id, 0);
559 
560  return layernum;
561 }
562 
563 bool ED_mesh_sculpt_color_ensure(Mesh *me, const char *name)
564 {
565  BLI_assert(me->edit_mesh == nullptr);
566 
567  if (me->totvert && !CustomData_has_layer(&me->vdata, CD_PROP_COLOR)) {
570  }
571 
572  DEG_id_tag_update(&me->id, 0);
573 
574  return (me->mloopcol != nullptr);
575 }
576 
578 {
579  CustomData *vdata = GET_CD_DATA(me, vdata);
580  CustomDataLayer *cdl;
581  int index;
582 
583  index = CustomData_get_layer_index_n(vdata, CD_PROP_COLOR, n);
584  cdl = (index == -1) ? nullptr : &vdata->layers[index];
585 
586  if (!cdl) {
587  return false;
588  }
589 
590  delete_customdata_layer(me, cdl);
591  DEG_id_tag_update(&me->id, 0);
593 
594  return true;
595 }
597 {
598  CustomData *vdata = GET_CD_DATA(me, vdata);
599  const int n = CustomData_get_active_layer(vdata, CD_PROP_COLOR);
600  if (n != -1) {
601  return ED_mesh_sculpt_color_remove_index(me, n);
602  }
603  return false;
604 }
605 bool ED_mesh_sculpt_color_remove_named(Mesh *me, const char *name)
606 {
607  CustomData *vdata = GET_CD_DATA(me, vdata);
608  const int n = CustomData_get_named_layer(vdata, CD_PROP_COLOR, name);
609  if (n != -1) {
610  return ED_mesh_sculpt_color_remove_index(me, n);
611  }
612  return false;
613 }
614 
615 /*********************** UV texture operators ************************/
616 
618 {
619  if (!layers_poll(C)) {
620  return false;
621  }
622 
623  Object *ob = ED_object_context(C);
624  Mesh *me = static_cast<Mesh *>(ob->data);
625  CustomData *ldata = GET_CD_DATA(me, ldata);
626  const int active = CustomData_get_active_layer(ldata, CD_MLOOPUV);
627  if (active != -1) {
628  return true;
629  }
630 
631  return false;
632 }
633 
635 {
636  Object *ob = ED_object_context(C);
637  Mesh *me = static_cast<Mesh *>(ob->data);
638 
639  if (ED_mesh_uv_add(me, nullptr, true, true, op->reports) == -1) {
640  return OPERATOR_CANCELLED;
641  }
642 
643  if (ob->mode & OB_MODE_TEXTURE_PAINT) {
645  ED_paint_proj_mesh_data_check(scene, ob, nullptr, nullptr, nullptr, nullptr);
647  }
648 
649  return OPERATOR_FINISHED;
650 }
651 
653 {
654  /* identifiers */
655  ot->name = "Add UV Map";
656  ot->description = "Add UV map";
657  ot->idname = "MESH_OT_uv_texture_add";
658 
659  /* api callbacks */
660  ot->poll = layers_poll;
662 
663  /* flags */
665 }
666 
668 {
669  Object *ob = ED_object_context(C);
670  Mesh *me = static_cast<Mesh *>(ob->data);
671 
672  if (!ED_mesh_uv_remove_active(me)) {
673  return OPERATOR_CANCELLED;
674  }
675 
676  if (ob->mode & OB_MODE_TEXTURE_PAINT) {
678  ED_paint_proj_mesh_data_check(scene, ob, nullptr, nullptr, nullptr, nullptr);
680  }
681 
682  return OPERATOR_FINISHED;
683 }
684 
686 {
687  /* identifiers */
688  ot->name = "Remove UV Map";
689  ot->description = "Remove UV map";
690  ot->idname = "MESH_OT_uv_texture_remove";
691 
692  /* api callbacks */
695 
696  /* flags */
698 }
699 
700 /*********************** vertex color operators ************************/
701 
703 {
704  if (!layers_poll(C)) {
705  return false;
706  }
707 
708  Object *ob = ED_object_context(C);
709  Mesh *me = static_cast<Mesh *>(ob->data);
710  CustomData *ldata = GET_CD_DATA(me, ldata);
712  if (active != -1) {
713  return true;
714  }
715 
716  return false;
717 }
718 
720 {
721  Object *ob = ED_object_context(C);
722  Mesh *me = static_cast<Mesh *>(ob->data);
723 
724  if (ED_mesh_color_add(me, nullptr, true, true, op->reports) == -1) {
725  return OPERATOR_CANCELLED;
726  }
727 
728  return OPERATOR_FINISHED;
729 }
730 
732 {
733  /* identifiers */
734  ot->name = "Add Vertex Color";
735  ot->description = "Add vertex color layer";
736  ot->idname = "MESH_OT_vertex_color_add";
737 
738  /* api callbacks */
739  ot->poll = layers_poll;
741 
742  /* flags */
744 }
745 
747 {
748  Object *ob = ED_object_context(C);
749  Mesh *me = static_cast<Mesh *>(ob->data);
750 
751  if (!ED_mesh_color_remove_active(me)) {
752  return OPERATOR_CANCELLED;
753  }
754 
755  return OPERATOR_FINISHED;
756 }
757 
759 {
760  /* identifiers */
761  ot->name = "Remove Vertex Color";
762  ot->description = "Remove vertex color layer";
763  ot->idname = "MESH_OT_vertex_color_remove";
764 
765  /* api callbacks */
768 
769  /* flags */
771 }
772 
773 /*********************** Sculpt Vertex Color Operators ************************/
774 
776 {
777  Object *ob = ED_object_context(C);
778  Mesh *me = static_cast<Mesh *>(ob->data);
779 
780  if (ED_mesh_sculpt_color_add(me, nullptr, true, true, op->reports) == -1) {
781  return OPERATOR_CANCELLED;
782  }
783 
784  return OPERATOR_FINISHED;
785 }
786 
788 {
789  /* identifiers */
790  ot->name = "Add Sculpt Vertex Color";
791  ot->description = "Add vertex color layer";
792  ot->idname = "MESH_OT_sculpt_vertex_color_add";
793 
794  /* api callbacks */
795  ot->poll = layers_poll;
797 
798  /* flags */
800 }
801 
803 {
804  Object *ob = ED_object_context(C);
805  Mesh *me = static_cast<Mesh *>(ob->data);
806 
808  return OPERATOR_CANCELLED;
809  }
810 
811  return OPERATOR_FINISHED;
812 }
813 
815 {
816  /* identifiers */
817  ot->name = "Remove Sculpt Vertex Color";
818  ot->description = "Remove vertex color layer";
819  ot->idname = "MESH_OT_sculpt_vertex_color_remove";
820 
821  /* api callbacks */
824 
825  /* flags */
827 }
828 
829 /* *** CustomData clear functions, we need an operator for each *** */
830 
832 {
833  Mesh *me = ED_mesh_context(C);
834 
835  int tot;
836  CustomData *data = mesh_customdata_get_type(me, htype, &tot);
837 
839 
841  if (me->edit_mesh) {
843  }
844  else {
846  }
847 
848  DEG_id_tag_update(&me->id, 0);
850 
851  return OPERATOR_FINISHED;
852  }
853  return OPERATOR_CANCELLED;
854 }
855 
856 /* Clear Mask */
858 {
859  Object *ob = ED_object_context(C);
860  if (ob && ob->type == OB_MESH) {
861  Mesh *me = static_cast<Mesh *>(ob->data);
862 
863  /* special case - can't run this if we're in sculpt mode */
864  if (ob->mode & OB_MODE_SCULPT) {
865  return false;
866  }
867 
868  if (!ID_IS_LINKED(me) && !ID_IS_OVERRIDE_LIBRARY(me)) {
869  CustomData *data = GET_CD_DATA(me, vdata);
871  return true;
872  }
873  data = GET_CD_DATA(me, ldata);
875  return true;
876  }
877  }
878  }
879  return false;
880 }
882 {
885 
886  if (ret_a == OPERATOR_FINISHED || ret_b == OPERATOR_FINISHED) {
887  return OPERATOR_FINISHED;
888  }
889  return OPERATOR_CANCELLED;
890 }
891 
893 {
894  /* NOTE: no create_mask yet */
895 
896  /* identifiers */
897  ot->name = "Clear Sculpt Mask Data";
898  ot->idname = "MESH_OT_customdata_mask_clear";
899  ot->description = "Clear vertex sculpt masking data from the mesh";
900 
901  /* api callbacks */
904 
905  /* flags */
907 }
908 
914 {
915  Object *ob = ED_object_context(C);
916 
917  if (ob && ob->type == OB_MESH) {
918  Mesh *me = static_cast<Mesh *>(ob->data);
919  if (!ID_IS_LINKED(me) && !ID_IS_OVERRIDE_LIBRARY(me)) {
920  CustomData *data = GET_CD_DATA(me, vdata);
922  }
923  }
924  return -1;
925 }
926 
928 {
929  return (mesh_customdata_skin_state(C) == 0);
930 }
931 
933 {
934  Object *ob = ED_object_context(C);
935  Mesh *me = static_cast<Mesh *>(ob->data);
936 
938 
939  DEG_id_tag_update(&me->id, 0);
941 
942  return OPERATOR_FINISHED;
943 }
944 
946 {
947  /* identifiers */
948  ot->name = "Add Skin Data";
949  ot->idname = "MESH_OT_customdata_skin_add";
950  ot->description = "Add a vertex skin layer";
951 
952  /* api callbacks */
955 
956  /* flags */
958 }
959 
961 {
962  return (mesh_customdata_skin_state(C) == 1);
963 }
964 
966 {
968 }
969 
971 {
972  /* identifiers */
973  ot->name = "Clear Skin Data";
974  ot->idname = "MESH_OT_customdata_skin_clear";
975  ot->description = "Clear vertex skin layer";
976 
977  /* api callbacks */
980 
981  /* flags */
983 }
984 
985 /* Clear custom loop normals */
987 {
988  Mesh *me = ED_mesh_context(C);
989 
991  CustomData *data = GET_CD_DATA(me, ldata);
992 
993  if (me->edit_mesh) {
994  /* Tag edges as sharp according to smooth threshold if needed,
995  * to preserve autosmooth shading. */
996  if (me->flag & ME_AUTOSMOOTH) {
998  }
999 
1001  }
1002  else {
1003  /* Tag edges as sharp according to smooth threshold if needed,
1004  * to preserve autosmooth shading. */
1005  if (me->flag & ME_AUTOSMOOTH) {
1007  me->totvert,
1008  me->medge,
1009  me->totedge,
1010  me->mloop,
1011  me->totloop,
1012  me->mpoly,
1014  me->totpoly,
1015  me->smoothresh);
1016  }
1017 
1019  }
1020 
1021  DEG_id_tag_update(&me->id, 0);
1023 
1024  return OPERATOR_FINISHED;
1025  }
1026  return OPERATOR_CANCELLED;
1027 }
1028 
1030 {
1031  /* identifiers */
1032  ot->name = "Add Custom Split Normals Data";
1033  ot->idname = "MESH_OT_customdata_custom_splitnormals_add";
1034  ot->description = "Add a custom split normals layer, if none exists yet";
1035 
1036  /* api callbacks */
1039 
1040  /* flags */
1042 }
1043 
1045 {
1046  Mesh *me = ED_mesh_context(C);
1047 
1049  BMEditMesh *em = me->edit_mesh;
1050  if (em != nullptr && em->bm->lnor_spacearr != nullptr) {
1052  }
1054  }
1055  return OPERATOR_CANCELLED;
1056 }
1057 
1059 {
1060  /* identifiers */
1061  ot->name = "Clear Custom Split Normals Data";
1062  ot->idname = "MESH_OT_customdata_custom_splitnormals_clear";
1063  ot->description = "Remove the custom split normals layer, if it exists";
1064 
1065  /* api callbacks */
1068 
1069  /* flags */
1071 }
1072 
1073 /************************** Add Geometry Layers *************************/
1074 
1075 void ED_mesh_update(Mesh *mesh, bContext *C, bool calc_edges, bool calc_edges_loose)
1076 {
1077  if (calc_edges || ((mesh->totpoly || mesh->totface) && mesh->totedge == 0)) {
1078  BKE_mesh_calc_edges(mesh, calc_edges, true);
1079  }
1080 
1081  if (calc_edges_loose && mesh->totedge) {
1083  }
1084 
1085  /* Default state is not to have tessface's so make sure this is the case. */
1087 
1088  /* Tag lazily calculated data as dirty. */
1090 
1091  DEG_id_tag_update(&mesh->id, 0);
1093 }
1094 
1095 static void mesh_add_verts(Mesh *mesh, int len)
1096 {
1097  if (len == 0) {
1098  return;
1099  }
1100 
1101  int totvert = mesh->totvert + len;
1102  CustomData vdata;
1103  CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH.vmask, CD_DEFAULT, totvert);
1104  CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert);
1105 
1106  if (!CustomData_has_layer(&vdata, CD_MVERT)) {
1107  CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, nullptr, totvert);
1108  }
1109 
1111  mesh->vdata = vdata;
1113 
1115 
1116  /* scan the input list and insert the new vertices */
1117 
1118  /* set default flags */
1119  MVert *mvert = &mesh->mvert[mesh->totvert];
1120  for (int i = 0; i < len; i++, mvert++) {
1121  mvert->flag |= SELECT;
1122  }
1123 
1124  /* set final vertex list size */
1125  mesh->totvert = totvert;
1126 }
1127 
1128 static void mesh_add_edges(Mesh *mesh, int len)
1129 {
1130  CustomData edata;
1131  MEdge *medge;
1132  int i, totedge;
1133 
1134  if (len == 0) {
1135  return;
1136  }
1137 
1138  totedge = mesh->totedge + len;
1139 
1140  /* Update custom-data. */
1141  CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge);
1142  CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
1143 
1144  if (!CustomData_has_layer(&edata, CD_MEDGE)) {
1145  CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, nullptr, totedge);
1146  }
1147 
1149  mesh->edata = edata;
1150  BKE_mesh_update_customdata_pointers(mesh, false); /* new edges don't change tessellation */
1151 
1153 
1154  /* set default flags */
1155  medge = &mesh->medge[mesh->totedge];
1156  for (i = 0; i < len; i++, medge++) {
1157  medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT;
1158  }
1159 
1160  mesh->totedge = totedge;
1161 }
1162 
1163 static void mesh_add_loops(Mesh *mesh, int len)
1164 {
1165  CustomData ldata;
1166  int totloop;
1167 
1168  if (len == 0) {
1169  return;
1170  }
1171 
1172  totloop = mesh->totloop + len; /* new face count */
1173 
1174  /* update customdata */
1175  CustomData_copy(&mesh->ldata, &ldata, CD_MASK_MESH.lmask, CD_DEFAULT, totloop);
1176  CustomData_copy_data(&mesh->ldata, &ldata, 0, 0, mesh->totloop);
1177 
1178  if (!CustomData_has_layer(&ldata, CD_MLOOP)) {
1179  CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, nullptr, totloop);
1180  }
1181 
1183 
1185  mesh->ldata = ldata;
1187 
1188  mesh->totloop = totloop;
1189 }
1190 
1191 static void mesh_add_polys(Mesh *mesh, int len)
1192 {
1193  CustomData pdata;
1194  MPoly *mpoly;
1195  int i, totpoly;
1196 
1197  if (len == 0) {
1198  return;
1199  }
1200 
1201  totpoly = mesh->totpoly + len; /* new face count */
1202 
1203  /* update customdata */
1204  CustomData_copy(&mesh->pdata, &pdata, CD_MASK_MESH.pmask, CD_DEFAULT, totpoly);
1205  CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly);
1206 
1207  if (!CustomData_has_layer(&pdata, CD_MPOLY)) {
1208  CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, nullptr, totpoly);
1209  }
1210 
1212  mesh->pdata = pdata;
1214 
1216 
1217  /* set default flags */
1218  mpoly = &mesh->mpoly[mesh->totpoly];
1219  for (i = 0; i < len; i++, mpoly++) {
1220  mpoly->flag = ME_FACE_SEL;
1221  }
1222 
1223  mesh->totpoly = totpoly;
1224 }
1225 
1226 /* -------------------------------------------------------------------- */
1231 {
1232  if (mesh->edit_mesh) {
1233  BKE_report(reports, RPT_ERROR, "Cannot add vertices in edit mode");
1234  return;
1235  }
1237 }
1238 
1240 {
1241  if (mesh->edit_mesh) {
1242  BKE_report(reports, RPT_ERROR, "Cannot add edges in edit mode");
1243  return;
1244  }
1246 }
1247 
1249 {
1250  if (mesh->edit_mesh) {
1251  BKE_report(reports, RPT_ERROR, "Cannot add loops in edit mode");
1252  return;
1253  }
1255 }
1256 
1258 {
1259  if (mesh->edit_mesh) {
1260  BKE_report(reports, RPT_ERROR, "Cannot add polygons in edit mode");
1261  return;
1262  }
1264 }
1265 
1268 /* -------------------------------------------------------------------- */
1272 static void mesh_remove_verts(Mesh *mesh, int len)
1273 {
1274  if (len == 0) {
1275  return;
1276  }
1277  const int totvert = mesh->totvert - len;
1278  CustomData_free_elem(&mesh->vdata, totvert, len);
1279  mesh->totvert = totvert;
1280 }
1281 
1282 static void mesh_remove_edges(Mesh *mesh, int len)
1283 {
1284  if (len == 0) {
1285  return;
1286  }
1287  const int totedge = mesh->totedge - len;
1288  CustomData_free_elem(&mesh->edata, totedge, len);
1289  mesh->totedge = totedge;
1290 }
1291 
1292 static void mesh_remove_loops(Mesh *mesh, int len)
1293 {
1294  if (len == 0) {
1295  return;
1296  }
1297  const int totloop = mesh->totloop - len;
1298  CustomData_free_elem(&mesh->ldata, totloop, len);
1299  mesh->totloop = totloop;
1300 }
1301 
1302 static void mesh_remove_polys(Mesh *mesh, int len)
1303 {
1304  if (len == 0) {
1305  return;
1306  }
1307  const int totpoly = mesh->totpoly - len;
1308  CustomData_free_elem(&mesh->pdata, totpoly, len);
1309  mesh->totpoly = totpoly;
1310 }
1311 
1313 {
1314  if (mesh->edit_mesh) {
1315  BKE_report(reports, RPT_ERROR, "Cannot remove vertices in edit mode");
1316  return;
1317  }
1318  if (count > mesh->totvert) {
1319  BKE_report(reports, RPT_ERROR, "Cannot remove more vertices than the mesh contains");
1320  return;
1321  }
1322 
1324 }
1325 
1327 {
1328  if (mesh->edit_mesh) {
1329  BKE_report(reports, RPT_ERROR, "Cannot remove edges in edit mode");
1330  return;
1331  }
1332  if (count > mesh->totedge) {
1333  BKE_report(reports, RPT_ERROR, "Cannot remove more edges than the mesh contains");
1334  return;
1335  }
1336 
1338 }
1339 
1341 {
1342  if (mesh->edit_mesh) {
1343  BKE_report(reports, RPT_ERROR, "Cannot remove loops in edit mode");
1344  return;
1345  }
1346  if (count > mesh->totloop) {
1347  BKE_report(reports, RPT_ERROR, "Cannot remove more loops than the mesh contains");
1348  return;
1349  }
1350 
1352 }
1353 
1355 {
1356  if (mesh->edit_mesh) {
1357  BKE_report(reports, RPT_ERROR, "Cannot remove polys in edit mode");
1358  return;
1359  }
1360  if (count > mesh->totpoly) {
1361  BKE_report(reports, RPT_ERROR, "Cannot remove more polys than the mesh contains");
1362  return;
1363  }
1364 
1366 }
1367 
1369 {
1374 }
1375 
1378 void ED_mesh_report_mirror_ex(wmOperator *op, int totmirr, int totfail, char selectmode)
1379 {
1380  const char *elem_type;
1381 
1382  if (selectmode & SCE_SELECT_VERTEX) {
1383  elem_type = "vertices";
1384  }
1385  else if (selectmode & SCE_SELECT_EDGE) {
1386  elem_type = "edges";
1387  }
1388  else {
1389  elem_type = "faces";
1390  }
1391 
1392  if (totfail) {
1393  BKE_reportf(
1394  op->reports, RPT_WARNING, "%d %s mirrored, %d failed", totmirr, elem_type, totfail);
1395  }
1396  else {
1397  BKE_reportf(op->reports, RPT_INFO, "%d %s mirrored", totmirr, elem_type);
1398  }
1399 }
1400 
1401 void ED_mesh_report_mirror(wmOperator *op, int totmirr, int totfail)
1402 {
1403  ED_mesh_report_mirror_ex(op, totmirr, totfail, SCE_SELECT_VERTEX);
1404 }
1405 
1407 {
1408  Mesh *mesh = static_cast<Mesh *>(CTX_data_pointer_get_type(C, "mesh", &RNA_Mesh).data);
1409  if (mesh != nullptr) {
1410  return mesh;
1411  }
1412 
1414  if (ob == nullptr) {
1415  return nullptr;
1416  }
1417 
1418  ID *data = (ID *)ob->data;
1419  if (data == nullptr || GS(data->name) != ID_ME) {
1420  return nullptr;
1421  }
1422 
1423  return (Mesh *)data;
1424 }
typedef float(TangentPoint)[2]
Generic geometry attributes built on CustomData.
void BKE_id_attributes_active_color_set(struct ID *id, struct CustomDataLayer *active_layer)
Definition: attribute.cc:715
struct CustomDataLayer * BKE_id_attributes_active_color_get(const struct ID *id)
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:473
CustomData interface, see also DNA_customdata_types.h.
void CustomData_free(struct CustomData *data, int totelem)
Definition: customdata.cc:2373
int CustomData_number_of_layers(const struct CustomData *data, int type)
bool CustomData_free_layer(struct CustomData *data, int type, int totelem, int index)
Definition: customdata.cc:2831
void CustomData_set_layer_active(struct CustomData *data, int type, int n)
Definition: customdata.cc:2542
@ CD_CALLOC
@ CD_DUPLICATE
@ CD_DEFAULT
void CustomData_copy(const struct CustomData *source, struct CustomData *dest, eCustomDataMask mask, eCDAllocType alloctype, int totelem)
void CustomData_free_layers(struct CustomData *data, int type, int totelem)
Definition: customdata.cc:2904
bool CustomData_has_layer(const struct CustomData *data, int type)
bool CustomData_layertype_is_singleton(int type)
Definition: customdata.cc:4280
int CustomData_get_layer_index_n(const struct CustomData *data, int type, int n)
void * CustomData_add_layer_named(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem, const char *name)
Definition: customdata.cc:2792
int CustomData_get_active_layer(const struct CustomData *data, int type)
void * CustomData_get_layer_n(const struct CustomData *data, int type, int n)
int CustomData_get_layer_index(const struct CustomData *data, int type)
void * CustomData_get_layer(const struct CustomData *data, int type)
int CustomData_get_named_layer(const struct CustomData *data, int type, const char *name)
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
Definition: customdata.cc:2776
int CustomData_get_n_offset(const struct CustomData *data, int type, int n)
void CustomData_free_elem(struct CustomData *data, int index, int count)
Definition: customdata.cc:3206
void CustomData_copy_data(const struct CustomData *source, struct CustomData *dest, int source_index, int dest_index, int count)
const CustomData_MeshMasks CD_MASK_MESH
Definition: customdata.cc:2065
const float(* BKE_mesh_poly_normals_ensure(const struct Mesh *mesh))[3]
void BKE_mesh_tessface_clear(struct Mesh *mesh)
Definition: mesh.cc:1654
bool BKE_mesh_has_custom_loop_normals(struct Mesh *me)
Definition: mesh.cc:894
void BKE_mesh_ensure_skin_customdata(struct Mesh *me)
Definition: mesh.cc:786
void BKE_mesh_calc_edges_loose(struct Mesh *mesh)
void BKE_lnor_spacearr_clear(MLoopNorSpaceArray *lnors_spacearr)
void BKE_mesh_update_customdata_pointers(struct Mesh *me, bool do_ensure_tess_cd)
Definition: mesh.cc:874
void BKE_mesh_normals_tag_dirty(struct Mesh *mesh)
Definition: mesh_normals.cc:95
void BKE_mesh_calc_edges(struct Mesh *mesh, bool keep_existing_edges, bool select_new_edges)
void BKE_edges_sharp_from_angle_set(const struct MVert *mverts, int numVerts, struct MEdge *medges, int numEdges, struct MLoop *mloops, int numLoops, struct MPoly *mpolys, const float(*polynors)[3], int numPolys, float split_angle)
void BKE_mesh_runtime_clear_cache(struct Mesh *mesh)
This function clears runtime cache of the given mesh.
Definition: mesh_runtime.cc:99
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition: report.c:83
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define M_PI
Definition: BLI_math_base.h:20
#define UNUSED(x)
#define ELEM(...)
void DEG_id_tag_update(struct ID *id, int flag)
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:566
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition: DNA_ID.h:588
@ ID_ME
Definition: DNA_ID_enums.h:48
@ CD_PROP_BYTE_COLOR
@ CD_PAINT_MASK
@ CD_MVERT_SKIN
@ CD_CUSTOMLOOPNORMAL
@ CD_PROP_COLOR
@ CD_MEDGE
@ CD_GRID_PAINT_MASK
@ CD_MVERT
@ CD_MLOOPUV
#define MAX_MTFACE
@ ME_AUTOSMOOTH
@ ME_FACE_SEL
@ ME_EDGEDRAW
@ ME_EDGERENDER
@ OB_MODE_SCULPT
@ OB_MODE_TEXTURE_PAINT
Object is a sort of wrapper for general info.
@ OB_MESH
#define SCE_SELECT_VERTEX
#define SCE_SELECT_EDGE
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
struct Object * ED_object_context(const struct bContext *C)
struct Object * ED_object_active_context(const struct bContext *C)
bool ED_paint_proj_mesh_data_check(struct Scene *scene, struct Object *ob, bool *uvs, bool *mat, bool *tex, bool *stencil)
bool ED_operator_editable_mesh(struct bContext *C)
Definition: screen_ops.c:427
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:25
@ 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 NC_SCENE
Definition: WM_types.h:328
#define ND_TOOLSETTINGS
Definition: WM_types.h:397
@ BM_LOOP
Definition: bmesh_class.h:385
@ 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
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
Definition: bmesh_class.h:541
#define BM_elem_flag_test(ele, hflag)
Definition: bmesh_inline.h:12
void BM_data_layer_free_n(BMesh *bm, CustomData *data, int type, int n)
Definition: bmesh_interp.c:922
void BM_data_layer_free(BMesh *bm, CustomData *data, int type)
Definition: bmesh_interp.c:875
void BM_data_layer_copy(BMesh *bm, CustomData *data, int type, int src_n, int dst_n)
Definition: bmesh_interp.c:944
void BM_data_layer_add(BMesh *bm, CustomData *data, int type)
Definition: bmesh_interp.c:839
void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *name)
Definition: bmesh_interp.c:857
#define BM_ITER_MESH(ele, iter, bm, itype)
@ BM_FACES_OF_MESH
@ BM_LOOPS_OF_FACE
#define BM_ITER_ELEM_INDEX(ele, iter, data, itype, indexvar)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_edges_sharp_from_angle_set(BMesh *bm, const float split_angle)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
const T * data() const
Definition: BLI_array.hh:300
#define sinf(x)
Definition: cuda/compat.h:102
#define cosf(x)
Definition: cuda/compat.h:101
#define SELECT
Scene scene
int len
Definition: draw_manager.c:108
int count
#define GS(x)
Definition: iris.c:225
void MESH_OT_customdata_mask_clear(wmOperatorType *ot)
Definition: mesh_data.cc:892
void ED_mesh_update(Mesh *mesh, bContext *C, bool calc_edges, bool calc_edges_loose)
Definition: mesh_data.cc:1075
bool ED_mesh_sculpt_color_remove_active(Mesh *me)
Definition: mesh_data.cc:596
int ED_mesh_sculpt_color_add(Mesh *me, const char *name, const bool active_set, const bool do_init, ReportList *UNUSED(reports))
Definition: mesh_data.cc:509
static bool sculpt_vertex_color_remove_poll(bContext *C)
Definition: mesh_data.cc:492
void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.cc:1326
static bool layers_poll(bContext *C)
Definition: mesh_data.cc:482
int ED_mesh_uv_add(Mesh *me, const char *name, const bool active_set, const bool do_init, ReportList *reports)
Definition: mesh_data.cc:244
static void mesh_uv_reset_bmface(BMFace *f, const int cd_loop_uv_offset)
Definition: mesh_data.cc:175
static void mesh_remove_loops(Mesh *mesh, int len)
Definition: mesh_data.cc:1292
bool ED_mesh_color_remove_index(Mesh *me, const int n)
Definition: mesh_data.cc:442
void ED_mesh_report_mirror_ex(wmOperator *op, int totmirr, int totfail, char selectmode)
Definition: mesh_data.cc:1378
bool ED_mesh_color_ensure(Mesh *me, const char *name)
Definition: mesh_data.cc:423
static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.cc:746
void MESH_OT_customdata_skin_add(wmOperatorType *ot)
Definition: mesh_data.cc:945
bool ED_mesh_sculpt_color_remove_named(Mesh *me, const char *name)
Definition: mesh_data.cc:605
bool ED_mesh_sculpt_color_remove_index(Mesh *me, const int n)
Definition: mesh_data.cc:577
static int mesh_sculpt_vertex_color_add_exec(bContext *C, wmOperator *op)
Definition: mesh_data.cc:775
static int mesh_uv_texture_add_exec(bContext *C, wmOperator *op)
Definition: mesh_data.cc:634
void MESH_OT_vertex_color_add(wmOperatorType *ot)
Definition: mesh_data.cc:731
void MESH_OT_uv_texture_remove(wmOperatorType *ot)
Definition: mesh_data.cc:685
bool ED_mesh_uv_remove_named(Mesh *me, const char *name)
Definition: mesh_data.cc:361
static void mesh_uv_reset_mface(MPoly *mp, MLoopUV *mloopuv)
Definition: mesh_data.cc:189
void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.cc:1239
static bool uv_texture_remove_poll(bContext *C)
Definition: mesh_data.cc:617
static void mesh_add_polys(Mesh *mesh, int len)
Definition: mesh_data.cc:1191
void ED_mesh_uv_loop_reset(bContext *C, Mesh *me)
Definition: mesh_data.cc:234
void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.cc:1248
static int mesh_customdata_custom_splitnormals_clear_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.cc:1044
int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set, const bool do_init, ReportList *UNUSED(reports))
Definition: mesh_data.cc:371
void ED_mesh_report_mirror(wmOperator *op, int totmirr, int totfail)
Definition: mesh_data.cc:1401
#define GET_CD_DATA(me, data)
Definition: mesh_data.cc:106
void ED_mesh_verts_add(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.cc:1230
void MESH_OT_customdata_skin_clear(wmOperatorType *ot)
Definition: mesh_data.cc:970
static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.cc:667
static bool vertex_color_remove_poll(bContext *C)
Definition: mesh_data.cc:702
void ED_mesh_geometry_clear(Mesh *mesh)
Definition: mesh_data.cc:1368
static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer)
Definition: mesh_data.cc:107
Mesh * ED_mesh_context(bContext *C)
Definition: mesh_data.cc:1406
static void mesh_add_edges(Mesh *mesh, int len)
Definition: mesh_data.cc:1128
void ED_mesh_uv_ensure(Mesh *me, const char *name)
Definition: mesh_data.cc:310
void ED_mesh_polys_remove(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.cc:1354
static bool mesh_customdata_skin_add_poll(bContext *C)
Definition: mesh_data.cc:927
static CustomData * mesh_customdata_get_type(Mesh *me, const char htype, int *r_tot)
Definition: mesh_data.cc:48
void ED_mesh_loops_remove(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.cc:1340
void MESH_OT_vertex_color_remove(wmOperatorType *ot)
Definition: mesh_data.cc:758
void MESH_OT_sculpt_vertex_color_remove(wmOperatorType *ot)
Definition: mesh_data.cc:814
static int mesh_customdata_skin_add_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.cc:932
bool ED_mesh_uv_remove_active(Mesh *me)
Definition: mesh_data.cc:351
static int mesh_customdata_skin_state(bContext *C)
Definition: mesh_data.cc:913
static int mesh_vertex_color_add_exec(bContext *C, wmOperator *op)
Definition: mesh_data.cc:719
bool ED_mesh_color_remove_named(Mesh *me, const char *name)
Definition: mesh_data.cc:470
static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.cc:986
bool ED_mesh_uv_remove_index(Mesh *me, const int n)
Definition: mesh_data.cc:331
void MESH_OT_sculpt_vertex_color_add(wmOperatorType *ot)
Definition: mesh_data.cc:787
static void mesh_remove_verts(Mesh *mesh, int len)
Definition: mesh_data.cc:1272
bool ED_mesh_sculpt_color_ensure(Mesh *me, const char *name)
Definition: mesh_data.cc:563
static void mesh_add_verts(Mesh *mesh, int len)
Definition: mesh_data.cc:1095
void MESH_OT_uv_texture_add(wmOperatorType *ot)
Definition: mesh_data.cc:652
static void mesh_add_loops(Mesh *mesh, int len)
Definition: mesh_data.cc:1163
static bool mesh_customdata_mask_clear_poll(bContext *C)
Definition: mesh_data.cc:857
bool ED_mesh_color_remove_active(Mesh *me)
Definition: mesh_data.cc:461
static void mesh_remove_edges(Mesh *mesh, int len)
Definition: mesh_data.cc:1282
void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.cc:1257
void MESH_OT_customdata_custom_splitnormals_add(wmOperatorType *ot)
Definition: mesh_data.cc:1029
static bool mesh_customdata_skin_clear_poll(bContext *C)
Definition: mesh_data.cc:960
static void mesh_remove_polys(Mesh *mesh, int len)
Definition: mesh_data.cc:1302
static int mesh_sculpt_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.cc:802
void ED_mesh_verts_remove(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.cc:1312
static int mesh_customdata_clear_exec__internal(bContext *C, char htype, int type)
Definition: mesh_data.cc:831
static void mesh_uv_reset_array(float **fuv, const int len)
Definition: mesh_data.cc:135
void ED_mesh_uv_loop_reset_ex(Mesh *me, const int layernum)
Definition: mesh_data.cc:200
static int mesh_customdata_mask_clear_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.cc:881
void MESH_OT_customdata_custom_splitnormals_clear(wmOperatorType *ot)
Definition: mesh_data.cc:1058
static int mesh_customdata_skin_clear_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.cc:965
bool active
all scheduled work for the GPU.
struct BMesh * bm
Definition: BKE_editmesh.h:40
int len
Definition: bmesh_class.h:267
int totvert
Definition: bmesh_class.h:297
struct MLoopNorSpaceArray * lnor_spacearr
Definition: bmesh_class.h:343
CustomData vdata
Definition: bmesh_class.h:337
int totedge
Definition: bmesh_class.h:297
CustomData edata
Definition: bmesh_class.h:337
int totloop
Definition: bmesh_class.h:297
CustomData pdata
Definition: bmesh_class.h:337
CustomData ldata
Definition: bmesh_class.h:337
int totface
Definition: bmesh_class.h:297
CustomDataLayer * layers
Definition: DNA_ID.h:368
struct MEdge * medge
struct BMEditMesh * edit_mesh
float smoothresh
CustomData vdata
struct MVert * mvert
struct MLoopCol * mloopcol
uint16_t flag
int totedge
struct MLoopUV * mloopuv
int totvert
struct MLoop * mloop
int totface
CustomData pdata
int totpoly
CustomData edata
int totloop
struct MPoly * mpoly
CustomData ldata
void * data
void * data
Definition: RNA_types.h:38
const char * name
Definition: WM_types.h:888
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
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
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition: wm_files.c:3479