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