Blender V2.61 - r43446

rna_mesh.c

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * Contributor(s): Blender Foundation (2008).
00019  *
00020  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00028 #include <stdlib.h>
00029 
00030 #include "RNA_define.h"
00031 
00032 #include "rna_internal.h"
00033 
00034 #include "DNA_material_types.h"
00035 #include "DNA_mesh_types.h"
00036 #include "DNA_meshdata_types.h"
00037 #include "DNA_object_types.h"
00038 
00039 #include "WM_types.h"
00040 
00041 #include "BLI_math_base.h"
00042 #include "BLI_math_rotation.h"
00043 
00044 #ifdef RNA_RUNTIME
00045 
00046 #include "DNA_scene_types.h"
00047 
00048 #include "BLI_editVert.h"
00049 #include "BLI_math.h"
00050 
00051 #include "BKE_customdata.h"
00052 #include "BKE_depsgraph.h"
00053 #include "BKE_main.h"
00054 #include "BKE_mesh.h"
00055 
00056 
00057 #include "ED_mesh.h" /* XXX Bad level call */
00058 
00059 #include "WM_api.h"
00060 #include "WM_types.h"
00061 
00062 static void rna_Mesh_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00063 {
00064     ID *id= ptr->id.data;
00065 
00066     /* cheating way for importers to avoid slow updates */
00067     if(id->us > 0) {
00068         DAG_id_tag_update(id, 0);
00069         WM_main_add_notifier(NC_GEOM|ND_DATA, id);
00070     }
00071 }
00072 
00073 static void rna_Mesh_update_select(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00074 {
00075     ID *id= ptr->id.data;
00076     /* cheating way for importers to avoid slow updates */
00077     if(id->us > 0) {
00078         WM_main_add_notifier(NC_GEOM|ND_SELECT, id);
00079     }
00080 }
00081 
00082 void rna_Mesh_update_draw(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00083 {
00084     ID *id= ptr->id.data;
00085     /* cheating way for importers to avoid slow updates */
00086     if(id->us > 0) {
00087         WM_main_add_notifier(NC_GEOM|ND_DATA, id);
00088     }
00089 }
00090 
00091 
00092 void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr)
00093 {
00094     Mesh* me = ptr->data;
00095     if ((me->editflag & ME_EDIT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_MASK)) {
00096         me->editflag ^= ME_EDIT_PAINT_MASK;
00097     }
00098     rna_Mesh_update_draw(bmain, scene, ptr);
00099 }
00100 
00101 void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr)
00102 {
00103     Mesh* me = ptr->data;
00104     if ((me->editflag & ME_EDIT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_MASK)) {
00105         me->editflag ^= ME_EDIT_VERT_SEL;
00106     }
00107     rna_Mesh_update_draw(bmain, scene, ptr);
00108 }
00109 static void rna_MeshVertex_normal_get(PointerRNA *ptr, float *value)
00110 {
00111     MVert *mvert= (MVert*)ptr->data;
00112     normal_short_to_float_v3(value, mvert->no);
00113 }
00114 
00115 static void rna_MeshVertex_normal_set(PointerRNA *ptr, const float *value)
00116 {
00117     MVert *mvert= (MVert*)ptr->data;
00118     float no[3];
00119 
00120     copy_v3_v3(no, value);
00121     normalize_v3(no);
00122     normal_float_to_short_v3(mvert->no, no);
00123 }
00124 
00125 static float rna_MeshVertex_bevel_weight_get(PointerRNA *ptr)
00126 {
00127     MVert *mvert= (MVert*)ptr->data;
00128     return mvert->bweight/255.0f;
00129 }
00130 
00131 static void rna_MeshVertex_bevel_weight_set(PointerRNA *ptr, float value)
00132 {
00133     MVert *mvert= (MVert*)ptr->data;
00134     mvert->bweight= (char)(CLAMPIS(value*255.0f, 0, 255));
00135 }
00136 
00137 static float rna_MEdge_bevel_weight_get(PointerRNA *ptr)
00138 {
00139     MEdge *medge= (MEdge*)ptr->data;
00140     return medge->bweight/255.0f;
00141 }
00142 
00143 static void rna_MEdge_bevel_weight_set(PointerRNA *ptr, float value)
00144 {
00145     MEdge *medge= (MEdge*)ptr->data;
00146     medge->bweight= (char)(CLAMPIS(value*255.0f, 0, 255));
00147 }
00148 
00149 static float rna_MEdge_crease_get(PointerRNA *ptr)
00150 {
00151     MEdge *medge= (MEdge*)ptr->data;
00152     return medge->crease/255.0f;
00153 }
00154 
00155 static void rna_MEdge_crease_set(PointerRNA *ptr, float value)
00156 {
00157     MEdge *medge= (MEdge*)ptr->data;
00158     medge->crease= (char)(CLAMPIS(value*255.0f, 0, 255));
00159 }
00160 
00161 static void rna_MeshFace_normal_get(PointerRNA *ptr, float *values)
00162 {
00163     Mesh *me= (Mesh*)ptr->id.data;
00164     MFace *mface= (MFace*)ptr->data;
00165     
00166     if(mface->v4)
00167         normal_quad_v3(values,me->mvert[mface->v1].co, me->mvert[mface->v2].co,
00168                        me->mvert[mface->v3].co, me->mvert[mface->v4].co);
00169     else
00170         normal_tri_v3( values,me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co);
00171 }
00172 
00173 static float rna_MeshFace_area_get(PointerRNA *ptr)
00174 {
00175     Mesh *me= (Mesh*)ptr->id.data;
00176     MFace *mface= (MFace*)ptr->data;
00177 
00178     if(mface->v4)
00179         return area_quad_v3(me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co, me->mvert[mface->v4].co);
00180     else
00181         return area_tri_v3(me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co);
00182 }
00183 
00184 /* notice red and blue are swapped */
00185 static void rna_MeshColor_color1_get(PointerRNA *ptr, float *values)
00186 {
00187     MCol *mcol= (MCol*)ptr->data;
00188 
00189     values[2]= (&mcol[0].r)[0]/255.0f;
00190     values[1]= (&mcol[0].r)[1]/255.0f;
00191     values[0]= (&mcol[0].r)[2]/255.0f;
00192 }
00193 
00194 static void rna_MeshColor_color1_set(PointerRNA *ptr, const float *values)
00195 {
00196     MCol *mcol= (MCol*)ptr->data;
00197 
00198     (&mcol[0].r)[2]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
00199     (&mcol[0].r)[1]= (char)(CLAMPIS(values[1]*255.0f, 0, 255));
00200     (&mcol[0].r)[0]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
00201 }
00202 
00203 static void rna_MeshColor_color2_get(PointerRNA *ptr, float *values)
00204 {
00205     MCol *mcol= (MCol*)ptr->data;
00206 
00207     values[2]= (&mcol[1].r)[0]/255.0f;
00208     values[1]= (&mcol[1].r)[1]/255.0f;
00209     values[0]= (&mcol[1].r)[2]/255.0f;
00210 }
00211 
00212 static void rna_MeshColor_color2_set(PointerRNA *ptr, const float *values)
00213 {
00214     MCol *mcol= (MCol*)ptr->data;
00215 
00216     (&mcol[1].r)[2]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
00217     (&mcol[1].r)[1]= (char)(CLAMPIS(values[1]*255.0f, 0, 255));
00218     (&mcol[1].r)[0]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
00219 }
00220 
00221 static void rna_MeshColor_color3_get(PointerRNA *ptr, float *values)
00222 {
00223     MCol *mcol= (MCol*)ptr->data;
00224 
00225     values[2]= (&mcol[2].r)[0]/255.0f;
00226     values[1]= (&mcol[2].r)[1]/255.0f;
00227     values[0]= (&mcol[2].r)[2]/255.0f;
00228 }
00229 
00230 static void rna_MeshColor_color3_set(PointerRNA *ptr, const float *values)
00231 {
00232     MCol *mcol= (MCol*)ptr->data;
00233 
00234     (&mcol[2].r)[2]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
00235     (&mcol[2].r)[1]= (char)(CLAMPIS(values[1]*255.0f, 0, 255));
00236     (&mcol[2].r)[0]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
00237 }
00238 
00239 static void rna_MeshColor_color4_get(PointerRNA *ptr, float *values)
00240 {
00241     MCol *mcol= (MCol*)ptr->data;
00242 
00243     values[2]= (&mcol[3].r)[0]/255.0f;
00244     values[1]= (&mcol[3].r)[1]/255.0f;
00245     values[0]= (&mcol[3].r)[2]/255.0f;
00246 }
00247 
00248 static void rna_MeshColor_color4_set(PointerRNA *ptr, const float *values)
00249 {
00250     MCol *mcol= (MCol*)ptr->data;
00251 
00252     (&mcol[3].r)[2]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
00253     (&mcol[3].r)[1]= (char)(CLAMPIS(values[1]*255.0f, 0, 255));
00254     (&mcol[3].r)[0]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
00255 }
00256 
00257 static void rna_Mesh_texspace_set(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00258 {
00259     Mesh *me= (Mesh*)ptr->data;
00260     
00261     if (me->texflag & AUTOSPACE)
00262         tex_space_mesh(me);
00263 }
00264 
00265 
00266 static int rna_Mesh_texspace_editable(PointerRNA *ptr)
00267 {
00268     Mesh *me= (Mesh*)ptr->data;
00269     return (me->texflag & AUTOSPACE)? 0: PROP_EDITABLE;
00270 }
00271 
00272 static void rna_Mesh_texspace_loc_get(PointerRNA *ptr, float *values)
00273 {
00274     Mesh *me= (Mesh *)ptr->data;
00275     
00276     if (!me->bb)
00277         tex_space_mesh(me);
00278     
00279     copy_v3_v3(values, me->loc);
00280 }
00281 
00282 static void rna_Mesh_texspace_loc_set(PointerRNA *ptr, const float *values)
00283 {
00284     Mesh *me= (Mesh *)ptr->data;
00285     
00286     copy_v3_v3(me->loc, values);
00287 }
00288 
00289 static void rna_Mesh_texspace_size_get(PointerRNA *ptr, float *values)
00290 {
00291     Mesh *me= (Mesh *)ptr->data;
00292     
00293     if (!me->bb)
00294         tex_space_mesh(me);
00295     
00296     copy_v3_v3(values, me->size);
00297 }
00298 
00299 static void rna_Mesh_texspace_size_set(PointerRNA *ptr, const float *values)
00300 {
00301     Mesh *me= (Mesh *)ptr->data;
00302     
00303     copy_v3_v3(me->size, values);
00304 }
00305 
00306 static void rna_MeshVertex_groups_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00307 {
00308     Mesh *me= (Mesh*)ptr->id.data;
00309 
00310     if(me->dvert) {
00311         MVert *mvert= (MVert*)ptr->data;
00312         MDeformVert *dvert= me->dvert + (mvert-me->mvert);
00313 
00314         rna_iterator_array_begin(iter, (void*)dvert->dw, sizeof(MDeformWeight), dvert->totweight, 0, NULL);
00315     }
00316     else
00317         rna_iterator_array_begin(iter, NULL, 0, 0, 0, NULL);
00318 }
00319 
00320 static void rna_MeshFace_material_index_range(PointerRNA *ptr, int *min, int *max)
00321 {
00322     Mesh *me= (Mesh*)ptr->id.data;
00323     *min= 0;
00324     *max= me->totcol-1;
00325     *max= MAX2(0, *max);
00326 }
00327 
00328 static CustomData *rna_mesh_fdata(Mesh *me)
00329 {
00330     return (me->edit_mesh)? &me->edit_mesh->fdata: &me->fdata;
00331 }
00332 
00333 static int rna_CustomDataLayer_length(PointerRNA *ptr, int type)
00334 {
00335     Mesh *me= (Mesh*)ptr->id.data;
00336     CustomData *fdata= rna_mesh_fdata(me);
00337     CustomDataLayer *layer;
00338     int i, length= 0;
00339 
00340     for(layer=fdata->layers, i=0; i<fdata->totlayer; layer++, i++)
00341         if(layer->type == type)
00342             length++;
00343 
00344     return length;
00345 }
00346 
00347 static int rna_CustomDataLayer_active_get(PointerRNA *ptr, int type, int render)
00348 {
00349     Mesh *me= (Mesh*)ptr->id.data;
00350     CustomData *fdata= rna_mesh_fdata(me);
00351     int n= ((CustomDataLayer*)ptr->data) - fdata->layers;
00352 
00353     if(render) return (n == CustomData_get_render_layer_index(fdata, type));
00354     else return (n == CustomData_get_active_layer_index(fdata, type));
00355 }
00356 
00357 static int rna_CustomDataLayer_clone_get(PointerRNA *ptr, int type, int UNUSED(render))
00358 {
00359     Mesh *me= (Mesh*)ptr->id.data;
00360     CustomData *fdata= rna_mesh_fdata(me);
00361     int n= ((CustomDataLayer*)ptr->data) - fdata->layers;
00362 
00363     return (n == CustomData_get_clone_layer_index(fdata, type));
00364 }
00365 
00366 static void rna_CustomDataLayer_active_set(PointerRNA *ptr, int value, int type, int render)
00367 {
00368     Mesh *me= (Mesh*)ptr->id.data;
00369     CustomData *fdata= rna_mesh_fdata(me);
00370     int n= ((CustomDataLayer*)ptr->data) - fdata->layers;
00371 
00372     if(value == 0)
00373         return;
00374 
00375     if(render) CustomData_set_layer_render_index(fdata, type, n);
00376     else CustomData_set_layer_active_index(fdata, type, n);
00377 }
00378 
00379 static void rna_CustomDataLayer_clone_set(PointerRNA *ptr, int value, int type, int UNUSED(render))
00380 {
00381     Mesh *me= (Mesh*)ptr->id.data;
00382     CustomData *fdata= rna_mesh_fdata(me);
00383     int n= ((CustomDataLayer*)ptr->data) - fdata->layers;
00384 
00385     if(value == 0)
00386         return;
00387 
00388     CustomData_set_layer_clone_index(fdata, type, n);
00389 }
00390 
00391 static int rna_uv_texture_check(CollectionPropertyIterator *UNUSED(iter), void *data)
00392 {
00393     CustomDataLayer *layer= (CustomDataLayer*)data;
00394     return (layer->type != CD_MTFACE);
00395 }
00396 
00397 static void rna_Mesh_uv_textures_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00398 {
00399     Mesh *me= (Mesh*)ptr->data;
00400     CustomData *fdata= rna_mesh_fdata(me);
00401     rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, 0, rna_uv_texture_check);
00402 }
00403 
00404 static int rna_Mesh_uv_textures_length(PointerRNA *ptr)
00405 {
00406     return rna_CustomDataLayer_length(ptr, CD_MTFACE);
00407 }
00408 
00409 static PointerRNA rna_Mesh_active_uv_texture_get(PointerRNA *ptr)
00410 {
00411     Mesh *me= (Mesh*)ptr->data;
00412     CustomData *fdata= rna_mesh_fdata(me);
00413     int index= CustomData_get_active_layer_index(fdata, CD_MTFACE);
00414     CustomDataLayer *cdl= (index == -1)? NULL: &fdata->layers[index];
00415 
00416     return rna_pointer_inherit_refine(ptr, &RNA_MeshTextureFaceLayer, cdl);
00417 }
00418 
00419 static PointerRNA rna_Mesh_uv_texture_clone_get(PointerRNA *ptr)
00420 {
00421     Mesh *me= (Mesh*)ptr->data;
00422     CustomData *fdata= rna_mesh_fdata(me);
00423     int index= CustomData_get_clone_layer_index(fdata, CD_MTFACE);
00424     CustomDataLayer *cdl= (index == -1)? NULL: &fdata->layers[index];
00425 
00426     return rna_pointer_inherit_refine(ptr, &RNA_MeshTextureFaceLayer, cdl);
00427 }
00428 
00429 static PointerRNA rna_Mesh_uv_texture_stencil_get(PointerRNA *ptr)
00430 {
00431     Mesh *me= (Mesh*)ptr->data;
00432     CustomData *fdata= rna_mesh_fdata(me);
00433     int index= CustomData_get_stencil_layer_index(fdata, CD_MTFACE);
00434     CustomDataLayer *cdl= (index == -1)? NULL: &fdata->layers[index];
00435 
00436     return rna_pointer_inherit_refine(ptr, &RNA_MeshTextureFaceLayer, cdl);
00437 }
00438 
00439 static void rna_Mesh_active_uv_texture_set(PointerRNA *ptr, PointerRNA value)
00440 {
00441     Mesh *me= (Mesh*)ptr->data;
00442     CustomData *fdata= rna_mesh_fdata(me);
00443     CustomDataLayer *cdl;
00444     int a;
00445 
00446     for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) {
00447         if(value.data == cdl) {
00448             CustomData_set_layer_active_index(fdata, CD_MTFACE, a);
00449             mesh_update_customdata_pointers(me);
00450             return;
00451         }
00452     }
00453 }
00454 
00455 static void rna_Mesh_uv_texture_clone_set(PointerRNA *ptr, PointerRNA value)
00456 {
00457     Mesh *me= (Mesh*)ptr->data;
00458     CustomData *fdata= rna_mesh_fdata(me);
00459     CustomDataLayer *cdl;
00460     int a;
00461 
00462     for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) {
00463         if(value.data == cdl) {
00464             CustomData_set_layer_clone_index(fdata, CD_MTFACE, a);
00465             return;
00466         }
00467     }
00468 }
00469 
00470 static void rna_Mesh_uv_texture_stencil_set(PointerRNA *ptr, PointerRNA value)
00471 {
00472     Mesh *me= (Mesh*)ptr->data;
00473     CustomData *fdata= rna_mesh_fdata(me);
00474     CustomDataLayer *cdl;
00475     int a;
00476 
00477     for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) {
00478         if(value.data == cdl) {
00479             CustomData_set_layer_stencil_index(fdata, CD_MTFACE, a);
00480             return;
00481         }
00482     }
00483 }
00484 
00485 static int rna_Mesh_active_uv_texture_index_get(PointerRNA *ptr)
00486 {
00487     Mesh *me= (Mesh*)ptr->data;
00488     CustomData *fdata= rna_mesh_fdata(me);
00489     return CustomData_get_active_layer(fdata, CD_MTFACE);
00490 }
00491 
00492 static int rna_Mesh_uv_texture_clone_index_get(PointerRNA *ptr)
00493 {
00494     Mesh *me= (Mesh*)ptr->data;
00495     CustomData *fdata= rna_mesh_fdata(me);
00496     return CustomData_get_clone_layer(fdata, CD_MTFACE);
00497 }
00498 
00499 static int rna_Mesh_uv_texture_stencil_index_get(PointerRNA *ptr)
00500 {
00501     Mesh *me= (Mesh*)ptr->data;
00502     CustomData *fdata= rna_mesh_fdata(me);
00503     return CustomData_get_stencil_layer(fdata, CD_MTFACE);
00504 }
00505 
00506 static void rna_Mesh_active_uv_texture_index_set(PointerRNA *ptr, int value)
00507 {
00508     Mesh *me= (Mesh*)ptr->data;
00509     CustomData *fdata= rna_mesh_fdata(me);
00510 
00511     CustomData_set_layer_active(fdata, CD_MTFACE, value);
00512     mesh_update_customdata_pointers(me);
00513 }
00514 
00515 static void rna_Mesh_uv_texture_clone_index_set(PointerRNA *ptr, int value)
00516 {
00517     Mesh *me= (Mesh*)ptr->data;
00518     CustomData *fdata= rna_mesh_fdata(me);
00519 
00520     CustomData_set_layer_clone(fdata, CD_MTFACE, value);
00521 }
00522 
00523 static void rna_Mesh_uv_texture_stencil_index_set(PointerRNA *ptr, int value)
00524 {
00525     Mesh *me= (Mesh*)ptr->data;
00526     CustomData *fdata= rna_mesh_fdata(me);
00527 
00528     CustomData_set_layer_stencil(fdata, CD_MTFACE, value);
00529 }
00530 
00531 static void rna_Mesh_active_uv_texture_index_range(PointerRNA *ptr, int *min, int *max)
00532 {
00533     Mesh *me= (Mesh*)ptr->data;
00534     CustomData *fdata= rna_mesh_fdata(me);
00535 
00536     *min= 0;
00537     *max= CustomData_number_of_layers(fdata, CD_MTFACE)-1;
00538     *max= MAX2(0, *max);
00539 }
00540 
00541 static PointerRNA rna_Mesh_active_mtface_get(PointerRNA *ptr)
00542 {
00543     Mesh *me= (Mesh*)ptr->data;
00544     EditMesh *em= BKE_mesh_get_editmesh(me);
00545     MTFace *tf;
00546 
00547     if (em && EM_texFaceCheck(em))
00548     {
00549         tf = EM_get_active_mtface(em, NULL, NULL, 1);
00550 
00551         return rna_pointer_inherit_refine(ptr, &RNA_MeshTextureFace, tf);
00552     }
00553 
00554     return rna_pointer_inherit_refine(ptr, &RNA_MeshTextureFace, NULL);
00555 }
00556 
00557 static void rna_MeshTextureFace_uv1_get(PointerRNA *ptr, float *values)
00558 {
00559     MTFace *mtface= (MTFace*)ptr->data;
00560     
00561     values[0]= mtface->uv[0][0];
00562     values[1]= mtface->uv[0][1];
00563 }
00564 
00565 static void rna_MeshTextureFace_uv1_set(PointerRNA *ptr, const float *values)
00566 {
00567     MTFace *mtface= (MTFace*)ptr->data;
00568 
00569     mtface->uv[0][0]= values[0];
00570     mtface->uv[0][1]= values[1];
00571 }
00572 
00573 static void rna_MeshTextureFace_uv2_get(PointerRNA *ptr, float *values)
00574 {
00575     MTFace *mtface= (MTFace*)ptr->data;
00576 
00577     values[0]= mtface->uv[1][0];
00578     values[1]= mtface->uv[1][1];
00579 }
00580 
00581 static void rna_MeshTextureFace_uv2_set(PointerRNA *ptr, const float *values)
00582 {
00583     MTFace *mtface= (MTFace*)ptr->data;
00584 
00585     mtface->uv[1][0]= values[0];
00586     mtface->uv[1][1]= values[1];
00587 }
00588 
00589 static void rna_MeshTextureFace_uv3_get(PointerRNA *ptr, float *values)
00590 {
00591     MTFace *mtface= (MTFace*)ptr->data;
00592 
00593     values[0]= mtface->uv[2][0];
00594     values[1]= mtface->uv[2][1];
00595 }
00596 
00597 static void rna_MeshTextureFace_uv3_set(PointerRNA *ptr, const float *values)
00598 {
00599     MTFace *mtface= (MTFace*)ptr->data;
00600 
00601     mtface->uv[2][0]= values[0];
00602     mtface->uv[2][1]= values[1];
00603 }
00604 
00605 static void rna_MeshTextureFace_uv4_get(PointerRNA *ptr, float *values)
00606 {
00607     MTFace *mtface= (MTFace*)ptr->data;
00608 
00609     values[0]= mtface->uv[3][0];
00610     values[1]= mtface->uv[3][1];
00611 }
00612 
00613 static void rna_MeshTextureFace_uv4_set(PointerRNA *ptr, const float *values)
00614 {
00615     MTFace *mtface= (MTFace*)ptr->data;
00616 
00617     mtface->uv[3][0]= values[0];
00618     mtface->uv[3][1]= values[1];
00619 }
00620 
00621 static int rna_CustomDataData_numverts(PointerRNA *ptr, int type)
00622 {
00623     Mesh *me= (Mesh*)ptr->id.data;
00624     CustomData *fdata= rna_mesh_fdata(me);
00625     CustomDataLayer *cdl;
00626     int a, b;
00627 
00628     for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) {
00629         if(cdl->type == type) {
00630             b= ((char*)ptr->data - ((char*)cdl->data))/CustomData_sizeof(type);
00631             if(b >= 0 && b < me->totface)
00632                 return (me->mface[b].v4? 4: 3);
00633         }
00634     }
00635 
00636     return 0;
00637 }
00638 
00639 static int rna_MeshTextureFace_uv_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
00640 {
00641     length[0]= rna_CustomDataData_numverts(ptr, CD_MTFACE);
00642     length[1]= 2;
00643     return length[0]*length[1];
00644 }
00645 
00646 static void rna_MeshTextureFace_uv_get(PointerRNA *ptr, float *values)
00647 {
00648     MTFace *mtface= (MTFace*)ptr->data;
00649     int totvert= rna_CustomDataData_numverts(ptr, CD_MTFACE);
00650 
00651     memcpy(values, mtface->uv, totvert * 2 * sizeof(float));
00652 }
00653 
00654 static void rna_MeshTextureFace_uv_set(PointerRNA *ptr, const float *values)
00655 {
00656     MTFace *mtface= (MTFace*)ptr->data;
00657     int totvert= rna_CustomDataData_numverts(ptr, CD_MTFACE);
00658 
00659     memcpy(mtface->uv, values, totvert * 2 * sizeof(float));
00660 }
00661 
00662 static void rna_MeshTextureFaceLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00663 {
00664     Mesh *me= (Mesh*)ptr->id.data;
00665     CustomDataLayer *layer= (CustomDataLayer*)ptr->data;
00666     rna_iterator_array_begin(iter, layer->data, sizeof(MTFace), (me->edit_mesh)? 0: me->totface, 0, NULL);
00667 }
00668 
00669 static int rna_MeshTextureFaceLayer_data_length(PointerRNA *ptr)
00670 {
00671     Mesh *me= (Mesh*)ptr->id.data;
00672     return (me->edit_mesh)? 0: me->totface;
00673 }
00674 
00675 static int rna_MeshTextureFaceLayer_active_render_get(PointerRNA *ptr)
00676 {
00677     return rna_CustomDataLayer_active_get(ptr, CD_MTFACE, 1);
00678 }
00679 
00680 static int rna_MeshTextureFaceLayer_active_get(PointerRNA *ptr)
00681 {
00682     return rna_CustomDataLayer_active_get(ptr, CD_MTFACE, 0);
00683 }
00684 
00685 static int rna_MeshTextureFaceLayer_clone_get(PointerRNA *ptr)
00686 {
00687     return rna_CustomDataLayer_clone_get(ptr, CD_MTFACE, 0);
00688 }
00689 
00690 static void rna_MeshTextureFaceLayer_active_render_set(PointerRNA *ptr, int value)
00691 {
00692     rna_CustomDataLayer_active_set(ptr, value, CD_MTFACE, 1);
00693 }
00694 
00695 static void rna_MeshTextureFaceLayer_active_set(PointerRNA *ptr, int value)
00696 {
00697     rna_CustomDataLayer_active_set(ptr, value, CD_MTFACE, 0);
00698 }
00699 
00700 static void rna_MeshTextureFaceLayer_clone_set(PointerRNA *ptr, int value)
00701 {
00702     rna_CustomDataLayer_clone_set(ptr, value, CD_MTFACE, 0);
00703 }
00704 
00705 static void rna_MeshTextureFaceLayer_name_set(PointerRNA *ptr, const char *value)
00706 {
00707     Mesh *me= (Mesh*)ptr->id.data;
00708     CustomData *fdata= rna_mesh_fdata(me);
00709     CustomDataLayer *cdl= (CustomDataLayer*)ptr->data;
00710     BLI_strncpy_utf8(cdl->name, value, sizeof(cdl->name));
00711     CustomData_set_layer_unique_name(fdata, cdl - fdata->layers);
00712 }
00713 
00714 static int rna_vertex_color_check(CollectionPropertyIterator *UNUSED(iter), void *data)
00715 {
00716     CustomDataLayer *layer= (CustomDataLayer*)data;
00717     return (layer->type != CD_MCOL);
00718 }
00719 
00720 static void rna_Mesh_vertex_colors_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00721 {
00722     Mesh *me= (Mesh*)ptr->data;
00723     CustomData *fdata= rna_mesh_fdata(me);
00724     rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, 0, rna_vertex_color_check);
00725 }
00726 
00727 static int rna_Mesh_vertex_colors_length(PointerRNA *ptr)
00728 {
00729     return rna_CustomDataLayer_length(ptr, CD_MCOL);
00730 }
00731 
00732 static PointerRNA rna_Mesh_active_vertex_color_get(PointerRNA *ptr)
00733 {
00734     Mesh *me= (Mesh*)ptr->data;
00735     CustomData *fdata= rna_mesh_fdata(me);
00736     int index= CustomData_get_active_layer_index(fdata, CD_MCOL);
00737     CustomDataLayer *cdl= (index == -1)? NULL: &fdata->layers[index];
00738 
00739     return rna_pointer_inherit_refine(ptr, &RNA_MeshColorLayer, cdl);
00740 }
00741 
00742 static void rna_Mesh_active_vertex_color_set(PointerRNA *ptr, PointerRNA value)
00743 {
00744     Mesh *me= (Mesh*)ptr->data;
00745     CustomData *fdata= rna_mesh_fdata(me);
00746     CustomDataLayer *cdl;
00747     int a;
00748 
00749     for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) {
00750         if(value.data == cdl) {
00751             CustomData_set_layer_active_index(fdata, CD_MCOL, a);
00752             mesh_update_customdata_pointers(me);
00753             return;
00754         }
00755     }
00756 }
00757 
00758 static int rna_Mesh_active_vertex_color_index_get(PointerRNA *ptr)
00759 {
00760     Mesh *me= (Mesh*)ptr->data;
00761     CustomData *fdata= rna_mesh_fdata(me);
00762     return CustomData_get_active_layer(fdata, CD_MCOL);
00763 }
00764 
00765 static void rna_Mesh_active_vertex_color_index_set(PointerRNA *ptr, int value)
00766 {
00767     Mesh *me= (Mesh*)ptr->data;
00768     CustomData *fdata= rna_mesh_fdata(me);
00769 
00770     CustomData_set_layer_active(fdata, CD_MCOL, value);
00771     mesh_update_customdata_pointers(me);
00772 }
00773 
00774 static void rna_Mesh_active_vertex_color_index_range(PointerRNA *ptr, int *min, int *max)
00775 {
00776     Mesh *me= (Mesh*)ptr->data;
00777     CustomData *fdata= rna_mesh_fdata(me);
00778 
00779     *min= 0;
00780     *max= CustomData_number_of_layers(fdata, CD_MCOL)-1;
00781     *max= MAX2(0, *max);
00782 }
00783 
00784 static void rna_MeshColorLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00785 {
00786     Mesh *me= (Mesh*)ptr->id.data;
00787     CustomDataLayer *layer= (CustomDataLayer*)ptr->data;
00788     rna_iterator_array_begin(iter, layer->data, sizeof(MCol)*4, (me->edit_mesh)? 0: me->totface, 0, NULL);
00789 }
00790 
00791 static int rna_MeshColorLayer_data_length(PointerRNA *ptr)
00792 {
00793     Mesh *me= (Mesh*)ptr->id.data;
00794     return (me->edit_mesh)? 0: me->totface;
00795 }
00796 
00797 static int rna_MeshColorLayer_active_render_get(PointerRNA *ptr)
00798 {
00799     return rna_CustomDataLayer_active_get(ptr, CD_MCOL, 1);
00800 }
00801 
00802 static int rna_MeshColorLayer_active_get(PointerRNA *ptr)
00803 {
00804     return rna_CustomDataLayer_active_get(ptr, CD_MCOL, 0);
00805 }
00806 
00807 static void rna_MeshColorLayer_active_render_set(PointerRNA *ptr, int value)
00808 {
00809     rna_CustomDataLayer_active_set(ptr, value, CD_MCOL, 1);
00810 }
00811 
00812 static void rna_MeshColorLayer_active_set(PointerRNA *ptr, int value)
00813 {
00814     rna_CustomDataLayer_active_set(ptr, value, CD_MCOL, 0);
00815 }
00816 
00817 static void rna_MeshColorLayer_name_set(PointerRNA *ptr, const char *value)
00818 {
00819     Mesh *me= (Mesh*)ptr->id.data;
00820     CustomData *fdata= rna_mesh_fdata(me);
00821     CustomDataLayer *cdl= (CustomDataLayer*)ptr->data;
00822     BLI_strncpy_utf8(cdl->name, value, sizeof(cdl->name));
00823     CustomData_set_layer_unique_name(fdata, cdl - fdata->layers);
00824 }
00825 
00826 static void rna_MeshFloatPropertyLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00827 {
00828     Mesh *me= (Mesh*)ptr->id.data;
00829     CustomDataLayer *layer= (CustomDataLayer*)ptr->data;
00830     rna_iterator_array_begin(iter, layer->data, sizeof(MFloatProperty), (me->edit_mesh)? 0: me->totface, 0, NULL);
00831 }
00832 
00833 static int rna_MeshFloatPropertyLayer_data_length(PointerRNA *ptr)
00834 {
00835     Mesh *me= (Mesh*)ptr->id.data;
00836     return (me->edit_mesh)? 0: me->totface;
00837 }
00838 
00839 static int rna_float_layer_check(CollectionPropertyIterator *UNUSED(iter), void *data)
00840 {
00841     CustomDataLayer *layer= (CustomDataLayer*)data;
00842     return (layer->type != CD_PROP_FLT);
00843 }
00844 
00845 static void rna_Mesh_float_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00846 {
00847     Mesh *me= (Mesh*)ptr->data;
00848     CustomData *fdata= rna_mesh_fdata(me);
00849     rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, 0, rna_float_layer_check);
00850 }
00851 
00852 static int rna_Mesh_float_layers_length(PointerRNA *ptr)
00853 {
00854     return rna_CustomDataLayer_length(ptr, CD_PROP_FLT);
00855 }
00856 
00857 static int rna_int_layer_check(CollectionPropertyIterator *UNUSED(iter), void *data)
00858 {
00859     CustomDataLayer *layer= (CustomDataLayer*)data;
00860     return (layer->type != CD_PROP_INT);
00861 }
00862 
00863 static void rna_MeshIntPropertyLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00864 {
00865     Mesh *me= (Mesh*)ptr->id.data;
00866     CustomDataLayer *layer= (CustomDataLayer*)ptr->data;
00867     rna_iterator_array_begin(iter, layer->data, sizeof(MIntProperty), (me->edit_mesh)? 0: me->totface, 0, NULL);
00868 }
00869 
00870 static int rna_MeshIntPropertyLayer_data_length(PointerRNA *ptr)
00871 {
00872     Mesh *me= (Mesh*)ptr->id.data;
00873     return (me->edit_mesh)? 0: me->totface;
00874 }
00875 
00876 static void rna_Mesh_int_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00877 {
00878     Mesh *me= (Mesh*)ptr->data;
00879     CustomData *fdata= rna_mesh_fdata(me);
00880     rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, 0, rna_int_layer_check);
00881 }
00882 
00883 static int rna_Mesh_int_layers_length(PointerRNA *ptr)
00884 {
00885     return rna_CustomDataLayer_length(ptr, CD_PROP_INT);
00886 }
00887 
00888 static int rna_string_layer_check(CollectionPropertyIterator *UNUSED(iter), void *data)
00889 {
00890     CustomDataLayer *layer= (CustomDataLayer*)data;
00891     return (layer->type != CD_PROP_STR);
00892 }
00893 
00894 static void rna_MeshStringPropertyLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00895 {
00896     Mesh *me= (Mesh*)ptr->id.data;
00897     CustomDataLayer *layer= (CustomDataLayer*)ptr->data;
00898     rna_iterator_array_begin(iter, layer->data, sizeof(MStringProperty), (me->edit_mesh)? 0: me->totface, 0, NULL);
00899 }
00900 
00901 static int rna_MeshStringPropertyLayer_data_length(PointerRNA *ptr)
00902 {
00903     Mesh *me= (Mesh*)ptr->id.data;
00904     return (me->edit_mesh)? 0: me->totface;
00905 }
00906 
00907 static void rna_Mesh_string_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00908 {
00909     Mesh *me= (Mesh*)ptr->data;
00910     CustomData *fdata= rna_mesh_fdata(me);
00911     rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, 0, rna_string_layer_check);
00912 }
00913 
00914 static int rna_Mesh_string_layers_length(PointerRNA *ptr)
00915 {
00916     return rna_CustomDataLayer_length(ptr, CD_PROP_STR);
00917 }
00918 
00919 static void rna_TextureFace_image_set(PointerRNA *ptr, PointerRNA value)
00920 {
00921     MTFace *tf= (MTFace*)ptr->data;
00922     ID *id= value.data;
00923 
00924     if(id) {
00925         /* special exception here, individual faces don't count
00926          * as reference, but we do ensure the refcount is not zero */
00927         if(id->us == 0)
00928             id_us_plus(id);
00929         else
00930             id_lib_extern(id);
00931     }
00932 
00933     tf->tpage= (struct Image*)id;
00934 }
00935 
00936 static void rna_Mesh_auto_smooth_angle_set(PointerRNA *ptr, float value)
00937 {
00938     Mesh *me= (Mesh*)ptr->id.data;
00939     value= RAD2DEGF(value);
00940     CLAMP(value, 1.0f, 80.0f);
00941     me->smoothresh= (int)value;
00942 }
00943 
00944 static float rna_Mesh_auto_smooth_angle_get(PointerRNA *ptr)
00945 {
00946     Mesh *me= (Mesh*)ptr->id.data;
00947     return DEG2RADF((float)me->smoothresh);
00948 }
00949 
00950 static int rna_MeshFace_verts_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
00951 {
00952     MFace *face= (MFace*)ptr->data;
00953 
00954     if(face)
00955         length[0]= (face->v4)? 4: 3;
00956     else
00957         length[0]= 4; // XXX rna_raw_access wants the length of a dummy face. this needs fixing. - Campbell
00958 
00959     return length[0];
00960 }
00961 
00962 static void rna_MeshFace_verts_get(PointerRNA *ptr, int *values)
00963 {
00964     MFace *face= (MFace*)ptr->data;
00965     memcpy(values, &face->v1, (face->v4 ? 4 : 3) * sizeof(int));
00966 }
00967 
00968 static void rna_MeshFace_verts_set(PointerRNA *ptr, const int *values)
00969 {
00970     MFace *face= (MFace*)ptr->data;
00971     memcpy(&face->v1, values, (face->v4 ? 4 : 3) * sizeof(int));
00972 }
00973 
00974 static int rna_MeshVertex_index_get(PointerRNA *ptr)
00975 {
00976     Mesh *me= (Mesh*)ptr->id.data;
00977     MVert *vert= (MVert*)ptr->data;
00978     return (int)(vert - me->mvert);
00979 }
00980 
00981 static int rna_MeshEdge_index_get(PointerRNA *ptr)
00982 {
00983     Mesh *me= (Mesh*)ptr->id.data;
00984     MEdge *edge= (MEdge*)ptr->data;
00985     return (int)(edge - me->medge);
00986 }
00987 
00988 static int rna_MeshFace_index_get(PointerRNA *ptr)
00989 {
00990     Mesh *me= (Mesh*)ptr->id.data;
00991     MFace *face= (MFace*)ptr->data;
00992     return (int)(face - me->mface);
00993 }
00994 
00995 /* path construction */
00996 
00997 static char *rna_VertexGroupElement_path(PointerRNA *ptr)
00998 {
00999     Mesh *me= (Mesh*)ptr->id.data; /* XXX not always! */
01000     MDeformWeight *dw= (MDeformWeight*)ptr->data;
01001     MDeformVert *dvert;
01002     int a, b;
01003     
01004     /* sanity check: make sure that mesh pointer is valid */
01005     if (me == NULL) 
01006         return NULL;
01007     else if (GS(me->id.name) != ID_ME) {
01008         /* if object pointer, try to resolve the object's data to mesh pointer */
01009         if (GS(me->id.name) == ID_OB) {
01010             Object *ob = (Object *)me;
01011             
01012             if (ob->type == OB_MESH)
01013                 me = (Mesh *)ob->data;
01014             else
01015                 return NULL; /* nothing can be done */
01016         }
01017         else
01018             return NULL; /* nothing can be done */
01019     }
01020     
01021     for(a=0, dvert=me->dvert; a<me->totvert; a++, dvert++) {
01022         for(b=0; b<dvert->totweight; b++) {
01023             if(dw == &dvert->dw[b])
01024                 return BLI_sprintfN("vertices[%d].groups[%d]", a, b);
01025         }
01026     }
01027 
01028     return NULL;
01029 }
01030 
01031 static char *rna_MeshFace_path(PointerRNA *ptr)
01032 {
01033     return BLI_sprintfN("faces[%d]", (int)((MFace*)ptr->data - ((Mesh*)ptr->id.data)->mface));
01034 }
01035 
01036 static char *rna_MeshEdge_path(PointerRNA *ptr)
01037 {
01038     return BLI_sprintfN("edges[%d]", (int)((MEdge*)ptr->data - ((Mesh*)ptr->id.data)->medge));
01039 }
01040 
01041 static char *rna_MeshVertex_path(PointerRNA *ptr)
01042 {
01043     return BLI_sprintfN("vertices[%d]", (int)((MVert*)ptr->data - ((Mesh*)ptr->id.data)->mvert));
01044 }
01045 
01046 static char *rna_MeshTextureFaceLayer_path(PointerRNA *ptr)
01047 {
01048     return BLI_sprintfN("uv_textures[\"%s\"]", ((CustomDataLayer*)ptr->data)->name);
01049 }
01050 
01051 static char *rna_CustomDataData_path(PointerRNA *ptr, char *collection, int type)
01052 {
01053     Mesh *me= (Mesh*)ptr->id.data;
01054     CustomData *fdata= rna_mesh_fdata(me);
01055     CustomDataLayer *cdl;
01056     int a, b;
01057 
01058     for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) {
01059         if(cdl->type == type) {
01060             b= ((char*)ptr->data - ((char*)cdl->data))/CustomData_sizeof(type);
01061             if(b >= 0 && b < me->totface)
01062                 return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, cdl->name, b);
01063         }
01064     }
01065 
01066     return NULL;
01067 }
01068 
01069 static char *rna_MeshTextureFace_path(PointerRNA *ptr)
01070 {
01071     return rna_CustomDataData_path(ptr, "uv_textures", CD_MTFACE);
01072 }
01073 
01074 static char *rna_MeshColorLayer_path(PointerRNA *ptr)
01075 {
01076     return BLI_sprintfN("vertex_colors[\"%s\"]", ((CustomDataLayer*)ptr->data)->name);
01077 }
01078 
01079 static char *rna_MeshColor_path(PointerRNA *ptr)
01080 {
01081     return rna_CustomDataData_path(ptr, "vertex_colors", CD_MCOL);
01082 }
01083 
01084 static char *rna_MeshSticky_path(PointerRNA *ptr)
01085 {
01086     return BLI_sprintfN("sticky[%d]", (int)((MSticky*)ptr->data - ((Mesh*)ptr->id.data)->msticky));
01087 }
01088 
01089 static char *rna_MeshIntPropertyLayer_path(PointerRNA *ptr)
01090 {
01091     return BLI_sprintfN("int_layers[\"%s\"]", ((CustomDataLayer*)ptr->data)->name);
01092 }
01093 
01094 static char *rna_MeshIntProperty_path(PointerRNA *ptr)
01095 {
01096     return rna_CustomDataData_path(ptr, "layers_int", CD_MCOL);
01097 }
01098 
01099 static char *rna_MeshFloatPropertyLayer_path(PointerRNA *ptr)
01100 {
01101     return BLI_sprintfN("float_layers[\"%s\"]", ((CustomDataLayer*)ptr->data)->name);
01102 }
01103 
01104 static char *rna_MeshFloatProperty_path(PointerRNA *ptr)
01105 {
01106     return rna_CustomDataData_path(ptr, "layers_float", CD_MCOL);
01107 }
01108 
01109 static char *rna_MeshStringPropertyLayer_path(PointerRNA *ptr)
01110 {
01111     return BLI_sprintfN("string_layers[\"%s\"]", ((CustomDataLayer*)ptr->data)->name);
01112 }
01113 
01114 static char *rna_MeshStringProperty_path(PointerRNA *ptr)
01115 {
01116     return rna_CustomDataData_path(ptr, "layers_string", CD_MCOL);
01117 }
01118 
01119 static int rna_Mesh_tot_vert_get(PointerRNA *ptr)
01120 {
01121     Mesh *me= (Mesh*)ptr->id.data;
01122     return me->edit_mesh ? me->edit_mesh->totvertsel : 0;
01123 }
01124 static int rna_Mesh_tot_edge_get(PointerRNA *ptr)
01125 {
01126     Mesh *me= (Mesh*)ptr->id.data;
01127     return me->edit_mesh ? me->edit_mesh->totedgesel: 0;
01128 }
01129 static int rna_Mesh_tot_face_get(PointerRNA *ptr)
01130 {
01131     Mesh *me= (Mesh*)ptr->id.data;
01132     return me->edit_mesh ? me->edit_mesh->totfacesel : 0;
01133 }
01134 
01135 static CustomDataLayer *rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C, const char *name)
01136 {
01137     CustomData *fdata;
01138     CustomDataLayer *cdl= NULL;
01139     int index;
01140 
01141     if(ED_mesh_color_add(C, NULL, NULL, me, name, FALSE)) {
01142         fdata= rna_mesh_fdata(me);
01143         index= CustomData_get_named_layer_index(fdata, CD_MCOL, name);
01144         cdl= (index == -1)? NULL: &fdata->layers[index];
01145     }
01146     return cdl;
01147 }
01148 
01149 static CustomDataLayer *rna_Mesh_int_property_new(struct Mesh *me, struct bContext *C, const char *name)
01150 {
01151     CustomDataLayer *cdl = NULL;
01152     int index;
01153 
01154     CustomData_add_layer_named(&me->fdata, CD_PROP_INT, CD_DEFAULT, NULL, me->totface, name);
01155     index = CustomData_get_named_layer_index(&me->fdata, CD_PROP_INT, name);
01156 
01157     cdl = (index == -1) ? NULL : &(me->fdata.layers[index]);
01158 
01159     return cdl;
01160 }
01161 
01162 static CustomDataLayer *rna_Mesh_float_property_new(struct Mesh *me, struct bContext *C, const char *name)
01163 {
01164     CustomDataLayer *cdl = NULL;
01165     int index;
01166 
01167     CustomData_add_layer_named(&me->fdata, CD_PROP_FLT, CD_DEFAULT, NULL, me->totface, name);
01168     index = CustomData_get_named_layer_index(&me->fdata, CD_PROP_FLT, name);
01169 
01170     cdl = (index == -1) ? NULL : &(me->fdata.layers[index]);
01171 
01172     return cdl;
01173 }
01174 
01175 static CustomDataLayer *rna_Mesh_string_property_new(struct Mesh *me, struct bContext *C, const char *name)
01176 {
01177     CustomDataLayer *cdl = NULL;
01178     int index;
01179 
01180     CustomData_add_layer_named(&me->fdata, CD_PROP_STR, CD_DEFAULT, NULL, me->totface, name);
01181     index = CustomData_get_named_layer_index(&me->fdata, CD_PROP_STR, name);
01182 
01183     cdl = (index == -1) ? NULL : &(me->fdata.layers[index]);
01184 
01185     return cdl;
01186 }
01187 
01188 static CustomDataLayer *rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, const char *name)
01189 {
01190     CustomData *fdata;
01191     CustomDataLayer *cdl= NULL;
01192     int index;
01193 
01194     if(ED_mesh_uv_texture_add(C, me, name, FALSE)) {
01195         fdata= rna_mesh_fdata(me);
01196         index= CustomData_get_named_layer_index(fdata, CD_MTFACE, name);
01197         cdl= (index == -1)? NULL: &fdata->layers[index];
01198     }
01199     return cdl;
01200 }
01201 
01202 #else
01203 
01204 static void rna_def_mvert_group(BlenderRNA *brna)
01205 {
01206     StructRNA *srna;
01207     PropertyRNA *prop;
01208 
01209     srna= RNA_def_struct(brna, "VertexGroupElement", NULL);
01210     RNA_def_struct_sdna(srna, "MDeformWeight");
01211     RNA_def_struct_path_func(srna, "rna_VertexGroupElement_path");
01212     RNA_def_struct_ui_text(srna, "Vertex Group Element", "Weight value of a vertex in a vertex group");
01213     RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX);
01214 
01215     /* we can't point to actual group, it is in the object and so
01216      * there is no unique group to point to, hence the index */
01217     prop= RNA_def_property(srna, "group", PROP_INT, PROP_UNSIGNED);
01218     RNA_def_property_int_sdna(prop, NULL, "def_nr");
01219     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
01220     RNA_def_property_ui_text(prop, "Group Index", "");
01221     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01222 
01223     prop= RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
01224     RNA_def_property_range(prop, 0.0f, 1.0f);
01225     RNA_def_property_ui_text(prop, "Weight", "Vertex Weight");
01226     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01227 }
01228 
01229 static void rna_def_mvert(BlenderRNA *brna)
01230 {
01231     StructRNA *srna;
01232     PropertyRNA *prop;
01233 
01234     srna= RNA_def_struct(brna, "MeshVertex", NULL);
01235     RNA_def_struct_sdna(srna, "MVert");
01236     RNA_def_struct_ui_text(srna, "Mesh Vertex", "Vertex in a Mesh datablock");
01237     RNA_def_struct_path_func(srna, "rna_MeshVertex_path");
01238     RNA_def_struct_ui_icon(srna, ICON_VERTEXSEL);
01239 
01240     prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
01241     RNA_def_property_ui_text(prop, "Location", "");
01242     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01243 
01244     prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION);
01245     // RNA_def_property_float_sdna(prop, NULL, "no");
01246     RNA_def_property_array(prop, 3);
01247     RNA_def_property_range(prop, -1.0f, 1.0f);
01248     RNA_def_property_float_funcs(prop, "rna_MeshVertex_normal_get", "rna_MeshVertex_normal_set", NULL);
01249     RNA_def_property_ui_text(prop, "Normal", "Vertex Normal");
01250 
01251     prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
01252     RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
01253     RNA_def_property_ui_text(prop, "Select", "");
01254     RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
01255 
01256     prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
01257     RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_HIDE);
01258     RNA_def_property_ui_text(prop, "Hide", "");
01259     RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
01260 
01261     prop= RNA_def_property(srna, "bevel_weight", PROP_FLOAT, PROP_NONE);
01262     RNA_def_property_float_funcs(prop, "rna_MeshVertex_bevel_weight_get", "rna_MeshVertex_bevel_weight_set", NULL);
01263     RNA_def_property_ui_text(prop, "Bevel Weight", "Weight used by the Bevel modifier 'Only Vertices' option");
01264     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01265 
01266     prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
01267     RNA_def_property_collection_funcs(prop, "rna_MeshVertex_groups_begin", "rna_iterator_array_next",
01268                                       "rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL);
01269     RNA_def_property_struct_type(prop, "VertexGroupElement");
01270     RNA_def_property_ui_text(prop, "Groups", "Weights for the vertex groups this vertex is member of");
01271 
01272     prop= RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
01273     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
01274     RNA_def_property_int_funcs(prop, "rna_MeshVertex_index_get", NULL, NULL);
01275     RNA_def_property_ui_text(prop, "Index", "Index number of the vertex");
01276 }
01277 
01278 static void rna_def_medge(BlenderRNA *brna)
01279 {
01280     StructRNA *srna;
01281     PropertyRNA *prop;
01282 
01283     srna= RNA_def_struct(brna, "MeshEdge", NULL);
01284     RNA_def_struct_sdna(srna, "MEdge");
01285     RNA_def_struct_ui_text(srna, "Mesh Edge", "Edge in a Mesh datablock");
01286     RNA_def_struct_path_func(srna, "rna_MeshEdge_path");
01287     RNA_def_struct_ui_icon(srna, ICON_EDGESEL);
01288 
01289     prop= RNA_def_property(srna, "vertices", PROP_INT, PROP_UNSIGNED);
01290     RNA_def_property_int_sdna(prop, NULL, "v1");
01291     RNA_def_property_array(prop, 2);
01292     RNA_def_property_ui_text(prop, "Vertices", "Vertex indices");
01293     // XXX allows creating invalid meshes
01294 
01295     prop= RNA_def_property(srna, "crease", PROP_FLOAT, PROP_NONE);
01296     RNA_def_property_float_funcs(prop, "rna_MEdge_crease_get", "rna_MEdge_crease_set", NULL);
01297     RNA_def_property_ui_text(prop, "Crease", "Weight used by the Subsurf modifier for creasing");
01298     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01299 
01300     prop= RNA_def_property(srna, "bevel_weight", PROP_FLOAT, PROP_NONE);
01301     RNA_def_property_float_funcs(prop, "rna_MEdge_bevel_weight_get", "rna_MEdge_bevel_weight_set", NULL);
01302     RNA_def_property_ui_text(prop, "Bevel Weight", "Weight used by the Bevel modifier");
01303     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01304 
01305     prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
01306     RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
01307     RNA_def_property_ui_text(prop, "Select", "");
01308     RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
01309 
01310     prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
01311     RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_HIDE);
01312     RNA_def_property_ui_text(prop, "Hide", "");
01313     RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
01314 
01315     prop= RNA_def_property(srna, "use_seam", PROP_BOOLEAN, PROP_NONE);
01316     RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_SEAM);
01317     RNA_def_property_ui_text(prop, "Seam", "Seam edge for UV unwrapping");
01318     RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
01319 
01320     prop= RNA_def_property(srna, "use_edge_sharp", PROP_BOOLEAN, PROP_NONE);
01321     RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_SHARP);
01322     RNA_def_property_ui_text(prop, "Sharp", "Sharp edge for the EdgeSplit modifier");
01323     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01324 
01325     prop= RNA_def_property(srna, "is_loose", PROP_BOOLEAN, PROP_NONE);
01326     RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_LOOSEEDGE);
01327     RNA_def_property_ui_text(prop, "Loose", "Loose edge");
01328 
01329     prop= RNA_def_property(srna, "is_fgon", PROP_BOOLEAN, PROP_NONE);
01330     RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_FGON);
01331     RNA_def_property_ui_text(prop, "Fgon", "Fgon edge");
01332 
01333     prop= RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
01334     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
01335     RNA_def_property_int_funcs(prop, "rna_MeshEdge_index_get", NULL, NULL);
01336     RNA_def_property_ui_text(prop, "Index", "Index number of the vertex");
01337 }
01338 
01339 static void rna_def_mface(BlenderRNA *brna)
01340 {
01341     StructRNA *srna;
01342     PropertyRNA *prop;
01343 
01344     srna= RNA_def_struct(brna, "MeshFace", NULL);
01345     RNA_def_struct_sdna(srna, "MFace");
01346     RNA_def_struct_ui_text(srna, "Mesh Face", "Face in a Mesh datablock");
01347     RNA_def_struct_path_func(srna, "rna_MeshFace_path");
01348     RNA_def_struct_ui_icon(srna, ICON_FACESEL);
01349 
01350     // XXX allows creating invalid meshes
01351     prop= RNA_def_property(srna, "vertices", PROP_INT, PROP_UNSIGNED);
01352     RNA_def_property_array(prop, 4);
01353     RNA_def_property_flag(prop, PROP_DYNAMIC);
01354     RNA_def_property_dynamic_array_funcs(prop, "rna_MeshFace_verts_get_length");
01355     RNA_def_property_int_funcs(prop, "rna_MeshFace_verts_get", "rna_MeshFace_verts_set", NULL);
01356     RNA_def_property_ui_text(prop, "Vertices", "Vertex indices");
01357 
01358     /* leaving this fixed size array for foreach_set used in import scripts */
01359     prop= RNA_def_property(srna, "vertices_raw", PROP_INT, PROP_UNSIGNED);
01360     RNA_def_property_int_sdna(prop, NULL, "v1");
01361     RNA_def_property_array(prop, 4);
01362     RNA_def_property_ui_text(prop, "Vertices", "Fixed size vertex indices array");
01363 
01364     prop= RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED);
01365     RNA_def_property_int_sdna(prop, NULL, "mat_nr");
01366     RNA_def_property_ui_text(prop, "Material Index", "");
01367     RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MeshFace_material_index_range");
01368     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01369 
01370     prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
01371     RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_FACE_SEL);
01372     RNA_def_property_ui_text(prop, "Select", "");
01373     RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
01374 
01375     prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
01376     RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_HIDE);
01377     RNA_def_property_ui_text(prop, "Hide", "");
01378     RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
01379 
01380     prop= RNA_def_property(srna, "use_smooth", PROP_BOOLEAN, PROP_NONE);
01381     RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_SMOOTH);
01382     RNA_def_property_ui_text(prop, "Smooth", "");
01383     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01384     
01385     prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION);
01386     RNA_def_property_array(prop, 3);
01387     RNA_def_property_range(prop, -1.0f, 1.0f);
01388     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
01389     RNA_def_property_float_funcs(prop, "rna_MeshFace_normal_get", NULL, NULL);
01390     RNA_def_property_ui_text(prop, "Face normal", "Local space unit length normal vector for this face");
01391 
01392     prop= RNA_def_property(srna, "area", PROP_FLOAT, PROP_UNSIGNED);
01393     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
01394     RNA_def_property_float_funcs(prop, "rna_MeshFace_area_get", NULL, NULL);
01395     RNA_def_property_ui_text(prop, "Face area", "Read only area of the face");
01396 
01397     prop= RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
01398     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
01399     RNA_def_property_int_funcs(prop, "rna_MeshFace_index_get", NULL, NULL);
01400     RNA_def_property_ui_text(prop, "Index", "Index number of the vertex");
01401 }
01402 
01403 static void rna_def_mtface(BlenderRNA *brna)
01404 {
01405     StructRNA *srna;
01406     PropertyRNA *prop;
01407     const int uv_dim[]= {4, 2};
01408 
01409     srna= RNA_def_struct(brna, "MeshTextureFaceLayer", NULL);
01410     RNA_def_struct_ui_text(srna, "Mesh UV Map", "UV map with assigned image textures in a Mesh datablock");
01411     RNA_def_struct_sdna(srna, "CustomDataLayer");
01412     RNA_def_struct_path_func(srna, "rna_MeshTextureFaceLayer_path");
01413     RNA_def_struct_ui_icon(srna, ICON_GROUP_UVS);
01414 
01415     prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
01416     RNA_def_struct_name_property(srna, prop);
01417     RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshTextureFaceLayer_name_set");
01418     RNA_def_property_ui_text(prop, "Name", "Name of UV map");
01419     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01420 
01421     prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
01422     RNA_def_property_boolean_funcs(prop, "rna_MeshTextureFaceLayer_active_get", "rna_MeshTextureFaceLayer_active_set");
01423     RNA_def_property_ui_text(prop, "Active", "Set the map as active for display and editing");
01424     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01425 
01426     prop= RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE);
01427     RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0);
01428     RNA_def_property_boolean_funcs(prop, "rna_MeshTextureFaceLayer_active_render_get",
01429                                    "rna_MeshTextureFaceLayer_active_render_set");
01430     RNA_def_property_ui_text(prop, "Active Render", "Set the map as active for rendering");
01431     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01432 
01433     prop= RNA_def_property(srna, "active_clone", PROP_BOOLEAN, PROP_NONE);
01434     RNA_def_property_boolean_sdna(prop, NULL, "active_clone", 0);
01435     RNA_def_property_boolean_funcs(prop, "rna_MeshTextureFaceLayer_clone_get", "rna_MeshTextureFaceLayer_clone_set");
01436     RNA_def_property_ui_text(prop, "Active Clone", "Set the map as active for cloning");
01437     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01438 
01439     prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
01440     RNA_def_property_struct_type(prop, "MeshTextureFace");
01441     RNA_def_property_ui_text(prop, "Data", "");
01442     RNA_def_property_collection_funcs(prop, "rna_MeshTextureFaceLayer_data_begin", "rna_iterator_array_next",
01443                                             "rna_iterator_array_end", "rna_iterator_array_get",
01444                                             "rna_MeshTextureFaceLayer_data_length", NULL, NULL, NULL);
01445 
01446     srna= RNA_def_struct(brna, "MeshTextureFace", NULL);
01447     RNA_def_struct_sdna(srna, "MTFace");
01448     RNA_def_struct_ui_text(srna, "Mesh UV Map Face", "UV map and image texture for a face");
01449     RNA_def_struct_path_func(srna, "rna_MeshTextureFace_path");
01450     RNA_def_struct_ui_icon(srna, ICON_FACESEL_HLT);
01451 
01452     prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
01453     RNA_def_property_pointer_sdna(prop, NULL, "tpage");
01454     RNA_def_property_pointer_funcs(prop, NULL, "rna_TextureFace_image_set", NULL, NULL);
01455     RNA_def_property_flag(prop, PROP_EDITABLE);
01456     RNA_def_property_ui_text(prop, "Image", "");
01457     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01458 
01459     prop= RNA_def_property(srna, "select_uv", PROP_BOOLEAN, PROP_NONE);
01460     RNA_def_property_boolean_sdna(prop, NULL, "flag", TF_SEL1);
01461     RNA_def_property_array(prop, 4);
01462     RNA_def_property_ui_text(prop, "UV Selected", "");
01463     RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
01464 
01465     prop= RNA_def_property(srna, "pin_uv", PROP_BOOLEAN, PROP_NONE);
01466     RNA_def_property_boolean_sdna(prop, NULL, "unwrap", TF_PIN1);
01467     RNA_def_property_array(prop, 4);
01468     RNA_def_property_ui_text(prop, "UV Pinned", "");
01469     RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
01470 
01471     prop= RNA_def_property(srna, "uv1", PROP_FLOAT, PROP_XYZ);
01472     RNA_def_property_array(prop, 2);
01473     RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv1_get", "rna_MeshTextureFace_uv1_set", NULL);
01474     RNA_def_property_ui_text(prop, "UV 1", "");
01475     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01476 
01477     prop= RNA_def_property(srna, "uv2", PROP_FLOAT, PROP_XYZ);
01478     RNA_def_property_array(prop, 2);
01479     RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv2_get", "rna_MeshTextureFace_uv2_set", NULL);
01480     RNA_def_property_ui_text(prop, "UV 2", "");
01481     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01482 
01483     prop= RNA_def_property(srna, "uv3", PROP_FLOAT, PROP_XYZ);
01484     RNA_def_property_array(prop, 2);
01485     RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv3_get", "rna_MeshTextureFace_uv3_set", NULL);
01486     RNA_def_property_ui_text(prop, "UV 3", "");
01487     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01488 
01489     prop= RNA_def_property(srna, "uv4", PROP_FLOAT, PROP_XYZ);
01490     RNA_def_property_array(prop, 2);
01491     RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv4_get", "rna_MeshTextureFace_uv4_set", NULL);
01492     RNA_def_property_ui_text(prop, "UV 4", "");
01493     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01494 
01495     prop= RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE);
01496     RNA_def_property_multi_array(prop, 2, uv_dim);
01497     RNA_def_property_flag(prop, PROP_DYNAMIC);
01498     RNA_def_property_dynamic_array_funcs(prop, "rna_MeshTextureFace_uv_get_length");
01499     RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv_get", "rna_MeshTextureFace_uv_set", NULL);
01500     RNA_def_property_ui_text(prop, "UV", "");
01501     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01502 
01503     prop= RNA_def_property(srna, "uv_raw", PROP_FLOAT, PROP_NONE);
01504     RNA_def_property_multi_array(prop, 2, uv_dim);
01505     RNA_def_property_float_sdna(prop, NULL, "uv");
01506     RNA_def_property_ui_text(prop, "UV", "Fixed size UV coordinates array");
01507 
01508 }
01509 
01510 static void rna_def_msticky(BlenderRNA *brna)
01511 {
01512     StructRNA *srna;
01513     PropertyRNA *prop;
01514 
01515     srna= RNA_def_struct(brna, "MeshSticky", NULL);
01516     RNA_def_struct_sdna(srna, "MSticky");
01517     RNA_def_struct_ui_text(srna, "Mesh Vertex Sticky Texture Coordinate", "Stricky texture coordinate");
01518     RNA_def_struct_path_func(srna, "rna_MeshSticky_path");
01519 
01520     prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_XYZ);
01521     RNA_def_property_ui_text(prop, "Location", "Sticky texture coordinate location");
01522     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01523 }
01524 
01525 static void rna_def_mcol(BlenderRNA *brna)
01526 {
01527     StructRNA *srna;
01528     PropertyRNA *prop;
01529 
01530     srna= RNA_def_struct(brna, "MeshColorLayer", NULL);
01531     RNA_def_struct_ui_text(srna, "Mesh Vertex Color Layer", "Layer of vertex colors in a Mesh datablock");
01532     RNA_def_struct_sdna(srna, "CustomDataLayer");
01533     RNA_def_struct_path_func(srna, "rna_MeshColorLayer_path");
01534     RNA_def_struct_ui_icon(srna, ICON_GROUP_VCOL);
01535 
01536     prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
01537     RNA_def_struct_name_property(srna, prop);
01538     RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshColorLayer_name_set");
01539     RNA_def_property_ui_text(prop, "Name", "Name of Vertex color layer");
01540     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01541 
01542     prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
01543     RNA_def_property_boolean_funcs(prop, "rna_MeshColorLayer_active_get", "rna_MeshColorLayer_active_set");
01544     RNA_def_property_ui_text(prop, "Active", "Sets the layer as active for display and editing");
01545     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01546 
01547     prop= RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE);
01548     RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0);
01549     RNA_def_property_boolean_funcs(prop, "rna_MeshColorLayer_active_render_get", "rna_MeshColorLayer_active_render_set");
01550     RNA_def_property_ui_text(prop, "Active Render", "Sets the layer as active for rendering");
01551     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01552 
01553     prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
01554     RNA_def_property_struct_type(prop, "MeshColor");
01555     RNA_def_property_ui_text(prop, "Data", "");
01556     RNA_def_property_collection_funcs(prop, "rna_MeshColorLayer_data_begin", "rna_iterator_array_next",
01557                                       "rna_iterator_array_end", "rna_iterator_array_get",
01558                                       "rna_MeshColorLayer_data_length", NULL, NULL, NULL);
01559 
01560     srna= RNA_def_struct(brna, "MeshColor", NULL);
01561     RNA_def_struct_sdna(srna, "MCol");
01562     RNA_def_struct_ui_text(srna, "Mesh Vertex Color", "Vertex colors for a face in a Mesh");
01563     RNA_def_struct_path_func(srna, "rna_MeshColor_path");
01564 
01565     prop= RNA_def_property(srna, "color1", PROP_FLOAT, PROP_COLOR);
01566     RNA_def_property_array(prop, 3);
01567     RNA_def_property_range(prop, 0.0f, 1.0f);
01568     RNA_def_property_float_funcs(prop, "rna_MeshColor_color1_get", "rna_MeshColor_color1_set", NULL);
01569     RNA_def_property_ui_text(prop, "Color 1", "");
01570     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01571 
01572     prop= RNA_def_property(srna, "color2", PROP_FLOAT, PROP_COLOR);
01573     RNA_def_property_array(prop, 3);
01574     RNA_def_property_range(prop, 0.0f, 1.0f);
01575     RNA_def_property_float_funcs(prop, "rna_MeshColor_color2_get", "rna_MeshColor_color2_set", NULL);
01576     RNA_def_property_ui_text(prop, "Color 2", "");
01577     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01578 
01579     prop= RNA_def_property(srna, "color3", PROP_FLOAT, PROP_COLOR);
01580     RNA_def_property_array(prop, 3);
01581     RNA_def_property_range(prop, 0.0f, 1.0f);
01582     RNA_def_property_float_funcs(prop, "rna_MeshColor_color3_get", "rna_MeshColor_color3_set", NULL);
01583     RNA_def_property_ui_text(prop, "Color 3", "");
01584     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01585 
01586     prop= RNA_def_property(srna, "color4", PROP_FLOAT, PROP_COLOR);
01587     RNA_def_property_array(prop, 3);
01588     RNA_def_property_range(prop, 0.0f, 1.0f);
01589     RNA_def_property_float_funcs(prop, "rna_MeshColor_color4_get", "rna_MeshColor_color4_set", NULL);
01590     RNA_def_property_ui_text(prop, "Color 4", "");
01591     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01592 }
01593 
01594 static void rna_def_mproperties(BlenderRNA *brna)
01595 {
01596     StructRNA *srna;
01597     PropertyRNA *prop;
01598 
01599     /* Float */
01600     srna= RNA_def_struct(brna, "MeshFloatPropertyLayer", NULL);
01601     RNA_def_struct_sdna(srna, "CustomDataLayer");
01602     RNA_def_struct_ui_text(srna, "Mesh Float Property Layer", "User defined layer of floating pointer number values");
01603     RNA_def_struct_path_func(srna, "rna_MeshFloatPropertyLayer_path");
01604 
01605     prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
01606     RNA_def_struct_name_property(srna, prop);
01607     RNA_def_property_ui_text(prop, "Name", "");
01608     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01609 
01610     prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
01611     RNA_def_property_struct_type(prop, "MeshFloatProperty");
01612     RNA_def_property_ui_text(prop, "Data", "");
01613     RNA_def_property_collection_funcs(prop, "rna_MeshFloatPropertyLayer_data_begin", "rna_iterator_array_next",
01614                                       "rna_iterator_array_end", "rna_iterator_array_get",
01615                                       "rna_MeshFloatPropertyLayer_data_length", NULL, NULL, NULL);
01616 
01617     srna= RNA_def_struct(brna, "MeshFloatProperty", NULL);
01618     RNA_def_struct_sdna(srna, "MFloatProperty");
01619     RNA_def_struct_ui_text(srna, "Mesh Float Property", "User defined floating point number value in a float properties layer");
01620     RNA_def_struct_path_func(srna, "rna_MeshFloatProperty_path");
01621 
01622     prop= RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
01623     RNA_def_property_float_sdna(prop, NULL, "f");
01624     RNA_def_property_ui_text(prop, "Value", "");
01625     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01626 
01627     /* Int */
01628     srna= RNA_def_struct(brna, "MeshIntPropertyLayer", NULL);
01629     RNA_def_struct_sdna(srna, "CustomDataLayer");
01630     RNA_def_struct_ui_text(srna, "Mesh Int Property Layer", "User defined layer of integer number values");
01631     RNA_def_struct_path_func(srna, "rna_MeshIntPropertyLayer_path");
01632 
01633     prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
01634     RNA_def_struct_name_property(srna, prop);
01635     RNA_def_property_ui_text(prop, "Name", "");
01636     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01637 
01638     prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
01639     RNA_def_property_struct_type(prop, "MeshIntProperty");
01640     RNA_def_property_ui_text(prop, "Data", "");
01641     RNA_def_property_collection_funcs(prop, "rna_MeshIntPropertyLayer_data_begin", "rna_iterator_array_next",
01642                                       "rna_iterator_array_end", "rna_iterator_array_get",
01643                                       "rna_MeshIntPropertyLayer_data_length", NULL, NULL, NULL);
01644 
01645     srna= RNA_def_struct(brna, "MeshIntProperty", NULL);
01646     RNA_def_struct_sdna(srna, "MIntProperty");
01647     RNA_def_struct_ui_text(srna, "Mesh Int Property", "User defined integer number value in an integer properties layer");
01648     RNA_def_struct_path_func(srna, "rna_MeshIntProperty_path");
01649 
01650     prop= RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
01651     RNA_def_property_int_sdna(prop, NULL, "i");
01652     RNA_def_property_ui_text(prop, "Value", "");
01653     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01654 
01655     /* String */
01656     srna= RNA_def_struct(brna, "MeshStringPropertyLayer", NULL);
01657     RNA_def_struct_sdna(srna, "CustomDataLayer");
01658     RNA_def_struct_ui_text(srna, "Mesh String Property Layer", "User defined layer of string text values");
01659     RNA_def_struct_path_func(srna, "rna_MeshStringPropertyLayer_path");
01660 
01661     prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
01662     RNA_def_struct_name_property(srna, prop);
01663     RNA_def_property_ui_text(prop, "Name", "");
01664     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01665 
01666     prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
01667     RNA_def_property_struct_type(prop, "MeshStringProperty");
01668     RNA_def_property_ui_text(prop, "Data", "");
01669     RNA_def_property_collection_funcs(prop, "rna_MeshStringPropertyLayer_data_begin", "rna_iterator_array_next",
01670                                       "rna_iterator_array_end", "rna_iterator_array_get",
01671                                       "rna_MeshStringPropertyLayer_data_length", NULL, NULL, NULL);
01672 
01673     srna= RNA_def_struct(brna, "MeshStringProperty", NULL);
01674     RNA_def_struct_sdna(srna, "MStringProperty");
01675     RNA_def_struct_ui_text(srna, "Mesh String Property", "User defined string text value in a string properties layer");
01676     RNA_def_struct_path_func(srna, "rna_MeshStringProperty_path");
01677 
01678     /* low level mesh data access, treat as bytes */
01679     prop= RNA_def_property(srna, "value", PROP_STRING, PROP_BYTESTRING);
01680     RNA_def_property_string_sdna(prop, NULL, "s");
01681     RNA_def_property_ui_text(prop, "Value", "");
01682     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01683 }
01684 
01685 /* mesh.vertices */
01686 static void rna_def_mesh_vertices(BlenderRNA *brna, PropertyRNA *cprop)
01687 {
01688     StructRNA *srna;
01689 //  PropertyRNA *prop;
01690 
01691     FunctionRNA *func;
01692 //  PropertyRNA *parm;
01693 
01694     RNA_def_property_srna(cprop, "MeshVertices");
01695     srna= RNA_def_struct(brna, "MeshVertices", NULL);
01696     RNA_def_struct_sdna(srna, "Mesh");
01697     RNA_def_struct_ui_text(srna, "Mesh Vertices", "Collection of mesh vertices");
01698 
01699     func= RNA_def_function(srna, "add", "ED_mesh_vertices_add");
01700     RNA_def_function_flag(func, FUNC_USE_REPORTS);
01701     RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add", 0, INT_MAX);
01702 }
01703 
01704 /* mesh.edges */
01705 static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop)
01706 {
01707     StructRNA *srna;
01708 //  PropertyRNA *prop;
01709 
01710     FunctionRNA *func;
01711 //  PropertyRNA *parm;
01712 
01713     RNA_def_property_srna(cprop, "MeshEdges");
01714     srna= RNA_def_struct(brna, "MeshEdges", NULL);
01715     RNA_def_struct_sdna(srna, "Mesh");
01716     RNA_def_struct_ui_text(srna, "Mesh Edges", "Collection of mesh edges");
01717 
01718     func= RNA_def_function(srna, "add", "ED_mesh_edges_add");
01719     RNA_def_function_flag(func, FUNC_USE_REPORTS);
01720     RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add", 0, INT_MAX);
01721 }
01722 
01723 /* mesh.faces */
01724 static void rna_def_mesh_faces(BlenderRNA *brna, PropertyRNA *cprop)
01725 {
01726     StructRNA *srna;
01727     PropertyRNA *prop;
01728 
01729     FunctionRNA *func;
01730     /*PropertyRNA *parm;*/
01731 
01732     RNA_def_property_srna(cprop, "MeshFaces");
01733     srna= RNA_def_struct(brna, "MeshFaces", NULL);
01734     RNA_def_struct_sdna(srna, "Mesh");
01735     RNA_def_struct_ui_text(srna, "Mesh Faces", "Collection of mesh faces");
01736 
01737     prop= RNA_def_property(srna, "active", PROP_INT, PROP_NONE);
01738     RNA_def_property_int_sdna(prop, NULL, "act_face");
01739     RNA_def_property_ui_text(prop, "Active Face", "The active face for this mesh");
01740 
01741     prop= RNA_def_property(srna, "active_tface", PROP_POINTER, PROP_UNSIGNED);
01742     RNA_def_property_struct_type(prop, "MeshTextureFace");
01743     RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_mtface_get", NULL, NULL, NULL);
01744     RNA_def_property_ui_text(prop, "Active UV Map Face", "Active UV Map Face");
01745     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01746 
01747     func= RNA_def_function(srna, "add", "ED_mesh_faces_add");
01748     RNA_def_function_flag(func, FUNC_USE_REPORTS);
01749     RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add", 0, INT_MAX);
01750 }
01751 
01752 /* mesh.vertex_colors */
01753 static void rna_def_vertex_colors(BlenderRNA *brna, PropertyRNA *cprop)
01754 {
01755     StructRNA *srna;
01756     PropertyRNA *prop;
01757 
01758     FunctionRNA *func;
01759     PropertyRNA *parm;
01760 
01761     RNA_def_property_srna(cprop, "VertexColors");
01762     srna= RNA_def_struct(brna, "VertexColors", NULL);
01763     RNA_def_struct_sdna(srna, "Mesh");
01764     RNA_def_struct_ui_text(srna, "Vertex Colors", "Collection of vertex colors");
01765     
01766     func= RNA_def_function(srna, "new", "rna_Mesh_vertex_color_new");
01767     RNA_def_function_flag(func, FUNC_USE_CONTEXT);
01768     RNA_def_function_ui_description(func, "Add a vertex color layer to Mesh");
01769     RNA_def_string(func, "name", "Col", 0, "", "Vertex color name");
01770     parm= RNA_def_pointer(func, "layer", "MeshColorLayer", "", "The newly created layer");
01771     RNA_def_function_return(func, parm);
01772     
01773 /*
01774     func= RNA_def_function(srna, "remove", "rna_Mesh_vertex_color_remove");
01775     RNA_def_function_ui_description(func, "Remove a vertex color layer");
01776     RNA_def_function_flag(func, FUNC_USE_REPORTS);
01777     parm= RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove");
01778     RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
01779 */
01780     prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED);
01781     RNA_def_property_struct_type(prop, "MeshColorLayer");
01782     RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_vertex_color_get", "rna_Mesh_active_vertex_color_set", NULL, NULL);
01783     RNA_def_property_flag(prop, PROP_EDITABLE);
01784     RNA_def_property_ui_text(prop, "Active Vertex Color Layer", "Active vertex color layer");
01785     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01786     
01787     prop= RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
01788     RNA_def_property_int_funcs(prop, "rna_Mesh_active_vertex_color_index_get", "rna_Mesh_active_vertex_color_index_set", "rna_Mesh_active_vertex_color_index_range");
01789     RNA_def_property_ui_text(prop, "Active Vertex Color Index", "Active vertex color index");
01790     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01791 }
01792 
01793 /* mesh int layers */
01794 static void rna_def_int_layers(BlenderRNA *brna, PropertyRNA *cprop)
01795 {
01796     StructRNA *srna;
01797 
01798     FunctionRNA *func;
01799     PropertyRNA *parm;
01800 
01801     RNA_def_property_srna(cprop, "IntProperties");
01802     srna= RNA_def_struct(brna, "IntProperties", NULL);
01803     RNA_def_struct_sdna(srna, "Mesh");
01804     RNA_def_struct_ui_text(srna, "Int Properties", "Collection of int properties");
01805 
01806     func= RNA_def_function(srna, "new", "rna_Mesh_int_property_new");
01807     RNA_def_function_flag(func, FUNC_USE_CONTEXT);
01808     RNA_def_function_ui_description(func, "Add a integer property layer to Mesh");
01809     RNA_def_string(func, "name", "Int Prop", 0, "",  "Int property name");
01810     parm= RNA_def_pointer(func, "layer", "MeshIntPropertyLayer", "", "The newly created layer");
01811     RNA_def_function_return(func, parm);
01812 }
01813 
01814 /* mesh float layers */
01815 static void rna_def_float_layers(BlenderRNA *brna, PropertyRNA *cprop)
01816 {
01817     StructRNA *srna;
01818 
01819     FunctionRNA *func;
01820     PropertyRNA *parm;
01821 
01822     RNA_def_property_srna(cprop, "FloatProperties");
01823     srna= RNA_def_struct(brna, "FloatProperties", NULL);
01824     RNA_def_struct_sdna(srna, "Mesh");
01825     RNA_def_struct_ui_text(srna, "Float Properties", "Collection of float properties");
01826 
01827     func= RNA_def_function(srna, "new", "rna_Mesh_float_property_new");
01828     RNA_def_function_flag(func, FUNC_USE_CONTEXT);
01829     RNA_def_function_ui_description(func, "Add a float property layer to Mesh");
01830     RNA_def_string(func, "name", "Float Prop", 0, "", "Float property name");
01831     parm= RNA_def_pointer(func, "layer", "MeshFloatPropertyLayer", "", "The newly created layer");
01832     RNA_def_function_return(func, parm);
01833 }
01834 
01835 /* mesh string layers */
01836 static void rna_def_string_layers(BlenderRNA *brna, PropertyRNA *cprop)
01837 {
01838     StructRNA *srna;
01839 
01840     FunctionRNA *func;
01841     PropertyRNA *parm;
01842 
01843     RNA_def_property_srna(cprop, "StringProperties");
01844     srna= RNA_def_struct(brna, "StringProperties", NULL);
01845     RNA_def_struct_sdna(srna, "Mesh");
01846     RNA_def_struct_ui_text(srna, "String Properties", "Collection of string properties");
01847 
01848     func= RNA_def_function(srna, "new", "rna_Mesh_string_property_new");
01849     RNA_def_function_flag(func, FUNC_USE_CONTEXT);
01850     RNA_def_function_ui_description(func, "Add a string property layer to Mesh");
01851     RNA_def_string(func, "name", "String Prop", 0, "", "String property name");
01852     parm= RNA_def_pointer(func, "layer", "MeshStringPropertyLayer", "", "The newly created layer");
01853     RNA_def_function_return(func, parm);
01854 }
01855 
01856 /* mesh.uv_layers */
01857 static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop)
01858 {
01859     StructRNA *srna;
01860     PropertyRNA *prop;
01861 
01862     FunctionRNA *func;
01863     PropertyRNA *parm;
01864 
01865     RNA_def_property_srna(cprop, "UVTextures");
01866     srna= RNA_def_struct(brna, "UVTextures", NULL);
01867     RNA_def_struct_sdna(srna, "Mesh");
01868     RNA_def_struct_ui_text(srna, "UV Maps", "Collection of UV maps");
01869     
01870     func= RNA_def_function(srna, "new", "rna_Mesh_uv_texture_new");
01871     RNA_def_function_flag(func, FUNC_USE_CONTEXT);
01872     RNA_def_function_ui_description(func, "Add a UV texture layer to Mesh");
01873     RNA_def_string(func, "name", "UVMap", 0, "", "UV map name");
01874     parm= RNA_def_pointer(func, "layer", "MeshTextureFaceLayer", "", "The newly created layer");
01875     RNA_def_function_return(func, parm);
01876 
01877 /*
01878     func= RNA_def_function(srna, "remove", "rna_Mesh_uv_layers_remove");
01879     RNA_def_function_ui_description(func, "Remove a vertex color layer");
01880     RNA_def_function_flag(func, FUNC_USE_REPORTS);
01881     parm= RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove");
01882     RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
01883 */
01884     prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED);
01885     RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
01886     RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_uv_texture_get", "rna_Mesh_active_uv_texture_set", NULL, NULL);
01887     RNA_def_property_flag(prop, PROP_EDITABLE);
01888     RNA_def_property_ui_text(prop, "Active UV Map", "Active UV Map");
01889     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01890 
01891     prop= RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
01892     RNA_def_property_int_funcs(prop, "rna_Mesh_active_uv_texture_index_get",
01893                                "rna_Mesh_active_uv_texture_index_set", "rna_Mesh_active_uv_texture_index_range");
01894     RNA_def_property_ui_text(prop, "Active UV Map Index", "Active UV Map index");
01895     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
01896 }
01897 
01898 static void rna_def_mesh(BlenderRNA *brna)
01899 {
01900     StructRNA *srna;
01901     PropertyRNA *prop;
01902 
01903     srna= RNA_def_struct(brna, "Mesh", "ID");
01904     RNA_def_struct_ui_text(srna, "Mesh", "Mesh datablock defining geometric surfaces");
01905     RNA_def_struct_ui_icon(srna, ICON_MESH_DATA);
01906 
01907     prop= RNA_def_property(srna, "vertices", PROP_COLLECTION, PROP_NONE);
01908     RNA_def_property_collection_sdna(prop, NULL, "mvert", "totvert");
01909     RNA_def_property_struct_type(prop, "MeshVertex");
01910     RNA_def_property_ui_text(prop, "Vertices", "Vertices of the mesh");
01911     rna_def_mesh_vertices(brna, prop);
01912 
01913     prop= RNA_def_property(srna, "edges", PROP_COLLECTION, PROP_NONE);
01914     RNA_def_property_collection_sdna(prop, NULL, "medge", "totedge");
01915     RNA_def_property_struct_type(prop, "MeshEdge");
01916     RNA_def_property_ui_text(prop, "Edges", "Edges of the mesh");
01917     rna_def_mesh_edges(brna, prop);
01918 
01919     prop= RNA_def_property(srna, "faces", PROP_COLLECTION, PROP_NONE);
01920     RNA_def_property_collection_sdna(prop, NULL, "mface", "totface");
01921     RNA_def_property_struct_type(prop, "MeshFace");
01922     RNA_def_property_ui_text(prop, "Faces", "Faces of the mesh");
01923     rna_def_mesh_faces(brna, prop);
01924 
01925     prop= RNA_def_property(srna, "sticky", PROP_COLLECTION, PROP_NONE);
01926     RNA_def_property_collection_sdna(prop, NULL, "msticky", "totvert");
01927     RNA_def_property_struct_type(prop, "MeshSticky");
01928     RNA_def_property_ui_text(prop, "Sticky", "Sticky texture coordinates");
01929 
01930     /* TODO, should this be allowed to be its self? */
01931     prop= RNA_def_property(srna, "texture_mesh", PROP_POINTER, PROP_NONE);
01932     RNA_def_property_pointer_sdna(prop, NULL, "texcomesh");
01933     RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
01934     RNA_def_property_ui_text(prop, "Texture Mesh", "Use another mesh for texture indices (vertex indices must be aligned)");
01935 
01936     /* UV textures */
01937     prop= RNA_def_property(srna, "uv_textures", PROP_COLLECTION, PROP_NONE);
01938     RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
01939     RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_textures_begin", NULL, NULL, NULL,
01940                                       "rna_Mesh_uv_textures_length", NULL, NULL, NULL);
01941     RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
01942     RNA_def_property_ui_text(prop, "UV Maps", "");
01943     rna_def_uv_textures(brna, prop);
01944 
01945     prop= RNA_def_property(srna, "uv_texture_clone", PROP_POINTER, PROP_UNSIGNED);
01946     RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
01947     RNA_def_property_pointer_funcs(prop, "rna_Mesh_uv_texture_clone_get", "rna_Mesh_uv_texture_clone_set", NULL, NULL);
01948     RNA_def_property_flag(prop, PROP_EDITABLE);
01949     RNA_def_property_ui_text(prop, "Clone UV Map", "UV map to be used as cloning source");
01950 
01951     prop= RNA_def_property(srna, "uv_texture_clone_index", PROP_INT, PROP_UNSIGNED);
01952     RNA_def_property_int_funcs(prop, "rna_Mesh_uv_texture_clone_index_get",
01953                                "rna_Mesh_uv_texture_clone_index_set", "rna_Mesh_active_uv_texture_index_range");
01954     RNA_def_property_ui_text(prop, "Clone UV Map Index", "Clone UV texture index");
01955 
01956     prop= RNA_def_property(srna, "uv_texture_stencil", PROP_POINTER, PROP_UNSIGNED);
01957     RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
01958     RNA_def_property_pointer_funcs(prop, "rna_Mesh_uv_texture_stencil_get", "rna_Mesh_uv_texture_stencil_set", NULL, NULL);
01959     RNA_def_property_flag(prop, PROP_EDITABLE);
01960     RNA_def_property_ui_text(prop, "Mask UV Map", "UV map to mask the painted area");
01961 
01962     prop= RNA_def_property(srna, "uv_texture_stencil_index", PROP_INT, PROP_UNSIGNED);
01963     RNA_def_property_int_funcs(prop, "rna_Mesh_uv_texture_stencil_index_get", "rna_Mesh_uv_texture_stencil_index_set", "rna_Mesh_active_uv_texture_index_range");
01964     RNA_def_property_ui_text(prop, "Mask UV Map Index", "Mask UV map index");
01965 
01966     /* Vertex colors */
01967 
01968     prop= RNA_def_property(srna, "vertex_colors", PROP_COLLECTION, PROP_NONE);
01969     RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
01970     RNA_def_property_collection_funcs(prop, "rna_Mesh_vertex_colors_begin", NULL, NULL, NULL,
01971                                       "rna_Mesh_vertex_colors_length", NULL, NULL, NULL);
01972     RNA_def_property_struct_type(prop, "MeshColorLayer");
01973     RNA_def_property_ui_text(prop, "Vertex Colors", "");
01974     rna_def_vertex_colors(brna, prop);
01975 
01976     prop= RNA_def_property(srna, "layers_float", PROP_COLLECTION, PROP_NONE);
01977     RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
01978     RNA_def_property_collection_funcs(prop, "rna_Mesh_float_layers_begin", NULL, NULL, NULL,
01979                                       "rna_Mesh_float_layers_length", NULL, NULL, NULL);
01980     RNA_def_property_struct_type(prop, "MeshFloatPropertyLayer");
01981     RNA_def_property_ui_text(prop, "Float Property Layers", "");
01982     rna_def_float_layers(brna, prop);
01983 
01984     prop= RNA_def_property(srna, "layers_int", PROP_COLLECTION, PROP_NONE);
01985     RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
01986     RNA_def_property_collection_funcs(prop, "rna_Mesh_int_layers_begin", NULL, NULL, NULL,
01987                                       "rna_Mesh_int_layers_length", NULL, NULL, NULL);
01988     RNA_def_property_struct_type(prop, "MeshIntPropertyLayer");
01989     RNA_def_property_ui_text(prop, "Int Property Layers", "");
01990     rna_def_int_layers(brna, prop);
01991 
01992     prop= RNA_def_property(srna, "layers_string", PROP_COLLECTION, PROP_NONE);
01993     RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
01994     RNA_def_property_collection_funcs(prop, "rna_Mesh_string_layers_begin", NULL, NULL, NULL,
01995                                       "rna_Mesh_string_layers_length", NULL, NULL, NULL);
01996     RNA_def_property_struct_type(prop, "MeshStringPropertyLayer");
01997     RNA_def_property_ui_text(prop, "String Property Layers", "");
01998     rna_def_string_layers(brna, prop);
01999 
02000     prop= RNA_def_property(srna, "use_auto_smooth", PROP_BOOLEAN, PROP_NONE);
02001     RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_AUTOSMOOTH);
02002     RNA_def_property_ui_text(prop, "Auto Smooth",
02003                              "Treat all set-smoothed faces with angles less than the "
02004                              "specified angle as 'smooth' during render");
02005 
02006 #if 1 /* expose as radians */
02007     prop= RNA_def_property(srna, "auto_smooth_angle", PROP_FLOAT, PROP_ANGLE);
02008     RNA_def_property_float_funcs(prop, "rna_Mesh_auto_smooth_angle_get", "rna_Mesh_auto_smooth_angle_set", NULL);
02009     RNA_def_property_ui_range(prop, DEG2RAD(1.0), DEG2RAD(80), 1.0, 1);
02010 #else
02011     prop= RNA_def_property(srna, "auto_smooth_angle", PROP_INT, PROP_NONE);
02012     RNA_def_property_int_sdna(prop, NULL, "smoothresh");
02013     RNA_def_property_range(prop, 1, 80);
02014 #endif
02015     RNA_def_property_ui_text(prop, "Auto Smooth Angle",
02016                              "Maximum angle between face normals that 'Auto Smooth' will operate on");
02017 
02018     prop= RNA_def_property(srna, "show_double_sided", PROP_BOOLEAN, PROP_NONE);
02019     RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_TWOSIDED);
02020     RNA_def_property_ui_text(prop, "Double Sided", "Render/display the mesh with double or single sided lighting");
02021     RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
02022 
02023     prop= RNA_def_property(srna, "texco_mesh", PROP_POINTER, PROP_NONE);
02024     RNA_def_property_pointer_sdna(prop, NULL, "texcomesh");
02025     RNA_def_property_flag(prop, PROP_EDITABLE);
02026     RNA_def_property_ui_text(prop, "Texture Space Mesh", "Derive texture coordinates from another mesh");
02027 
02028     prop= RNA_def_property(srna, "shape_keys", PROP_POINTER, PROP_NONE);
02029     RNA_def_property_pointer_sdna(prop, NULL, "key");
02030     RNA_def_property_ui_text(prop, "Shape Keys", "");
02031     
02032     /* texture space */
02033     prop= RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE);
02034     RNA_def_property_boolean_sdna(prop, NULL, "texflag", AUTOSPACE);
02035     RNA_def_property_ui_text(prop, "Auto Texture Space",
02036                              "Adjust active object's texture space automatically when transforming object");
02037     RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Mesh_texspace_set");
02038     
02039     prop= RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION);
02040     RNA_def_property_array(prop, 3);
02041     RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location");
02042     RNA_def_property_editable_func(prop, "rna_Mesh_texspace_editable");
02043     RNA_def_property_float_funcs(prop, "rna_Mesh_texspace_loc_get", "rna_Mesh_texspace_loc_set", NULL); 
02044     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02045     
02046     prop= RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ);
02047     RNA_def_property_array(prop, 3);
02048     RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size");
02049     RNA_def_property_editable_func(prop, "rna_Mesh_texspace_editable");
02050     RNA_def_property_float_funcs(prop, "rna_Mesh_texspace_size_get", "rna_Mesh_texspace_size_set", NULL);
02051     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02052     
02053     /* not supported yet
02054     prop= RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_EULER);
02055     RNA_def_property_float(prop, NULL, "rot");
02056     RNA_def_property_ui_text(prop, "Texture Space Rotation", "Texture space rotation");
02057     RNA_def_property_editable_func(prop, texspace_editable);
02058     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02059     */
02060     
02061     /* materials */
02062     prop= RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
02063     RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
02064     RNA_def_property_struct_type(prop, "Material");
02065     RNA_def_property_ui_text(prop, "Materials", "");
02066     RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
02067     RNA_def_property_collection_funcs(prop, 0, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");
02068 
02069     /* Mesh Draw Options for Edit Mode*/
02070     
02071     prop= RNA_def_property(srna, "show_edges", PROP_BOOLEAN, PROP_NONE);
02072     RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEDGES);
02073     RNA_def_property_ui_text(prop, "Draw Edges", "Display selected edges using highlights in the 3D view and UV editor");
02074     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02075     
02076     prop= RNA_def_property(srna, "show_all_edges", PROP_BOOLEAN, PROP_NONE);
02077     RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_ALLEDGES);
02078     RNA_def_property_ui_text(prop, "All Edges", "Display all edges for wireframe in all view modes in the 3D view");
02079     RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
02080 
02081     prop= RNA_def_property(srna, "show_faces", PROP_BOOLEAN, PROP_NONE);
02082     RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWFACES);
02083     RNA_def_property_ui_text(prop, "Draw Faces", "Display all faces as shades in the 3D view and UV editor");
02084     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02085     
02086     prop= RNA_def_property(srna, "show_normal_face", PROP_BOOLEAN, PROP_NONE);
02087     RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWNORMALS);
02088     RNA_def_property_ui_text(prop, "Draw Normals", "Display face normals as lines");
02089     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02090     
02091     prop= RNA_def_property(srna, "show_normal_vertex", PROP_BOOLEAN, PROP_NONE);
02092     RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_VNORMALS);
02093     RNA_def_property_ui_text(prop, "Draw Vertex Normals", "Display vertex normals as lines");
02094     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02095     
02096     prop= RNA_def_property(srna, "show_edge_crease", PROP_BOOLEAN, PROP_NONE);
02097     RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWCREASES);
02098     RNA_def_property_ui_text(prop, "Draw Creases", "Display creases created for subsurf weighting");
02099     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02100     
02101     prop= RNA_def_property(srna, "show_edge_bevel_weight", PROP_BOOLEAN, PROP_NONE);
02102     RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWBWEIGHTS);
02103     RNA_def_property_ui_text(prop, "Draw Bevel Weights", "Display weights created for the Bevel modifier");
02104     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02105     
02106     prop= RNA_def_property(srna, "show_edge_seams", PROP_BOOLEAN, PROP_NONE);
02107     RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWSEAMS);
02108     RNA_def_property_ui_text(prop, "Draw Seams", "Display UV unwrapping seams");
02109     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02110     
02111     prop= RNA_def_property(srna, "show_edge_sharp", PROP_BOOLEAN, PROP_NONE);
02112     RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWSHARP);
02113     RNA_def_property_ui_text(prop, "Draw Sharp", "Display sharp edges, used with the EdgeSplit modifier");
02114     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02115 
02116     prop= RNA_def_property(srna, "show_extra_edge_length", PROP_BOOLEAN, PROP_NONE);
02117     RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_EDGELEN);
02118     RNA_def_property_ui_text(prop, "Edge Length",
02119                              "Display selected edge lengths, using global values when set in the transform panel");
02120     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02121     
02122     prop= RNA_def_property(srna, "show_extra_face_angle", PROP_BOOLEAN, PROP_NONE);
02123     RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_FACEANG);
02124     RNA_def_property_ui_text(prop, "Faces Angles",
02125                              "Display the angles between the selected edges in degrees, using "
02126                              "global values when set in the transform panel");
02127     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02128     
02129     prop= RNA_def_property(srna, "show_extra_face_area", PROP_BOOLEAN, PROP_NONE);
02130     RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_FACEAREA);
02131     RNA_def_property_ui_text(prop, "Face Area",
02132                              "Display the area of selected faces, using global values when set in the transform panel");
02133     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02134 
02135     prop= RNA_def_property(srna, "show_extra_indices", PROP_BOOLEAN, PROP_NONE);
02136     RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_INDICES);
02137     RNA_def_property_ui_text(prop, "Indices", "Displays the index numbers of selected vertices, edges, and faces");
02138     RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
02139 
02140     /* editflag */
02141     prop= RNA_def_property(srna, "use_mirror_x", PROP_BOOLEAN, PROP_NONE);
02142     RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_X);
02143     RNA_def_property_ui_text(prop, "X Mirror", "X Axis mirror editing");
02144 
02145     /*
02146     prop= RNA_def_property(srna, "use_mirror_y", PROP_BOOLEAN, PROP_NONE);
02147     RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_Y);
02148     RNA_def_property_ui_text(prop, "Y Mirror", "Y Axis mirror editing");
02149 
02150     prop= RNA_def_property(srna, "use_mirror_x", PROP_BOOLEAN, PROP_NONE);
02151     RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_Z);
02152     RNA_def_property_ui_text(prop, "Z Mirror", "Z Axis mirror editing");
02153      */
02154 
02155     prop= RNA_def_property(srna, "use_mirror_topology", PROP_BOOLEAN, PROP_NONE);
02156     RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_TOPO);
02157     RNA_def_property_ui_text(prop, "Topology Mirror",
02158                              "Use topology based mirroring (for when both sides of mesh have matching, unique topology)");
02159 
02160     prop= RNA_def_property(srna, "use_paint_mask", PROP_BOOLEAN, PROP_NONE);
02161     RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_PAINT_MASK);
02162     RNA_def_property_ui_text(prop, "Paint Mask", "Face selection masking for painting");
02163     RNA_def_property_ui_icon(prop, ICON_FACESEL_HLT, 0);
02164     RNA_def_property_update(prop, 0, "rna_Mesh_update_facemask");
02165 
02166     
02167     prop= RNA_def_property(srna, "use_paint_mask_vertex", PROP_BOOLEAN, PROP_NONE);
02168     RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_VERT_SEL);
02169     RNA_def_property_ui_text(prop, "Vertex Selection", "Vertex selection masking for painting (weight paint only)");
02170     RNA_def_property_ui_icon(prop, ICON_VERTEXSEL, 0);
02171     RNA_def_property_update(prop, 0, "rna_Mesh_update_vertmask");
02172 
02173     /* readonly editmesh info - use for extrude menu */
02174     prop= RNA_def_property(srna, "total_vert_sel", PROP_INT, PROP_UNSIGNED);
02175     RNA_def_property_int_funcs(prop, "rna_Mesh_tot_vert_get", NULL, NULL);
02176     RNA_def_property_ui_text(prop, "Selected Vert Total", "Selected vertex count in editmode");
02177     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
02178 
02179     prop= RNA_def_property(srna, "total_edge_sel", PROP_INT, PROP_UNSIGNED);
02180     RNA_def_property_int_funcs(prop, "rna_Mesh_tot_edge_get", NULL, NULL);
02181     RNA_def_property_ui_text(prop, "Selected Edge Total", "Selected edge count in editmode");
02182     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
02183 
02184     prop= RNA_def_property(srna, "total_face_sel", PROP_INT, PROP_UNSIGNED);
02185     RNA_def_property_int_funcs(prop, "rna_Mesh_tot_face_get", NULL, NULL);
02186     RNA_def_property_ui_text(prop, "Selected Face Total", "Selected face count in editmode");
02187     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
02188 
02189     /* pointers */
02190     rna_def_animdata_common(srna);
02191 
02192     RNA_api_mesh(srna);
02193 }
02194 
02195 void RNA_def_mesh(BlenderRNA *brna)
02196 {
02197     rna_def_mesh(brna);
02198     rna_def_mvert(brna);
02199     rna_def_mvert_group(brna);
02200     rna_def_medge(brna);
02201     rna_def_mface(brna);
02202     rna_def_mtface(brna);
02203     rna_def_msticky(brna);
02204     rna_def_mcol(brna);
02205     rna_def_mproperties(brna);
02206 }
02207 
02208 #endif
02209