Blender  V2.93
mesh_data.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) 2009 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "MEM_guardedalloc.h"
25 
26 #include "DNA_mesh_types.h"
27 #include "DNA_meshdata_types.h"
28 #include "DNA_object_types.h"
29 #include "DNA_scene_types.h"
30 #include "DNA_view3d_types.h"
31 
32 #include "BLI_alloca.h"
33 #include "BLI_math.h"
34 #include "BLI_utildefines.h"
35 
36 #include "BKE_context.h"
37 #include "BKE_editmesh.h"
38 #include "BKE_mesh.h"
39 #include "BKE_report.h"
40 
41 #include "DEG_depsgraph.h"
42 
43 #include "RNA_access.h"
44 #include "RNA_define.h"
45 
46 #include "WM_api.h"
47 #include "WM_types.h"
48 
49 #include "ED_mesh.h"
50 #include "ED_object.h"
51 #include "ED_paint.h"
52 #include "ED_screen.h"
53 #include "ED_uvedit.h"
54 #include "ED_view3d.h"
55 
56 #include "mesh_intern.h" /* own include */
57 
58 static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_tot)
59 {
61  BMesh *bm = (me->edit_mesh) ? me->edit_mesh->bm : NULL;
62  int tot;
63 
64  /* this */
65  switch (htype) {
66  case BM_VERT:
67  if (bm) {
68  data = &bm->vdata;
69  tot = bm->totvert;
70  }
71  else {
72  data = &me->vdata;
73  tot = me->totvert;
74  }
75  break;
76  case BM_EDGE:
77  if (bm) {
78  data = &bm->edata;
79  tot = bm->totedge;
80  }
81  else {
82  data = &me->edata;
83  tot = me->totedge;
84  }
85  break;
86  case BM_LOOP:
87  if (bm) {
88  data = &bm->ldata;
89  tot = bm->totloop;
90  }
91  else {
92  data = &me->ldata;
93  tot = me->totloop;
94  }
95  break;
96  case BM_FACE:
97  if (bm) {
98  data = &bm->pdata;
99  tot = bm->totface;
100  }
101  else {
102  data = &me->pdata;
103  tot = me->totpoly;
104  }
105  break;
106  default:
107  BLI_assert(0);
108  tot = 0;
109  data = NULL;
110  break;
111  }
112 
113  *r_tot = tot;
114  return data;
115 }
116 
117 #define GET_CD_DATA(me, data) ((me)->edit_mesh ? &(me)->edit_mesh->bm->data : &(me)->data)
119 {
120  const int type = layer->type;
121  CustomData *data;
122  int layer_index, tot, n;
123 
124  char htype = BM_FACE;
125  if (ELEM(type, CD_MLOOPCOL, CD_MLOOPUV)) {
126  htype = BM_LOOP;
127  }
128  else if (ELEM(type, CD_PROP_COLOR)) {
129  htype = BM_VERT;
130  }
131 
132  data = mesh_customdata_get_type(me, htype, &tot);
133  layer_index = CustomData_get_layer_index(data, type);
134  n = (layer - &data->layers[layer_index]);
135  BLI_assert(n >= 0 && (n + layer_index) < data->totlayer);
136 
137  if (me->edit_mesh) {
139  }
140  else {
141  CustomData_free_layer(data, type, tot, layer_index + n);
143  }
144 }
145 
146 static void mesh_uv_reset_array(float **fuv, const int len)
147 {
148  if (len == 3) {
149  fuv[0][0] = 0.0;
150  fuv[0][1] = 0.0;
151 
152  fuv[1][0] = 1.0;
153  fuv[1][1] = 0.0;
154 
155  fuv[2][0] = 1.0;
156  fuv[2][1] = 1.0;
157  }
158  else if (len == 4) {
159  fuv[0][0] = 0.0;
160  fuv[0][1] = 0.0;
161 
162  fuv[1][0] = 1.0;
163  fuv[1][1] = 0.0;
164 
165  fuv[2][0] = 1.0;
166  fuv[2][1] = 1.0;
167 
168  fuv[3][0] = 0.0;
169  fuv[3][1] = 1.0;
170  /*make sure we ignore 2-sided faces*/
171  }
172  else if (len > 2) {
173  float fac = 0.0f, dfac = 1.0f / (float)len;
174 
175  dfac *= (float)M_PI * 2.0f;
176 
177  for (int i = 0; i < len; i++) {
178  fuv[i][0] = 0.5f * sinf(fac) + 0.5f;
179  fuv[i][1] = 0.5f * cosf(fac) + 0.5f;
180 
181  fac += dfac;
182  }
183  }
184 }
185 
186 static void mesh_uv_reset_bmface(BMFace *f, const int cd_loop_uv_offset)
187 {
188  float **fuv = BLI_array_alloca(fuv, f->len);
189  BMIter liter;
190  BMLoop *l;
191  int i;
192 
193  BM_ITER_ELEM_INDEX (l, &liter, f, BM_LOOPS_OF_FACE, i) {
194  fuv[i] = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset))->uv;
195  }
196 
197  mesh_uv_reset_array(fuv, f->len);
198 }
199 
200 static void mesh_uv_reset_mface(MPoly *mp, MLoopUV *mloopuv)
201 {
202  float **fuv = BLI_array_alloca(fuv, mp->totloop);
203 
204  for (int i = 0; i < mp->totloop; i++) {
205  fuv[i] = mloopuv[mp->loopstart + i].uv;
206  }
207 
208  mesh_uv_reset_array(fuv, mp->totloop);
209 }
210 
211 /* without bContext, called in uvedit */
212 void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum)
213 {
214  BMEditMesh *em = me->edit_mesh;
215 
216  if (em) {
217  /* Collect BMesh UVs */
218  const int cd_loop_uv_offset = CustomData_get_n_offset(&em->bm->ldata, CD_MLOOPUV, layernum);
219 
220  BMFace *efa;
221  BMIter iter;
222 
223  BLI_assert(cd_loop_uv_offset != -1);
224 
225  BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
226  if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
227  continue;
228  }
229 
230  mesh_uv_reset_bmface(efa, cd_loop_uv_offset);
231  }
232  }
233  else {
234  /* Collect Mesh UVs */
236  MLoopUV *mloopuv = CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, layernum);
237 
238  for (int i = 0; i < me->totpoly; i++) {
239  mesh_uv_reset_mface(&me->mpoly[i], mloopuv);
240  }
241  }
242 
243  DEG_id_tag_update(&me->id, 0);
244 }
245 
246 void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
247 {
248  /* could be ldata or pdata */
249  CustomData *ldata = GET_CD_DATA(me, ldata);
250  const int layernum = CustomData_get_active_layer(ldata, CD_MLOOPUV);
251  ED_mesh_uv_loop_reset_ex(me, layernum);
252 
254 }
255 
256 /* note: keep in sync with ED_mesh_color_add */
257 int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set, const bool do_init)
258 {
259  BMEditMesh *em;
260  int layernum_dst;
261 
262  bool is_init = false;
263 
264  if (me->edit_mesh) {
265  em = me->edit_mesh;
266 
267  layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV);
268  if (layernum_dst >= MAX_MTFACE) {
269  return -1;
270  }
271 
272  /* CD_MLOOPUV */
273  BM_data_layer_add_named(em->bm, &em->bm->ldata, CD_MLOOPUV, name);
274  /* copy data from active UV */
275  if (layernum_dst && do_init) {
276  const int layernum_src = CustomData_get_active_layer(&em->bm->ldata, CD_MLOOPUV);
277  BM_data_layer_copy(em->bm, &em->bm->ldata, CD_MLOOPUV, layernum_src, layernum_dst);
278 
279  is_init = true;
280  }
281  if (active_set || layernum_dst == 0) {
282  CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum_dst);
283  }
284  }
285  else {
286  layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
287  if (layernum_dst >= MAX_MTFACE) {
288  return -1;
289  }
290 
291  if (me->mloopuv && do_init) {
293  &me->ldata, CD_MLOOPUV, CD_DUPLICATE, me->mloopuv, me->totloop, name);
294  is_init = true;
295  }
296  else {
298  }
299 
300  if (active_set || layernum_dst == 0) {
301  CustomData_set_layer_active(&me->ldata, CD_MLOOPUV, layernum_dst);
302  }
303 
305  }
306 
307  /* don't overwrite our copied coords */
308  if (!is_init && do_init) {
309  ED_mesh_uv_loop_reset_ex(me, layernum_dst);
310  }
311 
312  DEG_id_tag_update(&me->id, 0);
314 
315  return layernum_dst;
316 }
317 
318 void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name)
319 {
320  BMEditMesh *em;
321  int layernum_dst;
322 
323  if (me->edit_mesh) {
324  em = me->edit_mesh;
325 
326  layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV);
327  if (layernum_dst == 0) {
328  ED_mesh_uv_texture_add(me, name, true, true);
329  }
330  }
331  else {
332  layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
333  if (layernum_dst == 0) {
334  ED_mesh_uv_texture_add(me, name, true, true);
335  }
336  }
337 }
338 
339 bool ED_mesh_uv_texture_remove_index(Mesh *me, const int n)
340 {
341  CustomData *ldata = GET_CD_DATA(me, ldata);
342  CustomDataLayer *cdlu;
343  int index;
344 
345  index = CustomData_get_layer_index_n(ldata, CD_MLOOPUV, n);
346  cdlu = (index == -1) ? NULL : &ldata->layers[index];
347 
348  if (!cdlu) {
349  return false;
350  }
351 
352  delete_customdata_layer(me, cdlu);
353 
354  DEG_id_tag_update(&me->id, 0);
356 
357  return true;
358 }
360 {
361  /* texpoly/uv are assumed to be in sync */
362  CustomData *ldata = GET_CD_DATA(me, ldata);
363  const int n = CustomData_get_active_layer(ldata, CD_MLOOPUV);
364 
365  if (n != -1) {
366  return ED_mesh_uv_texture_remove_index(me, n);
367  }
368  return false;
369 }
370 bool ED_mesh_uv_texture_remove_named(Mesh *me, const char *name)
371 {
372  /* texpoly/uv are assumed to be in sync */
373  CustomData *ldata = GET_CD_DATA(me, ldata);
374  const int n = CustomData_get_named_layer(ldata, CD_MLOOPUV, name);
375  if (n != -1) {
376  return ED_mesh_uv_texture_remove_index(me, n);
377  }
378  return false;
379 }
380 
381 /* note: keep in sync with ED_mesh_uv_texture_add */
382 int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set, const bool do_init)
383 {
384  BMEditMesh *em;
385  int layernum;
386 
387  if (me->edit_mesh) {
388  em = me->edit_mesh;
389 
390  layernum = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPCOL);
391  if (layernum >= MAX_MCOL) {
392  return -1;
393  }
394 
395  /* CD_MLOOPCOL */
396  BM_data_layer_add_named(em->bm, &em->bm->ldata, CD_MLOOPCOL, name);
397  /* copy data from active vertex color layer */
398  if (layernum && do_init) {
399  const int layernum_dst = CustomData_get_active_layer(&em->bm->ldata, CD_MLOOPCOL);
400  BM_data_layer_copy(em->bm, &em->bm->ldata, CD_MLOOPCOL, layernum_dst, layernum);
401  }
402  if (active_set || layernum == 0) {
404  }
405  }
406  else {
408  if (layernum >= MAX_MCOL) {
409  return -1;
410  }
411 
412  if (me->mloopcol && do_init) {
414  &me->ldata, CD_MLOOPCOL, CD_DUPLICATE, me->mloopcol, me->totloop, name);
415  }
416  else {
418  }
419 
420  if (active_set || layernum == 0) {
422  }
423 
425  }
426 
427  DEG_id_tag_update(&me->id, 0);
429 
430  return layernum;
431 }
432 
433 bool ED_mesh_color_ensure(struct Mesh *me, const char *name)
434 {
435  BLI_assert(me->edit_mesh == NULL);
436 
437  if (!me->mloopcol && me->totloop) {
440  }
441 
442  DEG_id_tag_update(&me->id, 0);
443 
444  return (me->mloopcol != NULL);
445 }
446 
447 bool ED_mesh_color_remove_index(Mesh *me, const int n)
448 {
449  CustomData *ldata = GET_CD_DATA(me, ldata);
450  CustomDataLayer *cdl;
451  int index;
452 
453  index = CustomData_get_layer_index_n(ldata, CD_MLOOPCOL, n);
454  cdl = (index == -1) ? NULL : &ldata->layers[index];
455 
456  if (!cdl) {
457  return false;
458  }
459 
460  delete_customdata_layer(me, cdl);
461  DEG_id_tag_update(&me->id, 0);
463 
464  return true;
465 }
467 {
468  CustomData *ldata = GET_CD_DATA(me, ldata);
469  const int n = CustomData_get_active_layer(ldata, CD_MLOOPCOL);
470  if (n != -1) {
471  return ED_mesh_color_remove_index(me, n);
472  }
473  return false;
474 }
475 bool ED_mesh_color_remove_named(Mesh *me, const char *name)
476 {
477  CustomData *ldata = GET_CD_DATA(me, ldata);
478  const int n = CustomData_get_named_layer(ldata, CD_MLOOPCOL, name);
479  if (n != -1) {
480  return ED_mesh_color_remove_index(me, n);
481  }
482  return false;
483 }
484 
485 /*********************** Sculpt Vertex colors operators ************************/
486 
487 /* note: keep in sync with ED_mesh_uv_texture_add */
488 int ED_mesh_sculpt_color_add(Mesh *me, const char *name, const bool active_set, const bool do_init)
489 {
490  BMEditMesh *em;
491  int layernum;
492 
493  if (me->edit_mesh) {
494  em = me->edit_mesh;
495 
497  if (layernum >= MAX_MCOL) {
498  return -1;
499  }
500 
501  /* CD_PROP_COLOR */
502  BM_data_layer_add_named(em->bm, &em->bm->vdata, CD_PROP_COLOR, name);
503  /* copy data from active vertex color layer */
504  if (layernum && do_init) {
505  const int layernum_dst = CustomData_get_active_layer(&em->bm->vdata, CD_PROP_COLOR);
506  BM_data_layer_copy(em->bm, &em->bm->vdata, CD_PROP_COLOR, layernum_dst, layernum);
507  }
508  if (active_set || layernum == 0) {
510  }
511  }
512  else {
513  layernum = CustomData_number_of_layers(&me->vdata, CD_PROP_COLOR);
514  if (layernum >= MAX_MCOL) {
515  return -1;
516  }
517 
518  if (CustomData_has_layer(&me->vdata, CD_PROP_COLOR) && do_init) {
519  MPropCol *color_data = CustomData_get_layer(&me->vdata, CD_PROP_COLOR);
521  &me->vdata, CD_PROP_COLOR, CD_DUPLICATE, color_data, me->totvert, name);
522  }
523  else {
525  }
526 
527  if (active_set || layernum == 0) {
528  CustomData_set_layer_active(&me->vdata, CD_PROP_COLOR, layernum);
529  }
530 
532  }
533 
534  DEG_id_tag_update(&me->id, 0);
536 
537  return layernum;
538 }
539 
540 bool ED_mesh_sculpt_color_ensure(struct Mesh *me, const char *name)
541 {
542  BLI_assert(me->edit_mesh == NULL);
543 
544  if (me->totvert && !CustomData_has_layer(&me->vdata, CD_PROP_COLOR)) {
547  }
548 
549  DEG_id_tag_update(&me->id, 0);
550 
551  return (me->mloopcol != NULL);
552 }
553 
555 {
556  CustomData *vdata = GET_CD_DATA(me, vdata);
557  CustomDataLayer *cdl;
558  int index;
559 
560  index = CustomData_get_layer_index_n(vdata, CD_PROP_COLOR, n);
561  cdl = (index == -1) ? NULL : &vdata->layers[index];
562 
563  if (!cdl) {
564  return false;
565  }
566 
567  delete_customdata_layer(me, cdl);
568  DEG_id_tag_update(&me->id, 0);
570 
571  return true;
572 }
574 {
575  CustomData *vdata = GET_CD_DATA(me, vdata);
576  const int n = CustomData_get_active_layer(vdata, CD_PROP_COLOR);
577  if (n != -1) {
578  return ED_mesh_sculpt_color_remove_index(me, n);
579  }
580  return false;
581 }
582 bool ED_mesh_sculpt_color_remove_named(Mesh *me, const char *name)
583 {
584  CustomData *vdata = GET_CD_DATA(me, vdata);
585  const int n = CustomData_get_named_layer(vdata, CD_PROP_COLOR, name);
586  if (n != -1) {
587  return ED_mesh_sculpt_color_remove_index(me, n);
588  }
589  return false;
590 }
591 
592 /*********************** UV texture operators ************************/
593 
594 static bool layers_poll(bContext *C)
595 {
596  Object *ob = ED_object_context(C);
597  ID *data = (ob) ? ob->data : NULL;
598  return (ob && !ID_IS_LINKED(ob) && ob->type == OB_MESH && data && !ID_IS_LINKED(data));
599 }
600 
602 {
603  Object *ob = ED_object_context(C);
604  Mesh *me = ob->data;
605 
606  if (ED_mesh_uv_texture_add(me, NULL, true, true) == -1) {
607  return OPERATOR_CANCELLED;
608  }
609 
610  if (ob->mode & OB_MODE_TEXTURE_PAINT) {
614  }
615 
616  return OPERATOR_FINISHED;
617 }
618 
620 {
621  /* identifiers */
622  ot->name = "Add UV Map";
623  ot->description = "Add UV map";
624  ot->idname = "MESH_OT_uv_texture_add";
625 
626  /* api callbacks */
627  ot->poll = layers_poll;
629 
630  /* flags */
632 }
633 
635 {
636  Object *ob = ED_object_context(C);
637  Mesh *me = ob->data;
638 
640  return OPERATOR_CANCELLED;
641  }
642 
643  if (ob->mode & OB_MODE_TEXTURE_PAINT) {
647  }
648 
649  return OPERATOR_FINISHED;
650 }
651 
653 {
654  /* identifiers */
655  ot->name = "Remove UV Map";
656  ot->description = "Remove UV map";
657  ot->idname = "MESH_OT_uv_texture_remove";
658 
659  /* api callbacks */
660  ot->poll = layers_poll;
662 
663  /* flags */
665 }
666 
667 /*********************** vertex color operators ************************/
668 
670 {
671  Object *ob = ED_object_context(C);
672  Mesh *me = ob->data;
673 
674  if (ED_mesh_color_add(me, NULL, true, true) == -1) {
675  return OPERATOR_CANCELLED;
676  }
677 
678  return OPERATOR_FINISHED;
679 }
680 
682 {
683  /* identifiers */
684  ot->name = "Add Vertex Color";
685  ot->description = "Add vertex color layer";
686  ot->idname = "MESH_OT_vertex_color_add";
687 
688  /* api callbacks */
689  ot->poll = layers_poll;
691 
692  /* flags */
694 }
695 
697 {
698  Object *ob = ED_object_context(C);
699  Mesh *me = ob->data;
700 
701  if (!ED_mesh_color_remove_active(me)) {
702  return OPERATOR_CANCELLED;
703  }
704 
705  return OPERATOR_FINISHED;
706 }
707 
709 {
710  /* identifiers */
711  ot->name = "Remove Vertex Color";
712  ot->description = "Remove vertex color layer";
713  ot->idname = "MESH_OT_vertex_color_remove";
714 
715  /* api callbacks */
717  ot->poll = layers_poll;
718 
719  /* flags */
721 }
722 
723 /*********************** Sculpt Vertex Color Operators ************************/
724 
726 {
727  Object *ob = ED_object_context(C);
728  Mesh *me = ob->data;
729 
730  if (ED_mesh_sculpt_color_add(me, NULL, true, true) == -1) {
731  return OPERATOR_CANCELLED;
732  }
733 
734  return OPERATOR_FINISHED;
735 }
736 
738 {
739  /* identifiers */
740  ot->name = "Add Sculpt Vertex Color";
741  ot->description = "Add vertex color layer";
742  ot->idname = "MESH_OT_sculpt_vertex_color_add";
743 
744  /* api callbacks */
745  ot->poll = layers_poll;
747 
748  /* flags */
750 }
751 
753 {
754  Object *ob = ED_object_context(C);
755  Mesh *me = ob->data;
756 
758  return OPERATOR_CANCELLED;
759  }
760 
761  return OPERATOR_FINISHED;
762 }
763 
765 {
766  /* identifiers */
767  ot->name = "Remove Sculpt Vertex Color";
768  ot->description = "Remove vertex color layer";
769  ot->idname = "MESH_OT_sculpt_vertex_color_remove";
770 
771  /* api callbacks */
773  ot->poll = layers_poll;
774 
775  /* flags */
777 }
778 
779 /* *** CustomData clear functions, we need an operator for each *** */
780 
782 {
783  Mesh *me = ED_mesh_context(C);
784 
785  int tot;
786  CustomData *data = mesh_customdata_get_type(me, htype, &tot);
787 
789 
791  if (me->edit_mesh) {
793  }
794  else {
796  }
797 
798  DEG_id_tag_update(&me->id, 0);
800 
801  return OPERATOR_FINISHED;
802  }
803  return OPERATOR_CANCELLED;
804 }
805 
806 /* Clear Mask */
808 {
809  Object *ob = ED_object_context(C);
810  if (ob && ob->type == OB_MESH) {
811  Mesh *me = ob->data;
812 
813  /* special case - can't run this if we're in sculpt mode */
814  if (ob->mode & OB_MODE_SCULPT) {
815  return false;
816  }
817 
818  if (!ID_IS_LINKED(me)) {
819  CustomData *data = GET_CD_DATA(me, vdata);
821  return true;
822  }
823  data = GET_CD_DATA(me, ldata);
825  return true;
826  }
827  }
828  }
829  return false;
830 }
832 {
835 
836  if (ret_a == OPERATOR_FINISHED || ret_b == OPERATOR_FINISHED) {
837  return OPERATOR_FINISHED;
838  }
839  return OPERATOR_CANCELLED;
840 }
841 
843 {
844 
845  /* identifiers */
846  ot->name = "Clear Sculpt Mask Data";
847  ot->idname = "MESH_OT_customdata_mask_clear";
848  ot->description = "Clear vertex sculpt masking data from the mesh";
849 
850  /* api callbacks */
853 
854  /* flags */
856 }
857 
863 {
864  Object *ob = ED_object_context(C);
865 
866  if (ob && ob->type == OB_MESH) {
867  Mesh *me = ob->data;
868  if (!ID_IS_LINKED(me)) {
869  CustomData *data = GET_CD_DATA(me, vdata);
871  }
872  }
873  return -1;
874 }
875 
877 {
878  return (mesh_customdata_skin_state(C) == 0);
879 }
880 
882 {
883  Object *ob = ED_object_context(C);
884  Mesh *me = ob->data;
885 
887 
888  DEG_id_tag_update(&me->id, 0);
890 
891  return OPERATOR_FINISHED;
892 }
893 
895 {
896  /* identifiers */
897  ot->name = "Add Skin Data";
898  ot->idname = "MESH_OT_customdata_skin_add";
899  ot->description = "Add a vertex skin layer";
900 
901  /* api callbacks */
904 
905  /* flags */
907 }
908 
910 {
911  return (mesh_customdata_skin_state(C) == 1);
912 }
913 
915 {
917 }
918 
920 {
921  /* identifiers */
922  ot->name = "Clear Skin Data";
923  ot->idname = "MESH_OT_customdata_skin_clear";
924  ot->description = "Clear vertex skin layer";
925 
926  /* api callbacks */
929 
930  /* flags */
932 }
933 
934 /* Clear custom loop normals */
936 {
937  Mesh *me = ED_mesh_context(C);
938 
940  CustomData *data = GET_CD_DATA(me, ldata);
941 
942  if (me->edit_mesh) {
943  /* Tag edges as sharp according to smooth threshold if needed,
944  * to preserve autosmooth shading. */
945  if (me->flag & ME_AUTOSMOOTH) {
947  }
948 
950  }
951  else {
952  /* Tag edges as sharp according to smooth threshold if needed,
953  * to preserve autosmooth shading. */
954  if (me->flag & ME_AUTOSMOOTH) {
955  float(*polynors)[3] = MEM_mallocN(sizeof(*polynors) * (size_t)me->totpoly, __func__);
956 
958  NULL,
959  me->totvert,
960  me->mloop,
961  me->mpoly,
962  me->totloop,
963  me->totpoly,
964  polynors,
965  true);
966 
968  me->totvert,
969  me->medge,
970  me->totedge,
971  me->mloop,
972  me->totloop,
973  me->mpoly,
974  polynors,
975  me->totpoly,
976  me->smoothresh);
977 
978  MEM_freeN(polynors);
979  }
980 
982  }
983 
984  DEG_id_tag_update(&me->id, 0);
986 
987  return OPERATOR_FINISHED;
988  }
989  return OPERATOR_CANCELLED;
990 }
991 
993 {
994  /* identifiers */
995  ot->name = "Add Custom Split Normals Data";
996  ot->idname = "MESH_OT_customdata_custom_splitnormals_add";
997  ot->description = "Add a custom split normals layer, if none exists yet";
998 
999  /* api callbacks */
1002 
1003  /* flags */
1005 }
1006 
1008 {
1009  Mesh *me = ED_mesh_context(C);
1010 
1012  BMEditMesh *em = me->edit_mesh;
1013  if (em != NULL && em->bm->lnor_spacearr != NULL) {
1015  }
1017  }
1018  return OPERATOR_CANCELLED;
1019 }
1020 
1022 {
1023  /* identifiers */
1024  ot->name = "Clear Custom Split Normals Data";
1025  ot->idname = "MESH_OT_customdata_custom_splitnormals_clear";
1026  ot->description = "Remove the custom split normals layer, if it exists";
1027 
1028  /* api callbacks */
1031 
1032  /* flags */
1034 }
1035 
1036 /************************** Add Geometry Layers *************************/
1037 
1038 void ED_mesh_update(Mesh *mesh, bContext *C, bool calc_edges, bool calc_edges_loose)
1039 {
1040  if (calc_edges || ((mesh->totpoly || mesh->totface) && mesh->totedge == 0)) {
1041  BKE_mesh_calc_edges(mesh, calc_edges, true);
1042  }
1043 
1044  if (calc_edges_loose && mesh->totedge) {
1046  }
1047 
1048  /* Default state is not to have tessface's so make sure this is the case. */
1050 
1052 
1053  DEG_id_tag_update(&mesh->id, 0);
1055 }
1056 
1057 static void mesh_add_verts(Mesh *mesh, int len)
1058 {
1059  if (len == 0) {
1060  return;
1061  }
1062 
1063  int totvert = mesh->totvert + len;
1064  CustomData vdata;
1065  CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH.vmask, CD_DEFAULT, totvert);
1066  CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert);
1067 
1068  if (!CustomData_has_layer(&vdata, CD_MVERT)) {
1069  CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert);
1070  }
1071 
1072  CustomData_free(&mesh->vdata, mesh->totvert);
1073  mesh->vdata = vdata;
1075 
1076  /* scan the input list and insert the new vertices */
1077 
1078  /* set default flags */
1079  MVert *mvert = &mesh->mvert[mesh->totvert];
1080  for (int i = 0; i < len; i++, mvert++) {
1081  mvert->flag |= SELECT;
1082  }
1083 
1084  /* set final vertex list size */
1085  mesh->totvert = totvert;
1086 }
1087 
1088 static void mesh_add_edges(Mesh *mesh, int len)
1089 {
1090  CustomData edata;
1091  MEdge *medge;
1092  int i, totedge;
1093 
1094  if (len == 0) {
1095  return;
1096  }
1097 
1098  totedge = mesh->totedge + len;
1099 
1100  /* update customdata */
1101  CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge);
1102  CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
1103 
1104  if (!CustomData_has_layer(&edata, CD_MEDGE)) {
1105  CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
1106  }
1107 
1108  CustomData_free(&mesh->edata, mesh->totedge);
1109  mesh->edata = edata;
1110  BKE_mesh_update_customdata_pointers(mesh, false); /* new edges don't change tessellation */
1111 
1112  /* set default flags */
1113  medge = &mesh->medge[mesh->totedge];
1114  for (i = 0; i < len; i++, medge++) {
1115  medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT;
1116  }
1117 
1118  mesh->totedge = totedge;
1119 }
1120 
1121 static void mesh_add_loops(Mesh *mesh, int len)
1122 {
1123  CustomData ldata;
1124  int totloop;
1125 
1126  if (len == 0) {
1127  return;
1128  }
1129 
1130  totloop = mesh->totloop + len; /* new face count */
1131 
1132  /* update customdata */
1133  CustomData_copy(&mesh->ldata, &ldata, CD_MASK_MESH.lmask, CD_DEFAULT, totloop);
1134  CustomData_copy_data(&mesh->ldata, &ldata, 0, 0, mesh->totloop);
1135 
1136  if (!CustomData_has_layer(&ldata, CD_MLOOP)) {
1137  CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop);
1138  }
1139 
1141  mesh->ldata = ldata;
1143 
1144  mesh->totloop = totloop;
1145 }
1146 
1147 static void mesh_add_polys(Mesh *mesh, int len)
1148 {
1149  CustomData pdata;
1150  MPoly *mpoly;
1151  int i, totpoly;
1152 
1153  if (len == 0) {
1154  return;
1155  }
1156 
1157  totpoly = mesh->totpoly + len; /* new face count */
1158 
1159  /* update customdata */
1160  CustomData_copy(&mesh->pdata, &pdata, CD_MASK_MESH.pmask, CD_DEFAULT, totpoly);
1161  CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly);
1162 
1163  if (!CustomData_has_layer(&pdata, CD_MPOLY)) {
1164  CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, NULL, totpoly);
1165  }
1166 
1167  CustomData_free(&mesh->pdata, mesh->totpoly);
1168  mesh->pdata = pdata;
1170 
1171  /* set default flags */
1172  mpoly = &mesh->mpoly[mesh->totpoly];
1173  for (i = 0; i < len; i++, mpoly++) {
1174  mpoly->flag = ME_FACE_SEL;
1175  }
1176 
1177  mesh->totpoly = totpoly;
1178 }
1179 
1180 /* -------------------------------------------------------------------- */
1185 {
1186  if (mesh->edit_mesh) {
1187  BKE_report(reports, RPT_ERROR, "Cannot add vertices in edit mode");
1188  return;
1189  }
1191 }
1192 
1194 {
1195  if (mesh->edit_mesh) {
1196  BKE_report(reports, RPT_ERROR, "Cannot add edges in edit mode");
1197  return;
1198  }
1200 }
1201 
1203 {
1204  if (mesh->edit_mesh) {
1205  BKE_report(reports, RPT_ERROR, "Cannot add loops in edit mode");
1206  return;
1207  }
1209 }
1210 
1212 {
1213  if (mesh->edit_mesh) {
1214  BKE_report(reports, RPT_ERROR, "Cannot add polygons in edit mode");
1215  return;
1216  }
1218 }
1219 
1222 /* -------------------------------------------------------------------- */
1226 static void mesh_remove_verts(Mesh *mesh, int len)
1227 {
1228  if (len == 0) {
1229  return;
1230  }
1231  const int totvert = mesh->totvert - len;
1232  CustomData_free_elem(&mesh->vdata, totvert, len);
1233  mesh->totvert = totvert;
1234 }
1235 
1236 static void mesh_remove_edges(Mesh *mesh, int len)
1237 {
1238  if (len == 0) {
1239  return;
1240  }
1241  const int totedge = mesh->totedge - len;
1242  CustomData_free_elem(&mesh->edata, totedge, len);
1243  mesh->totedge = totedge;
1244 }
1245 
1246 static void mesh_remove_loops(Mesh *mesh, int len)
1247 {
1248  if (len == 0) {
1249  return;
1250  }
1251  const int totloop = mesh->totloop - len;
1252  CustomData_free_elem(&mesh->ldata, totloop, len);
1253  mesh->totloop = totloop;
1254 }
1255 
1256 static void mesh_remove_polys(Mesh *mesh, int len)
1257 {
1258  if (len == 0) {
1259  return;
1260  }
1261  const int totpoly = mesh->totpoly - len;
1262  CustomData_free_elem(&mesh->pdata, totpoly, len);
1263  mesh->totpoly = totpoly;
1264 }
1265 
1267 {
1268  if (mesh->edit_mesh) {
1269  BKE_report(reports, RPT_ERROR, "Cannot remove vertices in edit mode");
1270  return;
1271  }
1272  if (count > mesh->totvert) {
1273  BKE_report(reports, RPT_ERROR, "Cannot remove more vertices than the mesh contains");
1274  return;
1275  }
1276 
1278 }
1279 
1281 {
1282  if (mesh->edit_mesh) {
1283  BKE_report(reports, RPT_ERROR, "Cannot remove edges in edit mode");
1284  return;
1285  }
1286  if (count > mesh->totedge) {
1287  BKE_report(reports, RPT_ERROR, "Cannot remove more edges than the mesh contains");
1288  return;
1289  }
1290 
1292 }
1293 
1295 {
1296  if (mesh->edit_mesh) {
1297  BKE_report(reports, RPT_ERROR, "Cannot remove loops in edit mode");
1298  return;
1299  }
1300  if (count > mesh->totloop) {
1301  BKE_report(reports, RPT_ERROR, "Cannot remove more loops than the mesh contains");
1302  return;
1303  }
1304 
1306 }
1307 
1309 {
1310  if (mesh->edit_mesh) {
1311  BKE_report(reports, RPT_ERROR, "Cannot remove polys in edit mode");
1312  return;
1313  }
1314  if (count > mesh->totpoly) {
1315  BKE_report(reports, RPT_ERROR, "Cannot remove more polys than the mesh contains");
1316  return;
1317  }
1318 
1320 }
1321 
1323 {
1328 }
1329 
1332 void ED_mesh_report_mirror_ex(wmOperator *op, int totmirr, int totfail, char selectmode)
1333 {
1334  const char *elem_type;
1335 
1336  if (selectmode & SCE_SELECT_VERTEX) {
1337  elem_type = "vertices";
1338  }
1339  else if (selectmode & SCE_SELECT_EDGE) {
1340  elem_type = "edges";
1341  }
1342  else {
1343  elem_type = "faces";
1344  }
1345 
1346  if (totfail) {
1347  BKE_reportf(
1348  op->reports, RPT_WARNING, "%d %s mirrored, %d failed", totmirr, elem_type, totfail);
1349  }
1350  else {
1351  BKE_reportf(op->reports, RPT_INFO, "%d %s mirrored", totmirr, elem_type);
1352  }
1353 }
1354 
1355 void ED_mesh_report_mirror(wmOperator *op, int totmirr, int totfail)
1356 {
1357  ED_mesh_report_mirror_ex(op, totmirr, totfail, SCE_SELECT_VERTEX);
1358 }
1359 
1361 {
1363  if (mesh != NULL) {
1364  return mesh;
1365  }
1366 
1368  if (ob == NULL) {
1369  return NULL;
1370  }
1371 
1372  ID *data = (ID *)ob->data;
1373  if (data == NULL || GS(data->name) != ID_ME) {
1374  return NULL;
1375  }
1376 
1377  return (Mesh *)data;
1378 }
typedef float(TangentPoint)[2]
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:456
void CustomData_free(struct CustomData *data, int totelem)
Definition: customdata.c:2239
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.c:2655
void CustomData_set_layer_active(struct CustomData *data, int type, int n)
Definition: customdata.c:2401
@ CD_CALLOC
@ CD_DUPLICATE
@ CD_DEFAULT
void CustomData_free_layers(struct CustomData *data, int type, int totelem)
Definition: customdata.c:2716
bool CustomData_has_layer(const struct CustomData *data, int type)
bool CustomData_layertype_is_singleton(int type)
Definition: customdata.c:4292
int CustomData_get_layer_index_n(const struct CustomData *data, int type, int n)
Definition: customdata.c:2308
void * CustomData_add_layer_named(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem, const char *name)
Definition: customdata.c:2637
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)
Definition: customdata.c:2365
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
Definition: customdata.c:2620
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.c:3004
void CustomData_copy(const struct CustomData *source, struct CustomData *dest, CustomDataMask mask, eCDAllocType alloctype, int totelem)
Definition: customdata.c:2193
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.c:1933
void BKE_mesh_tessface_clear(struct Mesh *mesh)
Definition: mesh.c:1567
bool BKE_mesh_has_custom_loop_normals(struct Mesh *me)
Definition: mesh.c:786
void BKE_mesh_ensure_skin_customdata(struct Mesh *me)
Definition: mesh.c:681
void BKE_mesh_calc_edges_loose(struct Mesh *mesh)
void BKE_edges_sharp_from_angle_set(const struct MVert *mverts, const int numVerts, struct MEdge *medges, const int numEdges, struct MLoop *mloops, const int numLoops, struct MPoly *mpolys, const float(*polynors)[3], const int numPolys, const float split_angle)
void BKE_lnor_spacearr_clear(MLoopNorSpaceArray *lnors_spacearr)
void BKE_mesh_calc_normals(struct Mesh *me)
void BKE_mesh_update_customdata_pointers(struct Mesh *me, const bool do_ensure_tess_cd)
Definition: mesh.c:766
void BKE_mesh_calc_edges(struct Mesh *mesh, bool keep_existing_edges, const bool select_new_edges)
void BKE_mesh_calc_normals_poly(struct MVert *mverts, float(*r_vertnors)[3], int numVerts, const struct MLoop *mloop, const struct MPoly *mpolys, int numLoops, int numPolys, float(*r_polyNors)[3], const bool only_face_normals)
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#define BLI_array_alloca(arr, realsize)
Definition: BLI_alloca.h:36
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define M_PI
Definition: BLI_math_base.h:38
#define UNUSED(x)
#define ELEM(...)
void DEG_id_tag_update(struct ID *id, int flag)
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:426
@ ID_ME
Definition: DNA_ID_enums.h:60
#define MAX_MCOL
@ CD_PAINT_MASK
@ CD_MVERT_SKIN
@ CD_CUSTOMLOOPNORMAL
@ CD_PROP_COLOR
@ CD_MLOOPCOL
@ CD_GRID_PAINT_MASK
@ CD_MVERT
@ CD_MLOOPUV
#define MAX_MTFACE
@ ME_AUTOSMOOTH
@ ME_EDGEDRAW
@ ME_EDGERENDER
@ ME_FACE_SEL
@ 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:398
_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.
StructRNA RNA_Mesh
#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 NC_SCENE
Definition: WM_types.h:279
#define ND_TOOLSETTINGS
Definition: WM_types.h:349
@ 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:530
#define BM_elem_flag_test(ele, hflag)
Definition: bmesh_inline.h:26
void BM_data_layer_free_n(BMesh *bm, CustomData *data, int type, int n)
Definition: bmesh_interp.c:952
void BM_data_layer_free(BMesh *bm, CustomData *data, int type)
Definition: bmesh_interp.c:930
void BM_data_layer_copy(BMesh *bm, CustomData *data, int type, int src_n, int dst_n)
Definition: bmesh_interp.c:974
void BM_data_layer_add(BMesh *bm, CustomData *data, int type)
Definition: bmesh_interp.c:894
void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *name)
Definition: bmesh_interp.c:912
#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)
Definition: bmesh_mesh.c:1382
return(oflags[bm->toolflag_index].f &oflag) !=0
ATTR_WARN_UNUSED_RESULT const BMLoop * l
#define SELECT
Scene scene
int count
#define GS(x)
Definition: iris.c:241
#define sinf(x)
#define cosf(x)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
void MESH_OT_customdata_mask_clear(wmOperatorType *ot)
Definition: mesh_data.c:842
void ED_mesh_update(Mesh *mesh, bContext *C, bool calc_edges, bool calc_edges_loose)
Definition: mesh_data.c:1038
bool ED_mesh_sculpt_color_remove_active(Mesh *me)
Definition: mesh_data.c:573
static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.c:601
void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.c:1280
static bool layers_poll(bContext *C)
Definition: mesh_data.c:594
static void mesh_uv_reset_bmface(BMFace *f, const int cd_loop_uv_offset)
Definition: mesh_data.c:186
bool ED_mesh_uv_texture_remove_named(Mesh *me, const char *name)
Definition: mesh_data.c:370
static void mesh_remove_loops(Mesh *mesh, int len)
Definition: mesh_data.c:1246
bool ED_mesh_color_remove_index(Mesh *me, const int n)
Definition: mesh_data.c:447
void ED_mesh_report_mirror_ex(wmOperator *op, int totmirr, int totfail, char selectmode)
Definition: mesh_data.c:1332
static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.c:696
void MESH_OT_customdata_skin_add(wmOperatorType *ot)
Definition: mesh_data.c:894
bool ED_mesh_sculpt_color_remove_named(Mesh *me, const char *name)
Definition: mesh_data.c:582
bool ED_mesh_sculpt_color_remove_index(Mesh *me, const int n)
Definition: mesh_data.c:554
static int mesh_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.c:669
void MESH_OT_vertex_color_add(wmOperatorType *ot)
Definition: mesh_data.c:681
void MESH_OT_uv_texture_remove(wmOperatorType *ot)
Definition: mesh_data.c:652
static void mesh_uv_reset_mface(MPoly *mp, MLoopUV *mloopuv)
Definition: mesh_data.c:200
void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.c:1193
static void mesh_add_polys(Mesh *mesh, int len)
Definition: mesh_data.c:1147
void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.c:1202
static int mesh_customdata_custom_splitnormals_clear_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.c:1007
void ED_mesh_report_mirror(wmOperator *op, int totmirr, int totfail)
Definition: mesh_data.c:1355
void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum)
Definition: mesh_data.c:212
void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
Definition: mesh_data.c:246
#define GET_CD_DATA(me, data)
Definition: mesh_data.c:117
void ED_mesh_verts_add(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.c:1184
static int mesh_sculpt_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.c:725
void MESH_OT_customdata_skin_clear(wmOperatorType *ot)
Definition: mesh_data.c:919
static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.c:634
void ED_mesh_geometry_clear(Mesh *mesh)
Definition: mesh_data.c:1322
static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer)
Definition: mesh_data.c:118
static void mesh_add_edges(Mesh *mesh, int len)
Definition: mesh_data.c:1088
int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set, const bool do_init)
Definition: mesh_data.c:382
void ED_mesh_polys_remove(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.c:1308
void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name)
Definition: mesh_data.c:318
bool ED_mesh_uv_texture_remove_active(Mesh *me)
Definition: mesh_data.c:359
static bool mesh_customdata_skin_add_poll(bContext *C)
Definition: mesh_data.c:876
static CustomData * mesh_customdata_get_type(Mesh *me, const char htype, int *r_tot)
Definition: mesh_data.c:58
void ED_mesh_loops_remove(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.c:1294
void MESH_OT_vertex_color_remove(wmOperatorType *ot)
Definition: mesh_data.c:708
void MESH_OT_sculpt_vertex_color_remove(wmOperatorType *ot)
Definition: mesh_data.c:764
static int mesh_customdata_skin_add_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.c:881
static int mesh_customdata_skin_state(bContext *C)
Definition: mesh_data.c:862
bool ED_mesh_color_ensure(struct Mesh *me, const char *name)
Definition: mesh_data.c:433
bool ED_mesh_color_remove_named(Mesh *me, const char *name)
Definition: mesh_data.c:475
int ED_mesh_sculpt_color_add(Mesh *me, const char *name, const bool active_set, const bool do_init)
Definition: mesh_data.c:488
static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.c:935
Mesh * ED_mesh_context(struct bContext *C)
Definition: mesh_data.c:1360
void MESH_OT_sculpt_vertex_color_add(wmOperatorType *ot)
Definition: mesh_data.c:737
bool ED_mesh_uv_texture_remove_index(Mesh *me, const int n)
Definition: mesh_data.c:339
bool ED_mesh_sculpt_color_ensure(struct Mesh *me, const char *name)
Definition: mesh_data.c:540
static void mesh_remove_verts(Mesh *mesh, int len)
Definition: mesh_data.c:1226
static void mesh_add_verts(Mesh *mesh, int len)
Definition: mesh_data.c:1057
void MESH_OT_uv_texture_add(wmOperatorType *ot)
Definition: mesh_data.c:619
static void mesh_add_loops(Mesh *mesh, int len)
Definition: mesh_data.c:1121
static bool mesh_customdata_mask_clear_poll(bContext *C)
Definition: mesh_data.c:807
bool ED_mesh_color_remove_active(Mesh *me)
Definition: mesh_data.c:466
static void mesh_remove_edges(Mesh *mesh, int len)
Definition: mesh_data.c:1236
void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.c:1211
void MESH_OT_customdata_custom_splitnormals_add(wmOperatorType *ot)
Definition: mesh_data.c:992
int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set, const bool do_init)
Definition: mesh_data.c:257
static bool mesh_customdata_skin_clear_poll(bContext *C)
Definition: mesh_data.c:909
static void mesh_remove_polys(Mesh *mesh, int len)
Definition: mesh_data.c:1256
static int mesh_sculpt_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.c:752
void ED_mesh_verts_remove(Mesh *mesh, ReportList *reports, int count)
Definition: mesh_data.c:1266
static int mesh_customdata_clear_exec__internal(bContext *C, char htype, int type)
Definition: mesh_data.c:781
static void mesh_uv_reset_array(float **fuv, const int len)
Definition: mesh_data.c:146
static int mesh_customdata_mask_clear_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.c:831
void MESH_OT_customdata_custom_splitnormals_clear(wmOperatorType *ot)
Definition: mesh_data.c:1021
static int mesh_customdata_skin_clear_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mesh_data.c:914
struct BMesh * bm
Definition: BKE_editmesh.h:52
int len
Definition: bmesh_class.h:279
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:273
struct MEdge * medge
struct BMEditMesh * edit_mesh
float smoothresh
struct CustomData pdata ldata
struct MVert * mvert
struct MLoopCol * mloopcol
int totedge
struct MLoopUV * mloopuv
int totvert
short flag
struct MLoop * mloop
int totface
int totpoly
int totloop
struct MPoly * mpoly
void * data
void * data
Definition: RNA_types.h:52
const char * name
Definition: WM_types.h:721
const char * idname
Definition: WM_types.h:723
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
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
uint len
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:3156