Blender  V2.93
rna_mesh.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 
17 /* note: the original vertex color stuff is now just used for
18  * getting info on the layers themselves, accessing the data is
19  * done through the (not yet written) mpoly interfaces.*/
20 
25 #include <stdlib.h>
26 
27 #include "MEM_guardedalloc.h"
28 
29 #include "DNA_material_types.h"
30 #include "DNA_mesh_types.h"
31 #include "DNA_meshdata_types.h"
32 #include "DNA_object_types.h"
33 
34 #include "BLI_math_base.h"
35 #include "BLI_math_rotation.h"
36 #include "BLI_utildefines.h"
37 
38 #include "BKE_editmesh.h"
39 
40 #include "RNA_access.h"
41 #include "RNA_define.h"
42 #include "RNA_enum_types.h"
43 #include "RNA_types.h"
44 
45 #include "rna_internal.h"
46 
47 #include "WM_types.h"
48 
50  {BMO_DELIM_NORMAL, "NORMAL", 0, "Normal", "Delimit by face directions"},
51  {BMO_DELIM_MATERIAL, "MATERIAL", 0, "Material", "Delimit by face material"},
52  {BMO_DELIM_SEAM, "SEAM", 0, "Seam", "Delimit by edge seams"},
53  {BMO_DELIM_SHARP, "SHARP", 0, "Sharp", "Delimit by sharp edges"},
54  {BMO_DELIM_UV, "UV", 0, "UVs", "Delimit by UV coordinates"},
55  {0, NULL, 0, NULL, NULL},
56 };
57 
59  {REMESH_VOXEL, "VOXEL", 0, "Voxel", "Use the voxel remesher"},
60  {REMESH_QUAD, "QUAD", 0, "Quad", "Use the quad remesher"},
61  {0, NULL, 0, NULL, NULL},
62 };
63 
64 #ifdef RNA_RUNTIME
65 
66 # include "DNA_scene_types.h"
67 
68 # include "BLI_math.h"
69 
70 # include "BKE_customdata.h"
71 # include "BKE_main.h"
72 # include "BKE_mesh.h"
73 # include "BKE_mesh_runtime.h"
74 # include "BKE_report.h"
75 
76 # include "DEG_depsgraph.h"
77 
78 # include "ED_mesh.h" /* XXX Bad level call */
79 
80 # include "WM_api.h"
81 
82 # include "rna_mesh_utils.h"
83 
84 /* -------------------------------------------------------------------- */
85 /* Generic helpers */
86 
87 static Mesh *rna_mesh(PointerRNA *ptr)
88 {
89  Mesh *me = (Mesh *)ptr->owner_id;
90  return me;
91 }
92 
93 static CustomData *rna_mesh_vdata_helper(Mesh *me)
94 {
95  return (me->edit_mesh) ? &me->edit_mesh->bm->vdata : &me->vdata;
96 }
97 
98 static CustomData *rna_mesh_edata_helper(Mesh *me)
99 {
100  return (me->edit_mesh) ? &me->edit_mesh->bm->edata : &me->edata;
101 }
102 
103 static CustomData *rna_mesh_pdata_helper(Mesh *me)
104 {
105  return (me->edit_mesh) ? &me->edit_mesh->bm->pdata : &me->pdata;
106 }
107 
108 static CustomData *rna_mesh_ldata_helper(Mesh *me)
109 {
110  return (me->edit_mesh) ? &me->edit_mesh->bm->ldata : &me->ldata;
111 }
112 
113 static CustomData *rna_mesh_fdata_helper(Mesh *me)
114 {
115  return (me->edit_mesh) ? NULL : &me->fdata;
116 }
117 
118 static CustomData *rna_mesh_vdata(PointerRNA *ptr)
119 {
120  Mesh *me = rna_mesh(ptr);
121  return rna_mesh_vdata_helper(me);
122 }
123 # if 0
124 static CustomData *rna_mesh_edata(PointerRNA *ptr)
125 {
126  Mesh *me = rna_mesh(ptr);
127  return rna_mesh_edata_helper(me);
128 }
129 # endif
130 static CustomData *rna_mesh_pdata(PointerRNA *ptr)
131 {
132  Mesh *me = rna_mesh(ptr);
133  return rna_mesh_pdata_helper(me);
134 }
135 
136 static CustomData *rna_mesh_ldata(PointerRNA *ptr)
137 {
138  Mesh *me = rna_mesh(ptr);
139  return rna_mesh_ldata_helper(me);
140 }
141 
142 /* -------------------------------------------------------------------- */
143 /* Generic CustomData Layer Functions */
144 
145 static void rna_cd_layer_name_set(CustomData *cdata, CustomDataLayer *cdl, const char *value)
146 {
147  BLI_strncpy_utf8(cdl->name, value, sizeof(cdl->name));
148  CustomData_set_layer_unique_name(cdata, cdl - cdata->layers);
149 }
150 
151 /* avoid using where possible!, ideally the type is known */
152 static CustomData *rna_cd_from_layer(PointerRNA *ptr, CustomDataLayer *cdl)
153 {
154  /* find out where we come from by */
155  Mesh *me = (Mesh *)ptr->owner_id;
156  CustomData *cd;
157 
158  /* rely on negative values wrapping */
159 # define TEST_CDL(cmd) \
160  if ((void)(cd = cmd(me)), ARRAY_HAS_ITEM(cdl, cd->layers, cd->totlayer)) { \
161  return cd; \
162  } \
163  ((void)0)
164 
165  TEST_CDL(rna_mesh_vdata_helper);
166  TEST_CDL(rna_mesh_edata_helper);
167  TEST_CDL(rna_mesh_pdata_helper);
168  TEST_CDL(rna_mesh_ldata_helper);
169  TEST_CDL(rna_mesh_fdata_helper);
170 
171 # undef TEST_CDL
172 
173  /* should _never_ happen */
174  return NULL;
175 }
176 
177 static void rna_MeshVertexLayer_name_set(PointerRNA *ptr, const char *value)
178 {
179  rna_cd_layer_name_set(rna_mesh_vdata(ptr), (CustomDataLayer *)ptr->data, value);
180 }
181 # if 0
182 static void rna_MeshEdgeLayer_name_set(PointerRNA *ptr, const char *value)
183 {
184  rna_cd_layer_name_set(rna_mesh_edata(ptr), (CustomDataLayer *)ptr->data, value);
185 }
186 # endif
187 static void rna_MeshPolyLayer_name_set(PointerRNA *ptr, const char *value)
188 {
189  rna_cd_layer_name_set(rna_mesh_pdata(ptr), (CustomDataLayer *)ptr->data, value);
190 }
191 static void rna_MeshLoopLayer_name_set(PointerRNA *ptr, const char *value)
192 {
193  rna_cd_layer_name_set(rna_mesh_ldata(ptr), (CustomDataLayer *)ptr->data, value);
194 }
195 /* only for layers shared between types */
196 static void rna_MeshAnyLayer_name_set(PointerRNA *ptr, const char *value)
197 {
198  CustomData *cd = rna_cd_from_layer(ptr, (CustomDataLayer *)ptr->data);
199  rna_cd_layer_name_set(cd, (CustomDataLayer *)ptr->data, value);
200 }
201 
202 static bool rna_Mesh_has_custom_normals_get(PointerRNA *ptr)
203 {
204  Mesh *me = ptr->data;
206 }
207 
208 /* -------------------------------------------------------------------- */
209 /* Update Callbacks */
210 
211 static void rna_Mesh_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
212 {
213  ID *id = ptr->owner_id;
214 
215  /* cheating way for importers to avoid slow updates */
216  if (id->us > 0) {
217  DEG_id_tag_update(id, 0);
219  }
220 }
221 
222 static void rna_Mesh_update_data_edit_weight(Main *bmain, Scene *scene, PointerRNA *ptr)
223 {
225 
226  rna_Mesh_update_data(bmain, scene, ptr);
227 }
228 
229 static void rna_Mesh_update_data_edit_active_color(Main *bmain, Scene *scene, PointerRNA *ptr)
230 {
232 
233  rna_Mesh_update_data(bmain, scene, ptr);
234 }
235 static void rna_Mesh_update_select(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
236 {
237  ID *id = ptr->owner_id;
238  /* cheating way for importers to avoid slow updates */
239  if (id->us > 0) {
241  }
242 }
243 
245 {
246  ID *id = ptr->owner_id;
247  /* cheating way for importers to avoid slow updates */
248  if (id->us > 0) {
250  }
251 }
252 
253 static void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr)
254 {
255  Mesh *me = ptr->data;
258  }
259 
261 
262  rna_Mesh_update_draw(bmain, scene, ptr);
263 }
264 
265 static void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr)
266 {
267  Mesh *me = ptr->data;
270  }
271 
273 
274  rna_Mesh_update_draw(bmain, scene, ptr);
275 }
276 
277 /* -------------------------------------------------------------------- */
278 /* Property get/set Callbacks */
279 
280 static void rna_MeshVertex_normal_get(PointerRNA *ptr, float *value)
281 {
282  MVert *mvert = (MVert *)ptr->data;
283  normal_short_to_float_v3(value, mvert->no);
284 }
285 
286 static void rna_MeshVertex_normal_set(PointerRNA *ptr, const float *value)
287 {
288  MVert *mvert = (MVert *)ptr->data;
289  float no[3];
290 
291  copy_v3_v3(no, value);
292  normalize_v3(no);
293  normal_float_to_short_v3(mvert->no, no);
294 }
295 
296 static float rna_MeshVertex_bevel_weight_get(PointerRNA *ptr)
297 {
298  MVert *mvert = (MVert *)ptr->data;
299  return mvert->bweight / 255.0f;
300 }
301 
302 static void rna_MeshVertex_bevel_weight_set(PointerRNA *ptr, float value)
303 {
304  MVert *mvert = (MVert *)ptr->data;
305  mvert->bweight = round_fl_to_uchar_clamp(value * 255.0f);
306 }
307 
308 static float rna_MEdge_bevel_weight_get(PointerRNA *ptr)
309 {
310  MEdge *medge = (MEdge *)ptr->data;
311  return medge->bweight / 255.0f;
312 }
313 
314 static void rna_MEdge_bevel_weight_set(PointerRNA *ptr, float value)
315 {
316  MEdge *medge = (MEdge *)ptr->data;
317  medge->bweight = round_fl_to_uchar_clamp(value * 255.0f);
318 }
319 
320 static float rna_MEdge_crease_get(PointerRNA *ptr)
321 {
322  MEdge *medge = (MEdge *)ptr->data;
323  return medge->crease / 255.0f;
324 }
325 
326 static void rna_MEdge_crease_set(PointerRNA *ptr, float value)
327 {
328  MEdge *medge = (MEdge *)ptr->data;
329  medge->crease = round_fl_to_uchar_clamp(value * 255.0f);
330 }
331 
332 static void rna_MeshLoop_normal_get(PointerRNA *ptr, float *values)
333 {
334  Mesh *me = rna_mesh(ptr);
335  MLoop *ml = (MLoop *)ptr->data;
336  const float(*vec)[3] = CustomData_get(&me->ldata, (int)(ml - me->mloop), CD_NORMAL);
337 
338  if (!vec) {
339  zero_v3(values);
340  }
341  else {
342  copy_v3_v3(values, (const float *)vec);
343  }
344 }
345 
346 static void rna_MeshLoop_normal_set(PointerRNA *ptr, const float *values)
347 {
348  Mesh *me = rna_mesh(ptr);
349  MLoop *ml = (MLoop *)ptr->data;
350  float(*vec)[3] = CustomData_get(&me->ldata, (int)(ml - me->mloop), CD_NORMAL);
351 
352  if (vec) {
353  normalize_v3_v3(*vec, values);
354  }
355 }
356 
357 static void rna_MeshLoop_tangent_get(PointerRNA *ptr, float *values)
358 {
359  Mesh *me = rna_mesh(ptr);
360  MLoop *ml = (MLoop *)ptr->data;
361  const float(*vec)[4] = CustomData_get(&me->ldata, (int)(ml - me->mloop), CD_MLOOPTANGENT);
362 
363  if (!vec) {
364  zero_v3(values);
365  }
366  else {
367  copy_v3_v3(values, (const float *)vec);
368  }
369 }
370 
371 static float rna_MeshLoop_bitangent_sign_get(PointerRNA *ptr)
372 {
373  Mesh *me = rna_mesh(ptr);
374  MLoop *ml = (MLoop *)ptr->data;
375  const float(*vec)[4] = CustomData_get(&me->ldata, (int)(ml - me->mloop), CD_MLOOPTANGENT);
376 
377  return (vec) ? (*vec)[3] : 0.0f;
378 }
379 
380 static void rna_MeshLoop_bitangent_get(PointerRNA *ptr, float *values)
381 {
382  Mesh *me = rna_mesh(ptr);
383  MLoop *ml = (MLoop *)ptr->data;
384  const float(*nor)[3] = CustomData_get(&me->ldata, (int)(ml - me->mloop), CD_NORMAL);
385  const float(*vec)[4] = CustomData_get(&me->ldata, (int)(ml - me->mloop), CD_MLOOPTANGENT);
386 
387  if (nor && vec) {
388  cross_v3_v3v3(values, (const float *)nor, (const float *)vec);
389  mul_v3_fl(values, (*vec)[3]);
390  }
391  else {
392  zero_v3(values);
393  }
394 }
395 
396 static void rna_MeshPolygon_normal_get(PointerRNA *ptr, float *values)
397 {
398  Mesh *me = rna_mesh(ptr);
399  MPoly *mp = (MPoly *)ptr->data;
400 
401  BKE_mesh_calc_poly_normal(mp, me->mloop + mp->loopstart, me->mvert, values);
402 }
403 
404 static void rna_MeshPolygon_center_get(PointerRNA *ptr, float *values)
405 {
406  Mesh *me = rna_mesh(ptr);
407  MPoly *mp = (MPoly *)ptr->data;
408 
409  BKE_mesh_calc_poly_center(mp, me->mloop + mp->loopstart, me->mvert, values);
410 }
411 
412 static float rna_MeshPolygon_area_get(PointerRNA *ptr)
413 {
414  Mesh *me = (Mesh *)ptr->owner_id;
415  MPoly *mp = (MPoly *)ptr->data;
416 
417  return BKE_mesh_calc_poly_area(mp, me->mloop + mp->loopstart, me->mvert);
418 }
419 
420 static void rna_MeshPolygon_flip(ID *id, MPoly *mp)
421 {
422  Mesh *me = (Mesh *)id;
423 
424  BKE_mesh_polygon_flip(mp, me->mloop, &me->ldata);
427 }
428 
429 static void rna_MeshLoopTriangle_verts_get(PointerRNA *ptr, int *values)
430 {
431  Mesh *me = rna_mesh(ptr);
432  MLoopTri *lt = (MLoopTri *)ptr->data;
433  values[0] = me->mloop[lt->tri[0]].v;
434  values[1] = me->mloop[lt->tri[1]].v;
435  values[2] = me->mloop[lt->tri[2]].v;
436 }
437 
438 static void rna_MeshLoopTriangle_normal_get(PointerRNA *ptr, float *values)
439 {
440  Mesh *me = rna_mesh(ptr);
441  MLoopTri *lt = (MLoopTri *)ptr->data;
442  unsigned int v1 = me->mloop[lt->tri[0]].v;
443  unsigned int v2 = me->mloop[lt->tri[1]].v;
444  unsigned int v3 = me->mloop[lt->tri[2]].v;
445 
446  normal_tri_v3(values, me->mvert[v1].co, me->mvert[v2].co, me->mvert[v3].co);
447 }
448 
449 static void rna_MeshLoopTriangle_split_normals_get(PointerRNA *ptr, float *values)
450 {
451  Mesh *me = rna_mesh(ptr);
452  const float(*lnors)[3] = CustomData_get_layer(&me->ldata, CD_NORMAL);
453 
454  if (!lnors) {
455  zero_v3(values + 0);
456  zero_v3(values + 3);
457  zero_v3(values + 6);
458  }
459  else {
460  MLoopTri *lt = (MLoopTri *)ptr->data;
461  copy_v3_v3(values + 0, lnors[lt->tri[0]]);
462  copy_v3_v3(values + 3, lnors[lt->tri[1]]);
463  copy_v3_v3(values + 6, lnors[lt->tri[2]]);
464  }
465 }
466 
467 static float rna_MeshLoopTriangle_area_get(PointerRNA *ptr)
468 {
469  Mesh *me = rna_mesh(ptr);
470  MLoopTri *lt = (MLoopTri *)ptr->data;
471  unsigned int v1 = me->mloop[lt->tri[0]].v;
472  unsigned int v2 = me->mloop[lt->tri[1]].v;
473  unsigned int v3 = me->mloop[lt->tri[2]].v;
474 
475  return area_tri_v3(me->mvert[v1].co, me->mvert[v2].co, me->mvert[v3].co);
476 }
477 
478 static void rna_MeshLoopColor_color_get(PointerRNA *ptr, float *values)
479 {
480  MLoopCol *mlcol = (MLoopCol *)ptr->data;
481 
482  values[0] = mlcol->r / 255.0f;
483  values[1] = mlcol->g / 255.0f;
484  values[2] = mlcol->b / 255.0f;
485  values[3] = mlcol->a / 255.0f;
486 }
487 
488 static void rna_MeshLoopColor_color_set(PointerRNA *ptr, const float *values)
489 {
490  MLoopCol *mlcol = (MLoopCol *)ptr->data;
491 
492  mlcol->r = round_fl_to_uchar_clamp(values[0] * 255.0f);
493  mlcol->g = round_fl_to_uchar_clamp(values[1] * 255.0f);
494  mlcol->b = round_fl_to_uchar_clamp(values[2] * 255.0f);
495  mlcol->a = round_fl_to_uchar_clamp(values[3] * 255.0f);
496 }
497 
498 static int rna_Mesh_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_info))
499 {
500  Mesh *me = (Mesh *)ptr->data;
502 }
503 
504 static void rna_Mesh_texspace_size_get(PointerRNA *ptr, float values[3])
505 {
506  Mesh *me = (Mesh *)ptr->data;
507 
509 
510  copy_v3_v3(values, me->size);
511 }
512 
513 static void rna_Mesh_texspace_loc_get(PointerRNA *ptr, float values[3])
514 {
515  Mesh *me = (Mesh *)ptr->data;
516 
518 
519  copy_v3_v3(values, me->loc);
520 }
521 
522 static void rna_MeshVertex_groups_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
523 {
524  Mesh *me = rna_mesh(ptr);
525 
526  if (me->dvert) {
527  MVert *mvert = (MVert *)ptr->data;
528  MDeformVert *dvert = me->dvert + (mvert - me->mvert);
529 
531  iter, (void *)dvert->dw, sizeof(MDeformWeight), dvert->totweight, 0, NULL);
532  }
533  else {
534  rna_iterator_array_begin(iter, NULL, 0, 0, 0, NULL);
535  }
536 }
537 
538 static void rna_MeshVertex_undeformed_co_get(PointerRNA *ptr, float values[3])
539 {
540  Mesh *me = rna_mesh(ptr);
541  MVert *mvert = (MVert *)ptr->data;
542  float(*orco)[3] = CustomData_get_layer(&me->vdata, CD_ORCO);
543 
544  if (orco) {
545  /* orco is normalized to 0..1, we do inverse to match mvert->co */
546  float loc[3], size[3];
547 
548  BKE_mesh_texspace_get(me->texcomesh ? me->texcomesh : me, loc, size);
549  madd_v3_v3v3v3(values, loc, orco[(mvert - me->mvert)], size);
550  }
551  else {
552  copy_v3_v3(values, mvert->co);
553  }
554 }
555 
556 static int rna_CustomDataLayer_active_get(PointerRNA *ptr, CustomData *data, int type, bool render)
557 {
558  int n = ((CustomDataLayer *)ptr->data) - data->layers;
559 
560  if (render) {
562  }
563  else {
565  }
566 }
567 
568 static int rna_CustomDataLayer_clone_get(PointerRNA *ptr, CustomData *data, int type)
569 {
570  int n = ((CustomDataLayer *)ptr->data) - data->layers;
571 
573 }
574 
575 static void rna_CustomDataLayer_active_set(
576  PointerRNA *ptr, CustomData *data, int value, int type, int render)
577 {
578  Mesh *me = (Mesh *)ptr->owner_id;
579  int n = (((CustomDataLayer *)ptr->data) - data->layers) - CustomData_get_layer_index(data, type);
580 
581  if (value == 0) {
582  return;
583  }
584 
585  if (render) {
587  }
588  else {
590  }
591 
593 }
594 
595 static void rna_CustomDataLayer_clone_set(PointerRNA *ptr, CustomData *data, int value, int type)
596 {
597  int n = ((CustomDataLayer *)ptr->data) - data->layers;
598 
599  if (value == 0) {
600  return;
601  }
602 
604 }
605 
606 static bool rna_MEdge_freestyle_edge_mark_get(PointerRNA *ptr)
607 {
608  Mesh *me = rna_mesh(ptr);
609  MEdge *medge = (MEdge *)ptr->data;
610  FreestyleEdge *fed = CustomData_get(&me->edata, (int)(medge - me->medge), CD_FREESTYLE_EDGE);
611 
612  return fed && (fed->flag & FREESTYLE_EDGE_MARK) != 0;
613 }
614 
615 static void rna_MEdge_freestyle_edge_mark_set(PointerRNA *ptr, bool value)
616 {
617  Mesh *me = rna_mesh(ptr);
618  MEdge *medge = (MEdge *)ptr->data;
619  FreestyleEdge *fed = CustomData_get(&me->edata, (int)(medge - me->medge), CD_FREESTYLE_EDGE);
620 
621  if (!fed) {
622  fed = CustomData_add_layer(&me->edata, CD_FREESTYLE_EDGE, CD_CALLOC, NULL, me->totedge);
623  }
624  if (value) {
625  fed->flag |= FREESTYLE_EDGE_MARK;
626  }
627  else {
628  fed->flag &= ~FREESTYLE_EDGE_MARK;
629  }
630 }
631 
632 static bool rna_MPoly_freestyle_face_mark_get(PointerRNA *ptr)
633 {
634  Mesh *me = rna_mesh(ptr);
635  MPoly *mpoly = (MPoly *)ptr->data;
636  FreestyleFace *ffa = CustomData_get(&me->pdata, (int)(mpoly - me->mpoly), CD_FREESTYLE_FACE);
637 
638  return ffa && (ffa->flag & FREESTYLE_FACE_MARK) != 0;
639 }
640 
641 static void rna_MPoly_freestyle_face_mark_set(PointerRNA *ptr, int value)
642 {
643  Mesh *me = rna_mesh(ptr);
644  MPoly *mpoly = (MPoly *)ptr->data;
645  FreestyleFace *ffa = CustomData_get(&me->pdata, (int)(mpoly - me->mpoly), CD_FREESTYLE_FACE);
646 
647  if (!ffa) {
648  ffa = CustomData_add_layer(&me->pdata, CD_FREESTYLE_FACE, CD_CALLOC, NULL, me->totpoly);
649  }
650  if (value) {
651  ffa->flag |= FREESTYLE_FACE_MARK;
652  }
653  else {
654  ffa->flag &= ~FREESTYLE_FACE_MARK;
655  }
656 }
657 
658 /* uv_layers */
659 
661 DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(uv_layer, ldata, CD_MLOOPUV, active, MeshUVLoopLayer)
662 DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(uv_layer, ldata, CD_MLOOPUV, clone, MeshUVLoopLayer)
664  uv_layer, ldata, CD_MLOOPUV, stencil, MeshUVLoopLayer)
665 DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(uv_layer, ldata, CD_MLOOPUV, render, MeshUVLoopLayer)
666 
667 /* MeshUVLoopLayer */
668 
669 static char *rna_MeshUVLoopLayer_path(PointerRNA *ptr)
670 {
671  CustomDataLayer *cdl = ptr->data;
672  char name_esc[sizeof(cdl->name) * 2];
673  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
674  return BLI_sprintfN("uv_layers[\"%s\"]", name_esc);
675 }
676 
677 static void rna_MeshUVLoopLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
678 {
679  Mesh *me = rna_mesh(ptr);
682  iter, layer->data, sizeof(MLoopUV), (me->edit_mesh) ? 0 : me->totloop, 0, NULL);
683 }
684 
685 static int rna_MeshUVLoopLayer_data_length(PointerRNA *ptr)
686 {
687  Mesh *me = rna_mesh(ptr);
688  return (me->edit_mesh) ? 0 : me->totloop;
689 }
690 
691 static bool rna_MeshUVLoopLayer_active_render_get(PointerRNA *ptr)
692 {
693  return rna_CustomDataLayer_active_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPUV, 1);
694 }
695 
696 static bool rna_MeshUVLoopLayer_active_get(PointerRNA *ptr)
697 {
698  return rna_CustomDataLayer_active_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPUV, 0);
699 }
700 
701 static bool rna_MeshUVLoopLayer_clone_get(PointerRNA *ptr)
702 {
703  return rna_CustomDataLayer_clone_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPUV);
704 }
705 
706 static void rna_MeshUVLoopLayer_active_render_set(PointerRNA *ptr, bool value)
707 {
708  rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPUV, 1);
709 }
710 
711 static void rna_MeshUVLoopLayer_active_set(PointerRNA *ptr, bool value)
712 {
713  rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPUV, 0);
714 }
715 
716 static void rna_MeshUVLoopLayer_clone_set(PointerRNA *ptr, bool value)
717 {
718  rna_CustomDataLayer_clone_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPUV);
719 }
720 
721 /* vertex_color_layers */
722 
725  vertex_color, ldata, CD_MLOOPCOL, active, MeshLoopColorLayer)
726 
727 static void rna_MeshLoopColorLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
728 {
729  Mesh *me = rna_mesh(ptr);
732  iter, layer->data, sizeof(MLoopCol), (me->edit_mesh) ? 0 : me->totloop, 0, NULL);
733 }
734 
735 static int rna_MeshLoopColorLayer_data_length(PointerRNA *ptr)
736 {
737  Mesh *me = rna_mesh(ptr);
738  return (me->edit_mesh) ? 0 : me->totloop;
739 }
740 
741 static bool rna_MeshLoopColorLayer_active_render_get(PointerRNA *ptr)
742 {
743  return rna_CustomDataLayer_active_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPCOL, 1);
744 }
745 
746 static bool rna_MeshLoopColorLayer_active_get(PointerRNA *ptr)
747 {
748  return rna_CustomDataLayer_active_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPCOL, 0);
749 }
750 
751 static void rna_MeshLoopColorLayer_active_render_set(PointerRNA *ptr, bool value)
752 {
753  rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPCOL, 1);
754 }
755 
756 static void rna_MeshLoopColorLayer_active_set(PointerRNA *ptr, bool value)
757 {
758  rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPCOL, 0);
759 }
760 
761 /* sculpt_vertex_color_layers */
762 
763 DEFINE_CUSTOMDATA_LAYER_COLLECTION(sculpt_vertex_color, vdata, CD_PROP_COLOR)
765  sculpt_vertex_color, vdata, CD_PROP_COLOR, active, MeshVertColorLayer)
766 
767 static void rna_MeshVertColorLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
768 {
769  Mesh *me = rna_mesh(ptr);
772  iter, layer->data, sizeof(MPropCol), (me->edit_mesh) ? 0 : me->totvert, 0, NULL);
773 }
774 
775 static int rna_MeshVertColorLayer_data_length(PointerRNA *ptr)
776 {
777  Mesh *me = rna_mesh(ptr);
778  return (me->edit_mesh) ? 0 : me->totvert;
779 }
780 
781 static bool rna_MeshVertColorLayer_active_render_get(PointerRNA *ptr)
782 {
783  return rna_CustomDataLayer_active_get(ptr, rna_mesh_vdata(ptr), CD_PROP_COLOR, 1);
784 }
785 
786 static bool rna_MeshVertColorLayer_active_get(PointerRNA *ptr)
787 {
788  return rna_CustomDataLayer_active_get(ptr, rna_mesh_vdata(ptr), CD_PROP_COLOR, 0);
789 }
790 
791 static void rna_MeshVertColorLayer_active_render_set(PointerRNA *ptr, bool value)
792 {
793  rna_CustomDataLayer_active_set(ptr, rna_mesh_vdata(ptr), value, CD_PROP_COLOR, 1);
794 }
795 
796 static void rna_MeshVertColorLayer_active_set(PointerRNA *ptr, bool value)
797 {
798  rna_CustomDataLayer_active_set(ptr, rna_mesh_vdata(ptr), value, CD_PROP_COLOR, 0);
799 }
800 
801 static int rna_float_layer_check(CollectionPropertyIterator *UNUSED(iter), void *data)
802 {
804  return (layer->type != CD_PROP_FLOAT);
805 }
806 
807 static void rna_Mesh_vertex_float_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
808 {
809  CustomData *vdata = rna_mesh_vdata(ptr);
811  (void *)vdata->layers,
812  sizeof(CustomDataLayer),
813  vdata->totlayer,
814  0,
815  rna_float_layer_check);
816 }
817 static void rna_Mesh_polygon_float_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
818 {
819  CustomData *pdata = rna_mesh_pdata(ptr);
821  (void *)pdata->layers,
822  sizeof(CustomDataLayer),
823  pdata->totlayer,
824  0,
825  rna_float_layer_check);
826 }
827 
828 static int rna_Mesh_vertex_float_layers_length(PointerRNA *ptr)
829 {
830  return CustomData_number_of_layers(rna_mesh_vdata(ptr), CD_PROP_FLOAT);
831 }
832 static int rna_Mesh_polygon_float_layers_length(PointerRNA *ptr)
833 {
834  return CustomData_number_of_layers(rna_mesh_pdata(ptr), CD_PROP_FLOAT);
835 }
836 
837 static int rna_int_layer_check(CollectionPropertyIterator *UNUSED(iter), void *data)
838 {
840  return (layer->type != CD_PROP_INT32);
841 }
842 
843 static void rna_Mesh_vertex_int_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
844 {
845  CustomData *vdata = rna_mesh_vdata(ptr);
847  (void *)vdata->layers,
848  sizeof(CustomDataLayer),
849  vdata->totlayer,
850  0,
851  rna_int_layer_check);
852 }
853 static void rna_Mesh_polygon_int_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
854 {
855  CustomData *pdata = rna_mesh_pdata(ptr);
857  (void *)pdata->layers,
858  sizeof(CustomDataLayer),
859  pdata->totlayer,
860  0,
861  rna_int_layer_check);
862 }
863 
864 static int rna_Mesh_vertex_int_layers_length(PointerRNA *ptr)
865 {
866  return CustomData_number_of_layers(rna_mesh_vdata(ptr), CD_PROP_INT32);
867 }
868 static int rna_Mesh_polygon_int_layers_length(PointerRNA *ptr)
869 {
870  return CustomData_number_of_layers(rna_mesh_pdata(ptr), CD_PROP_INT32);
871 }
872 
873 static int rna_string_layer_check(CollectionPropertyIterator *UNUSED(iter), void *data)
874 {
876  return (layer->type != CD_PROP_STRING);
877 }
878 
879 static void rna_Mesh_vertex_string_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
880 {
881  CustomData *vdata = rna_mesh_vdata(ptr);
883  (void *)vdata->layers,
884  sizeof(CustomDataLayer),
885  vdata->totlayer,
886  0,
887  rna_string_layer_check);
888 }
889 static void rna_Mesh_polygon_string_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
890 {
891  CustomData *pdata = rna_mesh_pdata(ptr);
893  (void *)pdata->layers,
894  sizeof(CustomDataLayer),
895  pdata->totlayer,
896  0,
897  rna_string_layer_check);
898 }
899 
900 static int rna_Mesh_vertex_string_layers_length(PointerRNA *ptr)
901 {
902  return CustomData_number_of_layers(rna_mesh_vdata(ptr), CD_PROP_STRING);
903 }
904 static int rna_Mesh_polygon_string_layers_length(PointerRNA *ptr)
905 {
906  return CustomData_number_of_layers(rna_mesh_pdata(ptr), CD_PROP_STRING);
907 }
908 
909 /* Skin vertices */
911 
912 static char *rna_MeshSkinVertexLayer_path(PointerRNA *ptr)
913 {
914  CustomDataLayer *cdl = ptr->data;
915  char name_esc[sizeof(cdl->name) * 2];
916  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
917  return BLI_sprintfN("skin_vertices[\"%s\"]", name_esc);
918 }
919 
920 static char *rna_VertCustomData_data_path(PointerRNA *ptr, const char *collection, int type);
921 static char *rna_MeshSkinVertex_path(PointerRNA *ptr)
922 {
923  return rna_VertCustomData_data_path(ptr, "skin_vertices", CD_MVERT_SKIN);
924 }
925 
926 static void rna_MeshSkinVertexLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
927 {
928  Mesh *me = rna_mesh(ptr);
930  rna_iterator_array_begin(iter, layer->data, sizeof(MVertSkin), me->totvert, 0, NULL);
931 }
932 
933 static int rna_MeshSkinVertexLayer_data_length(PointerRNA *ptr)
934 {
935  Mesh *me = rna_mesh(ptr);
936  return me->totvert;
937 }
938 
939 /* End skin vertices */
940 
941 /* Paint mask */
942 DEFINE_CUSTOMDATA_LAYER_COLLECTION(vertex_paint_mask, vdata, CD_PAINT_MASK)
943 
944 static char *rna_MeshPaintMaskLayer_path(PointerRNA *ptr)
945 {
946  CustomDataLayer *cdl = ptr->data;
947  char name_esc[sizeof(cdl->name) * 2];
948  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
949  return BLI_sprintfN("vertex_paint_masks[\"%s\"]", name_esc);
950 }
951 
952 static char *rna_MeshPaintMask_path(PointerRNA *ptr)
953 {
954  return rna_VertCustomData_data_path(ptr, "vertex_paint_masks", CD_PAINT_MASK);
955 }
956 
957 static void rna_MeshPaintMaskLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
958 {
959  Mesh *me = rna_mesh(ptr);
962  iter, layer->data, sizeof(MFloatProperty), (me->edit_mesh) ? 0 : me->totvert, 0, NULL);
963 }
964 
965 static int rna_MeshPaintMaskLayer_data_length(PointerRNA *ptr)
966 {
967  Mesh *me = rna_mesh(ptr);
968  return (me->edit_mesh) ? 0 : me->totvert;
969 }
970 
971 /* End paint mask */
972 
973 /* Face maps */
974 
977  face_map, pdata, CD_FACEMAP, active, MeshFaceMapLayer)
978 
979 static char *rna_MeshFaceMapLayer_path(PointerRNA *ptr)
980 {
981  CustomDataLayer *cdl = ptr->data;
982  char name_esc[sizeof(cdl->name) * 2];
983  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
984  return BLI_sprintfN("face_maps[\"%s\"]", name_esc);
985 }
986 
987 static void rna_MeshFaceMapLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
988 {
989  Mesh *me = rna_mesh(ptr);
992  iter, layer->data, sizeof(int), (me->edit_mesh) ? 0 : me->totpoly, 0, NULL);
993 }
994 
995 static int rna_MeshFaceMapLayer_data_length(PointerRNA *ptr)
996 {
997  Mesh *me = rna_mesh(ptr);
998  return (me->edit_mesh) ? 0 : me->totpoly;
999 }
1000 
1001 static PointerRNA rna_Mesh_face_map_new(struct Mesh *me, ReportList *reports, const char *name)
1002 {
1003  if (BKE_mesh_ensure_facemap_customdata(me) == false) {
1004  BKE_report(reports, RPT_ERROR, "Currently only single face map layers are supported");
1005  return PointerRNA_NULL;
1006  }
1007 
1008  CustomData *pdata = rna_mesh_pdata_helper(me);
1009 
1010  int index = CustomData_get_layer_index(pdata, CD_FACEMAP);
1011  BLI_assert(index != -1);
1012  CustomDataLayer *cdl = &pdata->layers[index];
1013  rna_cd_layer_name_set(pdata, cdl, name);
1014 
1015  PointerRNA ptr;
1016  RNA_pointer_create(&me->id, &RNA_MeshFaceMapLayer, cdl, &ptr);
1017  return ptr;
1018 }
1019 
1020 static void rna_Mesh_face_map_remove(struct Mesh *me,
1021  ReportList *reports,
1022  struct CustomDataLayer *layer)
1023 {
1024  /* just for sanity check */
1025  {
1026  CustomData *pdata = rna_mesh_pdata_helper(me);
1027  int index = CustomData_get_layer_index(pdata, CD_FACEMAP);
1028  if (index != -1) {
1029  CustomDataLayer *layer_test = &pdata->layers[index];
1030  if (layer != layer_test) {
1031  /* don't show name, its likely freed memory */
1032  BKE_report(reports, RPT_ERROR, "Face map not in mesh");
1033  return;
1034  }
1035  }
1036  }
1037 
1038  if (BKE_mesh_clear_facemap_customdata(me) == false) {
1039  BKE_report(reports, RPT_ERROR, "Error removing face map");
1040  }
1041 }
1042 
1043 /* End face maps */
1044 
1045 /* poly.vertices - this is faked loop access for convenience */
1046 static int rna_MeshPoly_vertices_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
1047 {
1048  MPoly *mp = (MPoly *)ptr->data;
1049  /* note, raw access uses dummy item, this _could_ crash,
1050  * watch out for this, mface uses it but it cant work here. */
1051  return (length[0] = mp->totloop);
1052 }
1053 
1054 static void rna_MeshPoly_vertices_get(PointerRNA *ptr, int *values)
1055 {
1056  Mesh *me = rna_mesh(ptr);
1057  MPoly *mp = (MPoly *)ptr->data;
1058  MLoop *ml = &me->mloop[mp->loopstart];
1059  unsigned int i;
1060  for (i = mp->totloop; i > 0; i--, values++, ml++) {
1061  *values = ml->v;
1062  }
1063 }
1064 
1065 static void rna_MeshPoly_vertices_set(PointerRNA *ptr, const int *values)
1066 {
1067  Mesh *me = rna_mesh(ptr);
1068  MPoly *mp = (MPoly *)ptr->data;
1069  MLoop *ml = &me->mloop[mp->loopstart];
1070  unsigned int i;
1071  for (i = mp->totloop; i > 0; i--, values++, ml++) {
1072  ml->v = *values;
1073  }
1074 }
1075 
1076 /* disabling, some importers don't know the total material count when assigning materials */
1077 # if 0
1078 static void rna_MeshPoly_material_index_range(
1079  PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
1080 {
1081  Mesh *me = rna_mesh(ptr);
1082  *min = 0;
1083  *max = max_ii(0, me->totcol - 1);
1084 }
1085 # endif
1086 
1087 static int rna_MeshVertex_index_get(PointerRNA *ptr)
1088 {
1089  Mesh *me = rna_mesh(ptr);
1090  MVert *vert = (MVert *)ptr->data;
1091  return (int)(vert - me->mvert);
1092 }
1093 
1094 static int rna_MeshEdge_index_get(PointerRNA *ptr)
1095 {
1096  Mesh *me = rna_mesh(ptr);
1097  MEdge *edge = (MEdge *)ptr->data;
1098  return (int)(edge - me->medge);
1099 }
1100 
1101 static int rna_MeshLoopTriangle_index_get(PointerRNA *ptr)
1102 {
1103  Mesh *me = rna_mesh(ptr);
1104  MLoopTri *ltri = (MLoopTri *)ptr->data;
1105  return (int)(ltri - me->runtime.looptris.array);
1106 }
1107 
1108 static int rna_MeshLoopTriangle_material_index_get(PointerRNA *ptr)
1109 {
1110  Mesh *me = rna_mesh(ptr);
1111  MLoopTri *ltri = (MLoopTri *)ptr->data;
1112  return me->mpoly[ltri->poly].mat_nr;
1113 }
1114 
1115 static bool rna_MeshLoopTriangle_use_smooth_get(PointerRNA *ptr)
1116 {
1117  Mesh *me = rna_mesh(ptr);
1118  MLoopTri *ltri = (MLoopTri *)ptr->data;
1119  return me->mpoly[ltri->poly].flag & ME_SMOOTH;
1120 }
1121 
1122 static int rna_MeshPolygon_index_get(PointerRNA *ptr)
1123 {
1124  Mesh *me = rna_mesh(ptr);
1125  MPoly *mpoly = (MPoly *)ptr->data;
1126  return (int)(mpoly - me->mpoly);
1127 }
1128 
1129 static int rna_MeshLoop_index_get(PointerRNA *ptr)
1130 {
1131  Mesh *me = rna_mesh(ptr);
1132  MLoop *mloop = (MLoop *)ptr->data;
1133  return (int)(mloop - me->mloop);
1134 }
1135 
1136 /* path construction */
1137 
1138 static char *rna_VertexGroupElement_path(PointerRNA *ptr)
1139 {
1140  Mesh *me = rna_mesh(ptr); /* XXX not always! */
1141  MDeformWeight *dw = (MDeformWeight *)ptr->data;
1142  MDeformVert *dvert;
1143  int a, b;
1144 
1145  for (a = 0, dvert = me->dvert; a < me->totvert; a++, dvert++) {
1146  for (b = 0; b < dvert->totweight; b++) {
1147  if (dw == &dvert->dw[b]) {
1148  return BLI_sprintfN("vertices[%d].groups[%d]", a, b);
1149  }
1150  }
1151  }
1152 
1153  return NULL;
1154 }
1155 
1156 static char *rna_MeshPolygon_path(PointerRNA *ptr)
1157 {
1158  return BLI_sprintfN("polygons[%d]", (int)((MPoly *)ptr->data - rna_mesh(ptr)->mpoly));
1159 }
1160 
1161 static char *rna_MeshLoopTriangle_path(PointerRNA *ptr)
1162 {
1163  return BLI_sprintfN("loop_triangles[%d]",
1164  (int)((MLoopTri *)ptr->data - rna_mesh(ptr)->runtime.looptris.array));
1165 }
1166 
1167 static char *rna_MeshEdge_path(PointerRNA *ptr)
1168 {
1169  return BLI_sprintfN("edges[%d]", (int)((MEdge *)ptr->data - rna_mesh(ptr)->medge));
1170 }
1171 
1172 static char *rna_MeshLoop_path(PointerRNA *ptr)
1173 {
1174  return BLI_sprintfN("loops[%d]", (int)((MLoop *)ptr->data - rna_mesh(ptr)->mloop));
1175 }
1176 
1177 static char *rna_MeshVertex_path(PointerRNA *ptr)
1178 {
1179  return BLI_sprintfN("vertices[%d]", (int)((MVert *)ptr->data - rna_mesh(ptr)->mvert));
1180 }
1181 
1182 static char *rna_VertCustomData_data_path(PointerRNA *ptr, const char *collection, int type)
1183 {
1184  CustomDataLayer *cdl;
1185  Mesh *me = rna_mesh(ptr);
1186  CustomData *vdata = rna_mesh_vdata(ptr);
1187  int a, b, totvert = (me->edit_mesh) ? 0 : me->totvert;
1188 
1189  for (cdl = vdata->layers, a = 0; a < vdata->totlayer; cdl++, a++) {
1190  if (cdl->type == type) {
1191  b = ((char *)ptr->data - ((char *)cdl->data)) / CustomData_sizeof(type);
1192  if (b >= 0 && b < totvert) {
1193  char name_esc[sizeof(cdl->name) * 2];
1194  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
1195  return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, name_esc, b);
1196  }
1197  }
1198  }
1199 
1200  return NULL;
1201 }
1202 
1203 static char *rna_PolyCustomData_data_path(PointerRNA *ptr, const char *collection, int type)
1204 {
1205  CustomDataLayer *cdl;
1206  Mesh *me = rna_mesh(ptr);
1207  CustomData *pdata = rna_mesh_pdata(ptr);
1208  int a, b, totpoly = (me->edit_mesh) ? 0 : me->totpoly;
1209 
1210  for (cdl = pdata->layers, a = 0; a < pdata->totlayer; cdl++, a++) {
1211  if (cdl->type == type) {
1212  b = ((char *)ptr->data - ((char *)cdl->data)) / CustomData_sizeof(type);
1213  if (b >= 0 && b < totpoly) {
1214  char name_esc[sizeof(cdl->name) * 2];
1215  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
1216  return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, name_esc, b);
1217  }
1218  }
1219  }
1220 
1221  return NULL;
1222 }
1223 
1224 static char *rna_LoopCustomData_data_path(PointerRNA *ptr, const char *collection, int type)
1225 {
1226  CustomDataLayer *cdl;
1227  Mesh *me = rna_mesh(ptr);
1228  CustomData *ldata = rna_mesh_ldata(ptr);
1229  int a, b, totloop = (me->edit_mesh) ? 0 : me->totloop;
1230 
1231  for (cdl = ldata->layers, a = 0; a < ldata->totlayer; cdl++, a++) {
1232  if (cdl->type == type) {
1233  b = ((char *)ptr->data - ((char *)cdl->data)) / CustomData_sizeof(type);
1234  if (b >= 0 && b < totloop) {
1235  char name_esc[sizeof(cdl->name) * 2];
1236  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
1237  return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, name_esc, b);
1238  }
1239  }
1240  }
1241 
1242  return NULL;
1243 }
1244 
1245 static char *rna_MeshUVLoop_path(PointerRNA *ptr)
1246 {
1247  return rna_LoopCustomData_data_path(ptr, "uv_layers", CD_MLOOPUV);
1248 }
1249 
1250 static char *rna_MeshLoopColorLayer_path(PointerRNA *ptr)
1251 {
1252  CustomDataLayer *cdl = ptr->data;
1253  char name_esc[sizeof(cdl->name) * 2];
1254  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
1255  return BLI_sprintfN("vertex_colors[\"%s\"]", name_esc);
1256 }
1257 
1258 static char *rna_MeshColor_path(PointerRNA *ptr)
1259 {
1260  return rna_LoopCustomData_data_path(ptr, "vertex_colors", CD_MLOOPCOL);
1261 }
1262 
1263 static char *rna_MeshVertColorLayer_path(PointerRNA *ptr)
1264 {
1265  CustomDataLayer *cdl = ptr->data;
1266  char name_esc[sizeof(cdl->name) * 2];
1267  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
1268  return BLI_sprintfN("sculpt_vertex_colors[\"%s\"]", name_esc);
1269 }
1270 
1271 static char *rna_MeshVertColor_path(PointerRNA *ptr)
1272 {
1273  return rna_VertCustomData_data_path(ptr, "sculpt_vertex_colors", CD_PROP_COLOR);
1274 }
1275 
1276 /**** Float Property Layer API ****/
1277 static char *rna_MeshVertexFloatPropertyLayer_path(PointerRNA *ptr)
1278 {
1279  CustomDataLayer *cdl = ptr->data;
1280  char name_esc[sizeof(cdl->name) * 2];
1281  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
1282  return BLI_sprintfN("vertex_float_layers[\"%s\"]", name_esc);
1283 }
1284 static char *rna_MeshPolygonFloatPropertyLayer_path(PointerRNA *ptr)
1285 {
1286  CustomDataLayer *cdl = ptr->data;
1287  char name_esc[sizeof(cdl->name) * 2];
1288  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
1289  return BLI_sprintfN("polygon_float_layers[\"%s\"]", name_esc);
1290 }
1291 
1292 static char *rna_MeshVertexFloatProperty_path(PointerRNA *ptr)
1293 {
1294  return rna_VertCustomData_data_path(ptr, "vertex_layers_float", CD_PROP_FLOAT);
1295 }
1296 static char *rna_MeshPolygonFloatProperty_path(PointerRNA *ptr)
1297 {
1298  return rna_PolyCustomData_data_path(ptr, "polygon_layers_float", CD_PROP_FLOAT);
1299 }
1300 
1301 static void rna_MeshVertexFloatPropertyLayer_data_begin(CollectionPropertyIterator *iter,
1302  PointerRNA *ptr)
1303 {
1304  Mesh *me = rna_mesh(ptr);
1305  CustomDataLayer *layer = (CustomDataLayer *)ptr->data;
1306  rna_iterator_array_begin(iter, layer->data, sizeof(MFloatProperty), me->totvert, 0, NULL);
1307 }
1308 static void rna_MeshPolygonFloatPropertyLayer_data_begin(CollectionPropertyIterator *iter,
1309  PointerRNA *ptr)
1310 {
1311  Mesh *me = rna_mesh(ptr);
1312  CustomDataLayer *layer = (CustomDataLayer *)ptr->data;
1313  rna_iterator_array_begin(iter, layer->data, sizeof(MFloatProperty), me->totpoly, 0, NULL);
1314 }
1315 
1316 static int rna_MeshVertexFloatPropertyLayer_data_length(PointerRNA *ptr)
1317 {
1318  Mesh *me = rna_mesh(ptr);
1319  return me->totvert;
1320 }
1321 static int rna_MeshPolygonFloatPropertyLayer_data_length(PointerRNA *ptr)
1322 {
1323  Mesh *me = rna_mesh(ptr);
1324  return me->totpoly;
1325 }
1326 
1327 /**** Int Property Layer API ****/
1328 static char *rna_MeshVertexIntPropertyLayer_path(PointerRNA *ptr)
1329 {
1330  CustomDataLayer *cdl = ptr->data;
1331  char name_esc[sizeof(cdl->name) * 2];
1332  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
1333  return BLI_sprintfN("vertex_int_layers[\"%s\"]", name_esc);
1334 }
1335 static char *rna_MeshPolygonIntPropertyLayer_path(PointerRNA *ptr)
1336 {
1337  CustomDataLayer *cdl = ptr->data;
1338  char name_esc[sizeof(cdl->name) * 2];
1339  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
1340  return BLI_sprintfN("polygon_int_layers[\"%s\"]", name_esc);
1341 }
1342 
1343 static char *rna_MeshVertexIntProperty_path(PointerRNA *ptr)
1344 {
1345  return rna_VertCustomData_data_path(ptr, "vertex_layers_int", CD_PROP_INT32);
1346 }
1347 static char *rna_MeshPolygonIntProperty_path(PointerRNA *ptr)
1348 {
1349  return rna_PolyCustomData_data_path(ptr, "polygon_layers_int", CD_PROP_INT32);
1350 }
1351 
1352 static void rna_MeshVertexIntPropertyLayer_data_begin(CollectionPropertyIterator *iter,
1353  PointerRNA *ptr)
1354 {
1355  Mesh *me = rna_mesh(ptr);
1356  CustomDataLayer *layer = (CustomDataLayer *)ptr->data;
1357  rna_iterator_array_begin(iter, layer->data, sizeof(MIntProperty), me->totvert, 0, NULL);
1358 }
1359 static void rna_MeshPolygonIntPropertyLayer_data_begin(CollectionPropertyIterator *iter,
1360  PointerRNA *ptr)
1361 {
1362  Mesh *me = rna_mesh(ptr);
1363  CustomDataLayer *layer = (CustomDataLayer *)ptr->data;
1364  rna_iterator_array_begin(iter, layer->data, sizeof(MIntProperty), me->totpoly, 0, NULL);
1365 }
1366 
1367 static int rna_MeshVertexIntPropertyLayer_data_length(PointerRNA *ptr)
1368 {
1369  Mesh *me = rna_mesh(ptr);
1370  return me->totvert;
1371 }
1372 static int rna_MeshPolygonIntPropertyLayer_data_length(PointerRNA *ptr)
1373 {
1374  Mesh *me = rna_mesh(ptr);
1375  return me->totpoly;
1376 }
1377 
1378 /**** String Property Layer API ****/
1379 static char *rna_MeshVertexStringPropertyLayer_path(PointerRNA *ptr)
1380 {
1381  CustomDataLayer *cdl = ptr->data;
1382  char name_esc[sizeof(cdl->name) * 2];
1383  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
1384  return BLI_sprintfN("vertex_string_layers[\"%s\"]", name_esc);
1385 }
1386 static char *rna_MeshPolygonStringPropertyLayer_path(PointerRNA *ptr)
1387 {
1388  CustomDataLayer *cdl = ptr->data;
1389  char name_esc[sizeof(cdl->name) * 2];
1390  BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
1391  return BLI_sprintfN("polygon_string_layers[\"%s\"]", name_esc);
1392 }
1393 
1394 static char *rna_MeshVertexStringProperty_path(PointerRNA *ptr)
1395 {
1396  return rna_VertCustomData_data_path(ptr, "vertex_layers_string", CD_PROP_STRING);
1397 }
1398 static char *rna_MeshPolygonStringProperty_path(PointerRNA *ptr)
1399 {
1400  return rna_PolyCustomData_data_path(ptr, "polygon_layers_string", CD_PROP_STRING);
1401 }
1402 
1403 static void rna_MeshVertexStringPropertyLayer_data_begin(CollectionPropertyIterator *iter,
1404  PointerRNA *ptr)
1405 {
1406  Mesh *me = rna_mesh(ptr);
1407  CustomDataLayer *layer = (CustomDataLayer *)ptr->data;
1408  rna_iterator_array_begin(iter, layer->data, sizeof(MStringProperty), me->totvert, 0, NULL);
1409 }
1410 static void rna_MeshPolygonStringPropertyLayer_data_begin(CollectionPropertyIterator *iter,
1411  PointerRNA *ptr)
1412 {
1413  Mesh *me = rna_mesh(ptr);
1414  CustomDataLayer *layer = (CustomDataLayer *)ptr->data;
1415  rna_iterator_array_begin(iter, layer->data, sizeof(MStringProperty), me->totpoly, 0, NULL);
1416 }
1417 
1418 static int rna_MeshVertexStringPropertyLayer_data_length(PointerRNA *ptr)
1419 {
1420  Mesh *me = rna_mesh(ptr);
1421  return me->totvert;
1422 }
1423 static int rna_MeshPolygonStringPropertyLayer_data_length(PointerRNA *ptr)
1424 {
1425  Mesh *me = rna_mesh(ptr);
1426  return me->totpoly;
1427 }
1428 
1429 /* XXX, we don't have proper byte string support yet, so for now use the (bytes + 1)
1430  * bmesh API exposes correct python/byte-string access. */
1431 void rna_MeshStringProperty_s_get(PointerRNA *ptr, char *value)
1432 {
1434  BLI_strncpy(value, ms->s, (int)ms->s_len + 1);
1435 }
1436 
1437 int rna_MeshStringProperty_s_length(PointerRNA *ptr)
1438 {
1440  return (int)ms->s_len + 1;
1441 }
1442 
1443 void rna_MeshStringProperty_s_set(PointerRNA *ptr, const char *value)
1444 {
1446  BLI_strncpy(ms->s, value, sizeof(ms->s));
1447 }
1448 
1449 static char *rna_MeshFaceMap_path(PointerRNA *ptr)
1450 {
1451  return rna_PolyCustomData_data_path(ptr, "face_maps", CD_FACEMAP);
1452 }
1453 
1454 /***************************************/
1455 
1456 static int rna_Mesh_tot_vert_get(PointerRNA *ptr)
1457 {
1458  Mesh *me = rna_mesh(ptr);
1459  return me->edit_mesh ? me->edit_mesh->bm->totvertsel : 0;
1460 }
1461 static int rna_Mesh_tot_edge_get(PointerRNA *ptr)
1462 {
1463  Mesh *me = rna_mesh(ptr);
1464  return me->edit_mesh ? me->edit_mesh->bm->totedgesel : 0;
1465 }
1466 static int rna_Mesh_tot_face_get(PointerRNA *ptr)
1467 {
1468  Mesh *me = rna_mesh(ptr);
1469  return me->edit_mesh ? me->edit_mesh->bm->totfacesel : 0;
1470 }
1471 
1472 static PointerRNA rna_Mesh_vertex_color_new(struct Mesh *me, const char *name, const bool do_init)
1473 {
1474  PointerRNA ptr;
1475  CustomData *ldata;
1476  CustomDataLayer *cdl = NULL;
1477  int index = ED_mesh_color_add(me, name, false, do_init);
1478 
1479  if (index != -1) {
1480  ldata = rna_mesh_ldata_helper(me);
1481  cdl = &ldata->layers[CustomData_get_layer_index_n(ldata, CD_MLOOPCOL, index)];
1482  }
1483 
1485  return ptr;
1486 }
1487 
1488 static void rna_Mesh_vertex_color_remove(struct Mesh *me,
1489  ReportList *reports,
1490  CustomDataLayer *layer)
1491 {
1492  if (ED_mesh_color_remove_named(me, layer->name) == false) {
1493  BKE_reportf(reports, RPT_ERROR, "Vertex color '%s' not found", layer->name);
1494  }
1495 }
1496 
1497 static PointerRNA rna_Mesh_sculpt_vertex_color_new(struct Mesh *me,
1498  const char *name,
1499  const bool do_init)
1500 {
1501  PointerRNA ptr;
1502  CustomData *vdata;
1503  CustomDataLayer *cdl = NULL;
1504  int index = ED_mesh_sculpt_color_add(me, name, false, do_init);
1505 
1506  if (index != -1) {
1507  vdata = rna_mesh_vdata_helper(me);
1508  cdl = &vdata->layers[CustomData_get_layer_index_n(vdata, CD_PROP_COLOR, index)];
1509  }
1510 
1512  return ptr;
1513 }
1514 
1515 static void rna_Mesh_sculpt_vertex_color_remove(struct Mesh *me,
1516  ReportList *reports,
1517  CustomDataLayer *layer)
1518 {
1519  if (ED_mesh_sculpt_color_remove_named(me, layer->name) == false) {
1520  BKE_reportf(reports, RPT_ERROR, "Sculpt vertex color '%s' not found", layer->name);
1521  }
1522 }
1523 
1524 # define DEFINE_CUSTOMDATA_PROPERTY_API( \
1525  elemname, datatype, cd_prop_type, cdata, countvar, layertype) \
1526  static PointerRNA rna_Mesh_##elemname##_##datatype##_property_new(struct Mesh *me, \
1527  const char *name) \
1528  { \
1529  PointerRNA ptr; \
1530  CustomDataLayer *cdl = NULL; \
1531  int index; \
1532 \
1533  CustomData_add_layer_named(&me->cdata, cd_prop_type, CD_DEFAULT, NULL, me->countvar, name); \
1534  index = CustomData_get_named_layer_index(&me->cdata, cd_prop_type, name); \
1535 \
1536  cdl = (index == -1) ? NULL : &(me->cdata.layers[index]); \
1537 \
1538  RNA_pointer_create(&me->id, &RNA_##layertype, cdl, &ptr); \
1539  return ptr; \
1540  }
1541 
1542 DEFINE_CUSTOMDATA_PROPERTY_API(
1543  vertex, float, CD_PROP_FLOAT, vdata, totvert, MeshVertexFloatPropertyLayer)
1544 DEFINE_CUSTOMDATA_PROPERTY_API(
1545  vertex, int, CD_PROP_INT32, vdata, totvert, MeshVertexIntPropertyLayer)
1546 DEFINE_CUSTOMDATA_PROPERTY_API(
1547  vertex, string, CD_PROP_STRING, vdata, totvert, MeshVertexStringPropertyLayer)
1548 DEFINE_CUSTOMDATA_PROPERTY_API(
1549  polygon, float, CD_PROP_FLOAT, pdata, totpoly, MeshPolygonFloatPropertyLayer)
1550 DEFINE_CUSTOMDATA_PROPERTY_API(
1551  polygon, int, CD_PROP_INT32, pdata, totpoly, MeshPolygonIntPropertyLayer)
1552 DEFINE_CUSTOMDATA_PROPERTY_API(
1553  polygon, string, CD_PROP_STRING, pdata, totpoly, MeshPolygonStringPropertyLayer)
1554 # undef DEFINE_CUSTOMDATA_PROPERTY_API
1555 
1556 static PointerRNA rna_Mesh_uv_layers_new(struct Mesh *me, const char *name, const bool do_init)
1557 {
1558  PointerRNA ptr;
1559  CustomData *ldata;
1560  CustomDataLayer *cdl = NULL;
1561  int index = ED_mesh_uv_texture_add(me, name, false, do_init);
1562 
1563  if (index != -1) {
1564  ldata = rna_mesh_ldata_helper(me);
1565  cdl = &ldata->layers[CustomData_get_layer_index_n(ldata, CD_MLOOPUV, index)];
1566  }
1567 
1568  RNA_pointer_create(&me->id, &RNA_MeshUVLoopLayer, cdl, &ptr);
1569  return ptr;
1570 }
1571 
1572 static void rna_Mesh_uv_layers_remove(struct Mesh *me, ReportList *reports, CustomDataLayer *layer)
1573 {
1574  if (ED_mesh_uv_texture_remove_named(me, layer->name) == false) {
1575  BKE_reportf(reports, RPT_ERROR, "Texture layer '%s' not found", layer->name);
1576  }
1577 }
1578 
1579 static bool rna_Mesh_is_editmode_get(PointerRNA *ptr)
1580 {
1581  Mesh *me = rna_mesh(ptr);
1582  return (me->edit_mesh != NULL);
1583 }
1584 
1585 /* only to quiet warnings */
1586 static void UNUSED_FUNCTION(rna_mesh_unused)(void)
1587 {
1588  /* unused functions made by macros */
1589  (void)rna_Mesh_skin_vertice_index_range;
1590  (void)rna_Mesh_vertex_paint_mask_index_range;
1591  (void)rna_Mesh_uv_layer_render_get;
1592  (void)rna_Mesh_uv_layer_render_index_get;
1593  (void)rna_Mesh_uv_layer_render_index_set;
1594  (void)rna_Mesh_uv_layer_render_set;
1595  (void)rna_Mesh_face_map_index_range;
1596  (void)rna_Mesh_face_map_active_index_set;
1597  (void)rna_Mesh_face_map_active_index_get;
1598  (void)rna_Mesh_face_map_active_set;
1599  /* end unused function block */
1600 }
1601 
1602 #else
1603 
1605 {
1606  StructRNA *srna;
1607  PropertyRNA *prop;
1608 
1609  srna = RNA_def_struct(brna, "VertexGroupElement", NULL);
1610  RNA_def_struct_sdna(srna, "MDeformWeight");
1611  RNA_def_struct_path_func(srna, "rna_VertexGroupElement_path");
1613  srna, "Vertex Group Element", "Weight value of a vertex in a vertex group");
1614  RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX);
1615 
1616  /* we can't point to actual group, it is in the object and so
1617  * there is no unique group to point to, hence the index */
1618  prop = RNA_def_property(srna, "group", PROP_INT, PROP_UNSIGNED);
1619  RNA_def_property_int_sdna(prop, NULL, "def_nr");
1621  RNA_def_property_ui_text(prop, "Group Index", "");
1622  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
1623 
1624  prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
1625  RNA_def_property_range(prop, 0.0f, 1.0f);
1626  RNA_def_property_ui_text(prop, "Weight", "Vertex Weight");
1627  RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_weight");
1628 }
1629 
1630 static void rna_def_mvert(BlenderRNA *brna)
1631 {
1632  StructRNA *srna;
1633  PropertyRNA *prop;
1634 
1635  srna = RNA_def_struct(brna, "MeshVertex", NULL);
1636  RNA_def_struct_sdna(srna, "MVert");
1637  RNA_def_struct_ui_text(srna, "Mesh Vertex", "Vertex in a Mesh data-block");
1638  RNA_def_struct_path_func(srna, "rna_MeshVertex_path");
1639  RNA_def_struct_ui_icon(srna, ICON_VERTEXSEL);
1640 
1641  prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
1642  RNA_def_property_ui_text(prop, "Location", "");
1643  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
1644 
1645  prop = RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION);
1646  /* RNA_def_property_float_sdna(prop, NULL, "no"); */
1647  RNA_def_property_array(prop, 3);
1648  RNA_def_property_range(prop, -1.0f, 1.0f);
1650  prop, "rna_MeshVertex_normal_get", "rna_MeshVertex_normal_set", NULL);
1651  RNA_def_property_ui_text(prop, "Normal", "Vertex Normal");
1652 
1653  prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1654  RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
1655  RNA_def_property_ui_text(prop, "Select", "");
1656  RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
1657 
1658  prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1659  RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_HIDE);
1660  RNA_def_property_ui_text(prop, "Hide", "");
1661  RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
1662 
1663  prop = RNA_def_property(srna, "bevel_weight", PROP_FLOAT, PROP_NONE);
1665  prop, "rna_MeshVertex_bevel_weight_get", "rna_MeshVertex_bevel_weight_set", NULL);
1667  prop, "Bevel Weight", "Weight used by the Bevel modifier 'Only Vertices' option");
1668  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
1669 
1670  prop = RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
1672  "rna_MeshVertex_groups_begin",
1673  "rna_iterator_array_next",
1674  "rna_iterator_array_end",
1675  "rna_iterator_array_get",
1676  NULL,
1677  NULL,
1678  NULL,
1679  NULL);
1680  RNA_def_property_struct_type(prop, "VertexGroupElement");
1682  prop, "Groups", "Weights for the vertex groups this vertex is member of");
1683 
1684  prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
1686  RNA_def_property_int_funcs(prop, "rna_MeshVertex_index_get", NULL, NULL);
1687  RNA_def_property_ui_text(prop, "Index", "Index of this vertex");
1688 
1689  prop = RNA_def_property(srna, "undeformed_co", PROP_FLOAT, PROP_TRANSLATION);
1690  RNA_def_property_array(prop, 3);
1692  prop,
1693  "Undeformed Location",
1694  "For meshes with modifiers applied, the coordinate of the vertex with no deforming "
1695  "modifiers applied, as used for generated texture coordinates");
1696  RNA_def_property_float_funcs(prop, "rna_MeshVertex_undeformed_co_get", NULL, NULL);
1698 }
1699 
1700 static void rna_def_medge(BlenderRNA *brna)
1701 {
1702  StructRNA *srna;
1703  PropertyRNA *prop;
1704 
1705  srna = RNA_def_struct(brna, "MeshEdge", NULL);
1706  RNA_def_struct_sdna(srna, "MEdge");
1707  RNA_def_struct_ui_text(srna, "Mesh Edge", "Edge in a Mesh data-block");
1708  RNA_def_struct_path_func(srna, "rna_MeshEdge_path");
1709  RNA_def_struct_ui_icon(srna, ICON_EDGESEL);
1710 
1711  prop = RNA_def_property(srna, "vertices", PROP_INT, PROP_UNSIGNED);
1712  RNA_def_property_int_sdna(prop, NULL, "v1");
1713  RNA_def_property_array(prop, 2);
1714  RNA_def_property_ui_text(prop, "Vertices", "Vertex indices");
1715  /* XXX allows creating invalid meshes */
1716 
1717  prop = RNA_def_property(srna, "crease", PROP_FLOAT, PROP_NONE);
1718  RNA_def_property_float_funcs(prop, "rna_MEdge_crease_get", "rna_MEdge_crease_set", NULL);
1720  prop, "Crease", "Weight used by the Subdivision Surface modifier for creasing");
1721  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
1722 
1723  prop = RNA_def_property(srna, "bevel_weight", PROP_FLOAT, PROP_NONE);
1725  prop, "rna_MEdge_bevel_weight_get", "rna_MEdge_bevel_weight_set", NULL);
1726  RNA_def_property_ui_text(prop, "Bevel Weight", "Weight used by the Bevel modifier");
1727  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
1728 
1729  prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1730  RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
1731  RNA_def_property_ui_text(prop, "Select", "");
1732  RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
1733 
1734  prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1735  RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_HIDE);
1736  RNA_def_property_ui_text(prop, "Hide", "");
1737  RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
1738 
1739  prop = RNA_def_property(srna, "use_seam", PROP_BOOLEAN, PROP_NONE);
1740  RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_SEAM);
1741  RNA_def_property_ui_text(prop, "Seam", "Seam edge for UV unwrapping");
1742  RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
1743 
1744  prop = RNA_def_property(srna, "use_edge_sharp", PROP_BOOLEAN, PROP_NONE);
1746  RNA_def_property_ui_text(prop, "Sharp", "Sharp edge for the Edge Split modifier");
1747  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
1748 
1749  prop = RNA_def_property(srna, "is_loose", PROP_BOOLEAN, PROP_NONE);
1751  RNA_def_property_ui_text(prop, "Loose", "Loose edge");
1752 
1753  prop = RNA_def_property(srna, "use_freestyle_mark", PROP_BOOLEAN, PROP_NONE);
1755  prop, "rna_MEdge_freestyle_edge_mark_get", "rna_MEdge_freestyle_edge_mark_set");
1756  RNA_def_property_ui_text(prop, "Freestyle Edge Mark", "Edge mark for Freestyle line rendering");
1757  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
1758 
1759  prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
1761  RNA_def_property_int_funcs(prop, "rna_MeshEdge_index_get", NULL, NULL);
1762  RNA_def_property_ui_text(prop, "Index", "Index of this edge");
1763 }
1764 
1765 static void rna_def_mlooptri(BlenderRNA *brna)
1766 {
1767  StructRNA *srna;
1768  PropertyRNA *prop;
1769  const int splitnor_dim[] = {3, 3};
1770 
1771  srna = RNA_def_struct(brna, "MeshLoopTriangle", NULL);
1772  RNA_def_struct_sdna(srna, "MLoopTri");
1773  RNA_def_struct_ui_text(srna, "Mesh Loop Triangle", "Tessellated triangle in a Mesh data-block");
1774  RNA_def_struct_path_func(srna, "rna_MeshLoopTriangle_path");
1775  RNA_def_struct_ui_icon(srna, ICON_FACESEL);
1776 
1777  prop = RNA_def_property(srna, "vertices", PROP_INT, PROP_UNSIGNED);
1778  RNA_def_property_array(prop, 3);
1779  RNA_def_property_int_funcs(prop, "rna_MeshLoopTriangle_verts_get", NULL, NULL);
1780  RNA_def_property_ui_text(prop, "Vertices", "Indices of triangle vertices");
1782 
1783  prop = RNA_def_property(srna, "loops", PROP_INT, PROP_UNSIGNED);
1784  RNA_def_property_int_sdna(prop, NULL, "tri");
1785  RNA_def_property_ui_text(prop, "Loops", "Indices of mesh loops that make up the triangle");
1787 
1788  prop = RNA_def_property(srna, "polygon_index", PROP_INT, PROP_UNSIGNED);
1789  RNA_def_property_int_sdna(prop, NULL, "poly");
1791  prop, "Polygon", "Index of mesh polygon that the triangle is a part of");
1793 
1794  prop = RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION);
1795  RNA_def_property_array(prop, 3);
1796  RNA_def_property_range(prop, -1.0f, 1.0f);
1798  RNA_def_property_float_funcs(prop, "rna_MeshLoopTriangle_normal_get", NULL, NULL);
1800  prop, "Triangle Normal", "Local space unit length normal vector for this triangle");
1801 
1802  prop = RNA_def_property(srna, "split_normals", PROP_FLOAT, PROP_DIRECTION);
1803  RNA_def_property_multi_array(prop, 2, splitnor_dim);
1804  RNA_def_property_range(prop, -1.0f, 1.0f);
1806  RNA_def_property_float_funcs(prop, "rna_MeshLoopTriangle_split_normals_get", NULL, NULL);
1808  prop,
1809  "Split Normals",
1810  "Local space unit length split normals vectors of the vertices of this triangle "
1811  "(must be computed beforehand using calc_normals_split or calc_tangents)");
1812 
1813  prop = RNA_def_property(srna, "area", PROP_FLOAT, PROP_UNSIGNED);
1815  RNA_def_property_float_funcs(prop, "rna_MeshLoopTriangle_area_get", NULL, NULL);
1816  RNA_def_property_ui_text(prop, "Triangle Area", "Area of this triangle");
1817 
1818  prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
1820  RNA_def_property_int_funcs(prop, "rna_MeshLoopTriangle_index_get", NULL, NULL);
1821  RNA_def_property_ui_text(prop, "Index", "Index of this loop triangle");
1822 
1823  prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED);
1825  RNA_def_property_int_funcs(prop, "rna_MeshLoopTriangle_material_index_get", NULL, NULL);
1826  RNA_def_property_ui_text(prop, "Material Index", "");
1827 
1828  prop = RNA_def_property(srna, "use_smooth", PROP_BOOLEAN, PROP_NONE);
1830  RNA_def_property_boolean_funcs(prop, "rna_MeshLoopTriangle_use_smooth_get", NULL);
1831  RNA_def_property_ui_text(prop, "Smooth", "");
1832 }
1833 
1834 static void rna_def_mloop(BlenderRNA *brna)
1835 {
1836  StructRNA *srna;
1837  PropertyRNA *prop;
1838 
1839  srna = RNA_def_struct(brna, "MeshLoop", NULL);
1840  RNA_def_struct_sdna(srna, "MLoop");
1841  RNA_def_struct_ui_text(srna, "Mesh Loop", "Loop in a Mesh data-block");
1842  RNA_def_struct_path_func(srna, "rna_MeshLoop_path");
1843  RNA_def_struct_ui_icon(srna, ICON_EDGESEL);
1844 
1845  prop = RNA_def_property(srna, "vertex_index", PROP_INT, PROP_UNSIGNED);
1846  RNA_def_property_int_sdna(prop, NULL, "v");
1847  RNA_def_property_ui_text(prop, "Vertex", "Vertex index");
1848 
1849  prop = RNA_def_property(srna, "edge_index", PROP_INT, PROP_UNSIGNED);
1850  RNA_def_property_int_sdna(prop, NULL, "e");
1851  RNA_def_property_ui_text(prop, "Edge", "Edge index");
1852 
1853  prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
1855  RNA_def_property_int_funcs(prop, "rna_MeshLoop_index_get", NULL, NULL);
1856  RNA_def_property_ui_text(prop, "Index", "Index of this loop");
1857 
1858  prop = RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION);
1859  RNA_def_property_array(prop, 3);
1860  RNA_def_property_range(prop, -1.0f, 1.0f);
1861  RNA_def_property_float_funcs(prop, "rna_MeshLoop_normal_get", "rna_MeshLoop_normal_set", NULL);
1863  prop,
1864  "Normal",
1865  "Local space unit length split normal vector of this vertex for this polygon "
1866  "(must be computed beforehand using calc_normals_split or calc_tangents)");
1867 
1868  prop = RNA_def_property(srna, "tangent", PROP_FLOAT, PROP_DIRECTION);
1869  RNA_def_property_array(prop, 3);
1870  RNA_def_property_range(prop, -1.0f, 1.0f);
1872  RNA_def_property_float_funcs(prop, "rna_MeshLoop_tangent_get", NULL, NULL);
1874  prop,
1875  "Tangent",
1876  "Local space unit length tangent vector of this vertex for this polygon "
1877  "(must be computed beforehand using calc_tangents)");
1878 
1879  prop = RNA_def_property(srna, "bitangent_sign", PROP_FLOAT, PROP_NONE);
1880  RNA_def_property_range(prop, -1.0f, 1.0f);
1882  RNA_def_property_float_funcs(prop, "rna_MeshLoop_bitangent_sign_get", NULL, NULL);
1884  prop,
1885  "Bitangent Sign",
1886  "Sign of the bitangent vector of this vertex for this polygon (must be computed "
1887  "beforehand using calc_tangents, bitangent = bitangent_sign * cross(normal, tangent))");
1888 
1889  prop = RNA_def_property(srna, "bitangent", PROP_FLOAT, PROP_DIRECTION);
1890  RNA_def_property_array(prop, 3);
1891  RNA_def_property_range(prop, -1.0f, 1.0f);
1893  RNA_def_property_float_funcs(prop, "rna_MeshLoop_bitangent_get", NULL, NULL);
1895  prop,
1896  "Bitangent",
1897  "Bitangent vector of this vertex for this polygon (must be computed beforehand using "
1898  "calc_tangents, use it only if really needed, slower access than bitangent_sign)");
1899 }
1900 
1901 static void rna_def_mpolygon(BlenderRNA *brna)
1902 {
1903  StructRNA *srna;
1904  PropertyRNA *prop;
1905  FunctionRNA *func;
1906 
1907  srna = RNA_def_struct(brna, "MeshPolygon", NULL);
1908  RNA_def_struct_sdna(srna, "MPoly");
1909  RNA_def_struct_ui_text(srna, "Mesh Polygon", "Polygon in a Mesh data-block");
1910  RNA_def_struct_path_func(srna, "rna_MeshPolygon_path");
1911  RNA_def_struct_ui_icon(srna, ICON_FACESEL);
1912 
1913  /* Faked, actually access to loop vertex values, don't this way because manually setting up
1914  * vertex/edge per loop is very low level.
1915  * Instead we setup poly sizes, assign indices, then calc edges automatic when creating
1916  * meshes from rna/py. */
1917  prop = RNA_def_property(srna, "vertices", PROP_INT, PROP_UNSIGNED);
1918  /* Eek, this is still used in some cases but in fact we don't want to use it at all here. */
1919  RNA_def_property_array(prop, 3);
1921  RNA_def_property_dynamic_array_funcs(prop, "rna_MeshPoly_vertices_get_length");
1922  RNA_def_property_int_funcs(prop, "rna_MeshPoly_vertices_get", "rna_MeshPoly_vertices_set", NULL);
1923  RNA_def_property_ui_text(prop, "Vertices", "Vertex indices");
1924 
1925  /* these are both very low level access */
1926  prop = RNA_def_property(srna, "loop_start", PROP_INT, PROP_UNSIGNED);
1927  RNA_def_property_int_sdna(prop, NULL, "loopstart");
1928  RNA_def_property_ui_text(prop, "Loop Start", "Index of the first loop of this polygon");
1929  /* also low level */
1930  prop = RNA_def_property(srna, "loop_total", PROP_INT, PROP_UNSIGNED);
1931  RNA_def_property_int_sdna(prop, NULL, "totloop");
1932  RNA_def_property_ui_text(prop, "Loop Total", "Number of loops used by this polygon");
1933 
1934  prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED);
1935  RNA_def_property_int_sdna(prop, NULL, "mat_nr");
1936  RNA_def_property_ui_text(prop, "Material Index", "");
1937 # if 0
1938  RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MeshPoly_material_index_range");
1939 # endif
1940  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
1941 
1942  prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1944  RNA_def_property_ui_text(prop, "Select", "");
1945  RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
1946 
1947  prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1948  RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_HIDE);
1949  RNA_def_property_ui_text(prop, "Hide", "");
1950  RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
1951 
1952  prop = RNA_def_property(srna, "use_smooth", PROP_BOOLEAN, PROP_NONE);
1954  RNA_def_property_ui_text(prop, "Smooth", "");
1955  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
1956 
1957  prop = RNA_def_property(srna, "use_freestyle_mark", PROP_BOOLEAN, PROP_NONE);
1959  prop, "rna_MPoly_freestyle_face_mark_get", "rna_MPoly_freestyle_face_mark_set");
1960  RNA_def_property_ui_text(prop, "Freestyle Face Mark", "Face mark for Freestyle line rendering");
1961  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
1962 
1963  prop = RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION);
1964  RNA_def_property_array(prop, 3);
1965  RNA_def_property_range(prop, -1.0f, 1.0f);
1967  RNA_def_property_float_funcs(prop, "rna_MeshPolygon_normal_get", NULL, NULL);
1969  prop, "Polygon Normal", "Local space unit length normal vector for this polygon");
1970 
1971  prop = RNA_def_property(srna, "center", PROP_FLOAT, PROP_XYZ);
1972  RNA_def_property_array(prop, 3);
1974  RNA_def_property_float_funcs(prop, "rna_MeshPolygon_center_get", NULL, NULL);
1975  RNA_def_property_ui_text(prop, "Polygon Center", "Center of this polygon");
1976 
1977  prop = RNA_def_property(srna, "area", PROP_FLOAT, PROP_UNSIGNED);
1979  RNA_def_property_float_funcs(prop, "rna_MeshPolygon_area_get", NULL, NULL);
1980  RNA_def_property_ui_text(prop, "Polygon Area", "Read only area of this polygon");
1981 
1982  prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
1984  RNA_def_property_int_funcs(prop, "rna_MeshPolygon_index_get", NULL, NULL);
1985  RNA_def_property_ui_text(prop, "Index", "Index of this polygon");
1986 
1987  func = RNA_def_function(srna, "flip", "rna_MeshPolygon_flip");
1989  RNA_def_function_ui_description(func, "Invert winding of this polygon (flip its normal)");
1990 }
1991 
1992 /* mesh.loop_uvs */
1993 static void rna_def_mloopuv(BlenderRNA *brna)
1994 {
1995  StructRNA *srna;
1996  PropertyRNA *prop;
1997 
1998  srna = RNA_def_struct(brna, "MeshUVLoopLayer", NULL);
1999  RNA_def_struct_sdna(srna, "CustomDataLayer");
2000  RNA_def_struct_path_func(srna, "rna_MeshUVLoopLayer_path");
2001 
2002  prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
2003  RNA_def_property_struct_type(prop, "MeshUVLoop");
2005  "rna_MeshUVLoopLayer_data_begin",
2006  "rna_iterator_array_next",
2007  "rna_iterator_array_end",
2008  "rna_iterator_array_get",
2009  "rna_MeshUVLoopLayer_data_length",
2010  NULL,
2011  NULL,
2012  NULL);
2013 
2014  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2015  RNA_def_struct_name_property(srna, prop);
2016  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshLoopLayer_name_set");
2017  RNA_def_property_ui_text(prop, "Name", "Name of UV map");
2018  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2019 
2020  prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
2022  prop, "rna_MeshUVLoopLayer_active_get", "rna_MeshUVLoopLayer_active_set");
2023  RNA_def_property_ui_text(prop, "Active", "Set the map as active for display and editing");
2024  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2025 
2026  prop = RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE);
2027  RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0);
2029  prop, "rna_MeshUVLoopLayer_active_render_get", "rna_MeshUVLoopLayer_active_render_set");
2030  RNA_def_property_ui_text(prop, "Active Render", "Set the map as active for rendering");
2031  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2032 
2033  prop = RNA_def_property(srna, "active_clone", PROP_BOOLEAN, PROP_NONE);
2034  RNA_def_property_boolean_sdna(prop, NULL, "active_clone", 0);
2036  prop, "rna_MeshUVLoopLayer_clone_get", "rna_MeshUVLoopLayer_clone_set");
2037  RNA_def_property_ui_text(prop, "Active Clone", "Set the map as active for cloning");
2038  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2039 
2040  srna = RNA_def_struct(brna, "MeshUVLoop", NULL);
2041  RNA_def_struct_sdna(srna, "MLoopUV");
2042  RNA_def_struct_path_func(srna, "rna_MeshUVLoop_path");
2043 
2044  prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_XYZ);
2045  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2046 
2047  prop = RNA_def_property(srna, "pin_uv", PROP_BOOLEAN, PROP_NONE);
2049  RNA_def_property_ui_text(prop, "UV Pinned", "");
2050 
2051  prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2053  RNA_def_property_ui_text(prop, "UV Select", "");
2054 }
2055 
2056 static void rna_def_mloopcol(BlenderRNA *brna)
2057 {
2058  StructRNA *srna;
2059  PropertyRNA *prop;
2060 
2061  srna = RNA_def_struct(brna, "MeshLoopColorLayer", NULL);
2063  srna, "Mesh Vertex Color Layer", "Layer of vertex colors in a Mesh data-block");
2064  RNA_def_struct_sdna(srna, "CustomDataLayer");
2065  RNA_def_struct_path_func(srna, "rna_MeshLoopColorLayer_path");
2066  RNA_def_struct_ui_icon(srna, ICON_GROUP_VCOL);
2067 
2068  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2069  RNA_def_struct_name_property(srna, prop);
2070  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshLoopLayer_name_set");
2071  RNA_def_property_ui_text(prop, "Name", "Name of Vertex color layer");
2072  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2073 
2074  prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
2076  prop, "rna_MeshLoopColorLayer_active_get", "rna_MeshLoopColorLayer_active_set");
2077  RNA_def_property_ui_text(prop, "Active", "Sets the layer as active for display and editing");
2078  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2079 
2080  prop = RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE);
2081  RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0);
2083  "rna_MeshLoopColorLayer_active_render_get",
2084  "rna_MeshLoopColorLayer_active_render_set");
2085  RNA_def_property_ui_text(prop, "Active Render", "Sets the layer as active for rendering");
2086  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2087 
2088  prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
2089  RNA_def_property_struct_type(prop, "MeshLoopColor");
2090  RNA_def_property_ui_text(prop, "Data", "");
2092  "rna_MeshLoopColorLayer_data_begin",
2093  "rna_iterator_array_next",
2094  "rna_iterator_array_end",
2095  "rna_iterator_array_get",
2096  "rna_MeshLoopColorLayer_data_length",
2097  NULL,
2098  NULL,
2099  NULL);
2100 
2101  srna = RNA_def_struct(brna, "MeshLoopColor", NULL);
2102  RNA_def_struct_sdna(srna, "MLoopCol");
2103  RNA_def_struct_ui_text(srna, "Mesh Vertex Color", "Vertex loop colors in a Mesh");
2104  RNA_def_struct_path_func(srna, "rna_MeshColor_path");
2105 
2106  prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
2107  RNA_def_property_array(prop, 4);
2108  RNA_def_property_range(prop, 0.0f, 1.0f);
2110  prop, "rna_MeshLoopColor_color_get", "rna_MeshLoopColor_color_set", NULL);
2111  RNA_def_property_ui_text(prop, "Color", "");
2112  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2113 }
2114 
2115 static void rna_def_MPropCol(BlenderRNA *brna)
2116 {
2117  StructRNA *srna;
2118  PropertyRNA *prop;
2119 
2120  srna = RNA_def_struct(brna, "MeshVertColorLayer", NULL);
2122  "Mesh Sculpt Vertex Color Layer",
2123  "Layer of sculpt vertex colors in a Mesh data-block");
2124  RNA_def_struct_sdna(srna, "CustomDataLayer");
2125  RNA_def_struct_path_func(srna, "rna_MeshVertColorLayer_path");
2126  RNA_def_struct_ui_icon(srna, ICON_GROUP_VCOL);
2127 
2128  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2129  RNA_def_struct_name_property(srna, prop);
2130  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshVertexLayer_name_set");
2131  RNA_def_property_ui_text(prop, "Name", "Name of Sculpt Vertex color layer");
2132  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2133 
2134  prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
2136  prop, "rna_MeshVertColorLayer_active_get", "rna_MeshVertColorLayer_active_set");
2138  prop, "Active", "Sets the sculpt vertex color layer as active for display and editing");
2139  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2140 
2141  prop = RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE);
2142  RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0);
2144  "rna_MeshVertColorLayer_active_render_get",
2145  "rna_MeshVertColorLayer_active_render_set");
2147  prop, "Active Render", "Sets the sculpt vertex color layer as active for rendering");
2148  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2149 
2150  prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
2151  RNA_def_property_struct_type(prop, "MeshVertColor");
2152  RNA_def_property_ui_text(prop, "Data", "");
2154  "rna_MeshVertColorLayer_data_begin",
2155  "rna_iterator_array_next",
2156  "rna_iterator_array_end",
2157  "rna_iterator_array_get",
2158  "rna_MeshVertColorLayer_data_length",
2159  NULL,
2160  NULL,
2161  NULL);
2162 
2163  srna = RNA_def_struct(brna, "MeshVertColor", NULL);
2164  RNA_def_struct_sdna(srna, "MPropCol");
2165  RNA_def_struct_ui_text(srna, "Mesh Sculpt Vertex Color", "Vertex colors in a Mesh");
2166  RNA_def_struct_path_func(srna, "rna_MeshVertColor_path");
2167 
2168  prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
2169  RNA_def_property_array(prop, 4);
2170  RNA_def_property_range(prop, 0.0f, 1.0f);
2171  RNA_def_property_ui_text(prop, "Color", "");
2172  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2173 }
2175 {
2176  StructRNA *srna;
2177  PropertyRNA *prop;
2178 
2179  /* Float */
2180 # define MESH_FLOAT_PROPERTY_LAYER(elemname) \
2181  srna = RNA_def_struct(brna, "Mesh" elemname "FloatPropertyLayer", NULL); \
2182  RNA_def_struct_sdna(srna, "CustomDataLayer"); \
2183  RNA_def_struct_ui_text(srna, \
2184  "Mesh " elemname " Float Property Layer", \
2185  "User defined layer of floating-point number values"); \
2186  RNA_def_struct_path_func(srna, "rna_Mesh" elemname "FloatPropertyLayer_path"); \
2187 \
2188  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); \
2189  RNA_def_struct_name_property(srna, prop); \
2190  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshAnyLayer_name_set"); \
2191  RNA_def_property_ui_text(prop, "Name", ""); \
2192  RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); \
2193 \
2194  prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); \
2195  RNA_def_property_struct_type(prop, "Mesh" elemname "FloatProperty"); \
2196  RNA_def_property_ui_text(prop, "Data", ""); \
2197  RNA_def_property_collection_funcs(prop, \
2198  "rna_Mesh" elemname "FloatPropertyLayer_data_begin", \
2199  "rna_iterator_array_next", \
2200  "rna_iterator_array_end", \
2201  "rna_iterator_array_get", \
2202  "rna_Mesh" elemname "FloatPropertyLayer_data_length", \
2203  NULL, \
2204  NULL, \
2205  NULL); \
2206 \
2207  srna = RNA_def_struct(brna, "Mesh" elemname "FloatProperty", NULL); \
2208  RNA_def_struct_sdna(srna, "MFloatProperty"); \
2209  RNA_def_struct_ui_text( \
2210  srna, \
2211  "Mesh " elemname " Float Property", \
2212  "User defined floating-point number value in a float properties layer"); \
2213  RNA_def_struct_path_func(srna, "rna_Mesh" elemname "FloatProperty_path"); \
2214 \
2215  prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE); \
2216  RNA_def_property_float_sdna(prop, NULL, "f"); \
2217  RNA_def_property_ui_text(prop, "Value", ""); \
2218  RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); \
2219  ((void)0)
2220 
2221  /* Int */
2222 # define MESH_INT_PROPERTY_LAYER(elemname) \
2223  srna = RNA_def_struct(brna, "Mesh" elemname "IntPropertyLayer", NULL); \
2224  RNA_def_struct_sdna(srna, "CustomDataLayer"); \
2225  RNA_def_struct_ui_text(srna, \
2226  "Mesh " elemname " Int Property Layer", \
2227  "User defined layer of integer number values"); \
2228  RNA_def_struct_path_func(srna, "rna_Mesh" elemname "IntPropertyLayer_path"); \
2229 \
2230  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); \
2231  RNA_def_struct_name_property(srna, prop); \
2232  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshAnyLayer_name_set"); \
2233  RNA_def_property_ui_text(prop, "Name", ""); \
2234  RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); \
2235 \
2236  prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); \
2237  RNA_def_property_struct_type(prop, "Mesh" elemname "IntProperty"); \
2238  RNA_def_property_ui_text(prop, "Data", ""); \
2239  RNA_def_property_collection_funcs(prop, \
2240  "rna_Mesh" elemname "IntPropertyLayer_data_begin", \
2241  "rna_iterator_array_next", \
2242  "rna_iterator_array_end", \
2243  "rna_iterator_array_get", \
2244  "rna_Mesh" elemname "IntPropertyLayer_data_length", \
2245  NULL, \
2246  NULL, \
2247  NULL); \
2248 \
2249  srna = RNA_def_struct(brna, "Mesh" elemname "IntProperty", NULL); \
2250  RNA_def_struct_sdna(srna, "MIntProperty"); \
2251  RNA_def_struct_ui_text(srna, \
2252  "Mesh " elemname " Int Property", \
2253  "User defined integer number value in an integer properties layer"); \
2254  RNA_def_struct_path_func(srna, "rna_Mesh" elemname "IntProperty_path"); \
2255 \
2256  prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE); \
2257  RNA_def_property_int_sdna(prop, NULL, "i"); \
2258  RNA_def_property_ui_text(prop, "Value", ""); \
2259  RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); \
2260  ((void)0)
2261 
2262  /* String */
2263 # define MESH_STRING_PROPERTY_LAYER(elemname) \
2264  srna = RNA_def_struct(brna, "Mesh" elemname "StringPropertyLayer", NULL); \
2265  RNA_def_struct_sdna(srna, "CustomDataLayer"); \
2266  RNA_def_struct_ui_text(srna, \
2267  "Mesh " elemname " String Property Layer", \
2268  "User defined layer of string text values"); \
2269  RNA_def_struct_path_func(srna, "rna_Mesh" elemname "StringPropertyLayer_path"); \
2270 \
2271  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); \
2272  RNA_def_struct_name_property(srna, prop); \
2273  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshAnyLayer_name_set"); \
2274  RNA_def_property_ui_text(prop, "Name", ""); \
2275  RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); \
2276 \
2277  prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); \
2278  RNA_def_property_struct_type(prop, "Mesh" elemname "StringProperty"); \
2279  RNA_def_property_ui_text(prop, "Data", ""); \
2280  RNA_def_property_collection_funcs(prop, \
2281  "rna_Mesh" elemname "StringPropertyLayer_data_begin", \
2282  "rna_iterator_array_next", \
2283  "rna_iterator_array_end", \
2284  "rna_iterator_array_get", \
2285  "rna_Mesh" elemname "StringPropertyLayer_data_length", \
2286  NULL, \
2287  NULL, \
2288  NULL); \
2289 \
2290  srna = RNA_def_struct(brna, "Mesh" elemname "StringProperty", NULL); \
2291  RNA_def_struct_sdna(srna, "MStringProperty"); \
2292  RNA_def_struct_ui_text(srna, \
2293  "Mesh " elemname " String Property", \
2294  "User defined string text value in a string properties layer"); \
2295  RNA_def_struct_path_func(srna, "rna_Mesh" elemname "StringProperty_path"); \
2296 \
2297  /* low level mesh data access, treat as bytes */ \
2298  prop = RNA_def_property(srna, "value", PROP_STRING, PROP_BYTESTRING); \
2299  RNA_def_property_string_sdna(prop, NULL, "s"); \
2300  RNA_def_property_string_funcs(prop, \
2301  "rna_MeshStringProperty_s_get", \
2302  "rna_MeshStringProperty_s_length", \
2303  "rna_MeshStringProperty_s_set"); \
2304  RNA_def_property_ui_text(prop, "Value", ""); \
2305  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2306 
2307  MESH_FLOAT_PROPERTY_LAYER("Vertex");
2308  MESH_FLOAT_PROPERTY_LAYER("Polygon");
2309  MESH_INT_PROPERTY_LAYER("Vertex");
2310  MESH_INT_PROPERTY_LAYER("Polygon");
2311  MESH_STRING_PROPERTY_LAYER("Vertex")
2312  MESH_STRING_PROPERTY_LAYER("Polygon")
2313 # undef MESH_PROPERTY_LAYER
2314 }
2315 
2316 void rna_def_texmat_common(StructRNA *srna, const char *texspace_editable)
2317 {
2318  PropertyRNA *prop;
2319 
2320  /* texture space */
2321  prop = RNA_def_property(srna, "auto_texspace", PROP_BOOLEAN, PROP_NONE);
2322  RNA_def_property_boolean_sdna(prop, NULL, "texflag", ME_AUTOSPACE);
2324  prop,
2325  "Auto Texture Space",
2326  "Adjust active object's texture space automatically when transforming object");
2327 
2328  prop = RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION);
2329  RNA_def_property_float_sdna(prop, NULL, "loc");
2330  RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location");
2331  RNA_def_property_float_funcs(prop, "rna_Mesh_texspace_loc_get", NULL, NULL);
2332  RNA_def_property_editable_func(prop, texspace_editable);
2333  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2334 
2335  prop = RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ);
2336  RNA_def_property_float_sdna(prop, NULL, "size");
2338  RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size");
2339  RNA_def_property_float_funcs(prop, "rna_Mesh_texspace_size_get", NULL, NULL);
2340  RNA_def_property_editable_func(prop, texspace_editable);
2341  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2342 
2343  /* materials */
2344  prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
2345  RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
2346  RNA_def_property_struct_type(prop, "Material");
2347  RNA_def_property_ui_text(prop, "Materials", "");
2348  RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
2350  prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");
2351 }
2352 
2353 /* scene.objects */
2354 /* mesh.vertices */
2356 {
2357  StructRNA *srna;
2358  /* PropertyRNA *prop; */
2359 
2360  FunctionRNA *func;
2361  PropertyRNA *parm;
2362 
2363  RNA_def_property_srna(cprop, "MeshVertices");
2364  srna = RNA_def_struct(brna, "MeshVertices", NULL);
2365  RNA_def_struct_sdna(srna, "Mesh");
2366  RNA_def_struct_ui_text(srna, "Mesh Vertices", "Collection of mesh vertices");
2367 
2368  func = RNA_def_function(srna, "add", "ED_mesh_verts_add");
2370  parm = RNA_def_int(
2371  func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add", 0, INT_MAX);
2373 # if 0 /* BMESH_TODO Remove until BMesh merge */
2374  func = RNA_def_function(srna, "remove", "ED_mesh_verts_remove");
2376  RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to remove", 0, INT_MAX);
2377 # endif
2378 }
2379 
2380 /* mesh.edges */
2381 static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop)
2382 {
2383  StructRNA *srna;
2384  /* PropertyRNA *prop; */
2385 
2386  FunctionRNA *func;
2387  PropertyRNA *parm;
2388 
2389  RNA_def_property_srna(cprop, "MeshEdges");
2390  srna = RNA_def_struct(brna, "MeshEdges", NULL);
2391  RNA_def_struct_sdna(srna, "Mesh");
2392  RNA_def_struct_ui_text(srna, "Mesh Edges", "Collection of mesh edges");
2393 
2394  func = RNA_def_function(srna, "add", "ED_mesh_edges_add");
2396  parm = RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of edges to add", 0, INT_MAX);
2398 # if 0 /* BMESH_TODO Remove until BMesh merge */
2399  func = RNA_def_function(srna, "remove", "ED_mesh_edges_remove");
2401  RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of edges to remove", 0, INT_MAX);
2402 # endif
2403 }
2404 
2405 /* mesh.loop_triangles */
2407 {
2408  StructRNA *srna;
2409 
2410  RNA_def_property_srna(cprop, "MeshLoopTriangles");
2411  srna = RNA_def_struct(brna, "MeshLoopTriangles", NULL);
2412  RNA_def_struct_sdna(srna, "Mesh");
2414  srna, "Mesh Loop Triangles", "Tessellation of mesh polygons into triangles");
2415 }
2416 
2417 /* mesh.loops */
2418 static void rna_def_mesh_loops(BlenderRNA *brna, PropertyRNA *cprop)
2419 {
2420  StructRNA *srna;
2421 
2422  /*PropertyRNA *prop;*/
2423 
2424  FunctionRNA *func;
2425  PropertyRNA *parm;
2426 
2427  RNA_def_property_srna(cprop, "MeshLoops");
2428  srna = RNA_def_struct(brna, "MeshLoops", NULL);
2429  RNA_def_struct_sdna(srna, "Mesh");
2430  RNA_def_struct_ui_text(srna, "Mesh Loops", "Collection of mesh loops");
2431 
2432  func = RNA_def_function(srna, "add", "ED_mesh_loops_add");
2434  parm = RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of loops to add", 0, INT_MAX);
2436 }
2437 
2438 /* mesh.polygons */
2440 {
2441  StructRNA *srna;
2442 
2443  PropertyRNA *prop;
2444 
2445  FunctionRNA *func;
2446  PropertyRNA *parm;
2447 
2448  RNA_def_property_srna(cprop, "MeshPolygons");
2449  srna = RNA_def_struct(brna, "MeshPolygons", NULL);
2450  RNA_def_struct_sdna(srna, "Mesh");
2451  RNA_def_struct_ui_text(srna, "Mesh Polygons", "Collection of mesh polygons");
2452 
2453  prop = RNA_def_property(srna, "active", PROP_INT, PROP_NONE);
2454  RNA_def_property_int_sdna(prop, NULL, "act_face");
2455  RNA_def_property_ui_text(prop, "Active Polygon", "The active polygon for this mesh");
2456 
2457  func = RNA_def_function(srna, "add", "ED_mesh_polys_add");
2459  parm = RNA_def_int(
2460  func, "count", 0, 0, INT_MAX, "Count", "Number of polygons to add", 0, INT_MAX);
2462 }
2463 
2464 static void rna_def_loop_colors(BlenderRNA *brna, PropertyRNA *cprop)
2465 {
2466  StructRNA *srna;
2467  PropertyRNA *prop;
2468 
2469  FunctionRNA *func;
2470  PropertyRNA *parm;
2471 
2472  RNA_def_property_srna(cprop, "LoopColors");
2473  srna = RNA_def_struct(brna, "LoopColors", NULL);
2474  RNA_def_struct_sdna(srna, "Mesh");
2475  RNA_def_struct_ui_text(srna, "Loop Colors", "Collection of vertex colors");
2476 
2477  func = RNA_def_function(srna, "new", "rna_Mesh_vertex_color_new");
2478  RNA_def_function_ui_description(func, "Add a vertex color layer to Mesh");
2479  RNA_def_string(func, "name", "Col", 0, "", "Vertex color name");
2480  RNA_def_boolean(func,
2481  "do_init",
2482  true,
2483  "",
2484  "Whether new layer's data should be initialized by copying current active one");
2485  parm = RNA_def_pointer(func, "layer", "MeshLoopColorLayer", "", "The newly created layer");
2487  RNA_def_function_return(func, parm);
2488 
2489  func = RNA_def_function(srna, "remove", "rna_Mesh_vertex_color_remove");
2490  RNA_def_function_ui_description(func, "Remove a vertex color layer");
2492  parm = RNA_def_pointer(func, "layer", "MeshLoopColorLayer", "", "The layer to remove");
2495 
2496  prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2497  RNA_def_property_struct_type(prop, "MeshLoopColorLayer");
2499  prop, "rna_Mesh_vertex_color_active_get", "rna_Mesh_vertex_color_active_set", NULL, NULL);
2501  RNA_def_property_ui_text(prop, "Active Vertex Color Layer", "Active vertex color layer");
2502  RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_active_color");
2503 
2504  prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
2506  "rna_Mesh_vertex_color_active_index_get",
2507  "rna_Mesh_vertex_color_active_index_set",
2508  "rna_Mesh_vertex_color_index_range");
2509  RNA_def_property_ui_text(prop, "Active Vertex Color Index", "Active vertex color index");
2510  RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_active_color");
2511 }
2512 
2513 static void rna_def_vert_colors(BlenderRNA *brna, PropertyRNA *cprop)
2514 {
2515  StructRNA *srna;
2516  PropertyRNA *prop;
2517 
2518  FunctionRNA *func;
2519  PropertyRNA *parm;
2520 
2521  RNA_def_property_srna(cprop, "VertColors");
2522  srna = RNA_def_struct(brna, "VertColors", NULL);
2523  RNA_def_struct_sdna(srna, "Mesh");
2524  RNA_def_struct_ui_text(srna, "Vert Colors", "Collection of sculpt vertex colors");
2525 
2526  func = RNA_def_function(srna, "new", "rna_Mesh_sculpt_vertex_color_new");
2527  RNA_def_function_ui_description(func, "Add a sculpt vertex color layer to Mesh");
2528  RNA_def_string(func, "name", "Col", 0, "", "Sculpt Vertex color name");
2529  RNA_def_boolean(func,
2530  "do_init",
2531  true,
2532  "",
2533  "Whether new layer's data should be initialized by copying current active one");
2534  parm = RNA_def_pointer(func, "layer", "MeshVertColorLayer", "", "The newly created layer");
2536  RNA_def_function_return(func, parm);
2537 
2538  func = RNA_def_function(srna, "remove", "rna_Mesh_sculpt_vertex_color_remove");
2539  RNA_def_function_ui_description(func, "Remove a vertex color layer");
2541  parm = RNA_def_pointer(func, "layer", "MeshVertColorLayer", "", "The layer to remove");
2544 
2545  prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2546  RNA_def_property_struct_type(prop, "MeshVertColorLayer");
2548  "rna_Mesh_sculpt_vertex_color_active_get",
2549  "rna_Mesh_sculpt_vertex_color_active_set",
2550  NULL,
2551  NULL);
2554  prop, "Active Sculpt Vertex Color Layer", "Active sculpt vertex color layer");
2555  RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_active_color");
2556 
2557  prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
2559  "rna_Mesh_sculpt_vertex_color_active_index_get",
2560  "rna_Mesh_sculpt_vertex_color_active_index_set",
2561  "rna_Mesh_sculpt_vertex_color_index_range");
2563  prop, "Active Sculpt Vertex Color Index", "Active sculpt vertex color index");
2564  RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_active_color");
2565 }
2566 
2567 static void rna_def_uv_layers(BlenderRNA *brna, PropertyRNA *cprop)
2568 {
2569  StructRNA *srna;
2570  PropertyRNA *prop;
2571 
2572  FunctionRNA *func;
2573  PropertyRNA *parm;
2574 
2575  RNA_def_property_srna(cprop, "UVLoopLayers");
2576  srna = RNA_def_struct(brna, "UVLoopLayers", NULL);
2577  RNA_def_struct_sdna(srna, "Mesh");
2578  RNA_def_struct_ui_text(srna, "UV Loop Layers", "Collection of uv loop layers");
2579 
2580  func = RNA_def_function(srna, "new", "rna_Mesh_uv_layers_new");
2581  RNA_def_function_ui_description(func, "Add a UV map layer to Mesh");
2582  RNA_def_string(func, "name", "UVMap", 0, "", "UV map name");
2583  RNA_def_boolean(func,
2584  "do_init",
2585  true,
2586  "",
2587  "Whether new layer's data should be initialized by copying current active one, "
2588  "or if none is active, with a default UVmap");
2589  parm = RNA_def_pointer(func, "layer", "MeshUVLoopLayer", "", "The newly created layer");
2591  RNA_def_function_return(func, parm);
2592 
2593  func = RNA_def_function(srna, "remove", "rna_Mesh_uv_layers_remove");
2594  RNA_def_function_ui_description(func, "Remove a vertex color layer");
2596  parm = RNA_def_pointer(func, "layer", "MeshUVLoopLayer", "", "The layer to remove");
2598 
2599  prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2600  RNA_def_property_struct_type(prop, "MeshUVLoopLayer");
2602  prop, "rna_Mesh_uv_layer_active_get", "rna_Mesh_uv_layer_active_set", NULL, NULL);
2604  RNA_def_property_ui_text(prop, "Active UV Loop Layer", "Active UV loop layer");
2605  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2606 
2607  prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
2609  "rna_Mesh_uv_layer_active_index_get",
2610  "rna_Mesh_uv_layer_active_index_set",
2611  "rna_Mesh_uv_layer_index_range");
2612  RNA_def_property_ui_text(prop, "Active UV Loop Layer Index", "Active UV loop layer index");
2613  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2614 }
2615 
2616 /* mesh float layers */
2618 {
2619  StructRNA *srna;
2620 
2621  FunctionRNA *func;
2622  PropertyRNA *parm;
2623 
2624  RNA_def_property_srna(cprop, "VertexFloatProperties");
2625  srna = RNA_def_struct(brna, "VertexFloatProperties", NULL);
2626  RNA_def_struct_sdna(srna, "Mesh");
2627  RNA_def_struct_ui_text(srna, "Vertex Float Properties", "Collection of float properties");
2628 
2629  func = RNA_def_function(srna, "new", "rna_Mesh_vertex_float_property_new");
2630  RNA_def_function_ui_description(func, "Add a float property layer to Mesh");
2631  RNA_def_string(func, "name", "Float Prop", 0, "", "Float property name");
2632  parm = RNA_def_pointer(
2633  func, "layer", "MeshVertexFloatPropertyLayer", "", "The newly created layer");
2635  RNA_def_function_return(func, parm);
2636 }
2637 
2638 /* mesh int layers */
2640 {
2641  StructRNA *srna;
2642 
2643  FunctionRNA *func;
2644  PropertyRNA *parm;
2645 
2646  RNA_def_property_srna(cprop, "VertexIntProperties");
2647  srna = RNA_def_struct(brna, "VertexIntProperties", NULL);
2648  RNA_def_struct_sdna(srna, "Mesh");
2649  RNA_def_struct_ui_text(srna, "Vertex Int Properties", "Collection of int properties");
2650 
2651  func = RNA_def_function(srna, "new", "rna_Mesh_vertex_int_property_new");
2652  RNA_def_function_ui_description(func, "Add a integer property layer to Mesh");
2653  RNA_def_string(func, "name", "Int Prop", 0, "", "Int property name");
2654  parm = RNA_def_pointer(
2655  func, "layer", "MeshVertexIntPropertyLayer", "", "The newly created layer");
2657  RNA_def_function_return(func, parm);
2658 }
2659 
2660 /* mesh string layers */
2662 {
2663  StructRNA *srna;
2664 
2665  FunctionRNA *func;
2666  PropertyRNA *parm;
2667 
2668  RNA_def_property_srna(cprop, "VertexStringProperties");
2669  srna = RNA_def_struct(brna, "VertexStringProperties", NULL);
2670  RNA_def_struct_sdna(srna, "Mesh");
2671  RNA_def_struct_ui_text(srna, "Vertex String Properties", "Collection of string properties");
2672 
2673  func = RNA_def_function(srna, "new", "rna_Mesh_vertex_string_property_new");
2674  RNA_def_function_ui_description(func, "Add a string property layer to Mesh");
2675  RNA_def_string(func, "name", "String Prop", 0, "", "String property name");
2676  parm = RNA_def_pointer(
2677  func, "layer", "MeshVertexStringPropertyLayer", "", "The newly created layer");
2679  RNA_def_function_return(func, parm);
2680 }
2681 
2682 /* mesh float layers */
2684 {
2685  StructRNA *srna;
2686 
2687  FunctionRNA *func;
2688  PropertyRNA *parm;
2689 
2690  RNA_def_property_srna(cprop, "PolygonFloatProperties");
2691  srna = RNA_def_struct(brna, "PolygonFloatProperties", NULL);
2692  RNA_def_struct_sdna(srna, "Mesh");
2693  RNA_def_struct_ui_text(srna, "Polygon Float Properties", "Collection of float properties");
2694 
2695  func = RNA_def_function(srna, "new", "rna_Mesh_polygon_float_property_new");
2696  RNA_def_function_ui_description(func, "Add a float property layer to Mesh");
2697  RNA_def_string(func, "name", "Float Prop", 0, "", "Float property name");
2698  parm = RNA_def_pointer(
2699  func, "layer", "MeshPolygonFloatPropertyLayer", "", "The newly created layer");
2701  RNA_def_function_return(func, parm);
2702 }
2703 
2704 /* mesh int layers */
2706 {
2707  StructRNA *srna;
2708 
2709  FunctionRNA *func;
2710  PropertyRNA *parm;
2711 
2712  RNA_def_property_srna(cprop, "PolygonIntProperties");
2713  srna = RNA_def_struct(brna, "PolygonIntProperties", NULL);
2714  RNA_def_struct_sdna(srna, "Mesh");
2715  RNA_def_struct_ui_text(srna, "Polygon Int Properties", "Collection of int properties");
2716 
2717  func = RNA_def_function(srna, "new", "rna_Mesh_polygon_int_property_new");
2718  RNA_def_function_ui_description(func, "Add a integer property layer to Mesh");
2719  RNA_def_string(func, "name", "Int Prop", 0, "", "Int property name");
2720  parm = RNA_def_pointer(
2721  func, "layer", "MeshPolygonIntPropertyLayer", "", "The newly created layer");
2723  RNA_def_function_return(func, parm);
2724 }
2725 
2726 /* mesh string layers */
2728 {
2729  StructRNA *srna;
2730 
2731  FunctionRNA *func;
2732  PropertyRNA *parm;
2733 
2734  RNA_def_property_srna(cprop, "PolygonStringProperties");
2735  srna = RNA_def_struct(brna, "PolygonStringProperties", NULL);
2736  RNA_def_struct_sdna(srna, "Mesh");
2737  RNA_def_struct_ui_text(srna, "Polygon String Properties", "Collection of string properties");
2738 
2739  func = RNA_def_function(srna, "new", "rna_Mesh_polygon_string_property_new");
2740  RNA_def_function_ui_description(func, "Add a string property layer to Mesh");
2741  RNA_def_string(func, "name", "String Prop", 0, "", "String property name");
2742  parm = RNA_def_pointer(
2743  func, "layer", "MeshPolygonStringPropertyLayer", "", "The newly created layer");
2745  RNA_def_function_return(func, parm);
2746 }
2747 
2749 {
2750  StructRNA *srna;
2751  PropertyRNA *prop;
2752 
2753  srna = RNA_def_struct(brna, "MeshSkinVertexLayer", NULL);
2755  srna, "Mesh Skin Vertex Layer", "Per-vertex skin data for use with the Skin modifier");
2756  RNA_def_struct_sdna(srna, "CustomDataLayer");
2757  RNA_def_struct_path_func(srna, "rna_MeshSkinVertexLayer_path");
2758 
2759  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2760  RNA_def_struct_name_property(srna, prop);
2761  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshVertexLayer_name_set");
2762  RNA_def_property_ui_text(prop, "Name", "Name of skin layer");
2763  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2764 
2765  prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
2766  RNA_def_property_struct_type(prop, "MeshSkinVertex");
2767  RNA_def_property_ui_text(prop, "Data", "");
2769  "rna_MeshSkinVertexLayer_data_begin",
2770  "rna_iterator_array_next",
2771  "rna_iterator_array_end",
2772  "rna_iterator_array_get",
2773  "rna_MeshSkinVertexLayer_data_length",
2774  NULL,
2775  NULL,
2776  NULL);
2777 
2778  /* SkinVertex struct */
2779  srna = RNA_def_struct(brna, "MeshSkinVertex", NULL);
2780  RNA_def_struct_sdna(srna, "MVertSkin");
2782  srna, "Skin Vertex", "Per-vertex skin data for use with the Skin modifier");
2783  RNA_def_struct_path_func(srna, "rna_MeshSkinVertex_path");
2784 
2785  prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_UNSIGNED);
2786  RNA_def_property_array(prop, 2);
2787  RNA_def_property_ui_range(prop, 0.001, 100.0, 1, 3);
2788  RNA_def_property_ui_text(prop, "Radius", "Radius of the skin");
2789  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2790 
2791  /* Flags */
2792 
2793  prop = RNA_def_property(srna, "use_root", PROP_BOOLEAN, PROP_NONE);
2796  "Root",
2797  "Vertex is a root for rotation calculations and armature generation, "
2798  "setting this flag does not clear other roots in the same mesh island");
2799  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2800 
2801  prop = RNA_def_property(srna, "use_loose", PROP_BOOLEAN, PROP_NONE);
2804  prop, "Loose", "If vertex has multiple adjacent edges, it is hulled to them directly");
2805  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2806 }
2807 
2809 {
2810  StructRNA *srna;
2811  PropertyRNA *prop;
2812 
2813  srna = RNA_def_struct(brna, "MeshPaintMaskLayer", NULL);
2814  RNA_def_struct_ui_text(srna, "Mesh Paint Mask Layer", "Per-vertex paint mask data");
2815  RNA_def_struct_sdna(srna, "CustomDataLayer");
2816  RNA_def_struct_path_func(srna, "rna_MeshPaintMaskLayer_path");
2817 
2818  prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
2819  RNA_def_property_struct_type(prop, "MeshPaintMaskProperty");
2820  RNA_def_property_ui_text(prop, "Data", "");
2821 
2823  "rna_MeshPaintMaskLayer_data_begin",
2824  "rna_iterator_array_next",
2825  "rna_iterator_array_end",
2826  "rna_iterator_array_get",
2827  "rna_MeshPaintMaskLayer_data_length",
2828  NULL,
2829  NULL,
2830  NULL);
2831 
2832  srna = RNA_def_struct(brna, "MeshPaintMaskProperty", NULL);
2833  RNA_def_struct_sdna(srna, "MFloatProperty");
2834  RNA_def_struct_ui_text(srna, "Mesh Paint Mask Property", "Floating-point paint mask value");
2835  RNA_def_struct_path_func(srna, "rna_MeshPaintMask_path");
2836 
2837  prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
2838  RNA_def_property_float_sdna(prop, NULL, "f");
2839  RNA_def_property_ui_text(prop, "Value", "");
2840  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2841 }
2842 
2843 static void rna_def_face_map(BlenderRNA *brna)
2844 {
2845  StructRNA *srna;
2846  PropertyRNA *prop;
2847 
2848  srna = RNA_def_struct(brna, "MeshFaceMapLayer", NULL);
2849  RNA_def_struct_ui_text(srna, "Mesh Face Map Layer", "Per-face map index");
2850  RNA_def_struct_sdna(srna, "CustomDataLayer");
2851  RNA_def_struct_path_func(srna, "rna_MeshFaceMapLayer_path");
2852 
2853  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2854  RNA_def_struct_name_property(srna, prop);
2855  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshPolyLayer_name_set");
2856  RNA_def_property_ui_text(prop, "Name", "Name of face map layer");
2857  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2858 
2859  prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
2860  RNA_def_property_struct_type(prop, "MeshFaceMap");
2861  RNA_def_property_ui_text(prop, "Data", "");
2863  "rna_MeshFaceMapLayer_data_begin",
2864  "rna_iterator_array_next",
2865  "rna_iterator_array_end",
2866  "rna_iterator_array_get",
2867  "rna_MeshFaceMapLayer_data_length",
2868  NULL,
2869  NULL,
2870  NULL);
2871 
2872  /* FaceMap struct */
2873  srna = RNA_def_struct(brna, "MeshFaceMap", NULL);
2874  RNA_def_struct_sdna(srna, "MIntProperty");
2875  RNA_def_struct_ui_text(srna, "Int Property", "");
2876  RNA_def_struct_path_func(srna, "rna_MeshFaceMap_path");
2877 
2878  prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
2879  RNA_def_property_int_sdna(prop, NULL, "i");
2880  RNA_def_property_ui_text(prop, "Value", "");
2881  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2882 }
2883 
2884 static void rna_def_face_maps(BlenderRNA *brna, PropertyRNA *cprop)
2885 {
2886  StructRNA *srna;
2887  PropertyRNA *prop;
2888 
2889  RNA_def_property_srna(cprop, "MeshFaceMapLayers");
2890  srna = RNA_def_struct(brna, "MeshFaceMapLayers", NULL);
2891  RNA_def_struct_ui_text(srna, "Mesh Face Map Layer", "Per-face map index");
2892  RNA_def_struct_sdna(srna, "Mesh");
2893  RNA_def_struct_ui_text(srna, "Mesh Face Maps", "Collection of mesh face maps");
2894 
2895  /* add this since we only ever have one layer anyway, don't bother with active_index */
2896  prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2897  RNA_def_property_struct_type(prop, "MeshFaceMapLayer");
2898  RNA_def_property_pointer_funcs(prop, "rna_Mesh_face_map_active_get", NULL, NULL, NULL);
2899  RNA_def_property_ui_text(prop, "Active Face Map Layer", "");
2900  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
2901 
2902  FunctionRNA *func;
2903  PropertyRNA *parm;
2904 
2905  func = RNA_def_function(srna, "new", "rna_Mesh_face_map_new");
2907  RNA_def_function_ui_description(func, "Add a float property layer to Mesh");
2908  RNA_def_string(func, "name", "Face Map", 0, "", "Face map name");
2909  parm = RNA_def_pointer(func, "layer", "MeshFaceMapLayer", "", "The newly created layer");
2911  RNA_def_function_return(func, parm);
2912 
2913  func = RNA_def_function(srna, "remove", "rna_Mesh_face_map_remove");
2914  RNA_def_function_ui_description(func, "Remove a face map layer");
2916  parm = RNA_def_pointer(func, "layer", "MeshFaceMapLayer", "", "The layer to remove");
2919 }
2920 
2921 static void rna_def_mesh(BlenderRNA *brna)
2922 {
2923  StructRNA *srna;
2924  PropertyRNA *prop;
2925 
2926  srna = RNA_def_struct(brna, "Mesh", "ID");
2927  RNA_def_struct_ui_text(srna, "Mesh", "Mesh data-block defining geometric surfaces");
2928  RNA_def_struct_ui_icon(srna, ICON_MESH_DATA);
2929 
2930  prop = RNA_def_property(srna, "vertices", PROP_COLLECTION, PROP_NONE);
2931  RNA_def_property_collection_sdna(prop, NULL, "mvert", "totvert");
2932  RNA_def_property_struct_type(prop, "MeshVertex");
2934  RNA_def_property_ui_text(prop, "Vertices", "Vertices of the mesh");
2935  rna_def_mesh_vertices(brna, prop);
2936 
2937  prop = RNA_def_property(srna, "edges", PROP_COLLECTION, PROP_NONE);
2938  RNA_def_property_collection_sdna(prop, NULL, "medge", "totedge");
2939  RNA_def_property_struct_type(prop, "MeshEdge");
2941  RNA_def_property_ui_text(prop, "Edges", "Edges of the mesh");
2942  rna_def_mesh_edges(brna, prop);
2943 
2944  prop = RNA_def_property(srna, "loops", PROP_COLLECTION, PROP_NONE);
2945  RNA_def_property_collection_sdna(prop, NULL, "mloop", "totloop");
2946  RNA_def_property_struct_type(prop, "MeshLoop");
2948  RNA_def_property_ui_text(prop, "Loops", "Loops of the mesh (polygon corners)");
2949  rna_def_mesh_loops(brna, prop);
2950 
2951  prop = RNA_def_property(srna, "polygons", PROP_COLLECTION, PROP_NONE);
2952  RNA_def_property_collection_sdna(prop, NULL, "mpoly", "totpoly");
2953  RNA_def_property_struct_type(prop, "MeshPolygon");
2955  RNA_def_property_ui_text(prop, "Polygons", "Polygons of the mesh");
2956  rna_def_mesh_polygons(brna, prop);
2957 
2958  prop = RNA_def_property(srna, "loop_triangles", PROP_COLLECTION, PROP_NONE);
2959  RNA_def_property_collection_sdna(prop, NULL, "runtime.looptris.array", "runtime.looptris.len");
2960  RNA_def_property_struct_type(prop, "MeshLoopTriangle");
2962  RNA_def_property_ui_text(prop, "Loop Triangles", "Tessellation of mesh polygons into triangles");
2963  rna_def_mesh_looptris(brna, prop);
2964 
2965  /* TODO, should this be allowed to be its self? */
2966  prop = RNA_def_property(srna, "texture_mesh", PROP_POINTER, PROP_NONE);
2967  RNA_def_property_pointer_sdna(prop, NULL, "texcomesh");
2971  prop,
2972  "Texture Mesh",
2973  "Use another mesh for texture indices (vertex indices must be aligned)");
2974 
2975  /* UV loop layers */
2976  prop = RNA_def_property(srna, "uv_layers", PROP_COLLECTION, PROP_NONE);
2977  RNA_def_property_collection_sdna(prop, NULL, "ldata.layers", "ldata.totlayer");
2979  "rna_Mesh_uv_layers_begin",
2980  NULL,
2981  NULL,
2982  NULL,
2983  "rna_Mesh_uv_layers_length",
2984  NULL,
2985  NULL,
2986  NULL);
2987  RNA_def_property_struct_type(prop, "MeshUVLoopLayer");
2989  RNA_def_property_ui_text(prop, "UV Loop Layers", "All UV loop layers");
2990  rna_def_uv_layers(brna, prop);
2991 
2992  prop = RNA_def_property(srna, "uv_layer_clone", PROP_POINTER, PROP_NONE);
2993  RNA_def_property_struct_type(prop, "MeshUVLoopLayer");
2995  prop, "rna_Mesh_uv_layer_clone_get", "rna_Mesh_uv_layer_clone_set", NULL, NULL);
2998  prop, "Clone UV Loop Layer", "UV loop layer to be used as cloning source");
2999 
3000  prop = RNA_def_property(srna, "uv_layer_clone_index", PROP_INT, PROP_UNSIGNED);
3002  "rna_Mesh_uv_layer_clone_index_get",
3003  "rna_Mesh_uv_layer_clone_index_set",
3004  "rna_Mesh_uv_layer_index_range");
3005  RNA_def_property_ui_text(prop, "Clone UV Loop Layer Index", "Clone UV loop layer index");
3006 
3007  prop = RNA_def_property(srna, "uv_layer_stencil", PROP_POINTER, PROP_NONE);
3008  RNA_def_property_struct_type(prop, "MeshUVLoopLayer");
3010  prop, "rna_Mesh_uv_layer_stencil_get", "rna_Mesh_uv_layer_stencil_set", NULL, NULL);
3012  RNA_def_property_ui_text(prop, "Mask UV Loop Layer", "UV loop layer to mask the painted area");
3013 
3014  prop = RNA_def_property(srna, "uv_layer_stencil_index", PROP_INT, PROP_UNSIGNED);
3016  "rna_Mesh_uv_layer_stencil_index_get",
3017  "rna_Mesh_uv_layer_stencil_index_set",
3018  "rna_Mesh_uv_layer_index_range");
3019  RNA_def_property_ui_text(prop, "Mask UV Loop Layer Index", "Mask UV loop layer index");
3020  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
3021 
3022  /* Vertex colors */
3023 
3024  prop = RNA_def_property(srna, "vertex_colors", PROP_COLLECTION, PROP_NONE);
3025  RNA_def_property_collection_sdna(prop, NULL, "ldata.layers", "ldata.totlayer");
3027  "rna_Mesh_vertex_colors_begin",
3028  NULL,
3029  NULL,
3030  NULL,
3031  "rna_Mesh_vertex_colors_length",
3032  NULL,
3033  NULL,
3034  NULL);
3035  RNA_def_property_struct_type(prop, "MeshLoopColorLayer");
3037  RNA_def_property_ui_text(prop, "Vertex Colors", "All vertex colors");
3038  rna_def_loop_colors(brna, prop);
3039 
3040  /* Sculpt Vertex colors */
3041 
3042  prop = RNA_def_property(srna, "sculpt_vertex_colors", PROP_COLLECTION, PROP_NONE);
3043  RNA_def_property_collection_sdna(prop, NULL, "vdata.layers", "vdata.totlayer");
3045  "rna_Mesh_sculpt_vertex_colors_begin",
3046  NULL,
3047  NULL,
3048  NULL,
3049  "rna_Mesh_sculpt_vertex_colors_length",
3050  NULL,
3051  NULL,
3052  NULL);
3053  RNA_def_property_struct_type(prop, "MeshVertColorLayer");
3054  RNA_def_property_ui_text(prop, "Sculpt Vertex Colors", "All vertex colors");
3055  rna_def_vert_colors(brna, prop);
3056 
3057  /* TODO, edge customdata layers (bmesh py api can access already) */
3058  prop = RNA_def_property(srna, "vertex_layers_float", PROP_COLLECTION, PROP_NONE);
3059  RNA_def_property_collection_sdna(prop, NULL, "vdata.layers", "vdata.totlayer");
3061  "rna_Mesh_vertex_float_layers_begin",
3062  NULL,
3063  NULL,
3064  NULL,
3065  "rna_Mesh_vertex_float_layers_length",
3066  NULL,
3067  NULL,
3068  NULL);
3069  RNA_def_property_struct_type(prop, "MeshVertexFloatPropertyLayer");
3071  RNA_def_property_ui_text(prop, "Float Property Layers", "");
3072  rna_def_vertex_float_layers(brna, prop);
3073 
3074  prop = RNA_def_property(srna, "vertex_layers_int", PROP_COLLECTION, PROP_NONE);
3075  RNA_def_property_collection_sdna(prop, NULL, "vdata.layers", "vdata.totlayer");
3077  "rna_Mesh_vertex_int_layers_begin",
3078  NULL,
3079  NULL,
3080  NULL,
3081  "rna_Mesh_vertex_int_layers_length",
3082  NULL,
3083  NULL,
3084  NULL);
3085  RNA_def_property_struct_type(prop, "MeshVertexIntPropertyLayer");
3087  RNA_def_property_ui_text(prop, "Int Property Layers", "");
3088  rna_def_vertex_int_layers(brna, prop);
3089 
3090  prop = RNA_def_property(srna, "vertex_layers_string", PROP_COLLECTION, PROP_NONE);
3091  RNA_def_property_collection_sdna(prop, NULL, "vdata.layers", "vdata.totlayer");
3093  "rna_Mesh_vertex_string_layers_begin",
3094  NULL,
3095  NULL,
3096  NULL,
3097  "rna_Mesh_vertex_string_layers_length",
3098  NULL,
3099  NULL,
3100  NULL);
3101  RNA_def_property_struct_type(prop, "MeshVertexStringPropertyLayer");
3103  RNA_def_property_ui_text(prop, "String Property Layers", "");
3104  rna_def_vertex_string_layers(brna, prop);
3105 
3106  prop = RNA_def_property(srna, "polygon_layers_float", PROP_COLLECTION, PROP_NONE);
3107  RNA_def_property_collection_sdna(prop, NULL, "pdata.layers", "pdata.totlayer");
3109  "rna_Mesh_polygon_float_layers_begin",
3110  NULL,
3111  NULL,
3112  NULL,
3113  "rna_Mesh_polygon_float_layers_length",
3114  NULL,
3115  NULL,
3116  NULL);
3117  RNA_def_property_struct_type(prop, "MeshPolygonFloatPropertyLayer");
3119  RNA_def_property_ui_text(prop, "Float Property Layers", "");
3120  rna_def_polygon_float_layers(brna, prop);
3121 
3122  prop = RNA_def_property(srna, "polygon_layers_int", PROP_COLLECTION, PROP_NONE);
3123  RNA_def_property_collection_sdna(prop, NULL, "pdata.layers", "pdata.totlayer");
3125  "rna_Mesh_polygon_int_layers_begin",
3126  NULL,
3127  NULL,
3128  NULL,
3129  "rna_Mesh_polygon_int_layers_length",
3130  NULL,
3131  NULL,
3132  NULL);
3133  RNA_def_property_struct_type(prop, "MeshPolygonIntPropertyLayer");
3135  RNA_def_property_ui_text(prop, "Int Property Layers", "");
3136  rna_def_polygon_int_layers(brna, prop);
3137 
3138  prop = RNA_def_property(srna, "polygon_layers_string", PROP_COLLECTION, PROP_NONE);
3139  RNA_def_property_collection_sdna(prop, NULL, "pdata.layers", "pdata.totlayer");
3141  "rna_Mesh_polygon_string_layers_begin",
3142  NULL,
3143  NULL,
3144  NULL,
3145  "rna_Mesh_polygon_string_layers_length",
3146  NULL,
3147  NULL,
3148  NULL);
3149  RNA_def_property_struct_type(prop, "MeshPolygonStringPropertyLayer");
3151  RNA_def_property_ui_text(prop, "String Property Layers", "");
3152  rna_def_polygon_string_layers(brna, prop);
3153 
3154  /* face-maps */
3155  prop = RNA_def_property(srna, "face_maps", PROP_COLLECTION, PROP_NONE);
3156  RNA_def_property_collection_sdna(prop, NULL, "pdata.layers", "pdata.totlayer");
3158  "rna_Mesh_face_maps_begin",
3159  NULL,
3160  NULL,
3161  NULL,
3162  "rna_Mesh_face_maps_length",
3163  NULL,
3164  NULL,
3165  NULL);
3166  RNA_def_property_struct_type(prop, "MeshFaceMapLayer");
3168  RNA_def_property_ui_text(prop, "Face Map", "");
3169  rna_def_face_maps(brna, prop);
3170 
3171  /* Skin vertices */
3172  prop = RNA_def_property(srna, "skin_vertices", PROP_COLLECTION, PROP_NONE);
3173  RNA_def_property_collection_sdna(prop, NULL, "vdata.layers", "vdata.totlayer");
3175  "rna_Mesh_skin_vertices_begin",
3176  NULL,
3177  NULL,
3178  NULL,
3179  "rna_Mesh_skin_vertices_length",
3180  NULL,
3181  NULL,
3182  NULL);
3183  RNA_def_property_struct_type(prop, "MeshSkinVertexLayer");
3185  RNA_def_property_ui_text(prop, "Skin Vertices", "All skin vertices");
3186  rna_def_skin_vertices(brna, prop);
3187  /* End skin vertices */
3188 
3189  /* Paint mask */
3190  prop = RNA_def_property(srna, "vertex_paint_masks", PROP_COLLECTION, PROP_NONE);
3191  RNA_def_property_collection_sdna(prop, NULL, "vdata.layers", "vdata.totlayer");
3193  "rna_Mesh_vertex_paint_masks_begin",
3194  NULL,
3195  NULL,
3196  NULL,
3197  "rna_Mesh_vertex_paint_masks_length",
3198  NULL,
3199  NULL,
3200  NULL);
3201  RNA_def_property_struct_type(prop, "MeshPaintMaskLayer");
3203  RNA_def_property_ui_text(prop, "Vertex Paint Mask", "Vertex paint mask");
3204  rna_def_paint_mask(brna, prop);
3205  /* End paint mask */
3206 
3207  /* Attributes */
3209 
3210  /* Remesh */
3211  prop = RNA_def_property(srna, "remesh_voxel_size", PROP_FLOAT, PROP_DISTANCE);
3212  RNA_def_property_float_sdna(prop, NULL, "remesh_voxel_size");
3213  RNA_def_property_range(prop, 0.0001f, FLT_MAX);
3214  RNA_def_property_ui_range(prop, 0.0001f, FLT_MAX, 0.01, 4);
3216  "Voxel Size",
3217  "Size of the voxel in object space used for volume evaluation. Lower "
3218  "values preserve finer details");
3219  RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
3220 
3221  prop = RNA_def_property(srna, "remesh_voxel_adaptivity", PROP_FLOAT, PROP_DISTANCE);
3222  RNA_def_property_float_sdna(prop, NULL, "remesh_voxel_adaptivity");
3223  RNA_def_property_range(prop, 0.0f, 1.0f);
3224  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 4);
3226  prop,
3227  "Adaptivity",
3228  "Reduces the final face count by simplifying geometry where detail is not needed, "
3229  "generating triangles. A value greater than 0 disables Fix Poles");
3230  RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
3231 
3232  prop = RNA_def_property(srna, "use_remesh_smooth_normals", PROP_BOOLEAN, PROP_NONE);
3234  RNA_def_property_ui_text(prop, "Smooth Normals", "Smooth the normals of the remesher result");
3235  RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
3236 
3237  prop = RNA_def_property(srna, "use_remesh_fix_poles", PROP_BOOLEAN, PROP_NONE);
3239  RNA_def_property_ui_text(prop, "Fix Poles", "Produces less poles and a better topology flow");
3240  RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
3241 
3242  prop = RNA_def_property(srna, "use_remesh_preserve_volume", PROP_BOOLEAN, PROP_NONE);
3245  prop,
3246  "Preserve Volume",
3247  "Projects the mesh to preserve the volume and details of the original mesh");
3248  RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
3249 
3250  prop = RNA_def_property(srna, "use_remesh_preserve_paint_mask", PROP_BOOLEAN, PROP_NONE);
3252  RNA_def_property_boolean_default(prop, false);
3253  RNA_def_property_ui_text(prop, "Preserve Paint Mask", "Keep the current mask on the new mesh");
3254  RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
3255 
3256  prop = RNA_def_property(srna, "use_remesh_preserve_sculpt_face_sets", PROP_BOOLEAN, PROP_NONE);
3258  RNA_def_property_boolean_default(prop, false);
3260  prop, "Preserve Face Sets", "Keep the current Face Sets on the new mesh");
3261  RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
3262 
3263  prop = RNA_def_property(srna, "use_remesh_preserve_vertex_colors", PROP_BOOLEAN, PROP_NONE);
3265  RNA_def_property_boolean_default(prop, false);
3267  prop, "Preserve Vertex Colors", "Keep the current vertex colors on the new mesh");
3268  RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
3269 
3270  prop = RNA_def_property(srna, "remesh_mode", PROP_ENUM, PROP_NONE);
3271  RNA_def_property_enum_sdna(prop, NULL, "remesh_mode");
3273  RNA_def_property_ui_text(prop, "Remesh Mode", "");
3274  RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
3275 
3276  /* End remesh */
3277 
3278  /* Symmetry */
3279  prop = RNA_def_property(srna, "use_mirror_x", PROP_BOOLEAN, PROP_NONE);
3280  RNA_def_property_boolean_sdna(prop, NULL, "symmetry", ME_SYMMETRY_X);
3281  RNA_def_property_ui_text(prop, "X", "Enable symmetry in the X axis");
3282  RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
3283 
3284  prop = RNA_def_property(srna, "use_mirror_y", PROP_BOOLEAN, PROP_NONE);
3285  RNA_def_property_boolean_sdna(prop, NULL, "symmetry", ME_SYMMETRY_Y);
3286  RNA_def_property_ui_text(prop, "Y", "Enable symmetry in the Y axis");
3287  RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
3288 
3289  prop = RNA_def_property(srna, "use_mirror_z", PROP_BOOLEAN, PROP_NONE);
3290  RNA_def_property_boolean_sdna(prop, NULL, "symmetry", ME_SYMMETRY_Z);
3291  RNA_def_property_ui_text(prop, "Z", "Enable symmetry in the Z axis");
3292  RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
3293 
3294  prop = RNA_def_property(srna, "use_mirror_vertex_groups", PROP_BOOLEAN, PROP_NONE);
3297  "Mirror Vertex Groups",
3298  "Mirror the left/right vertex groups when painting. The symmetry axis "
3299  "is determined by the symmetry settings");
3300  RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
3301  /* End Symmetry */
3302 
3303  prop = RNA_def_property(srna, "use_auto_smooth", PROP_BOOLEAN, PROP_NONE);
3306  prop,
3307  "Auto Smooth",
3308  "Auto smooth (based on smooth/sharp faces/edges and angle between faces), "
3309  "or use custom split normals data if available");
3310  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
3311 
3312  prop = RNA_def_property(srna, "auto_smooth_angle", PROP_FLOAT, PROP_ANGLE);
3313  RNA_def_property_float_sdna(prop, NULL, "smoothresh");
3314  RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
3316  "Auto Smooth Angle",
3317  "Maximum angle between face normals that will be considered as smooth "
3318  "(unused if custom split normals data are available)");
3319  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
3320 
3321  RNA_define_verify_sdna(false);
3322  prop = RNA_def_property(srna, "has_custom_normals", PROP_BOOLEAN, PROP_NONE);
3323  RNA_def_property_boolean_sdna(prop, NULL, "", 0);
3326  prop, "Has Custom Normals", "True if there are custom split normals data in this mesh");
3327  RNA_def_property_boolean_funcs(prop, "rna_Mesh_has_custom_normals_get", NULL);
3328  RNA_define_verify_sdna(true);
3329 
3330  prop = RNA_def_property(srna, "texco_mesh", PROP_POINTER, PROP_NONE);
3331  RNA_def_property_pointer_sdna(prop, NULL, "texcomesh");
3335  prop, "Texture Space Mesh", "Derive texture coordinates from another mesh");
3336 
3337  prop = RNA_def_property(srna, "shape_keys", PROP_POINTER, PROP_NONE);
3338  RNA_def_property_pointer_sdna(prop, NULL, "key");
3341  RNA_def_property_ui_text(prop, "Shape Keys", "");
3342 
3343  /* texture space */
3344  prop = RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE);
3345  RNA_def_property_boolean_sdna(prop, NULL, "texflag", ME_AUTOSPACE);
3347  prop,
3348  "Auto Texture Space",
3349  "Adjust active object's texture space automatically when transforming object");
3350  RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
3351 
3352 # if 0
3353  prop = RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION);
3354  RNA_def_property_array(prop, 3);
3355  RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location");
3356  RNA_def_property_editable_func(prop, "rna_Mesh_texspace_editable");
3358  prop, "rna_Mesh_texspace_loc_get", "rna_Mesh_texspace_loc_set", NULL);
3359  RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
3360 # endif
3361 
3362  /* editflag */
3363  prop = RNA_def_property(srna, "use_mirror_topology", PROP_BOOLEAN, PROP_NONE);
3366  "Topology Mirror",
3367  "Use topology based mirroring "
3368  "(for when both sides of mesh have matching, unique topology)");
3369 
3370  prop = RNA_def_property(srna, "use_paint_mask", PROP_BOOLEAN, PROP_NONE);
3372  RNA_def_property_ui_text(prop, "Paint Mask", "Face selection masking for painting");
3373  RNA_def_property_ui_icon(prop, ICON_FACESEL, 0);
3374  RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_Mesh_update_facemask");
3375 
3376  prop = RNA_def_property(srna, "use_paint_mask_vertex", PROP_BOOLEAN, PROP_NONE);
3378  RNA_def_property_ui_text(prop, "Vertex Selection", "Vertex selection masking for painting");
3379  RNA_def_property_ui_icon(prop, ICON_VERTEXSEL, 0);
3380  RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_Mesh_update_vertmask");
3381 
3382  /* customdata flags */
3383  prop = RNA_def_property(srna, "use_customdata_vertex_bevel", PROP_BOOLEAN, PROP_NONE);
3385  RNA_def_property_ui_text(prop, "Store Vertex Bevel Weight", "");
3386 
3387  prop = RNA_def_property(srna, "use_customdata_edge_bevel", PROP_BOOLEAN, PROP_NONE);
3389  RNA_def_property_ui_text(prop, "Store Edge Bevel Weight", "");
3390 
3391  prop = RNA_def_property(srna, "use_customdata_edge_crease", PROP_BOOLEAN, PROP_NONE);
3393  RNA_def_property_ui_text(prop, "Store Edge Crease", "");
3394 
3395  /* readonly editmesh info - use for extrude menu */
3396  prop = RNA_def_property(srna, "total_vert_sel", PROP_INT, PROP_UNSIGNED);
3397  RNA_def_property_int_funcs(prop, "rna_Mesh_tot_vert_get", NULL, NULL);
3398  RNA_def_property_ui_text(prop, "Selected Vertex Total", "Selected vertex count in editmode");
3400 
3401  prop = RNA_def_property(srna, "total_edge_sel", PROP_INT, PROP_UNSIGNED);
3402  RNA_def_property_int_funcs(prop, "rna_Mesh_tot_edge_get", NULL, NULL);
3403  RNA_def_property_ui_text(prop, "Selected Edge Total", "Selected edge count in editmode");
3405 
3406  prop = RNA_def_property(srna, "total_face_sel", PROP_INT, PROP_UNSIGNED);
3407  RNA_def_property_int_funcs(prop, "rna_Mesh_tot_face_get", NULL, NULL);
3408  RNA_def_property_ui_text(prop, "Selected Face Total", "Selected face count in editmode");
3410 
3411  prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
3412  RNA_def_property_boolean_funcs(prop, "rna_Mesh_is_editmode_get", NULL);
3414  RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");
3415 
3416  /* pointers */
3418  rna_def_texmat_common(srna, "rna_Mesh_texspace_editable");
3419 
3420  RNA_api_mesh(srna);
3421 }
3422 
3424 {
3425  rna_def_mesh(brna);
3426  rna_def_mvert(brna);
3427  rna_def_mvert_group(brna);
3428  rna_def_medge(brna);
3429  rna_def_mlooptri(brna);
3430  rna_def_mloop(brna);
3431  rna_def_mpolygon(brna);
3432  rna_def_mloopuv(brna);
3433  rna_def_mloopcol(brna);
3434  rna_def_MPropCol(brna);
3435  rna_def_mproperties(brna);
3436  rna_def_face_map(brna);
3437 }
3438 
3439 #endif
typedef float(TangentPoint)[2]
CustomData interface, see also DNA_customdata_types.h.
int CustomData_get_active_layer_index(const struct CustomData *data, int type)
int CustomData_number_of_layers(const struct CustomData *data, int type)
void CustomData_set_layer_active(struct CustomData *data, int type, int n)
Definition: customdata.c:2401
@ CD_CALLOC
int CustomData_get_render_layer_index(const struct CustomData *data, int type)
void CustomData_set_layer_unique_name(struct CustomData *data, int index)
Definition: customdata.c:4361
int CustomData_get_layer_index_n(const struct CustomData *data, int type, int n)
Definition: customdata.c:2308
void CustomData_set_layer_render(struct CustomData *data, int type, int n)
Definition: customdata.c:2410
void CustomData_set_layer_clone_index(struct CustomData *data, int type, int n)
Definition: customdata.c:2457
int CustomData_get_layer_index(const struct CustomData *data, int type)
void * CustomData_get_layer(const struct CustomData *data, int type)
int CustomData_sizeof(int type)
Definition: customdata.c:4277
int CustomData_get_clone_layer_index(const struct CustomData *data, int type)
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
Definition: customdata.c:2620
void * CustomData_get(const struct CustomData *data, int index, int type)
bool BKE_mesh_clear_facemap_customdata(struct Mesh *me)
Definition: mesh.c:732
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_calc_poly_center(const struct MPoly *mpoly, const struct MLoop *loopstart, const struct MVert *mvarray, float r_cent[3])
bool BKE_mesh_ensure_facemap_customdata(struct Mesh *me)
Definition: mesh.c:713
void BKE_mesh_calc_poly_normal(const struct MPoly *mpoly, const struct MLoop *loopstart, const struct MVert *mvarray, float r_no[3])
void BKE_mesh_batch_cache_dirty_tag(struct Mesh *me, eMeshBatchDirtyMode mode)
Definition: mesh_runtime.c:251
void BKE_mesh_update_customdata_pointers(struct Mesh *me, const bool do_ensure_tess_cd)
Definition: mesh.c:766
void BKE_mesh_texspace_ensure(struct Mesh *me)
Definition: mesh.c:1116
void BKE_mesh_texspace_get(struct Mesh *me, float r_loc[3], float r_size[3])
Definition: mesh.c:1123
float BKE_mesh_calc_poly_area(const struct MPoly *mpoly, const struct MLoop *loopstart, const struct MVert *mvarray)
void BKE_mesh_polygon_flip(struct MPoly *mpoly, struct MLoop *mloop, struct CustomData *ldata)
void BKE_mesh_runtime_clear_geometry(struct Mesh *mesh)
Definition: mesh_runtime.c:226
@ BKE_MESH_BATCH_DIRTY_ALL
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_assert(a)
Definition: BLI_assert.h:58
MINLINE int max_ii(int a, int b)
MINLINE unsigned char round_fl_to_uchar_clamp(float a)
float area_tri_v3(const float v1[3], const float v2[3], const float v3[3])
Definition: math_geom.c:116
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
Definition: math_geom.c:51
#define DEG2RADF(_deg)
MINLINE void madd_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3])
MINLINE void normal_float_to_short_v3(short r[3], const float n[3])
MINLINE float normalize_v3(float r[3])
MINLINE void normal_short_to_float_v3(float r[3], const short n[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
size_t size_t char size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, const size_t dst_maxncpy) ATTR_NONNULL()
Definition: string.c:333
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string_utf8.c:258
#define UNUSED_FUNCTION(x)
#define ARRAY_HAS_ITEM(arr_item, arr_start, arr_len)
#define UNUSED(x)
void DEG_id_tag_update(struct ID *id, int flag)
@ CD_FACEMAP
@ CD_MLOOPTANGENT
@ CD_PAINT_MASK
@ CD_MVERT_SKIN
@ CD_PROP_FLOAT
@ CD_PROP_COLOR
@ CD_PROP_INT32
@ CD_MLOOPCOL
@ CD_FREESTYLE_EDGE
@ CD_FREESTYLE_FACE
@ CD_PROP_STRING
@ CD_MLOOPUV
@ REMESH_QUAD
@ REMESH_VOXEL
@ ME_CDFLAG_EDGE_CREASE
@ ME_CDFLAG_VERT_BWEIGHT
@ ME_CDFLAG_EDGE_BWEIGHT
@ ME_REMESH_REPROJECT_VOLUME
@ ME_REMESH_REPROJECT_VERTEX_COLORS
@ ME_REMESH_REPROJECT_SCULPT_FACE_SETS
@ ME_AUTOSMOOTH
@ ME_REMESH_FIX_POLES
@ ME_REMESH_SMOOTH_NORMALS
@ ME_REMESH_REPROJECT_PAINT_MASK
@ ME_SYMMETRY_X
@ ME_SYMMETRY_Y
@ ME_SYMMETRY_Z
@ ME_EDIT_MIRROR_VERTEX_GROUPS
@ ME_EDIT_PAINT_VERT_SEL
@ ME_EDIT_PAINT_FACE_SEL
@ ME_EDIT_MIRROR_TOPO
@ ME_AUTOSPACE
@ FREESTYLE_EDGE_MARK
@ ME_HIDE
@ ME_SEAM
@ ME_LOOSEEDGE
@ ME_SHARP
@ MLOOPUV_PINNED
@ MLOOPUV_VERTSEL
@ FREESTYLE_FACE_MARK
@ MVERT_SKIN_LOOSE
@ MVERT_SKIN_ROOT
@ ME_SMOOTH
@ ME_FACE_SEL
Object is a sort of wrapper for general info.
bool ED_mesh_sculpt_color_remove_named(struct Mesh *me, const char *name)
Definition: mesh_data.c:582
int ED_mesh_color_add(struct Mesh *me, const char *name, const bool active_set, const bool do_init)
Definition: mesh_data.c:382
bool ED_mesh_uv_texture_remove_named(struct Mesh *me, const char *name)
Definition: mesh_data.c:370
bool ED_mesh_color_remove_named(struct Mesh *me, const char *name)
Definition: mesh_data.c:475
int ED_mesh_sculpt_color_add(struct Mesh *me, const char *name, const bool active_set, const bool do_init)
Definition: mesh_data.c:488
int ED_mesh_uv_texture_add(struct Mesh *me, const char *name, const bool active_set, const bool do_init)
Definition: mesh_data.c:257
_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
_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 const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
StructRNA RNA_MeshVertColorLayer
StructRNA RNA_MeshLoopColorLayer
#define RNA_MAX_ARRAY_DIMENSION
Definition: RNA_define.h:42
@ PARM_RNAPTR
Definition: RNA_types.h:339
@ PARM_REQUIRED
Definition: RNA_types.h:337
@ FUNC_USE_REPORTS
Definition: RNA_types.h:578
@ FUNC_USE_SELF_ID
Definition: RNA_types.h:565
@ PROP_FLOAT
Definition: RNA_types.h:75
@ PROP_BOOLEAN
Definition: RNA_types.h:73
@ PROP_ENUM
Definition: RNA_types.h:77
@ PROP_INT
Definition: RNA_types.h:74
@ PROP_STRING
Definition: RNA_types.h:76
@ PROP_POINTER
Definition: RNA_types.h:78
@ PROP_COLLECTION
Definition: RNA_types.h:79
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition: RNA_types.h:297
@ PROPOVERRIDE_IGNORE
Definition: RNA_types.h:317
@ PROP_THICK_WRAP
Definition: RNA_types.h:270
@ PROP_DYNAMIC
Definition: RNA_types.h:275
@ PROP_PROPORTIONAL
Definition: RNA_types.h:209
@ PROP_NEVER_UNLINK
Definition: RNA_types.h:232
@ PROP_EDITABLE
Definition: RNA_types.h:175
@ PROP_NEVER_NULL
Definition: RNA_types.h:225
@ PROP_PTR_NO_OWNERSHIP
Definition: RNA_types.h:242
@ PROP_ID_SELF_CHECK
Definition: RNA_types.h:218
@ PROP_DIRECTION
Definition: RNA_types.h:141
@ PROP_XYZ
Definition: RNA_types.h:148
@ PROP_DISTANCE
Definition: RNA_types.h:135
@ PROP_COLOR
Definition: RNA_types.h:139
@ PROP_ANGLE
Definition: RNA_types.h:132
@ PROP_NONE
Definition: RNA_types.h:113
@ PROP_TRANSLATION
Definition: RNA_types.h:140
@ PROP_UNSIGNED
Definition: RNA_types.h:129
#define NC_GEOM
Definition: WM_types.h:294
#define ND_DATA
Definition: WM_types.h:408
#define ND_SELECT
Definition: WM_types.h:407
#define ND_SPACE_VIEW3D
Definition: WM_types.h:423
#define NC_SPACE
Definition: WM_types.h:293
@ BMO_DELIM_NORMAL
@ BMO_DELIM_MATERIAL
@ BMO_DELIM_SEAM
@ BMO_DELIM_SHARP
@ BMO_DELIM_UV
return(oflags[bm->toolflag_index].f &oflag) !=0
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
Definition: btQuaternion.h:895
#define SELECT
Scene scene
uint nor
static unsigned a[3]
Definition: RandGen.cpp:92
bool active
all scheduled work for the GPU.
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:146
const PointerRNA PointerRNA_NULL
Definition: rna_access.c:71
void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, bool free_ptr, IteratorSkipFunc skip)
Definition: rna_access.c:4875
void rna_def_animdata_common(StructRNA *srna)
void rna_def_attributes_common(StructRNA *srna)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2762
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
Definition: rna_define.c:1212
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
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4159
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
Definition: rna_define.c:2257
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
Definition: rna_define.c:3312
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4302
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3153
void RNA_define_verify_sdna(bool verify)
Definition: rna_define.c:751
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1676
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
Definition: rna_define.c:1684
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4262
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
Definition: rna_define.c:3462
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
Definition: rna_define.c:3408
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1259
void RNA_def_property_boolean_default(PropertyRNA *prop, bool value)
Definition: rna_define.c:1957
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
Definition: rna_define.c:2971
void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength)
Definition: rna_define.c:2953
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
Definition: rna_define.c:1629
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
Definition: rna_define.c:1892
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
Definition: rna_define.c:1067
void RNA_def_property_array(PropertyRNA *prop, int length)
Definition: rna_define.c:1568
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
Definition: rna_define.c:1757
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
Definition: rna_define.c:1792
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
Definition: rna_define.c:2791
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4337
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2927
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
Definition: rna_define.c:2877
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1279
void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
Definition: rna_define.c:1122
void RNA_def_function_flag(FunctionRNA *func, int flag)
Definition: rna_define.c:4332
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1517
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
Definition: rna_define.c:3373
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1047
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2623
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3055
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
Definition: rna_define.c:1267
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3675
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
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2515
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
Definition: rna_define.c:1706
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2364
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
Definition: rna_define.c:1525
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1547
void rna_Mesh_update_draw(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr)
void RNA_api_mesh(struct StructRNA *srna)
Definition: rna_mesh_api.c:217
void rna_def_texmat_common(StructRNA *srna, const char *texspace_editable)
Definition: rna_mesh.c:2316
#define MESH_INT_PROPERTY_LAYER(elemname)
static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2381
static void rna_def_mvert(BlenderRNA *brna)
Definition: rna_mesh.c:1630
#define MESH_STRING_PROPERTY_LAYER(elemname)
static void rna_def_mloopuv(BlenderRNA *brna)
Definition: rna_mesh.c:1993
static void rna_def_mlooptri(BlenderRNA *brna)
Definition: rna_mesh.c:1765
static void rna_def_uv_layers(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2567
static void rna_def_mpolygon(BlenderRNA *brna)
Definition: rna_mesh.c:1901
static void rna_def_mesh_looptris(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2406
static void rna_def_face_map(BlenderRNA *brna)
Definition: rna_mesh.c:2843
static void rna_def_mesh_vertices(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2355
static void rna_def_vertex_int_layers(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2639
static void rna_def_polygon_string_layers(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2727
static void rna_def_mesh_polygons(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2439
#define MESH_FLOAT_PROPERTY_LAYER(elemname)
static void rna_def_mloopcol(BlenderRNA *brna)
Definition: rna_mesh.c:2056
static void rna_def_polygon_float_layers(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2683
void RNA_def_mesh(BlenderRNA *brna)
Definition: rna_mesh.c:3423
static void rna_def_vertex_float_layers(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2617
static void rna_def_vertex_string_layers(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2661
static void rna_def_paint_mask(BlenderRNA *brna, PropertyRNA *UNUSED(cprop))
Definition: rna_mesh.c:2808
static void rna_def_loop_colors(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2464
static void rna_def_MPropCol(BlenderRNA *brna)
Definition: rna_mesh.c:2115
const EnumPropertyItem rna_enum_mesh_delimit_mode_items[]
Definition: rna_mesh.c:49
static void rna_def_vert_colors(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2513
static void rna_def_face_maps(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2884
static void rna_def_mproperties(BlenderRNA *brna)
Definition: rna_mesh.c:2174
static void rna_def_mesh(BlenderRNA *brna)
Definition: rna_mesh.c:2921
static void rna_def_mvert_group(BlenderRNA *brna)
Definition: rna_mesh.c:1604
static void rna_def_polygon_int_layers(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2705
static void rna_def_skin_vertices(BlenderRNA *brna, PropertyRNA *UNUSED(cprop))
Definition: rna_mesh.c:2748
static const EnumPropertyItem rna_enum_mesh_remesh_mode_items[]
Definition: rna_mesh.c:58
static void rna_def_medge(BlenderRNA *brna)
Definition: rna_mesh.c:1700
static void rna_def_mloop(BlenderRNA *brna)
Definition: rna_mesh.c:1834
static void rna_def_mesh_loops(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_mesh.c:2418
#define DEFINE_CUSTOMDATA_LAYER_COLLECTION(collection_name, customdata_type, layer_type)
#define DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(collection_name, customdata_type, layer_type, active_type, layer_rna_type)
#define min(a, b)
Definition: sort.c:51
struct BMesh * bm
Definition: BKE_editmesh.h:52
int totfacesel
Definition: bmesh_class.h:298
CustomData vdata
Definition: bmesh_class.h:337
CustomData edata
Definition: bmesh_class.h:337
int totvertsel
Definition: bmesh_class.h:298
int totedgesel
Definition: bmesh_class.h:298
CustomData pdata
Definition: bmesh_class.h:337
CustomData ldata
Definition: bmesh_class.h:337
CustomDataLayer * layers
Definition: DNA_ID.h:273
int us
Definition: DNA_ID.h:293
unsigned char a
unsigned char b
unsigned char r
unsigned char g
struct MLoopTri * array
unsigned int poly
unsigned int tri[3]
unsigned int v
short mat_nr
float co[3]
short no[3]
Definition: BKE_main.h:116
struct MLoopTri_Store looptris
struct MEdge * medge
struct BMEditMesh * edit_mesh
struct Mesh * texcomesh
struct CustomData pdata ldata
struct MVert * mvert
float size[3]
struct MDeformVert * dvert
int totedge
char editflag
int totvert
struct MLoop * mloop
Mesh_Runtime runtime
struct CustomData vdata edata fdata
short texflag
int totpoly
short totcol
int totloop
struct MPoly * mpoly
float loc[3]
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
float max
void WM_main_add_notifier(unsigned int type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3157