Blender V2.61 - r43446

rna_object.c

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