|
Blender
V2.59
|
00001 /* 00002 * $Id: rna_object.c 38553 2011-07-21 01:37:15Z 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 <stdio.h> 00031 #include <stdlib.h> 00032 00033 #include "RNA_access.h" 00034 #include "RNA_define.h" 00035 #include "RNA_enum_types.h" 00036 00037 #include "rna_internal.h" 00038 00039 #include "DNA_action_types.h" 00040 #include "DNA_customdata_types.h" 00041 #include "DNA_controller_types.h" 00042 #include "DNA_group_types.h" 00043 #include "DNA_material_types.h" 00044 #include "DNA_mesh_types.h" 00045 #include "DNA_object_force.h" 00046 #include "DNA_object_types.h" 00047 #include "DNA_property_types.h" 00048 #include "DNA_scene_types.h" 00049 #include "DNA_meta_types.h" 00050 00051 #include "BKE_group.h" /* needed for object_in_group() */ 00052 00053 #include "BLO_sys_types.h" /* needed for intptr_t used in ED_mesh.h */ 00054 #include "ED_mesh.h" 00055 00056 #include "WM_api.h" 00057 #include "WM_types.h" 00058 00059 EnumPropertyItem object_mode_items[] = { 00060 {OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object", ""}, 00061 {OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit", ""}, 00062 {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""}, 00063 {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""}, 00064 {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""}, 00065 {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""}, 00066 {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""}, 00067 {OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose", ""}, 00068 {0, NULL, 0, NULL, NULL}}; 00069 00070 static EnumPropertyItem parent_type_items[] = { 00071 {PAROBJECT, "OBJECT", 0, "Object", "The object is parented to an object"}, 00072 {PARCURVE, "CURVE", 0, "Curve", "The object is parented to a curve"}, 00073 {PARKEY, "KEY", 0, "Key", ""}, 00074 {PARSKEL, "ARMATURE", 0, "Armature", ""}, 00075 {PARSKEL, "LATTICE", 0, "Lattice", "The object is parented to a lattice"}, // PARSKEL reuse will give issues 00076 {PARVERT1, "VERTEX", 0, "Vertex", "The object is parented to a vertex"}, 00077 {PARVERT3, "VERTEX_3", 0, "3 Vertices", ""}, 00078 {PARBONE, "BONE", 0, "Bone", "The object is parented to a bone"}, 00079 {0, NULL, 0, NULL, NULL}}; 00080 00081 static EnumPropertyItem collision_bounds_items[] = { 00082 {OB_BOUND_BOX, "BOX", 0, "Box", ""}, 00083 {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""}, 00084 {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", ""}, 00085 {OB_BOUND_CONE, "CONE", 0, "Cone", ""}, 00086 {OB_BOUND_POLYT, "CONVEX_HULL", 0, "Convex Hull", ""}, 00087 {OB_BOUND_POLYH, "TRIANGLE_MESH", 0, "Triangle Mesh", ""}, 00088 {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", ""}, 00089 //{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""}, 00090 {0, NULL, 0, NULL, NULL}}; 00091 00092 EnumPropertyItem metaelem_type_items[] = { 00093 {MB_BALL, "BALL", ICON_META_BALL, "Ball", ""}, 00094 {MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""}, 00095 {MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""}, 00096 {MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""}, // NOTE: typo at original definition! 00097 {MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""}, 00098 {0, NULL, 0, NULL, NULL}}; 00099 00100 /* used for 2 enums */ 00101 #define OBTYPE_CU_CURVE {OB_CURVE, "CURVE", 0, "Curve", ""} 00102 #define OBTYPE_CU_SURF {OB_SURF, "SURFACE", 0, "Surface", ""} 00103 #define OBTYPE_CU_FONT {OB_FONT, "FONT", 0, "Font", ""} 00104 00105 EnumPropertyItem object_type_items[] = { 00106 {OB_MESH, "MESH", 0, "Mesh", ""}, 00107 OBTYPE_CU_CURVE, 00108 OBTYPE_CU_SURF, 00109 {OB_MBALL, "META", 0, "Meta", ""}, 00110 OBTYPE_CU_FONT, 00111 {0, "", 0, NULL, NULL}, 00112 {OB_ARMATURE, "ARMATURE", 0, "Armature", ""}, 00113 {OB_LATTICE, "LATTICE", 0, "Lattice", ""}, 00114 {OB_EMPTY, "EMPTY", 0, "Empty", ""}, 00115 {0, "", 0, NULL, NULL}, 00116 {OB_CAMERA, "CAMERA", 0, "Camera", ""}, 00117 {OB_LAMP, "LAMP", 0, "Lamp", ""}, 00118 {0, NULL, 0, NULL, NULL}}; 00119 00120 EnumPropertyItem object_type_curve_items[] = { 00121 OBTYPE_CU_CURVE, 00122 OBTYPE_CU_SURF, 00123 OBTYPE_CU_FONT, 00124 {0, NULL, 0, NULL, NULL}}; 00125 00126 00127 #ifdef RNA_RUNTIME 00128 00129 #include "BLI_math.h" 00130 00131 #include "DNA_key_types.h" 00132 #include "DNA_constraint_types.h" 00133 #include "DNA_lattice_types.h" 00134 00135 #include "BKE_armature.h" 00136 #include "BKE_bullet.h" 00137 #include "BKE_constraint.h" 00138 #include "BKE_context.h" 00139 #include "BKE_curve.h" 00140 #include "BKE_depsgraph.h" 00141 #include "BKE_effect.h" 00142 #include "BKE_key.h" 00143 #include "BKE_object.h" 00144 #include "BKE_material.h" 00145 #include "BKE_mesh.h" 00146 #include "BKE_particle.h" 00147 #include "BKE_scene.h" 00148 #include "BKE_deform.h" 00149 00150 #include "BLI_editVert.h" /* for EditMesh->mat_nr */ 00151 00152 #include "ED_mesh.h" 00153 #include "ED_object.h" 00154 #include "ED_particle.h" 00155 #include "ED_curve.h" 00156 #include "ED_lattice.h" 00157 00158 static void rna_Object_internal_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) 00159 { 00160 DAG_id_tag_update(ptr->id.data, OB_RECALC_OB); 00161 } 00162 00163 static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr) 00164 { 00165 /* dont use compat so we get predictable rotation */ 00166 object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat, FALSE, TRUE); 00167 rna_Object_internal_update(bmain, scene, ptr); 00168 } 00169 00170 static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) 00171 { 00172 Object *ob= ptr->id.data; 00173 00174 if(ob->parent) { 00175 float invmat[4][4]; /* for inverse of parent's matrix */ 00176 invert_m4_m4(invmat, ob->parent->obmat); 00177 mul_m4_m4m4((float(*)[4])values, ob->obmat, invmat); 00178 } 00179 else { 00180 copy_m4_m4((float(*)[4])values, ob->obmat); 00181 } 00182 } 00183 00184 static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16]) 00185 { 00186 Object *ob= ptr->id.data; 00187 00188 /* localspace matrix is truly relative to the parent, but parameters 00189 * stored in object are relative to parentinv matrix. Undo the parent 00190 * inverse part before updating obmat and calling apply_obmat() */ 00191 if(ob->parent) { 00192 float invmat[4][4]; 00193 invert_m4_m4(invmat, ob->parentinv); 00194 mul_m4_m4m4(ob->obmat, (float(*)[4])values, invmat); 00195 } 00196 else { 00197 copy_m4_m4(ob->obmat, (float(*)[4])values); 00198 } 00199 00200 /* dont use compat so we get predictable rotation */ 00201 object_apply_mat4(ob, ob->obmat, FALSE, FALSE); 00202 } 00203 00204 static void rna_Object_matrix_basis_get(PointerRNA *ptr, float values[16]) 00205 { 00206 Object *ob= ptr->id.data; 00207 object_to_mat4(ob, (float(*)[4])values); 00208 } 00209 00210 static void rna_Object_matrix_basis_set(PointerRNA *ptr, const float values[16]) 00211 { 00212 Object *ob= ptr->id.data; 00213 object_apply_mat4(ob, (float(*)[4])values, FALSE, FALSE); 00214 } 00215 00216 void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) 00217 { 00218 DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA); 00219 WM_main_add_notifier(NC_OBJECT|ND_DRAW, ptr->id.data); 00220 } 00221 00222 void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr) 00223 { 00224 Object *ob= ptr->id.data; 00225 00226 if(scene->obedit == ob) { 00227 /* exit/enter editmode to get new shape */ 00228 switch(ob->type) { 00229 case OB_MESH: 00230 load_editMesh(scene, ob); 00231 make_editMesh(scene, ob); 00232 break; 00233 case OB_CURVE: 00234 case OB_SURF: 00235 load_editNurb(ob); 00236 make_editNurb(ob); 00237 break; 00238 case OB_LATTICE: 00239 load_editLatt(ob); 00240 make_editLatt(ob); 00241 break; 00242 } 00243 } 00244 00245 rna_Object_internal_update_data(bmain, scene, ptr); 00246 } 00247 00248 static void rna_Object_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr) 00249 { 00250 DAG_id_tag_update(ptr->id.data, OB_RECALC_OB); 00251 DAG_scene_sort(bmain, scene); 00252 WM_main_add_notifier(NC_OBJECT|ND_PARENT, ptr->id.data); 00253 } 00254 00255 /* when changing the selection flag the scene needs updating */ 00256 static void rna_Object_select_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) 00257 { 00258 Object *ob= (Object*)ptr->id.data; 00259 short mode = ob->flag & SELECT ? BA_SELECT : BA_DESELECT; 00260 ED_base_object_select(object_in_scene(ob, scene), mode); 00261 } 00262 00263 static void rna_Base_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) 00264 { 00265 Base *base= (Base*)ptr->data; 00266 short mode = base->flag & BA_SELECT ? BA_SELECT : BA_DESELECT; 00267 ED_base_object_select(base, mode); 00268 } 00269 00270 static void rna_Object_layer_update__internal(Main *bmain, Scene *scene, Base *base, Object *ob) 00271 { 00272 /* try to avoid scene sort */ 00273 if(scene == NULL) { 00274 /* pass - unlikely but when running scripts on startup it happens */ 00275 } 00276 else if((ob->lay & scene->lay) && (base->lay & scene->lay)) { 00277 /* pass */ 00278 } 00279 else if((ob->lay & scene->lay)==0 && (base->lay & scene->lay)==0) { 00280 /* pass */ 00281 } 00282 else { 00283 DAG_scene_sort(bmain, scene); 00284 } 00285 } 00286 00287 static void rna_Object_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) 00288 { 00289 Object *ob= (Object*)ptr->id.data; 00290 Base *base; 00291 00292 base= scene ? object_in_scene(ob, scene) : NULL; 00293 if(!base) 00294 return; 00295 00296 SWAP(int, base->lay, ob->lay); 00297 00298 rna_Object_layer_update__internal(bmain, scene, base, ob); 00299 ob->lay= base->lay; 00300 00301 WM_main_add_notifier(NC_SCENE|ND_LAYER_CONTENT, scene); 00302 } 00303 00304 static void rna_Base_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) 00305 { 00306 Base *base= (Base*)ptr->data; 00307 Object *ob= (Object*)base->object; 00308 00309 rna_Object_layer_update__internal(bmain, scene, base, ob); 00310 ob->lay= base->lay; 00311 00312 WM_main_add_notifier(NC_SCENE|ND_LAYER_CONTENT, scene); 00313 } 00314 00315 static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) 00316 { 00317 Object *ob= (Object*)ptr->data; 00318 ID *id= value.data; 00319 00320 if (id == NULL || ob->mode & OB_MODE_EDIT) 00321 return; 00322 00323 if (ob->type == OB_EMPTY) { 00324 if(ob->data) { 00325 id_us_min((ID*)ob->data); 00326 ob->data = NULL; 00327 } 00328 00329 if (id && GS(id->name) == ID_IM) { 00330 id_us_plus(id); 00331 ob->data = id; 00332 } 00333 } 00334 else if(ob->type == OB_MESH) { 00335 set_mesh(ob, (Mesh*)id); 00336 } 00337 else { 00338 if(ob->data) 00339 id_us_min((ID*)ob->data); 00340 if(id) 00341 id_us_plus(id); 00342 00343 ob->data= id; 00344 test_object_materials(id); 00345 00346 if(GS(id->name)==ID_CU) 00347 test_curve_type(ob); 00348 else if(ob->type==OB_ARMATURE) 00349 armature_rebuild_pose(ob, ob->data); 00350 } 00351 } 00352 00353 static StructRNA *rna_Object_data_typef(PointerRNA *ptr) 00354 { 00355 Object *ob= (Object*)ptr->data; 00356 00357 switch(ob->type) { 00358 case OB_EMPTY: return &RNA_Image; 00359 case OB_MESH: return &RNA_Mesh; 00360 case OB_CURVE: return &RNA_Curve; 00361 case OB_SURF: return &RNA_Curve; 00362 case OB_FONT: return &RNA_Curve; 00363 case OB_MBALL: return &RNA_MetaBall; 00364 case OB_LAMP: return &RNA_Lamp; 00365 case OB_CAMERA: return &RNA_Camera; 00366 case OB_LATTICE: return &RNA_Lattice; 00367 case OB_ARMATURE: return &RNA_Armature; 00368 default: return &RNA_ID; 00369 } 00370 } 00371 00372 static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value) 00373 { 00374 Object *ob= (Object*)ptr->data; 00375 Object *par= (Object*)value.data; 00376 00377 ED_object_parent(ob, par, ob->partype, ob->parsubstr); 00378 } 00379 00380 static void rna_Object_parent_type_set(PointerRNA *ptr, int value) 00381 { 00382 Object *ob= (Object*)ptr->data; 00383 00384 ED_object_parent(ob, ob->parent, value, ob->parsubstr); 00385 } 00386 00387 static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) 00388 { 00389 Object *ob= (Object*)ptr->data; 00390 EnumPropertyItem *item= NULL; 00391 int totitem= 0; 00392 00393 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PAROBJECT); 00394 00395 if(ob->parent) { 00396 Object *par= ob->parent; 00397 00398 if(par->type == OB_CURVE) 00399 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARCURVE); 00400 else if(par->type == OB_LATTICE) 00401 RNA_enum_items_add_value(&item, &totitem, &parent_type_items[4], PARSKEL); // special hack: prevents this overriding others 00402 else if(par->type == OB_ARMATURE) { 00403 RNA_enum_items_add_value(&item, &totitem, &parent_type_items[3], PARSKEL); // special hack: prevents this being overrided 00404 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARBONE); 00405 } 00406 else if(par->type == OB_MESH) { 00407 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT1); 00408 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT3); 00409 } 00410 } 00411 00412 RNA_enum_item_end(&item, &totitem); 00413 *free= 1; 00414 00415 return item; 00416 } 00417 00418 static EnumPropertyItem *rna_Object_collision_bounds_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) 00419 { 00420 Object *ob= (Object*)ptr->data; 00421 EnumPropertyItem *item= NULL; 00422 int totitem= 0; 00423 00424 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_POLYH); 00425 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_POLYT); 00426 00427 if(ob->body_type!=OB_BODY_TYPE_SOFT) { 00428 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CONE); 00429 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CYLINDER); 00430 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_SPHERE); 00431 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_BOX); 00432 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CAPSULE); 00433 } 00434 00435 RNA_enum_item_end(&item, &totitem); 00436 *free= 1; 00437 00438 return item; 00439 } 00440 00441 static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value) 00442 { 00443 Object *ob= (Object*)ptr->data; 00444 00445 ED_object_parent(ob, ob->parent, ob->partype, value); 00446 } 00447 00448 static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value) 00449 { 00450 Object *ob= (Object *)ptr->data; 00451 Group *grp = (Group *)value.data; 00452 00453 /* must not let this be set if the object belongs in this group already, 00454 * thus causing a cycle/infinite-recursion leading to crashes on load [#25298] 00455 */ 00456 if (object_in_group(ob, grp) == 0) 00457 ob->dup_group = grp; 00458 else 00459 BKE_report(NULL, RPT_ERROR, "Cannot set dupli-group as object belongs in group being instanced thus causing a cycle"); 00460 } 00461 00462 void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value) 00463 { 00464 Object *ob= (Object *)ptr->id.data; 00465 bDeformGroup *dg= (bDeformGroup *)ptr->data; 00466 BLI_strncpy(dg->name, value, sizeof(dg->name)); 00467 defgroup_unique_name(dg, ob); 00468 } 00469 00470 static int rna_VertexGroup_index_get(PointerRNA *ptr) 00471 { 00472 Object *ob= (Object*)ptr->id.data; 00473 00474 return BLI_findindex(&ob->defbase, ptr->data); 00475 } 00476 00477 static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr) 00478 { 00479 Object *ob= (Object*)ptr->id.data; 00480 return rna_pointer_inherit_refine(ptr, &RNA_VertexGroup, BLI_findlink(&ob->defbase, ob->actdef-1)); 00481 } 00482 00483 static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr) 00484 { 00485 Object *ob= (Object*)ptr->id.data; 00486 return ob->actdef-1; 00487 } 00488 00489 static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value) 00490 { 00491 Object *ob= (Object*)ptr->id.data; 00492 ob->actdef= value+1; 00493 } 00494 00495 static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min, int *max) 00496 { 00497 Object *ob= (Object*)ptr->id.data; 00498 00499 *min= 0; 00500 *max= BLI_countlist(&ob->defbase)-1; 00501 *max= MAX2(0, *max); 00502 } 00503 00504 void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index) 00505 { 00506 Object *ob= (Object*)ptr->id.data; 00507 bDeformGroup *dg; 00508 00509 dg= BLI_findlink(&ob->defbase, index-1); 00510 00511 if(dg) BLI_strncpy(value, dg->name, sizeof(dg->name)); 00512 else BLI_strncpy(value, "", sizeof(dg->name)); 00513 } 00514 00515 int rna_object_vgroup_name_index_length(PointerRNA *ptr, int index) 00516 { 00517 Object *ob= (Object*)ptr->id.data; 00518 bDeformGroup *dg; 00519 00520 dg= BLI_findlink(&ob->defbase, index-1); 00521 return (dg)? strlen(dg->name): 0; 00522 } 00523 00524 void rna_object_vgroup_name_index_set(PointerRNA *ptr, const char *value, short *index) 00525 { 00526 Object *ob= (Object*)ptr->id.data; 00527 *index= defgroup_name_index(ob, value) + 1; 00528 } 00529 00530 void rna_object_vgroup_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen) 00531 { 00532 Object *ob= (Object*)ptr->id.data; 00533 bDeformGroup *dg= defgroup_find_name(ob, value); 00534 if(dg) { 00535 BLI_strncpy(result, value, maxlen); 00536 return; 00537 } 00538 00539 result[0]= '\0'; 00540 } 00541 00542 void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen) 00543 { 00544 Object *ob= (Object*)ptr->id.data; 00545 Mesh *me; 00546 CustomDataLayer *layer; 00547 int a; 00548 00549 if(ob->type == OB_MESH && ob->data) { 00550 me= (Mesh*)ob->data; 00551 00552 for(a=0; a<me->fdata.totlayer; a++) { 00553 layer= &me->fdata.layers[a]; 00554 00555 if(layer->type == CD_MTFACE && strcmp(layer->name, value) == 0) { 00556 BLI_strncpy(result, value, maxlen); 00557 return; 00558 } 00559 } 00560 } 00561 00562 BLI_strncpy(result, "", maxlen); 00563 } 00564 00565 void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen) 00566 { 00567 Object *ob= (Object*)ptr->id.data; 00568 Mesh *me; 00569 CustomDataLayer *layer; 00570 int a; 00571 00572 if(ob->type == OB_MESH && ob->data) { 00573 me= (Mesh*)ob->data; 00574 00575 for(a=0; a<me->fdata.totlayer; a++) { 00576 layer= &me->fdata.layers[a]; 00577 00578 if(layer->type == CD_MCOL && strcmp(layer->name, value) == 0) { 00579 BLI_strncpy(result, value, maxlen); 00580 return; 00581 } 00582 } 00583 } 00584 00585 BLI_strncpy(result, "", maxlen); 00586 } 00587 00588 static int rna_Object_active_material_index_get(PointerRNA *ptr) 00589 { 00590 Object *ob= (Object*)ptr->id.data; 00591 return MAX2(ob->actcol-1, 0); 00592 } 00593 00594 static void rna_Object_active_material_index_set(PointerRNA *ptr, int value) 00595 { 00596 Object *ob= (Object*)ptr->id.data; 00597 ob->actcol= value+1; 00598 00599 if(ob->type==OB_MESH) { 00600 Mesh *me= ob->data; 00601 00602 if(me->edit_mesh) 00603 me->edit_mesh->mat_nr= value; 00604 } 00605 } 00606 00607 static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, int *max) 00608 { 00609 Object *ob= (Object*)ptr->id.data; 00610 *min= 0; 00611 *max= MAX2(ob->totcol-1, 0); 00612 } 00613 00614 /* returns active base material */ 00615 static PointerRNA rna_Object_active_material_get(PointerRNA *ptr) 00616 { 00617 Object *ob= (Object*)ptr->id.data; 00618 Material *ma; 00619 00620 ma= (ob->totcol)? give_current_material(ob, ob->actcol): NULL; 00621 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma); 00622 } 00623 00624 static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value) 00625 { 00626 Object *ob= (Object*)ptr->id.data; 00627 00628 DAG_id_tag_update(value.data, 0); 00629 assign_material(ob, value.data, ob->actcol); 00630 } 00631 00632 static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int *min, int *max) 00633 { 00634 Object *ob= (Object*)ptr->id.data; 00635 *min= 0; 00636 *max= BLI_countlist(&ob->particlesystem)-1; 00637 *max= MAX2(0, *max); 00638 } 00639 00640 static int rna_Object_active_particle_system_index_get(PointerRNA *ptr) 00641 { 00642 Object *ob= (Object*)ptr->id.data; 00643 return psys_get_current_num(ob); 00644 } 00645 00646 static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int value) 00647 { 00648 Object *ob= (Object*)ptr->id.data; 00649 psys_set_current_num(ob, value); 00650 } 00651 00652 static void rna_Object_particle_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) 00653 { 00654 Object *ob= (Object*)ptr->id.data; 00655 00656 PE_current_changed(scene, ob); 00657 } 00658 00659 /* rotation - axis-angle */ 00660 static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value) 00661 { 00662 Object *ob= ptr->data; 00663 00664 /* for now, assume that rotation mode is axis-angle */ 00665 value[0]= ob->rotAngle; 00666 copy_v3_v3(&value[1], ob->rotAxis); 00667 } 00668 00669 /* rotation - axis-angle */ 00670 static void rna_Object_rotation_axis_angle_set(PointerRNA *ptr, const float *value) 00671 { 00672 Object *ob= ptr->data; 00673 00674 /* for now, assume that rotation mode is axis-angle */ 00675 ob->rotAngle= value[0]; 00676 copy_v3_v3(ob->rotAxis, (float *)&value[1]); 00677 00678 // TODO: validate axis? 00679 } 00680 00681 static void rna_Object_rotation_mode_set(PointerRNA *ptr, int value) 00682 { 00683 Object *ob= ptr->data; 00684 00685 /* use API Method for conversions... */ 00686 BKE_rotMode_change_values(ob->quat, ob->rot, ob->rotAxis, &ob->rotAngle, ob->rotmode, (short)value); 00687 00688 /* finally, set the new rotation type */ 00689 ob->rotmode= value; 00690 } 00691 00692 static void rna_Object_dimensions_get(PointerRNA *ptr, float *value) 00693 { 00694 Object *ob= ptr->data; 00695 object_get_dimensions(ob, value); 00696 } 00697 00698 static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value) 00699 { 00700 Object *ob= ptr->data; 00701 object_set_dimensions(ob, value); 00702 } 00703 00704 static int rna_Object_location_editable(PointerRNA *ptr, int index) 00705 { 00706 Object *ob= (Object *)ptr->data; 00707 00708 /* only if the axis in question is locked, not editable... */ 00709 if ((index == 0) && (ob->protectflag & OB_LOCK_LOCX)) 00710 return 0; 00711 else if ((index == 1) && (ob->protectflag & OB_LOCK_LOCY)) 00712 return 0; 00713 else if ((index == 2) && (ob->protectflag & OB_LOCK_LOCZ)) 00714 return 0; 00715 else 00716 return PROP_EDITABLE; 00717 } 00718 00719 static int rna_Object_scale_editable(PointerRNA *ptr, int index) 00720 { 00721 Object *ob= (Object *)ptr->data; 00722 00723 /* only if the axis in question is locked, not editable... */ 00724 if ((index == 0) && (ob->protectflag & OB_LOCK_SCALEX)) 00725 return 0; 00726 else if ((index == 1) && (ob->protectflag & OB_LOCK_SCALEY)) 00727 return 0; 00728 else if ((index == 2) && (ob->protectflag & OB_LOCK_SCALEZ)) 00729 return 0; 00730 else 00731 return PROP_EDITABLE; 00732 } 00733 00734 static int rna_Object_rotation_euler_editable(PointerRNA *ptr, int index) 00735 { 00736 Object *ob= (Object *)ptr->data; 00737 00738 /* only if the axis in question is locked, not editable... */ 00739 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTX)) 00740 return 0; 00741 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTY)) 00742 return 0; 00743 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTZ)) 00744 return 0; 00745 else 00746 return PROP_EDITABLE; 00747 } 00748 00749 static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index) 00750 { 00751 Object *ob= (Object *)ptr->data; 00752 00753 /* only consider locks if locking components individually... */ 00754 if (ob->protectflag & OB_LOCK_ROT4D) { 00755 /* only if the axis in question is locked, not editable... */ 00756 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTW)) 00757 return 0; 00758 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTX)) 00759 return 0; 00760 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTY)) 00761 return 0; 00762 else if ((index == 3) && (ob->protectflag & OB_LOCK_ROTZ)) 00763 return 0; 00764 } 00765 00766 return PROP_EDITABLE; 00767 } 00768 00769 00770 static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr) 00771 { 00772 Object *ob= (Object*)ptr->id.data; 00773 Material *ma; 00774 int index= (Material**)ptr->data - ob->mat; 00775 00776 ma= give_current_material(ob, index+1); 00777 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma); 00778 } 00779 00780 static void rna_MaterialSlot_material_set(PointerRNA *ptr, PointerRNA value) 00781 { 00782 Object *ob= (Object*)ptr->id.data; 00783 int index= (Material**)ptr->data - ob->mat; 00784 00785 assign_material(ob, value.data, index+1); 00786 } 00787 00788 static int rna_MaterialSlot_link_get(PointerRNA *ptr) 00789 { 00790 Object *ob= (Object*)ptr->id.data; 00791 int index= (Material**)ptr->data - ob->mat; 00792 00793 return ob->matbits[index] != 0; 00794 } 00795 00796 static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value) 00797 { 00798 Object *ob= (Object*)ptr->id.data; 00799 int index= (Material**)ptr->data - ob->mat; 00800 00801 if(value) { 00802 ob->matbits[index]= 1; 00803 ob->colbits |= (1<<index); 00804 } 00805 else { 00806 ob->matbits[index]= 0; 00807 ob->colbits &= ~(1<<index); 00808 } 00809 } 00810 00811 static int rna_MaterialSlot_name_length(PointerRNA *ptr) 00812 { 00813 Object *ob= (Object*)ptr->id.data; 00814 Material *ma; 00815 int index= (Material**)ptr->data - ob->mat; 00816 00817 ma= give_current_material(ob, index+1); 00818 00819 if(ma) 00820 return strlen(ma->id.name+2); 00821 00822 return 0; 00823 } 00824 00825 static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str) 00826 { 00827 Object *ob= (Object*)ptr->id.data; 00828 Material *ma; 00829 int index= (Material**)ptr->data - ob->mat; 00830 00831 ma= give_current_material(ob, index+1); 00832 00833 if(ma) 00834 strcpy(str, ma->id.name+2); 00835 else 00836 strcpy(str, ""); 00837 } 00838 00839 static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr) 00840 { 00841 rna_Object_internal_update(bmain, scene, ptr); 00842 WM_main_add_notifier(NC_OBJECT|ND_OB_SHADING, ptr->id.data); 00843 } 00844 00845 /* why does this have to be so complicated?, can't all this crap be 00846 * moved to in BGE conversion function? - Campbell * 00847 * 00848 * logic from check_body_type() 00849 * */ 00850 static int rna_GameObjectSettings_physics_type_get(PointerRNA *ptr) 00851 { 00852 Object *ob= (Object*)ptr->id.data; 00853 00854 /* determine the body_type setting based on flags */ 00855 if (!(ob->gameflag & OB_COLLISION)) { 00856 if (ob->gameflag & OB_OCCLUDER) { 00857 ob->body_type = OB_BODY_TYPE_OCCLUDER; 00858 } else { 00859 ob->body_type = OB_BODY_TYPE_NO_COLLISION; 00860 } 00861 } else if (ob->gameflag & OB_SENSOR) { 00862 ob->body_type = OB_BODY_TYPE_SENSOR; 00863 } else if (!(ob->gameflag & OB_DYNAMIC)) { 00864 ob->body_type = OB_BODY_TYPE_STATIC; 00865 } else if (!(ob->gameflag & (OB_RIGID_BODY|OB_SOFT_BODY))) { 00866 ob->body_type = OB_BODY_TYPE_DYNAMIC; 00867 } else if (ob->gameflag & OB_RIGID_BODY) { 00868 ob->body_type = OB_BODY_TYPE_RIGID; 00869 } else { 00870 ob->body_type = OB_BODY_TYPE_SOFT; 00871 /* create the structure here because we display soft body buttons in the main panel */ 00872 if (!ob->bsoft) 00873 ob->bsoft = bsbNew(); 00874 } 00875 00876 return ob->body_type; 00877 } 00878 00879 static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value) 00880 { 00881 Object *ob= (Object*)ptr->id.data; 00882 ob->body_type= value; 00883 00884 switch (ob->body_type) { 00885 case OB_BODY_TYPE_SENSOR: 00886 ob->gameflag |= OB_SENSOR|OB_COLLISION|OB_GHOST; 00887 ob->gameflag &= ~(OB_OCCLUDER|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_ACTOR|OB_ANISOTROPIC_FRICTION|OB_DO_FH|OB_ROT_FH|OB_COLLISION_RESPONSE); 00888 break; 00889 case OB_BODY_TYPE_OCCLUDER: 00890 ob->gameflag |= OB_OCCLUDER; 00891 ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_DYNAMIC); 00892 break; 00893 case OB_BODY_TYPE_NO_COLLISION: 00894 ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_OCCLUDER|OB_DYNAMIC); 00895 break; 00896 case OB_BODY_TYPE_STATIC: 00897 ob->gameflag |= OB_COLLISION; 00898 ob->gameflag &= ~(OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR); 00899 break; 00900 case OB_BODY_TYPE_DYNAMIC: 00901 ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_ACTOR; 00902 ob->gameflag &= ~(OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR); 00903 break; 00904 case OB_BODY_TYPE_RIGID: 00905 ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_RIGID_BODY|OB_ACTOR; 00906 ob->gameflag &= ~(OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR); 00907 break; 00908 default: 00909 case OB_BODY_TYPE_SOFT: 00910 ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_SOFT_BODY|OB_ACTOR; 00911 ob->gameflag &= ~(OB_RIGID_BODY|OB_OCCLUDER|OB_SENSOR); 00912 00913 /* assume triangle mesh, if no bounds chosen for soft body */ 00914 if ((ob->gameflag & OB_BOUNDS) && (ob->boundtype<OB_BOUND_POLYH)) 00915 { 00916 ob->boundtype=OB_BOUND_POLYH; 00917 } 00918 /* create a BulletSoftBody structure if not already existing */ 00919 if (!ob->bsoft) 00920 ob->bsoft = bsbNew(); 00921 break; 00922 } 00923 } 00924 00925 static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr) 00926 { 00927 Object *ob= (Object*)ptr->id.data; 00928 ParticleSystem *psys= psys_get_current(ob); 00929 return rna_pointer_inherit_refine(ptr, &RNA_ParticleSystem, psys); 00930 } 00931 00932 static PointerRNA rna_Object_game_settings_get(PointerRNA *ptr) 00933 { 00934 return rna_pointer_inherit_refine(ptr, &RNA_GameObjectSettings, ptr->id.data); 00935 } 00936 00937 00938 static unsigned int rna_Object_layer_validate__internal(const int *values, unsigned int lay) 00939 { 00940 int i, tot= 0; 00941 00942 /* ensure we always have some layer selected */ 00943 for(i=0; i<20; i++) 00944 if(values[i]) 00945 tot++; 00946 00947 if(tot==0) 00948 return 0; 00949 00950 for(i=0; i<20; i++) { 00951 if(values[i]) lay |= (1<<i); 00952 else lay &= ~(1<<i); 00953 } 00954 00955 return lay; 00956 } 00957 00958 static void rna_Object_layer_set(PointerRNA *ptr, const int *values) 00959 { 00960 Object *ob= (Object*)ptr->data; 00961 unsigned int lay; 00962 00963 lay= rna_Object_layer_validate__internal(values, ob->lay); 00964 if(lay) 00965 ob->lay= lay; 00966 } 00967 00968 static void rna_Base_layer_set(PointerRNA *ptr, const int *values) 00969 { 00970 Base *base= (Base*)ptr->data; 00971 00972 unsigned int lay; 00973 lay= rna_Object_layer_validate__internal(values, base->lay); 00974 if(lay) 00975 base->lay= lay; 00976 00977 /* rna_Base_layer_update updates the objects layer */ 00978 } 00979 00980 static void rna_GameObjectSettings_state_get(PointerRNA *ptr, int *values) 00981 { 00982 Object *ob= (Object*)ptr->data; 00983 int i; 00984 int all_states = (ob->scaflag & OB_ALLSTATE?1:0); 00985 00986 memset(values, 0, sizeof(int)*OB_MAX_STATES); 00987 for(i=0; i<OB_MAX_STATES; i++) 00988 values[i] = (ob->state & (1<<i)) | all_states; 00989 } 00990 00991 static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values) 00992 { 00993 Object *ob= (Object*)ptr->data; 00994 int i, tot= 0; 00995 00996 /* ensure we always have some state selected */ 00997 for(i=0; i<OB_MAX_STATES; i++) 00998 if(values[i]) 00999 tot++; 01000 01001 if(tot==0) 01002 return; 01003 01004 for(i=0; i<OB_MAX_STATES; i++) { 01005 if(values[i]) ob->state |= (1<<i); 01006 else ob->state &= ~(1<<i); 01007 } 01008 } 01009 01010 static void rna_GameObjectSettings_used_state_get(PointerRNA *ptr, int *values) 01011 { 01012 Object *ob= (Object*)ptr->data; 01013 bController *cont; 01014 01015 memset(values, 0, sizeof(int)*OB_MAX_STATES); 01016 for (cont=ob->controllers.first; cont; cont=cont->next) { 01017 int i; 01018 01019 for (i=0; i<OB_MAX_STATES; i++) { 01020 if (cont->state_mask & (1<<i)) 01021 values[i] = 1; 01022 } 01023 } 01024 } 01025 01026 static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max) 01027 { 01028 Object *ob= (Object*)ptr->id.data; 01029 Key *key= ob_get_key(ob); 01030 01031 *min= 0; 01032 if(key) { 01033 *max= BLI_countlist(&key->block)-1; 01034 if(*max < 0) *max= 0; 01035 } 01036 else { 01037 *max= 0; 01038 } 01039 } 01040 01041 static int rna_Object_active_shape_key_index_get(PointerRNA *ptr) 01042 { 01043 Object *ob= (Object*)ptr->id.data; 01044 01045 return MAX2(ob->shapenr-1, 0); 01046 } 01047 01048 static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value) 01049 { 01050 Object *ob= (Object*)ptr->id.data; 01051 01052 ob->shapenr= value+1; 01053 } 01054 01055 static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr) 01056 { 01057 Object *ob= (Object*)ptr->id.data; 01058 Key *key= ob_get_key(ob); 01059 KeyBlock *kb; 01060 PointerRNA keyptr; 01061 01062 if(key==NULL) 01063 return PointerRNA_NULL; 01064 01065 kb= BLI_findlink(&key->block, ob->shapenr-1); 01066 RNA_pointer_create((ID *)key, &RNA_ShapeKey, kb, &keyptr); 01067 return keyptr; 01068 } 01069 01070 static PointerRNA rna_Object_field_get(PointerRNA *ptr) 01071 { 01072 Object *ob= (Object*)ptr->id.data; 01073 01074 /* weak */ 01075 if(!ob->pd) 01076 ob->pd= object_add_collision_fields(0); 01077 01078 return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, ob->pd); 01079 } 01080 01081 static PointerRNA rna_Object_collision_get(PointerRNA *ptr) 01082 { 01083 Object *ob= (Object*)ptr->id.data; 01084 01085 if(ob->type != OB_MESH) 01086 return PointerRNA_NULL; 01087 01088 /* weak */ 01089 if(!ob->pd) 01090 ob->pd= object_add_collision_fields(0); 01091 01092 return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd); 01093 } 01094 01095 static PointerRNA rna_Object_active_constraint_get(PointerRNA *ptr) 01096 { 01097 Object *ob= (Object*)ptr->id.data; 01098 bConstraint *con= constraints_get_active(&ob->constraints); 01099 return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con); 01100 } 01101 01102 static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value) 01103 { 01104 Object *ob= (Object*)ptr->id.data; 01105 constraints_set_active(&ob->constraints, (bConstraint *)value.data); 01106 } 01107 01108 static bConstraint *rna_Object_constraints_new(Object *object, int type) 01109 { 01110 WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_ADDED, object); 01111 return add_ob_constraint(object, NULL, type); 01112 } 01113 01114 static void rna_Object_constraints_remove(Object *object, ReportList *reports, bConstraint *con) 01115 { 01116 if(BLI_findindex(&object->constraints, con) == -1) { 01117 BKE_reportf(reports, RPT_ERROR, "Constraint '%s' not found in object '%s'.", con->name, object->id.name+2); 01118 return; 01119 } 01120 01121 remove_constraint(&object->constraints, con); 01122 ED_object_constraint_update(object); 01123 ED_object_constraint_set_active(object, NULL); 01124 WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, object); 01125 } 01126 01127 static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports, const char *name, int type) 01128 { 01129 return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type); 01130 } 01131 01132 static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, ModifierData *md) 01133 { 01134 ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md); 01135 } 01136 01137 static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) 01138 { 01139 Object *ob= (Object*)ptr->id.data; 01140 BoundBox *bb= object_get_boundbox(ob); 01141 if(bb) { 01142 memcpy(values, bb->vec, sizeof(bb->vec)); 01143 } 01144 else { 01145 fill_vn(values, sizeof(bb->vec)/sizeof(float), 0.0f); 01146 } 01147 01148 } 01149 01150 static bDeformGroup *rna_Object_vgroup_new(Object *ob, const char *name) 01151 { 01152 bDeformGroup *defgroup = ED_vgroup_add_name(ob, name); 01153 01154 WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob); 01155 01156 return defgroup; 01157 } 01158 01159 static void rna_Object_vgroup_remove(Object *ob, bDeformGroup *defgroup) 01160 { 01161 ED_vgroup_delete(ob, defgroup); 01162 01163 WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob); 01164 } 01165 01166 static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *reports, int index_len, int *index, float weight, int assignmode) 01167 { 01168 Object *ob = (Object *)id; 01169 01170 if(ED_vgroup_object_is_edit_mode(ob)) { 01171 BKE_reportf(reports, RPT_ERROR, "VertexGroup.add(): Can't be called while object is in edit mode."); 01172 return; 01173 } 01174 01175 while(index_len--) 01176 ED_vgroup_vert_add(ob, def, *index++, weight, assignmode); /* XXX, not efficient calling within loop*/ 01177 01178 WM_main_add_notifier(NC_GEOM|ND_DATA, (ID *)ob->data); 01179 } 01180 01181 static void rna_VertexGroup_vertex_remove(ID *id, bDeformGroup *dg, ReportList *reports, int index_len, int *index) 01182 { 01183 Object *ob = (Object *)id; 01184 01185 if(ED_vgroup_object_is_edit_mode(ob)) { 01186 BKE_reportf(reports, RPT_ERROR, "VertexGroup.remove(): Can't be called while object is in edit mode."); 01187 return; 01188 } 01189 01190 while(index_len--) 01191 ED_vgroup_vert_remove(ob, dg, *index++); 01192 01193 WM_main_add_notifier(NC_GEOM|ND_DATA, (ID *)ob->data); 01194 } 01195 01196 static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *reports, int index) 01197 { 01198 float weight = ED_vgroup_vert_weight((Object *)id, dg, index); 01199 01200 if(weight < 0) { 01201 BKE_reportf(reports, RPT_ERROR, "Vertex not in group"); 01202 } 01203 return weight; 01204 } 01205 01206 /* generic poll functions */ 01207 int rna_Lattice_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) 01208 { 01209 return ((Object *)value.id.data)->type == OB_LATTICE; 01210 } 01211 01212 int rna_Curve_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) 01213 { 01214 return ((Object *)value.id.data)->type == OB_CURVE; 01215 } 01216 01217 int rna_Armature_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) 01218 { 01219 return ((Object *)value.id.data)->type == OB_ARMATURE; 01220 } 01221 01222 int rna_Mesh_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) 01223 { 01224 return ((Object *)value.id.data)->type == OB_MESH; 01225 } 01226 01227 int rna_Camera_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) 01228 { 01229 return ((Object *)value.id.data)->type == OB_CAMERA; 01230 } 01231 01232 #else 01233 01234 static int rna_matrix_dimsize_4x4[]= {4, 4}; 01235 01236 static void rna_def_vertex_group(BlenderRNA *brna) 01237 { 01238 StructRNA *srna; 01239 PropertyRNA *prop; 01240 FunctionRNA *func; 01241 01242 static EnumPropertyItem assign_mode_items[] = { 01243 {WEIGHT_REPLACE, "REPLACE", 0, "Replace", "Replace"}, 01244 {WEIGHT_ADD, "ADD", 0, "Add", "Add"}, 01245 {WEIGHT_SUBTRACT, "SUBTRACT", 0, "Subtract", "Subtract"}, 01246 {0, NULL, 0, NULL, NULL} 01247 }; 01248 01249 srna= RNA_def_struct(brna, "VertexGroup", NULL); 01250 RNA_def_struct_sdna(srna, "bDeformGroup"); 01251 RNA_def_struct_ui_text(srna, "Vertex Group", "Group of vertices, used for armature deform and other purposes"); 01252 RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX); 01253 01254 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); 01255 RNA_def_property_ui_text(prop, "Name", "Vertex group name"); 01256 RNA_def_struct_name_property(srna, prop); 01257 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_VertexGroup_name_set"); 01258 RNA_def_property_update(prop, NC_GEOM|ND_DATA|NA_RENAME, "rna_Object_internal_update_data"); /* update data because modifiers may use [#24761] */ 01259 01260 prop= RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED); 01261 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 01262 RNA_def_property_int_funcs(prop, "rna_VertexGroup_index_get", NULL, NULL); 01263 RNA_def_property_ui_text(prop, "Index", "Index number of the vertex group"); 01264 01265 func= RNA_def_function(srna, "add", "rna_VertexGroup_vertex_add"); 01266 RNA_def_function_ui_description(func, "Add vertices to the group."); 01267 RNA_def_function_flag(func, FUNC_USE_REPORTS|FUNC_USE_SELF_ID); 01268 /* TODO, see how array size of 0 works, this shouldnt be used */ 01269 prop= RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List.", 0, 0); 01270 RNA_def_property_flag(prop, PROP_DYNAMIC|PROP_REQUIRED); 01271 prop= RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight.", 0.0f, 1.0f); 01272 RNA_def_property_flag(prop, PROP_REQUIRED); 01273 prop= RNA_def_enum(func, "type", assign_mode_items, 0, "", "Vertex assign mode."); 01274 RNA_def_property_flag(prop, PROP_REQUIRED); 01275 01276 func= RNA_def_function(srna, "remove", "rna_VertexGroup_vertex_remove"); 01277 RNA_def_function_ui_description(func, "Remove a vertex from the group."); 01278 RNA_def_function_flag(func, FUNC_USE_REPORTS|FUNC_USE_SELF_ID); 01279 /* TODO, see how array size of 0 works, this shouldnt be used */ 01280 prop= RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List.", 0, 0); 01281 RNA_def_property_flag(prop, PROP_DYNAMIC|PROP_REQUIRED); 01282 01283 func= RNA_def_function(srna, "weight", "rna_VertexGroup_weight"); 01284 RNA_def_function_ui_description(func, "Get a vertex weight from the group."); 01285 RNA_def_function_flag(func, FUNC_USE_REPORTS|FUNC_USE_SELF_ID); 01286 prop=RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "The index of the vertex.", 0, INT_MAX); 01287 RNA_def_property_flag(prop, PROP_REQUIRED); 01288 prop= RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight.", 0.0f, 1.0f); 01289 RNA_def_function_return(func, prop); 01290 } 01291 01292 static void rna_def_material_slot(BlenderRNA *brna) 01293 { 01294 StructRNA *srna; 01295 PropertyRNA *prop; 01296 01297 static EnumPropertyItem link_items[] = { 01298 {1, "OBJECT", 0, "Object", ""}, 01299 {0, "DATA", 0, "Data", ""}, 01300 {0, NULL, 0, NULL, NULL}}; 01301 01302 /* NOTE: there is no MaterialSlot equivalent in DNA, so the internal 01303 * pointer data points to ob->mat + index, and we manually implement 01304 * get/set for the properties. */ 01305 01306 srna= RNA_def_struct(brna, "MaterialSlot", NULL); 01307 RNA_def_struct_ui_text(srna, "Material Slot", "Material slot in an object"); 01308 RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA); 01309 01310 prop= RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE); 01311 RNA_def_property_struct_type(prop, "Material"); 01312 RNA_def_property_flag(prop, PROP_EDITABLE); 01313 RNA_def_property_pointer_funcs(prop, "rna_MaterialSlot_material_get", "rna_MaterialSlot_material_set", NULL, NULL); 01314 RNA_def_property_ui_text(prop, "Material", "Material datablock used by this material slot"); 01315 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_MaterialSlot_update"); 01316 01317 prop= RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE); 01318 RNA_def_property_enum_items(prop, link_items); 01319 RNA_def_property_enum_funcs(prop, "rna_MaterialSlot_link_get", "rna_MaterialSlot_link_set", NULL); 01320 RNA_def_property_ui_text(prop, "Link", "Link material to object or the object's data"); 01321 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_MaterialSlot_update"); 01322 01323 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); 01324 RNA_def_property_string_funcs(prop, "rna_MaterialSlot_name_get", "rna_MaterialSlot_name_length", NULL); 01325 RNA_def_property_ui_text(prop, "Name", "Material slot name"); 01326 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 01327 RNA_def_struct_name_property(srna, prop); 01328 } 01329 01330 static void rna_def_object_game_settings(BlenderRNA *brna) 01331 { 01332 StructRNA *srna; 01333 PropertyRNA *prop; 01334 01335 static EnumPropertyItem body_type_items[] = { 01336 {OB_BODY_TYPE_NO_COLLISION, "NO_COLLISION", 0, "No Collision", "Disable collision for this object"}, 01337 {OB_BODY_TYPE_STATIC, "STATIC", 0, "Static", "Stationary object"}, 01338 {OB_BODY_TYPE_DYNAMIC, "DYNAMIC", 0, "Dynamic", "Linear physics"}, 01339 {OB_BODY_TYPE_RIGID, "RIGID_BODY", 0, "Rigid Body", "Linear and angular physics"}, 01340 {OB_BODY_TYPE_SOFT, "SOFT_BODY", 0, "Soft Body", "Soft body"}, 01341 {OB_BODY_TYPE_OCCLUDER, "OCCLUDE", 0, "Occlude", "Occluder for optimizing scene rendering"}, 01342 {OB_BODY_TYPE_SENSOR, "SENSOR", 0, "Sensor", "Collision Sensor, detects static and dynamic objects but not the other collision sensor objects"}, 01343 {0, NULL, 0, NULL, NULL}}; 01344 01345 srna= RNA_def_struct(brna, "GameObjectSettings", NULL); 01346 RNA_def_struct_sdna(srna, "Object"); 01347 RNA_def_struct_nested(brna, srna, "Object"); 01348 RNA_def_struct_ui_text(srna, "Game Object Settings", "Game engine related settings for the object"); 01349 RNA_def_struct_ui_icon(srna, ICON_GAME); 01350 01351 /* logic */ 01352 01353 prop= RNA_def_property(srna, "sensors", PROP_COLLECTION, PROP_NONE); 01354 RNA_def_property_struct_type(prop, "Sensor"); 01355 RNA_def_property_ui_text(prop, "Sensors", "Game engine sensor to detect events"); 01356 01357 prop= RNA_def_property(srna, "controllers", PROP_COLLECTION, PROP_NONE); 01358 RNA_def_property_struct_type(prop, "Controller"); 01359 RNA_def_property_ui_text(prop, "Controllers", "Game engine controllers to process events, connecting sensor to actuators"); 01360 01361 prop= RNA_def_property(srna, "actuators", PROP_COLLECTION, PROP_NONE); 01362 RNA_def_property_struct_type(prop, "Actuator"); 01363 RNA_def_property_ui_text(prop, "Actuators", "Game engine actuators to act on events"); 01364 01365 prop= RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE); 01366 RNA_def_property_collection_sdna(prop, NULL, "prop", NULL); 01367 RNA_def_property_struct_type(prop, "GameProperty"); /* rna_property.c */ 01368 RNA_def_property_ui_text(prop, "Properties", "Game engine properties"); 01369 01370 prop= RNA_def_property(srna, "show_sensors", PROP_BOOLEAN, PROP_NONE); 01371 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSENS); 01372 RNA_def_property_ui_text(prop, "Show Sensors", "Shows sensors for this object in the user interface"); 01373 01374 prop= RNA_def_property(srna, "show_controllers", PROP_BOOLEAN, PROP_NONE); 01375 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWCONT); 01376 RNA_def_property_ui_text(prop, "Show Controllers", "Shows controllers for this object in the user interface"); 01377 01378 prop= RNA_def_property(srna, "show_actuators", PROP_BOOLEAN, PROP_NONE); 01379 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWACT); 01380 RNA_def_property_ui_text(prop, "Show Actuators", "Shows actuators for this object in the user interface"); 01381 01382 /* physics */ 01383 01384 prop= RNA_def_property(srna, "physics_type", PROP_ENUM, PROP_NONE); 01385 RNA_def_property_enum_sdna(prop, NULL, "body_type"); 01386 RNA_def_property_enum_items(prop, body_type_items); 01387 RNA_def_property_enum_funcs(prop, "rna_GameObjectSettings_physics_type_get", "rna_GameObjectSettings_physics_type_set", NULL); 01388 RNA_def_property_ui_text(prop, "Physics Type", "Selects the type of physical representation"); 01389 RNA_def_property_update(prop, NC_LOGIC, NULL); 01390 01391 prop= RNA_def_property(srna, "use_actor", PROP_BOOLEAN, PROP_NONE); 01392 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ACTOR); 01393 RNA_def_property_ui_text(prop, "Actor", "Object is detected by the Near and Radar sensor"); 01394 01395 prop= RNA_def_property(srna, "use_ghost", PROP_BOOLEAN, PROP_NONE); 01396 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_GHOST); 01397 RNA_def_property_ui_text(prop, "Ghost", "Object does not restitute collisions, like a ghost"); 01398 01399 prop= RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE); 01400 RNA_def_property_range(prop, 0.01, 10000.0); 01401 RNA_def_property_ui_text(prop, "Mass", "Mass of the object"); 01402 01403 prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH); 01404 RNA_def_property_float_sdna(prop, NULL, "inertia"); 01405 RNA_def_property_range(prop, 0.01, 10.0); 01406 RNA_def_property_ui_text(prop, "Radius", "Radius of bounding sphere and material physics"); 01407 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 01408 01409 prop= RNA_def_property(srna, "use_sleep", PROP_BOOLEAN, PROP_NONE); 01410 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_COLLISION_RESPONSE); 01411 RNA_def_property_ui_text(prop, "No Sleeping", "Disable auto (de)activation in physics simulation"); 01412 01413 prop= RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE); 01414 RNA_def_property_float_sdna(prop, NULL, "damping"); 01415 RNA_def_property_range(prop, 0.0, 1.0); 01416 RNA_def_property_ui_text(prop, "Damping", "General movement damping"); 01417 01418 prop= RNA_def_property(srna, "rotation_damping", PROP_FLOAT, PROP_NONE); 01419 RNA_def_property_float_sdna(prop, NULL, "rdamping"); 01420 RNA_def_property_range(prop, 0.0, 1.0); 01421 RNA_def_property_ui_text(prop, "Rotation Damping", "General rotation damping"); 01422 01423 prop= RNA_def_property(srna, "velocity_min", PROP_FLOAT, PROP_NONE); 01424 RNA_def_property_float_sdna(prop, NULL, "min_vel"); 01425 RNA_def_property_range(prop, 0.0, 1000.0); 01426 RNA_def_property_ui_text(prop, "Velocity Min", "Clamp velocity to this minimum speed (except when totally still)"); 01427 01428 prop= RNA_def_property(srna, "velocity_max", PROP_FLOAT, PROP_NONE); 01429 RNA_def_property_float_sdna(prop, NULL, "max_vel"); 01430 RNA_def_property_range(prop, 0.0, 1000.0); 01431 RNA_def_property_ui_text(prop, "Velocity Max", "Clamp velocity to this maximum speed"); 01432 01433 /* lock position */ 01434 prop= RNA_def_property(srna, "lock_location_x", PROP_BOOLEAN, PROP_NONE); 01435 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_AXIS); 01436 RNA_def_property_ui_text(prop, "Lock X Axis", "Disable simulation of linear motion along the X axis"); 01437 01438 prop= RNA_def_property(srna, "lock_location_y", PROP_BOOLEAN, PROP_NONE); 01439 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_AXIS); 01440 RNA_def_property_ui_text(prop, "Lock Y Axis", "Disable simulation of linear motion along the Y axis"); 01441 01442 prop= RNA_def_property(srna, "lock_location_z", PROP_BOOLEAN, PROP_NONE); 01443 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_AXIS); 01444 RNA_def_property_ui_text(prop, "Lock Z Axis", "Disable simulation of linear motion along the Z axis"); 01445 01446 01447 /* lock rotation */ 01448 prop= RNA_def_property(srna, "lock_rotation_x", PROP_BOOLEAN, PROP_NONE); 01449 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_ROT_AXIS); 01450 RNA_def_property_ui_text(prop, "Lock X Rotation Axis", "Disable simulation of angular motion along the X axis"); 01451 01452 prop= RNA_def_property(srna, "lock_rotation_y", PROP_BOOLEAN, PROP_NONE); 01453 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_ROT_AXIS); 01454 RNA_def_property_ui_text(prop, "Lock Y Rotation Axis", "Disable simulation of angular motion along the Y axis"); 01455 01456 prop= RNA_def_property(srna, "lock_rotation_z", PROP_BOOLEAN, PROP_NONE); 01457 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_ROT_AXIS); 01458 RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis"); 01459 01460 /* is this used anywhere ? */ 01461 prop= RNA_def_property(srna, "use_activity_culling", PROP_BOOLEAN, PROP_NONE); 01462 RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflag2", OB_NEVER_DO_ACTIVITY_CULLING); 01463 RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis"); 01464 01465 01466 prop= RNA_def_property(srna, "use_material_physics_fh", PROP_BOOLEAN, PROP_NONE); 01467 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_DO_FH); 01468 RNA_def_property_ui_text(prop, "Use Material Force Field", "React to force field physics settings in materials"); 01469 01470 prop= RNA_def_property(srna, "use_rotate_from_normal", PROP_BOOLEAN, PROP_NONE); 01471 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ROT_FH); 01472 RNA_def_property_ui_text(prop, "Rotate From Normal", "Use face normal to rotate object, so that it points away from the surface"); 01473 01474 prop= RNA_def_property(srna, "form_factor", PROP_FLOAT, PROP_NONE); 01475 RNA_def_property_float_sdna(prop, NULL, "formfactor"); 01476 RNA_def_property_range(prop, 0.0, 1.0); 01477 RNA_def_property_ui_text(prop, "Form Factor", "Form factor scales the inertia tensor"); 01478 01479 prop= RNA_def_property(srna, "use_anisotropic_friction", PROP_BOOLEAN, PROP_NONE); 01480 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ANISOTROPIC_FRICTION); 01481 RNA_def_property_ui_text(prop, "Anisotropic Friction", "Enable anisotropic friction"); 01482 01483 prop= RNA_def_property(srna, "friction_coefficients", PROP_FLOAT, PROP_NONE); 01484 RNA_def_property_float_sdna(prop, NULL, "anisotropicFriction"); 01485 RNA_def_property_range(prop, 0.0, 1.0); 01486 RNA_def_property_ui_text(prop, "Friction Coefficients", "Relative friction coefficient in the in the X, Y and Z directions, when anisotropic friction is enabled"); 01487 01488 prop= RNA_def_property(srna, "use_collision_bounds", PROP_BOOLEAN, PROP_NONE); 01489 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_BOUNDS); 01490 RNA_def_property_ui_text(prop, "Use Collision Bounds", "Specify a collision bounds type other than the default"); 01491 01492 prop= RNA_def_property(srna, "collision_bounds_type", PROP_ENUM, PROP_NONE); 01493 RNA_def_property_enum_sdna(prop, NULL, "boundtype"); 01494 RNA_def_property_enum_items(prop, collision_bounds_items); 01495 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_collision_bounds_itemf"); 01496 RNA_def_property_ui_text(prop, "Collision Bounds", "Selects the collision type"); 01497 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 01498 01499 prop= RNA_def_property(srna, "use_collision_compound", PROP_BOOLEAN, PROP_NONE); 01500 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_CHILD); 01501 RNA_def_property_ui_text(prop, "Collision Compound", "Add children to form a compound collision object"); 01502 01503 prop= RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH); 01504 RNA_def_property_float_sdna(prop, NULL, "margin"); 01505 RNA_def_property_range(prop, 0.0, 1.0); 01506 RNA_def_property_ui_text(prop, "Collision Margin", "Extra margin around object for collision detection, small amount required for stability"); 01507 01508 prop= RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE); 01509 RNA_def_property_pointer_sdna(prop, NULL, "bsoft"); 01510 RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for Bullet soft body simulation"); 01511 01512 /* state */ 01513 01514 prop= RNA_def_property(srna, "states_visible", PROP_BOOLEAN, PROP_LAYER_MEMBER); 01515 RNA_def_property_boolean_sdna(prop, NULL, "state", 1); 01516 RNA_def_property_array(prop, OB_MAX_STATES); 01517 RNA_def_property_ui_text(prop, "State", "State determining which controllers are displayed"); 01518 RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_state_get", "rna_GameObjectSettings_state_set"); 01519 01520 prop= RNA_def_property(srna, "used_states", PROP_BOOLEAN, PROP_LAYER_MEMBER); 01521 RNA_def_property_array(prop, OB_MAX_STATES); 01522 RNA_def_property_ui_text(prop, "Used State", "States which are being used by controllers"); 01523 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 01524 RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_used_state_get", NULL); 01525 01526 prop= RNA_def_property(srna, "states_initial", PROP_BOOLEAN, PROP_NONE); 01527 RNA_def_property_boolean_sdna(prop, NULL, "init_state", 1); 01528 RNA_def_property_array(prop, OB_MAX_STATES); 01529 RNA_def_property_ui_text(prop, "Initial State", "Initial state when the game starts"); 01530 01531 prop= RNA_def_property(srna, "show_debug_state", PROP_BOOLEAN, PROP_NONE); 01532 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_DEBUGSTATE); 01533 RNA_def_property_ui_text(prop, "Debug State", "Print state debug info in the game engine"); 01534 RNA_def_property_ui_icon(prop, ICON_INFO, 0); 01535 01536 prop= RNA_def_property(srna, "use_all_states", PROP_BOOLEAN, PROP_NONE); 01537 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_ALLSTATE); 01538 RNA_def_property_ui_text(prop, "All", "Set all state bits"); 01539 01540 prop= RNA_def_property(srna, "show_state_panel", PROP_BOOLEAN, PROP_NONE); 01541 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSTATE); 01542 RNA_def_property_ui_text(prop, "States", "Show state panel"); 01543 RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1); 01544 } 01545 01546 static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop) 01547 { 01548 StructRNA *srna; 01549 PropertyRNA *prop; 01550 01551 FunctionRNA *func; 01552 PropertyRNA *parm; 01553 01554 RNA_def_property_srna(cprop, "ObjectConstraints"); 01555 srna= RNA_def_struct(brna, "ObjectConstraints", NULL); 01556 RNA_def_struct_sdna(srna, "Object"); 01557 RNA_def_struct_ui_text(srna, "Object Constraints", "Collection of object constraints"); 01558 01559 01560 /* Collection active property */ 01561 prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); 01562 RNA_def_property_struct_type(prop, "Constraint"); 01563 RNA_def_property_pointer_funcs(prop, "rna_Object_active_constraint_get", "rna_Object_active_constraint_set", NULL, NULL); 01564 RNA_def_property_flag(prop, PROP_EDITABLE); 01565 RNA_def_property_ui_text(prop, "Active Constraint", "Active Object constraint"); 01566 01567 01568 /* Constraint collection */ 01569 func= RNA_def_function(srna, "new", "rna_Object_constraints_new"); 01570 RNA_def_function_ui_description(func, "Add a new constraint to this object"); 01571 /* object to add */ 01572 parm= RNA_def_enum(func, "type", constraint_type_items, 1, "", "Constraint type to add."); 01573 RNA_def_property_flag(parm, PROP_REQUIRED); 01574 /* return type */ 01575 parm= RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint."); 01576 RNA_def_function_return(func, parm); 01577 01578 func= RNA_def_function(srna, "remove", "rna_Object_constraints_remove"); 01579 RNA_def_function_ui_description(func, "Remove a constraint from this object."); 01580 RNA_def_function_flag(func, FUNC_USE_REPORTS); 01581 /* constraint to remove */ 01582 parm= RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint."); 01583 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); 01584 } 01585 01586 /* object.modifiers */ 01587 static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop) 01588 { 01589 StructRNA *srna; 01590 01591 FunctionRNA *func; 01592 PropertyRNA *parm; 01593 01594 RNA_def_property_srna(cprop, "ObjectModifiers"); 01595 srna= RNA_def_struct(brna, "ObjectModifiers", NULL); 01596 RNA_def_struct_sdna(srna, "Object"); 01597 RNA_def_struct_ui_text(srna, "Object Modifiers", "Collection of object modifiers"); 01598 01599 #if 0 01600 prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); 01601 RNA_def_property_struct_type(prop, "EditBone"); 01602 RNA_def_property_pointer_sdna(prop, NULL, "act_edbone"); 01603 RNA_def_property_flag(prop, PROP_EDITABLE); 01604 RNA_def_property_ui_text(prop, "Active EditBone", "Armatures active edit bone"); 01605 //RNA_def_property_update(prop, 0, "rna_Armature_act_editbone_update"); 01606 RNA_def_property_pointer_funcs(prop, NULL, "rna_Armature_act_edit_bone_set", NULL, NULL); 01607 01608 /* todo, redraw */ 01609 // RNA_def_property_collection_active(prop, prop_act); 01610 #endif 01611 01612 /* add target */ 01613 func= RNA_def_function(srna, "new", "rna_Object_modifier_new"); 01614 RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS); 01615 RNA_def_function_ui_description(func, "Add a new modifier."); 01616 parm= RNA_def_string(func, "name", "Name", 0, "", "New name for the bone."); 01617 RNA_def_property_flag(parm, PROP_REQUIRED); 01618 /* modifier to add */ 01619 parm= RNA_def_enum(func, "type", modifier_type_items, 1, "", "Modifier type to add."); 01620 RNA_def_property_flag(parm, PROP_REQUIRED); 01621 /* return type */ 01622 parm= RNA_def_pointer(func, "modifier", "Modifier", "", "Newly created modifier."); 01623 RNA_def_function_return(func, parm); 01624 01625 /* remove target */ 01626 func= RNA_def_function(srna, "remove", "rna_Object_modifier_remove"); 01627 RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS); 01628 RNA_def_function_ui_description(func, "Remove an existing modifier from the object."); 01629 /* target to remove*/ 01630 parm= RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove."); 01631 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); 01632 } 01633 01634 /* object.particle_systems */ 01635 static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop) 01636 { 01637 StructRNA *srna; 01638 01639 PropertyRNA *prop; 01640 01641 // FunctionRNA *func; 01642 // PropertyRNA *parm; 01643 01644 RNA_def_property_srna(cprop, "ParticleSystems"); 01645 srna= RNA_def_struct(brna, "ParticleSystems", NULL); 01646 RNA_def_struct_sdna(srna, "Object"); 01647 RNA_def_struct_ui_text(srna, "Particle Systems", "Collection of particle systems"); 01648 01649 prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); 01650 RNA_def_property_struct_type(prop, "ParticleSystem"); 01651 RNA_def_property_pointer_funcs(prop, "rna_Object_active_particle_system_get", NULL, NULL, NULL); 01652 RNA_def_property_ui_text(prop, "Active Particle System", "Active particle system being displayed"); 01653 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 01654 01655 prop= RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); 01656 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 01657 RNA_def_property_int_funcs(prop, "rna_Object_active_particle_system_index_get", "rna_Object_active_particle_system_index_set", "rna_Object_active_particle_system_index_range"); 01658 RNA_def_property_ui_text(prop, "Active Particle System Index", "Index of active particle system slot"); 01659 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_particle_update"); 01660 } 01661 01662 01663 /* object.vertex_groups */ 01664 static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) 01665 { 01666 StructRNA *srna; 01667 01668 PropertyRNA *prop; 01669 01670 FunctionRNA *func; 01671 PropertyRNA *parm; 01672 01673 RNA_def_property_srna(cprop, "VertexGroups"); 01674 srna= RNA_def_struct(brna, "VertexGroups", NULL); 01675 RNA_def_struct_sdna(srna, "Object"); 01676 RNA_def_struct_ui_text(srna, "Vertex Groups", "Collection of vertex groups"); 01677 01678 prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); 01679 RNA_def_property_struct_type(prop, "VertexGroup"); 01680 RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get", "rna_Object_active_vertex_group_set", NULL, NULL); 01681 RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object"); 01682 RNA_def_property_update(prop, NC_GEOM|ND_DATA, "rna_Object_internal_update_data"); 01683 01684 prop= RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE); 01685 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 01686 RNA_def_property_int_sdna(prop, NULL, "actdef"); 01687 RNA_def_property_int_funcs(prop, "rna_Object_active_vertex_group_index_get", "rna_Object_active_vertex_group_index_set", "rna_Object_active_vertex_group_index_range"); 01688 RNA_def_property_ui_text(prop, "Active Vertex Group Index", "Active index in vertex group array"); 01689 RNA_def_property_update(prop, NC_GEOM|ND_DATA, "rna_Object_internal_update_data"); 01690 01691 /* vertex groups */ // add_vertex_group 01692 func= RNA_def_function(srna, "new", "rna_Object_vgroup_new"); 01693 RNA_def_function_ui_description(func, "Add vertex group to object."); 01694 RNA_def_string(func, "name", "Group", 0, "", "Vertex group name."); /* optional */ 01695 parm= RNA_def_pointer(func, "group", "VertexGroup", "", "New vertex group."); 01696 RNA_def_function_return(func, parm); 01697 01698 func= RNA_def_function(srna, "remove", "rna_Object_vgroup_remove"); 01699 RNA_def_function_ui_description(func, "Delete vertex group from object."); 01700 parm= RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove."); 01701 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); 01702 } 01703 01704 01705 static void rna_def_object(BlenderRNA *brna) 01706 { 01707 StructRNA *srna; 01708 PropertyRNA *prop; 01709 01710 static EnumPropertyItem empty_drawtype_items[] = { 01711 {OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""}, 01712 {OB_ARROWS, "ARROWS", 0, "Arrows", ""}, 01713 {OB_SINGLE_ARROW, "SINGLE_ARROW", 0, "Single Arrow", ""}, 01714 {OB_CIRCLE, "CIRCLE", 0, "Circle", ""}, 01715 {OB_CUBE, "CUBE", 0, "Cube", ""}, 01716 {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""}, 01717 {OB_EMPTY_CONE, "CONE", 0, "Cone", ""}, 01718 {OB_EMPTY_IMAGE, "IMAGE", 0, "Image", ""}, 01719 {0, NULL, 0, NULL, NULL}}; 01720 01721 static EnumPropertyItem track_items[] = { 01722 {OB_POSX, "POS_X", 0, "+X", ""}, 01723 {OB_POSY, "POS_Y", 0, "+Y", ""}, 01724 {OB_POSZ, "POS_Z", 0, "+Z", ""}, 01725 {OB_NEGX, "NEG_X", 0, "-X", ""}, 01726 {OB_NEGY, "NEG_Y", 0, "-Y", ""}, 01727 {OB_NEGZ, "NEG_Z", 0, "-Z", ""}, 01728 {0, NULL, 0, NULL, NULL}}; 01729 01730 static EnumPropertyItem up_items[] = { 01731 {OB_POSX, "X", 0, "X", ""}, 01732 {OB_POSY, "Y", 0, "Y", ""}, 01733 {OB_POSZ, "Z", 0, "Z", ""}, 01734 {0, NULL, 0, NULL, NULL}}; 01735 01736 static EnumPropertyItem drawtype_items[] = { 01737 {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", "Draw the bounding box of the object"}, 01738 {OB_WIRE, "WIRE", 0, "Wire", "Draw the object as a wireframe"}, 01739 {OB_SOLID, "SOLID", 0, "Solid", "Draw the object as a solid (If solid drawing is enabled in the viewport)"}, 01740 // disabled {OB_SHADED, "SHADED", 0, "Shaded", ""}, 01741 {OB_TEXTURE, "TEXTURED", 0, "Textured", "Draw the object with textures (If textures are enabled in the viewport)"}, 01742 {0, NULL, 0, NULL, NULL}}; 01743 01744 static EnumPropertyItem boundtype_items[] = { 01745 {OB_BOUND_BOX, "BOX", 0, "Box", "Draw bounds as box"}, 01746 {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", "Draw bounds as sphere"}, 01747 {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", "Draw bounds as cylinder"}, 01748 {OB_BOUND_CONE, "CONE", 0, "Cone", "Draw bounds as cone"}, 01749 {OB_BOUND_POLYH, "POLYHEDRON", 0, "Polyhedron", "Draw bounds as polyhedron"}, 01750 {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", "Draw bounds as capsule"}, 01751 {0, NULL, 0, NULL, NULL}}; 01752 01753 static EnumPropertyItem dupli_items[] = { 01754 {0, "NONE", 0, "None", ""}, 01755 {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"}, 01756 {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"}, 01757 {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"}, 01758 {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"}, 01759 {0, NULL, 0, NULL, NULL}}; 01760 01761 // XXX: this RNA enum define is currently duplicated for objects, since there is some text here which is not applicable 01762 static EnumPropertyItem prop_rotmode_items[] = { 01763 {ROT_MODE_QUAT, "QUATERNION", 0, "Quaternion (WXYZ)", "No Gimbal Lock"}, 01764 {ROT_MODE_XYZ, "XYZ", 0, "XYZ Euler", "XYZ Rotation Order. Prone to Gimbal Lock. (Default)"}, 01765 {ROT_MODE_XZY, "XZY", 0, "XZY Euler", "XZY Rotation Order. Prone to Gimbal Lock"}, 01766 {ROT_MODE_YXZ, "YXZ", 0, "YXZ Euler", "YXZ Rotation Order. Prone to Gimbal Lock"}, 01767 {ROT_MODE_YZX, "YZX", 0, "YZX Euler", "YZX Rotation Order. Prone to Gimbal Lock"}, 01768 {ROT_MODE_ZXY, "ZXY", 0, "ZXY Euler", "ZXY Rotation Order. Prone to Gimbal Lock"}, 01769 {ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order. Prone to Gimbal Lock"}, 01770 {ROT_MODE_AXISANGLE, "AXIS_ANGLE", 0, "Axis Angle", "Axis Angle (W+XYZ). Defines a rotation around some axis defined by 3D-Vector"}, 01771 {0, NULL, 0, NULL, NULL}}; 01772 01773 static float default_quat[4] = {1,0,0,0}; /* default quaternion values */ 01774 static float default_axisAngle[4] = {0,0,1,0}; /* default axis-angle rotation values */ 01775 static float default_scale[3] = {1,1,1}; /* default scale values */ 01776 static int boundbox_dimsize[]= {8, 3}; 01777 01778 srna= RNA_def_struct(brna, "Object", "ID"); 01779 RNA_def_struct_ui_text(srna, "Object", "Object datablock defining an object in a scene"); 01780 RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT); 01781 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); 01782 01783 prop= RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE); 01784 RNA_def_property_struct_type(prop, "ID"); 01785 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_set", "rna_Object_data_typef", NULL); 01786 RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK); 01787 RNA_def_property_ui_text(prop, "Data", "Object data"); 01788 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data"); 01789 01790 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); 01791 RNA_def_property_enum_sdna(prop, NULL, "type"); 01792 RNA_def_property_enum_items(prop, object_type_items); 01793 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 01794 RNA_def_property_ui_text(prop, "Type", "Type of Object"); 01795 01796 prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); 01797 RNA_def_property_enum_sdna(prop, NULL, "mode"); 01798 RNA_def_property_enum_items(prop, object_mode_items); 01799 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 01800 RNA_def_property_ui_text(prop, "Mode", "Object interaction mode"); 01801 01802 prop= RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER); 01803 RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); 01804 RNA_def_property_array(prop, 20); 01805 RNA_def_property_ui_text(prop, "Layers", "Layers the object is on"); 01806 RNA_def_property_boolean_funcs(prop, NULL, "rna_Object_layer_set"); 01807 RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); 01808 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_layer_update"); 01809 01810 prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); 01811 RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); 01812 RNA_def_property_ui_text(prop, "Select", "Object selection state"); 01813 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_select_update"); 01814 01815 /* for data access */ 01816 prop= RNA_def_property(srna, "bound_box", PROP_FLOAT, PROP_NONE); 01817 RNA_def_property_multi_array(prop, 2, boundbox_dimsize); 01818 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 01819 RNA_def_property_float_funcs(prop, "rna_Object_boundbox_get", NULL, NULL); 01820 RNA_def_property_ui_text(prop, "Bound Box", "Objects bound box in object-space coordinates, all values are -1.0 when not available."); 01821 01822 /* parent */ 01823 prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); 01824 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_parent_set", NULL, NULL); 01825 RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); 01826 RNA_def_property_ui_text(prop, "Parent", "Parent Object"); 01827 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); 01828 01829 prop= RNA_def_property(srna, "parent_type", PROP_ENUM, PROP_NONE); 01830 RNA_def_property_enum_bitflag_sdna(prop, NULL, "partype"); 01831 RNA_def_property_enum_items(prop, parent_type_items); 01832 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_parent_type_set", "rna_Object_parent_type_itemf"); 01833 RNA_def_property_ui_text(prop, "Parent Type", "Type of parent relation"); 01834 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); 01835 01836 prop= RNA_def_property(srna, "parent_vertices", PROP_INT, PROP_UNSIGNED); 01837 RNA_def_property_int_sdna(prop, NULL, "par1"); 01838 RNA_def_property_array(prop, 3); 01839 RNA_def_property_ui_text(prop, "Parent Vertices", "Indices of vertices in cases of a vertex parenting relation"); 01840 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update"); 01841 01842 prop= RNA_def_property(srna, "parent_bone", PROP_STRING, PROP_NONE); 01843 RNA_def_property_string_sdna(prop, NULL, "parsubstr"); 01844 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Object_parent_bone_set"); 01845 RNA_def_property_ui_text(prop, "Parent Bone", "Name of parent bone in case of a bone parenting relation"); 01846 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); 01847 01848 /* Track and Up flags */ 01849 // XXX: these have been saved here for a bit longer (after old track was removed), since some other tools still refer to this 01850 prop= RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE); 01851 RNA_def_property_enum_sdna(prop, NULL, "trackflag"); 01852 RNA_def_property_enum_items(prop, track_items); 01853 RNA_def_property_ui_text(prop, "Track Axis", "Axis that points in 'forward' direction (applies to DupliFrame when parent 'Follow' is enabled)"); 01854 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update"); 01855 01856 prop= RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE); 01857 RNA_def_property_enum_sdna(prop, NULL, "upflag"); 01858 RNA_def_property_enum_items(prop, up_items); 01859 RNA_def_property_ui_text(prop, "Up Axis", "Axis that points in the upward direction (applies to DupliFrame when parent 'Follow' is enabled)"); 01860 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update"); 01861 01862 /* proxy */ 01863 prop= RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE); 01864 RNA_def_property_ui_text(prop, "Proxy", "Library object this proxy object controls"); 01865 01866 prop= RNA_def_property(srna, "proxy_group", PROP_POINTER, PROP_NONE); 01867 RNA_def_property_ui_text(prop, "Proxy Group", "Library group duplicator object this proxy object controls"); 01868 01869 /* materials */ 01870 prop= RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE); 01871 RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); 01872 RNA_def_property_struct_type(prop, "MaterialSlot"); 01873 RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", NULL, NULL, NULL); /* don't dereference pointer! */ 01874 RNA_def_property_ui_text(prop, "Material Slots", "Material slots in the object"); 01875 01876 prop= RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE); 01877 RNA_def_property_struct_type(prop, "Material"); 01878 RNA_def_property_pointer_funcs(prop, "rna_Object_active_material_get", "rna_Object_active_material_set", NULL, NULL); 01879 RNA_def_property_flag(prop, PROP_EDITABLE); 01880 RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed"); 01881 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_MaterialSlot_update"); 01882 01883 prop= RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED); 01884 RNA_def_property_int_sdna(prop, NULL, "actcol"); 01885 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 01886 RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set", "rna_Object_active_material_index_range"); 01887 RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot"); 01888 RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); 01889 01890 /* transform */ 01891 prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); 01892 RNA_def_property_float_sdna(prop, NULL, "loc"); 01893 RNA_def_property_editable_array_func(prop, "rna_Object_location_editable"); 01894 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); 01895 RNA_def_property_ui_text(prop, "Location", "Location of the object"); 01896 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 01897 01898 prop= RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION); 01899 RNA_def_property_float_sdna(prop, NULL, "quat"); 01900 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable"); 01901 RNA_def_property_float_array_default(prop, default_quat); 01902 RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions"); 01903 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 01904 01905 /* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but 01906 * having a single one is better for Keyframing and other property-management situations... 01907 */ 01908 prop= RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE); 01909 RNA_def_property_array(prop, 4); 01910 RNA_def_property_float_funcs(prop, "rna_Object_rotation_axis_angle_get", "rna_Object_rotation_axis_angle_set", NULL); 01911 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable"); 01912 RNA_def_property_float_array_default(prop, default_axisAngle); 01913 RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation"); 01914 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 01915 01916 prop= RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER); 01917 RNA_def_property_float_sdna(prop, NULL, "rot"); 01918 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_euler_editable"); 01919 RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers"); 01920 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 01921 01922 prop= RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE); 01923 RNA_def_property_enum_sdna(prop, NULL, "rotmode"); 01924 RNA_def_property_enum_items(prop, prop_rotmode_items); // XXX move to using a single define of this someday 01925 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_rotation_mode_set", NULL); 01926 RNA_def_property_ui_text(prop, "Rotation Mode", ""); 01927 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 01928 01929 prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); 01930 RNA_def_property_float_sdna(prop, NULL, "size"); 01931 RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable"); 01932 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); 01933 RNA_def_property_float_array_default(prop, default_scale); 01934 RNA_def_property_ui_text(prop, "Scale", "Scaling of the object"); 01935 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 01936 01937 prop= RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ_LENGTH); 01938 RNA_def_property_array(prop, 3); 01939 RNA_def_property_float_funcs(prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", NULL); 01940 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); 01941 RNA_def_property_ui_text(prop, "Dimensions", "Absolute bounding box dimensions of the object"); 01942 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 01943 01944 01945 /* delta transforms */ 01946 prop= RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_TRANSLATION); 01947 RNA_def_property_float_sdna(prop, NULL, "dloc"); 01948 RNA_def_property_ui_text(prop, "Delta Location", "Extra translation added to the location of the object"); 01949 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 01950 01951 prop= RNA_def_property(srna, "delta_rotation_euler", PROP_FLOAT, PROP_EULER); 01952 RNA_def_property_float_sdna(prop, NULL, "drot"); 01953 RNA_def_property_ui_text(prop, "Delta Rotation (Euler)", "Extra rotation added to the rotation of the object (when using Euler rotations)"); 01954 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 01955 01956 prop= RNA_def_property(srna, "delta_rotation_quaternion", PROP_FLOAT, PROP_QUATERNION); 01957 RNA_def_property_float_sdna(prop, NULL, "dquat"); 01958 RNA_def_property_float_array_default(prop, default_quat); 01959 RNA_def_property_ui_text(prop, "Delta Rotation (Quaternion)", "Extra rotation added to the rotation of the object (when using Quaternion rotations)"); 01960 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 01961 01962 #if 0 // XXX not supported well yet... 01963 prop= RNA_def_property(srna, "delta_rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE); 01964 RNA_def_property_float_sdna(prop, NULL, "dquat"); // FIXME: this is not a single field any more! (drotAxis and drotAngle) 01965 RNA_def_property_float_array_default(prop, default_axisAngle); 01966 RNA_def_property_ui_text(prop, "Delta Rotation (Axis Angle)", "Extra rotation added to the rotation of the object (when using Axis-Angle rotations)"); 01967 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 01968 #endif 01969 01970 prop= RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_XYZ); 01971 RNA_def_property_float_sdna(prop, NULL, "dsize"); 01972 RNA_def_property_ui_text(prop, "Delta Scale", "Extra scaling added to the scale of the object"); 01973 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 01974 01975 /* transform locks */ 01976 prop= RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_XYZ); 01977 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX); 01978 RNA_def_property_array(prop, 3); 01979 RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface"); 01980 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); 01981 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 01982 01983 prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_XYZ); 01984 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX); 01985 RNA_def_property_array(prop, 3); 01986 RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface"); 01987 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); 01988 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 01989 01990 // XXX this is sub-optimal - it really should be included above, but due to technical reasons we can't do this! 01991 prop= RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE); 01992 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTW); 01993 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); 01994 RNA_def_property_ui_text(prop, "Lock Rotation (4D Angle)", "Lock editing of 'angle' component of four-component rotations in the interface"); 01995 // XXX this needs a better name 01996 prop= RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE); 01997 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROT4D); 01998 RNA_def_property_ui_text(prop, "Lock Rotations (4D)", "Lock editing of four component rotations by components (instead of as Eulers)"); 01999 02000 prop= RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_XYZ); 02001 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX); 02002 RNA_def_property_array(prop, 3); 02003 RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface"); 02004 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); 02005 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 02006 02007 /* matrix */ 02008 prop= RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX); 02009 RNA_def_property_float_sdna(prop, NULL, "obmat"); 02010 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); 02011 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 02012 RNA_def_property_ui_text(prop, "Matrix World", "Worldspace transformation matrix"); 02013 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_matrix_world_update"); 02014 02015 prop= RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX); 02016 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); 02017 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 02018 RNA_def_property_ui_text(prop, "Local Matrix", "Parent relative transformation matrix"); 02019 RNA_def_property_float_funcs(prop, "rna_Object_matrix_local_get", "rna_Object_matrix_local_set", NULL); 02020 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, NULL); 02021 02022 prop= RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX); 02023 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); 02024 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 02025 RNA_def_property_ui_text(prop, "Input Matrix", "Matrix access to location, rotation and scale (including deltas), before constraints and parenting are applied."); 02026 RNA_def_property_float_funcs(prop, "rna_Object_matrix_basis_get", "rna_Object_matrix_basis_set", NULL); 02027 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 02028 02029 /* collections */ 02030 prop= RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE); 02031 RNA_def_property_struct_type(prop, "Constraint"); 02032 RNA_def_property_ui_text(prop, "Constraints", "Constraints affecting the transformation of the object"); 02033 // RNA_def_property_collection_funcs(prop, 0, 0, 0, 0, 0, 0, 0, "constraints__add", "constraints__remove"); 02034 rna_def_object_constraints(brna, prop); 02035 02036 prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); 02037 RNA_def_property_struct_type(prop, "Modifier"); 02038 RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the geometric data of the object"); 02039 rna_def_object_modifiers(brna, prop); 02040 02041 /* game engine */ 02042 prop= RNA_def_property(srna, "game", PROP_POINTER, PROP_NONE); 02043 RNA_def_property_flag(prop, PROP_NEVER_NULL); 02044 RNA_def_property_struct_type(prop, "GameObjectSettings"); 02045 RNA_def_property_pointer_funcs(prop, "rna_Object_game_settings_get", NULL, NULL, NULL); 02046 RNA_def_property_ui_text(prop, "Game Settings", "Game engine related settings for the object"); 02047 02048 /* vertex groups */ 02049 prop= RNA_def_property(srna, "vertex_groups", PROP_COLLECTION, PROP_NONE); 02050 RNA_def_property_collection_sdna(prop, NULL, "defbase", NULL); 02051 RNA_def_property_struct_type(prop, "VertexGroup"); 02052 RNA_def_property_ui_text(prop, "Vertex Groups", "Vertex groups of the object"); 02053 rna_def_object_vertex_groups(brna, prop); 02054 02055 /* empty */ 02056 prop= RNA_def_property(srna, "empty_draw_type", PROP_ENUM, PROP_NONE); 02057 RNA_def_property_enum_sdna(prop, NULL, "empty_drawtype"); 02058 RNA_def_property_enum_items(prop, empty_drawtype_items); 02059 RNA_def_property_ui_text(prop, "Empty Display Type", "Viewport display style for empties"); 02060 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02061 02062 prop= RNA_def_property(srna, "empty_draw_size", PROP_FLOAT, PROP_DISTANCE); 02063 RNA_def_property_float_sdna(prop, NULL, "empty_drawsize"); 02064 RNA_def_property_range(prop, 0.0001f, 1000.0f); 02065 RNA_def_property_ui_range(prop, 0.01, 100, 1, 2); 02066 RNA_def_property_ui_text(prop, "Empty Display Size", "Size of display for empties in the viewport"); 02067 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02068 02069 prop= RNA_def_property(srna, "empty_image_offset", PROP_FLOAT, PROP_DISTANCE); 02070 RNA_def_property_float_sdna(prop, NULL, "ima_ofs"); 02071 RNA_def_property_ui_text(prop, "Origin Offset", "Origin offset distance"); 02072 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1f, 2); 02073 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02074 02075 /* render */ 02076 prop= RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED); 02077 RNA_def_property_int_sdna(prop, NULL, "index"); 02078 RNA_def_property_ui_text(prop, "Pass Index", "Index # for the IndexOB render pass"); 02079 RNA_def_property_update(prop, NC_OBJECT, NULL); 02080 02081 prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); 02082 RNA_def_property_float_sdna(prop, NULL, "col"); 02083 RNA_def_property_ui_text(prop, "Color", "Object color and alpha, used when faces have the ObColor mode enabled"); 02084 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02085 02086 /* physics */ 02087 prop= RNA_def_property(srna, "field", PROP_POINTER, PROP_NONE); 02088 RNA_def_property_pointer_sdna(prop, NULL, "pd"); 02089 RNA_def_property_struct_type(prop, "FieldSettings"); 02090 RNA_def_property_pointer_funcs(prop, "rna_Object_field_get", NULL, NULL, NULL); 02091 RNA_def_property_ui_text(prop, "Field Settings", "Settings for using the objects as a field in physics simulation"); 02092 02093 prop= RNA_def_property(srna, "collision", PROP_POINTER, PROP_NONE); 02094 RNA_def_property_pointer_sdna(prop, NULL, "pd"); 02095 RNA_def_property_struct_type(prop, "CollisionSettings"); 02096 RNA_def_property_pointer_funcs(prop, "rna_Object_collision_get", NULL, NULL, NULL); 02097 RNA_def_property_ui_text(prop, "Collision Settings", "Settings for using the objects as a collider in physics simulation"); 02098 02099 prop= RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE); 02100 RNA_def_property_pointer_sdna(prop, NULL, "soft"); 02101 RNA_def_property_struct_type(prop, "SoftBodySettings"); 02102 RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for soft body simulation"); 02103 02104 prop= RNA_def_property(srna, "particle_systems", PROP_COLLECTION, PROP_NONE); 02105 RNA_def_property_collection_sdna(prop, NULL, "particlesystem", NULL); 02106 RNA_def_property_struct_type(prop, "ParticleSystem"); 02107 RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object"); 02108 rna_def_object_particle_systems(brna, prop); 02109 02110 /* restrict */ 02111 prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); 02112 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW); 02113 RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport"); 02114 RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); 02115 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02116 02117 prop= RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); 02118 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT); 02119 RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection in the viewport"); 02120 RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1); 02121 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02122 02123 prop= RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE); 02124 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER); 02125 RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability"); 02126 RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); 02127 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02128 02129 /* anim */ 02130 rna_def_animdata_common(srna); 02131 02132 rna_def_animviz_common(srna); 02133 rna_def_motionpath_common(srna); 02134 02135 /* duplicates */ 02136 // XXX: evil old crap 02137 prop= RNA_def_property(srna, "use_slow_parent", PROP_BOOLEAN, PROP_NONE); 02138 RNA_def_property_boolean_sdna(prop, NULL, "partype", PARSLOW); 02139 RNA_def_property_ui_text(prop, "Slow Parent", "Create a delay in the parent relationship"); 02140 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update"); 02141 02142 prop= RNA_def_property(srna, "dupli_type", PROP_ENUM, PROP_NONE); 02143 RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag"); 02144 RNA_def_property_enum_items(prop, dupli_items); 02145 RNA_def_property_ui_text(prop, "Dupli Type", "If not None, object duplication method to use"); 02146 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); 02147 02148 prop= RNA_def_property(srna, "use_dupli_frames_speed", PROP_BOOLEAN, PROP_NONE); 02149 RNA_def_property_boolean_negative_sdna(prop, NULL, "transflag", OB_DUPLINOSPEED); 02150 RNA_def_property_ui_text(prop, "Dupli Frames Speed", "Set dupliframes to use the frame"); // TODO, better descriptio! 02151 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update"); 02152 02153 prop= RNA_def_property(srna, "use_dupli_vertices_rotation", PROP_BOOLEAN, PROP_NONE); 02154 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIROT); 02155 RNA_def_property_ui_text(prop, "Dupli Verts Rotation", "Rotate dupli according to vertex normal"); 02156 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02157 02158 prop= RNA_def_property(srna, "use_dupli_faces_scale", PROP_BOOLEAN, PROP_NONE); 02159 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIFACES_SCALE); 02160 RNA_def_property_ui_text(prop, "Dupli Faces Inherit Scale", "Scale dupli based on face size"); 02161 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update"); 02162 02163 prop= RNA_def_property(srna, "dupli_faces_scale", PROP_FLOAT, PROP_NONE); 02164 RNA_def_property_float_sdna(prop, NULL, "dupfacesca"); 02165 RNA_def_property_range(prop, 0.001f, 10000.0f); 02166 RNA_def_property_ui_text(prop, "Dupli Faces Scale", "Scale the DupliFace objects"); 02167 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02168 02169 prop= RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE); 02170 RNA_def_property_pointer_sdna(prop, NULL, "dup_group"); 02171 RNA_def_property_flag(prop, PROP_EDITABLE); 02172 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_dup_group_set", NULL, NULL); 02173 RNA_def_property_ui_text(prop, "Dupli Group", "Instance an existing group"); 02174 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); 02175 02176 prop= RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE|PROP_UNIT_TIME); 02177 RNA_def_property_int_sdna(prop, NULL, "dupsta"); 02178 RNA_def_property_range(prop, MINAFRAME, MAXFRAME); 02179 RNA_def_property_ui_text(prop, "Dupli Frames Start", "Start frame for DupliFrames"); 02180 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update"); 02181 02182 prop= RNA_def_property(srna, "dupli_frames_end", PROP_INT, PROP_NONE|PROP_UNIT_TIME); 02183 RNA_def_property_int_sdna(prop, NULL, "dupend"); 02184 RNA_def_property_range(prop, MINAFRAME, MAXFRAME); 02185 RNA_def_property_ui_text(prop, "Dupli Frames End", "End frame for DupliFrames"); 02186 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update"); 02187 02188 prop= RNA_def_property(srna, "dupli_frames_on", PROP_INT, PROP_NONE|PROP_UNIT_TIME); 02189 RNA_def_property_int_sdna(prop, NULL, "dupon"); 02190 RNA_def_property_range(prop, MINFRAME, MAXFRAME); 02191 RNA_def_property_ui_range(prop, 1, 1500, 1, 0); 02192 RNA_def_property_ui_text(prop, "Dupli Frames On", "Number of frames to use between DupOff frames"); 02193 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update"); 02194 02195 prop= RNA_def_property(srna, "dupli_frames_off", PROP_INT, PROP_NONE|PROP_UNIT_TIME); 02196 RNA_def_property_int_sdna(prop, NULL, "dupoff"); 02197 RNA_def_property_range(prop, 0, MAXFRAME); 02198 RNA_def_property_ui_range(prop, 0, 1500, 1, 0); 02199 RNA_def_property_ui_text(prop, "Dupli Frames Off", "Recurring frames to exclude from the Dupliframes"); 02200 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update"); 02201 02202 prop= RNA_def_property(srna, "dupli_list", PROP_COLLECTION, PROP_NONE); 02203 RNA_def_property_collection_sdna(prop, NULL, "duplilist", NULL); 02204 RNA_def_property_struct_type(prop, "DupliObject"); 02205 RNA_def_property_ui_text(prop, "Dupli list", "Object duplis"); 02206 02207 prop= RNA_def_property(srna, "is_duplicator", PROP_BOOLEAN, PROP_NONE); 02208 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLI); 02209 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 02210 02211 /* time offset */ 02212 prop= RNA_def_property(srna, "time_offset", PROP_FLOAT, PROP_NONE|PROP_UNIT_TIME); 02213 RNA_def_property_float_sdna(prop, NULL, "sf"); 02214 RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); 02215 RNA_def_property_ui_text(prop, "Time Offset", "Animation offset in frames for F-Curve and dupligroup instances"); 02216 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 02217 02218 prop= RNA_def_property(srna, "use_time_offset_edit", PROP_BOOLEAN, PROP_NONE); 02219 RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_OB); 02220 RNA_def_property_ui_text(prop, "Time Offset Edit", "Use time offset when inserting keys and display time offset for F-Curve and action views"); 02221 02222 prop= RNA_def_property(srna, "use_time_offset_parent", PROP_BOOLEAN, PROP_NONE); 02223 RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_PARENT); 02224 RNA_def_property_ui_text(prop, "Time Offset Parent", "Apply the time offset to this objects parent relationship"); 02225 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 02226 02227 prop= RNA_def_property(srna, "use_time_offset_particle", PROP_BOOLEAN, PROP_NONE); 02228 RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_PARTICLE); 02229 RNA_def_property_ui_text(prop, "Time Offset Particle", "Let the time offset work on the particle effect"); 02230 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 02231 02232 prop= RNA_def_property(srna, "use_time_offset_add_parent", PROP_BOOLEAN, PROP_NONE); 02233 RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_PARENTADD); 02234 RNA_def_property_ui_text(prop, "Time Offset Add Parent", "Add the parents time offset value"); 02235 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); 02236 02237 /* drawing */ 02238 prop= RNA_def_property(srna, "draw_type", PROP_ENUM, PROP_NONE); 02239 RNA_def_property_enum_sdna(prop, NULL, "dt"); 02240 RNA_def_property_enum_items(prop, drawtype_items); 02241 RNA_def_property_ui_text(prop, "Maximum Draw Type", "Maximum draw type to display object with in viewport"); 02242 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02243 02244 prop= RNA_def_property(srna, "show_bounds", PROP_BOOLEAN, PROP_NONE); 02245 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_BOUNDBOX); 02246 RNA_def_property_ui_text(prop, "Draw Bounds", "Displays the object's bounds"); 02247 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02248 02249 prop= RNA_def_property(srna, "draw_bounds_type", PROP_ENUM, PROP_NONE); 02250 RNA_def_property_enum_sdna(prop, NULL, "boundtype"); 02251 RNA_def_property_enum_items(prop, boundtype_items); 02252 RNA_def_property_ui_text(prop, "Draw Bounds Type", "Object boundary display type"); 02253 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02254 02255 prop= RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE); 02256 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWNAME); 02257 RNA_def_property_ui_text(prop, "Draw Name", "Displays the object's name"); 02258 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02259 02260 prop= RNA_def_property(srna, "show_axis", PROP_BOOLEAN, PROP_NONE); 02261 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_AXIS); 02262 RNA_def_property_ui_text(prop, "Draw Axis", "Displays the object's origin and axis"); 02263 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02264 02265 prop= RNA_def_property(srna, "show_texture_space", PROP_BOOLEAN, PROP_NONE); 02266 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_TEXSPACE); 02267 RNA_def_property_ui_text(prop, "Draw Texture Space", "Displays the object's texture space"); 02268 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02269 02270 prop= RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE); 02271 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWWIRE); 02272 RNA_def_property_ui_text(prop, "Draw Wire", "Adds the object's wireframe over solid drawing"); 02273 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02274 02275 prop= RNA_def_property(srna, "show_transparent", PROP_BOOLEAN, PROP_NONE); 02276 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWTRANSP); 02277 RNA_def_property_ui_text(prop, "Draw Transparent", "Displays material transparency in the object (unsupported for duplicator drawing)"); 02278 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02279 02280 prop= RNA_def_property(srna, "show_x_ray", PROP_BOOLEAN, PROP_NONE); 02281 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWXRAY); 02282 RNA_def_property_ui_text(prop, "X-Ray", "Makes the object draw in front of others (unsupported for duplicator drawing)"); 02283 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 02284 02285 /* Grease Pencil */ 02286 prop= RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE); 02287 RNA_def_property_pointer_sdna(prop, NULL, "gpd"); 02288 RNA_def_property_flag(prop, PROP_EDITABLE); 02289 RNA_def_property_struct_type(prop, "GreasePencil"); 02290 RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock"); 02291 02292 /* pose */ 02293 prop= RNA_def_property(srna, "pose_library", PROP_POINTER, PROP_NONE); 02294 RNA_def_property_pointer_sdna(prop, NULL, "poselib"); 02295 RNA_def_property_flag(prop, PROP_EDITABLE); 02296 RNA_def_property_struct_type(prop, "Action"); 02297 RNA_def_property_ui_text(prop, "Pose Library", "Action used as a pose library for armatures"); 02298 02299 prop= RNA_def_property(srna, "pose", PROP_POINTER, PROP_NONE); 02300 RNA_def_property_pointer_sdna(prop, NULL, "pose"); 02301 RNA_def_property_struct_type(prop, "Pose"); 02302 RNA_def_property_ui_text(prop, "Pose", "Current pose for armatures"); 02303 02304 /* shape keys */ 02305 prop= RNA_def_property(srna, "show_only_shape_key", PROP_BOOLEAN, PROP_NONE); 02306 RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_LOCK); 02307 RNA_def_property_ui_text(prop, "Shape Key Lock", "Always show the current Shape for this Object"); 02308 RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1); 02309 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data"); 02310 02311 prop= RNA_def_property(srna, "use_shape_key_edit_mode", PROP_BOOLEAN, PROP_NONE); 02312 RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_EDIT_MODE); 02313 RNA_def_property_ui_text(prop, "Shape Key Edit Mode", "Apply shape keys in edit mode (for Meshes only)"); 02314 RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0); 02315 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data"); 02316 02317 prop= RNA_def_property(srna, "active_shape_key", PROP_POINTER, PROP_NONE); 02318 RNA_def_property_struct_type(prop, "ShapeKey"); 02319 RNA_def_property_pointer_funcs(prop, "rna_Object_active_shape_key_get", NULL, NULL, NULL); 02320 RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key"); 02321 02322 prop= RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE); 02323 RNA_def_property_int_sdna(prop, NULL, "shapenr"); 02324 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); // XXX this is really unpredictable... 02325 RNA_def_property_int_funcs(prop, "rna_Object_active_shape_key_index_get", "rna_Object_active_shape_key_index_set", "rna_Object_active_shape_key_index_range"); 02326 RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index"); 02327 RNA_def_property_update(prop, 0, "rna_Object_active_shape_update"); 02328 02329 RNA_api_object(srna); 02330 } 02331 02332 static void rna_def_dupli_object(BlenderRNA *brna) 02333 { 02334 StructRNA *srna; 02335 PropertyRNA *prop; 02336 02337 srna= RNA_def_struct(brna, "DupliObject", NULL); 02338 RNA_def_struct_sdna(srna, "DupliObject"); 02339 RNA_def_struct_ui_text(srna, "Object Duplicate", "An object duplicate"); 02340 /* RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); */ 02341 02342 prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); 02343 RNA_def_property_pointer_sdna(prop, NULL, "ob"); 02344 /* RNA_def_property_pointer_funcs(prop, "rna_DupliObject_object_get", NULL, NULL, NULL); */ 02345 RNA_def_property_ui_text(prop, "Object", "Object being duplicated"); 02346 02347 prop= RNA_def_property(srna, "matrix_original", PROP_FLOAT, PROP_MATRIX); 02348 RNA_def_property_float_sdna(prop, NULL, "omat"); 02349 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); 02350 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 02351 RNA_def_property_ui_text(prop, "Object Matrix", "The original matrix of this object before it was duplicated"); 02352 02353 prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); 02354 RNA_def_property_float_sdna(prop, NULL, "mat"); 02355 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); 02356 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 02357 RNA_def_property_ui_text(prop, "Object Duplicate Matrix", "Object duplicate transformation matrix"); 02358 02359 /* TODO: DupliObject has more properties that can be wrapped */ 02360 } 02361 02362 static void rna_def_object_base(BlenderRNA *brna) 02363 { 02364 StructRNA *srna; 02365 PropertyRNA *prop; 02366 02367 srna= RNA_def_struct(brna, "ObjectBase", NULL); 02368 RNA_def_struct_sdna(srna, "Base"); 02369 RNA_def_struct_ui_text(srna, "Object Base", "An object instance in a scene"); 02370 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); 02371 02372 prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); 02373 RNA_def_property_pointer_sdna(prop, NULL, "object"); 02374 RNA_def_property_ui_text(prop, "Object", "Object this base links to"); 02375 02376 /* same as object layer */ 02377 prop= RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER); 02378 RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); 02379 RNA_def_property_array(prop, 20); 02380 RNA_def_property_ui_text(prop, "Layers", "Layers the object base is on"); 02381 RNA_def_property_boolean_funcs(prop, NULL, "rna_Base_layer_set"); 02382 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Base_layer_update"); 02383 02384 prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); 02385 RNA_def_property_boolean_sdna(prop, NULL, "flag", BA_SELECT); 02386 RNA_def_property_ui_text(prop, "Select", "Object base selection state"); 02387 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Base_select_update"); 02388 02389 RNA_api_object_base(srna); 02390 } 02391 02392 void RNA_def_object(BlenderRNA *brna) 02393 { 02394 rna_def_object(brna); 02395 rna_def_object_game_settings(brna); 02396 rna_def_object_base(brna); 02397 rna_def_vertex_group(brna); 02398 rna_def_material_slot(brna); 02399 rna_def_dupli_object(brna); 02400 } 02401 02402 #endif