4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * Contributor(s): Blender Foundation (2008).
22 * ***** END GPL LICENSE BLOCK *****
28 #include "RNA_access.h"
29 #include "RNA_define.h"
30 #include "RNA_enum_types.h"
32 #include "rna_internal.h"
34 #include "DNA_action_types.h"
35 #include "DNA_customdata_types.h"
36 #include "DNA_controller_types.h"
37 #include "DNA_material_types.h"
38 #include "DNA_mesh_types.h"
39 #include "DNA_object_force.h"
40 #include "DNA_object_types.h"
41 #include "DNA_property_types.h"
42 #include "DNA_scene_types.h"
47 EnumPropertyItem object_mode_items[] = {
48 {OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object", ""},
49 {OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit", ""},
50 {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""},
51 {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
52 {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
53 {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
54 {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""},
55 {OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose", ""},
56 {0, NULL, 0, NULL, NULL}};
58 static EnumPropertyItem parent_type_items[] = {
59 {PAROBJECT, "OBJECT", 0, "Object", ""},
60 {PARCURVE, "CURVE", 0, "Curve", ""},
61 {PARKEY, "KEY", 0, "Key", ""},
62 {PARSKEL, "ARMATURE", 0, "Armature", ""},
63 {PARSKEL, "LATTICE", 0, "Lattice", ""}, // PARSKEL reuse will give issues
64 {PARVERT1, "VERTEX", 0, "Vertex", ""},
65 {PARVERT3, "VERTEX_3", 0, "3 Vertices", ""},
66 {PARBONE, "BONE", 0, "Bone", ""},
67 {0, NULL, 0, NULL, NULL}};
69 static EnumPropertyItem collision_bounds_items[] = {
70 {OB_BOUND_BOX, "BOX", 0, "Box", ""},
71 {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""},
72 {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", ""},
73 {OB_BOUND_CONE, "CONE", 0, "Cone", ""},
74 {OB_BOUND_POLYT, "CONVEX_HULL", 0, "Convex Hull", ""},
75 {OB_BOUND_POLYH, "TRIANGLE_MESH", 0, "Triangle Mesh", ""},
76 //{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""},
77 {0, NULL, 0, NULL, NULL}};
79 /* used for 2 enums */
80 #define OBTYPE_CU_CURVE {OB_CURVE, "CURVE", 0, "Curve", ""}
81 #define OBTYPE_CU_SURF {OB_SURF, "SURFACE", 0, "Surface", ""}
82 #define OBTYPE_CU_TEXT {OB_FONT, "TEXT", 0, "Text", ""}
84 EnumPropertyItem object_type_items[] = {
85 {OB_MESH, "MESH", 0, "Mesh", ""},
88 {OB_MBALL, "META", 0, "Meta", ""},
90 {0, "", 0, NULL, NULL},
91 {OB_ARMATURE, "ARMATURE", 0, "Armature", ""},
92 {OB_LATTICE, "LATTICE", 0, "Lattice", ""},
93 {OB_EMPTY, "EMPTY", 0, "Empty", ""},
94 {0, "", 0, NULL, NULL},
95 {OB_CAMERA, "CAMERA", 0, "Camera", ""},
96 {OB_LAMP, "LAMP", 0, "Lamp", ""},
97 {0, NULL, 0, NULL, NULL}};
99 EnumPropertyItem object_type_curve_items[] = {
103 {0, NULL, 0, NULL, NULL}};
107 #include "BLI_math.h"
109 #include "DNA_key_types.h"
110 #include "DNA_constraint_types.h"
112 #include "BKE_armature.h"
113 #include "BKE_bullet.h"
114 #include "BKE_constraint.h"
115 #include "BKE_context.h"
116 #include "BKE_curve.h"
117 #include "BKE_depsgraph.h"
118 #include "BKE_effect.h"
120 #include "BKE_object.h"
121 #include "BKE_material.h"
122 #include "BKE_mesh.h"
123 #include "BKE_particle.h"
124 #include "BKE_scene.h"
126 #include "BLI_editVert.h" /* for EditMesh->mat_nr */
129 #include "ED_object.h"
130 #include "ED_particle.h"
132 void rna_Object_update(Main *bmain, Scene *scene, PointerRNA *ptr)
134 DAG_id_flush_update(ptr->id.data, OB_RECALC_OB);
137 void rna_Object_matrix_update(Main *bmain, Scene *scene, PointerRNA *ptr)
139 object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat);
140 rna_Object_update(bmain, scene, ptr);
143 void rna_Object_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
145 DAG_id_flush_update(ptr->id.data, OB_RECALC_DATA);
146 WM_main_add_notifier(NC_OBJECT|ND_DRAW, ptr->id.data);
149 void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
151 Object *ob= ptr->id.data;
152 int editmode= (scene->obedit == ob && ob->type == OB_MESH);
155 /* exit/enter editmode to get new shape */
156 load_editMesh(scene, ob);
157 make_editMesh(scene, ob);
160 rna_Object_update_data(bmain, scene, ptr);
163 static void rna_Object_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
165 DAG_id_flush_update(ptr->id.data, OB_RECALC_OB);
166 DAG_scene_sort(scene);
169 /* when changing the selection flag the scene needs updating */
170 static void rna_Object_select_update(Main *bmain, Scene *scene, PointerRNA *ptr)
172 Object *ob= (Object*)ptr->id.data;
173 short mode = ob->flag & SELECT ? BA_SELECT : BA_DESELECT;
174 ED_base_object_select(object_in_scene(ob, scene), mode);
177 static void rna_Base_select_update(Main *bmain, Scene *scene, PointerRNA *ptr)
179 Base *base= (Base*)ptr->data;
180 short mode = base->flag & BA_SELECT ? BA_SELECT : BA_DESELECT;
181 ED_base_object_select(base, mode);
184 static void rna_Object_layer_update__internal(Scene *scene, Base *base, Object *ob)
186 /* try to avoid scene sort */
187 if((ob->lay & scene->lay) && (base->lay & scene->lay)) {
189 } else if((ob->lay & scene->lay)==0 && (base->lay & scene->lay)==0) {
192 DAG_scene_sort(scene);
196 static void rna_Object_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
198 Object *ob= (Object*)ptr->id.data;
201 base= object_in_scene(ob, scene);
205 SWAP(int, base->lay, ob->lay);
207 rna_Object_layer_update__internal(scene, base, ob);
211 static void rna_Base_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
213 Base *base= (Base*)ptr->id.data;
214 Object *ob= (Object*)base->object;
216 rna_Object_layer_update__internal(scene, base, ob);
220 static int rna_Object_data_editable(PointerRNA *ptr)
222 Object *ob= (Object*)ptr->data;
224 return (ob->type == OB_EMPTY)? 0: PROP_EDITABLE;
227 static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
229 Object *ob= (Object*)ptr->data;
232 if(ob->type == OB_EMPTY || id == NULL || ob->mode & OB_MODE_EDIT)
235 if(ob->type == OB_MESH) {
236 set_mesh(ob, (Mesh*)id);
240 id_us_min((ID*)ob->data);
245 test_object_materials(id);
247 if(GS(id->name)==ID_CU)
249 else if(ob->type==OB_ARMATURE)
250 armature_rebuild_pose(ob, ob->data);
254 static StructRNA *rna_Object_data_typef(PointerRNA *ptr)
256 Object *ob= (Object*)ptr->data;
259 case OB_MESH: return &RNA_Mesh;
260 case OB_CURVE: return &RNA_Curve;
261 case OB_SURF: return &RNA_Curve;
262 case OB_FONT: return &RNA_Curve;
263 case OB_MBALL: return &RNA_MetaBall;
264 case OB_LAMP: return &RNA_Lamp;
265 case OB_CAMERA: return &RNA_Camera;
266 case OB_LATTICE: return &RNA_Lattice;
267 case OB_ARMATURE: return &RNA_Armature;
268 default: return &RNA_ID;
272 static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value)
274 Object *ob= (Object*)ptr->data;
275 Object *par= (Object*)value.data;
277 ED_object_parent(ob, par, ob->partype, ob->parsubstr);
280 static void rna_Object_parent_type_set(PointerRNA *ptr, int value)
282 Object *ob= (Object*)ptr->data;
284 ED_object_parent(ob, ob->parent, value, ob->parsubstr);
287 static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *C, PointerRNA *ptr, int *free)
289 Object *ob= (Object*)ptr->data;
290 EnumPropertyItem *item= NULL;
293 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PAROBJECT);
296 Object *par= ob->parent;
298 if(par->type == OB_CURVE)
299 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARCURVE);
300 else if(par->type == OB_LATTICE)
301 RNA_enum_items_add_value(&item, &totitem, &parent_type_items[4], PARSKEL); // special hack: prevents this overriding others
302 else if(par->type == OB_ARMATURE) {
303 RNA_enum_items_add_value(&item, &totitem, &parent_type_items[3], PARSKEL); // special hack: prevents this being overrided
304 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARBONE);
306 else if(par->type == OB_MESH) {
307 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT1);
308 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT3);
312 RNA_enum_item_end(&item, &totitem);
318 static EnumPropertyItem *rna_Object_collision_bounds_itemf(bContext *C, PointerRNA *ptr, int *free)
320 Object *ob= (Object*)ptr->data;
321 EnumPropertyItem *item= NULL;
324 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_POLYH);
325 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_POLYT);
327 if(ob->body_type!=OB_BODY_TYPE_SOFT) {
328 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CONE);
329 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CYLINDER);
330 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_SPHERE);
331 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_BOX);
334 RNA_enum_item_end(&item, &totitem);
340 static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value)
342 Object *ob= (Object*)ptr->data;
344 ED_object_parent(ob, ob->parent, ob->partype, value);
347 static int rna_VertexGroup_index_get(PointerRNA *ptr)
349 Object *ob= (Object*)ptr->id.data;
351 return BLI_findindex(&ob->defbase, ptr->data);
354 static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr)
356 Object *ob= (Object*)ptr->id.data;
357 return rna_pointer_inherit_refine(ptr, &RNA_VertexGroup, BLI_findlink(&ob->defbase, ob->actdef-1));
360 static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr)
362 Object *ob= (Object*)ptr->id.data;
363 return MAX2(ob->actdef-1, 0);
366 static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value)
368 Object *ob= (Object*)ptr->id.data;
372 static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min, int *max)
374 Object *ob= (Object*)ptr->id.data;
377 *max= BLI_countlist(&ob->defbase)-1;
381 void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
383 Object *ob= (Object*)ptr->id.data;
386 dg= BLI_findlink(&ob->defbase, index-1);
388 if(dg) BLI_strncpy(value, dg->name, sizeof(dg->name));
389 else BLI_strncpy(value, "", sizeof(dg->name));
392 int rna_object_vgroup_name_index_length(PointerRNA *ptr, int index)
394 Object *ob= (Object*)ptr->id.data;
397 dg= BLI_findlink(&ob->defbase, index-1);
398 return (dg)? strlen(dg->name): 0;
401 void rna_object_vgroup_name_index_set(PointerRNA *ptr, const char *value, short *index)
403 Object *ob= (Object*)ptr->id.data;
407 for(a=1, dg=ob->defbase.first; dg; dg=dg->next, a++) {
408 if(strcmp(dg->name, value) == 0) {
417 void rna_object_vgroup_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
419 Object *ob= (Object*)ptr->id.data;
422 for(dg=ob->defbase.first; dg; dg=dg->next) {
423 if(strcmp(dg->name, value) == 0) {
424 BLI_strncpy(result, value, maxlen);
429 BLI_strncpy(result, "", maxlen);
432 void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
434 Object *ob= (Object*)ptr->id.data;
436 CustomDataLayer *layer;
439 if(ob->type == OB_MESH && ob->data) {
442 for(a=0; a<me->fdata.totlayer; a++) {
443 layer= &me->fdata.layers[a];
445 if(layer->type == CD_MTFACE && strcmp(layer->name, value) == 0) {
446 BLI_strncpy(result, value, maxlen);
452 BLI_strncpy(result, "", maxlen);
455 void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
457 Object *ob= (Object*)ptr->id.data;
459 CustomDataLayer *layer;
462 if(ob->type == OB_MESH && ob->data) {
465 for(a=0; a<me->fdata.totlayer; a++) {
466 layer= &me->fdata.layers[a];
468 if(layer->type == CD_MCOL && strcmp(layer->name, value) == 0) {
469 BLI_strncpy(result, value, maxlen);
475 BLI_strncpy(result, "", maxlen);
478 static int rna_Object_active_material_index_get(PointerRNA *ptr)
480 Object *ob= (Object*)ptr->id.data;
481 return MAX2(ob->actcol-1, 0);
484 static void rna_Object_active_material_index_set(PointerRNA *ptr, int value)
486 Object *ob= (Object*)ptr->id.data;
489 if(ob->type==OB_MESH) {
493 me->edit_mesh->mat_nr= value;
497 static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, int *max)
499 Object *ob= (Object*)ptr->id.data;
501 *max= MAX2(ob->totcol-1, 0);
504 static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
506 Object *ob= (Object*)ptr->id.data;
509 ma= (ob->totcol)? give_current_material(ob, ob->actcol): NULL;
510 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
513 static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value)
515 Object *ob= (Object*)ptr->id.data;
517 assign_material(ob, value.data, ob->actcol);
520 static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int *min, int *max)
522 Object *ob= (Object*)ptr->id.data;
524 *max= BLI_countlist(&ob->particlesystem)-1;
528 static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
530 Object *ob= (Object*)ptr->id.data;
531 return psys_get_current_num(ob);
534 static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int value)
536 Object *ob= (Object*)ptr->id.data;
537 psys_set_current_num(ob, value);
540 static void rna_Object_particle_update(Main *bmain, Scene *scene, PointerRNA *ptr)
542 Object *ob= (Object*)ptr->id.data;
544 PE_current_changed(scene, ob);
547 /* rotation - axis-angle */
548 static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value)
550 Object *ob= ptr->data;
552 /* for now, assume that rotation mode is axis-angle */
553 value[0]= ob->rotAngle;
554 copy_v3_v3(&value[1], ob->rotAxis);
557 /* rotation - axis-angle */
558 static void rna_Object_rotation_axis_angle_set(PointerRNA *ptr, const float *value)
560 Object *ob= ptr->data;
562 /* for now, assume that rotation mode is axis-angle */
563 ob->rotAngle= value[0];
564 copy_v3_v3(ob->rotAxis, (float *)&value[1]);
566 // TODO: validate axis?
569 static void rna_Object_rotation_mode_set(PointerRNA *ptr, int value)
571 Object *ob= ptr->data;
573 /* use API Method for conversions... */
574 BKE_rotMode_change_values(ob->quat, ob->rot, ob->rotAxis, &ob->rotAngle, ob->rotmode, (short)value);
576 /* finally, set the new rotation type */
580 static void rna_Object_dimensions_get(PointerRNA *ptr, float *value)
582 Object *ob= ptr->data;
583 object_get_dimensions(ob, value);
586 static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value)
588 Object *ob= ptr->data;
589 object_set_dimensions(ob, value);
592 static int rna_Object_location_editable(PointerRNA *ptr, int index)
594 Object *ob= (Object *)ptr->data;
596 /* only if the axis in question is locked, not editable... */
597 if ((index == 0) && (ob->protectflag & OB_LOCK_LOCX))
599 else if ((index == 1) && (ob->protectflag & OB_LOCK_LOCY))
601 else if ((index == 2) && (ob->protectflag & OB_LOCK_LOCZ))
604 return PROP_EDITABLE;
607 static int rna_Object_scale_editable(PointerRNA *ptr, int index)
609 Object *ob= (Object *)ptr->data;
611 /* only if the axis in question is locked, not editable... */
612 if ((index == 0) && (ob->protectflag & OB_LOCK_SCALEX))
614 else if ((index == 1) && (ob->protectflag & OB_LOCK_SCALEY))
616 else if ((index == 2) && (ob->protectflag & OB_LOCK_SCALEZ))
619 return PROP_EDITABLE;
622 static int rna_Object_rotation_euler_editable(PointerRNA *ptr, int index)
624 Object *ob= (Object *)ptr->data;
626 /* only if the axis in question is locked, not editable... */
627 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTX))
629 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTY))
631 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTZ))
634 return PROP_EDITABLE;
637 static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index)
639 Object *ob= (Object *)ptr->data;
641 /* only consider locks if locking components individually... */
642 if (ob->protectflag & OB_LOCK_ROT4D) {
643 /* only if the axis in question is locked, not editable... */
644 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTW))
646 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTX))
648 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTY))
650 else if ((index == 3) && (ob->protectflag & OB_LOCK_ROTZ))
654 return PROP_EDITABLE;
658 static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr)
660 Object *ob= (Object*)ptr->id.data;
662 int index= (Material**)ptr->data - ob->mat;
664 ma= give_current_material(ob, index+1);
665 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
668 static void rna_MaterialSlot_material_set(PointerRNA *ptr, PointerRNA value)
670 Object *ob= (Object*)ptr->id.data;
671 int index= (Material**)ptr->data - ob->mat;
673 assign_material(ob, value.data, index+1);
676 static int rna_MaterialSlot_link_get(PointerRNA *ptr)
678 Object *ob= (Object*)ptr->id.data;
679 int index= (Material**)ptr->data - ob->mat;
681 return ob->matbits[index] != 0;
684 static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value)
686 Object *ob= (Object*)ptr->id.data;
687 int index= (Material**)ptr->data - ob->mat;
690 ob->matbits[index]= 1;
691 ob->colbits |= (1<<index);
694 ob->matbits[index]= 0;
695 ob->colbits &= ~(1<<index);
699 static int rna_MaterialSlot_name_length(PointerRNA *ptr)
701 Object *ob= (Object*)ptr->id.data;
703 int index= (Material**)ptr->data - ob->mat;
705 ma= give_current_material(ob, index+1);
708 return strlen(ma->id.name+2);
713 static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str)
715 Object *ob= (Object*)ptr->id.data;
717 int index= (Material**)ptr->data - ob->mat;
719 ma= give_current_material(ob, index+1);
722 strcpy(str, ma->id.name+2);
727 /* why does this have to be so complicated?, can't all this crap be
728 * moved to in BGE conversion function? - Campbell *
730 * logic from check_body_type()
732 static int rna_GameObjectSettings_physics_type_get(PointerRNA *ptr)
734 Object *ob= (Object*)ptr->id.data;
736 /* determine the body_type setting based on flags */
737 if (!(ob->gameflag & OB_COLLISION)) {
738 if (ob->gameflag & OB_OCCLUDER) {
739 ob->body_type = OB_BODY_TYPE_OCCLUDER;
740 } else if (ob->gameflag & OB_NAVMESH){
741 ob->body_type = OB_BODY_TYPE_NAVMESH;
743 ob->body_type = OB_BODY_TYPE_NO_COLLISION;
745 } else if (ob->gameflag & OB_SENSOR) {
746 ob->body_type = OB_BODY_TYPE_SENSOR;
747 } else if (!(ob->gameflag & OB_DYNAMIC)) {
748 ob->body_type = OB_BODY_TYPE_STATIC;
749 } else if (!(ob->gameflag & (OB_RIGID_BODY|OB_SOFT_BODY))) {
750 ob->body_type = OB_BODY_TYPE_DYNAMIC;
751 } else if (ob->gameflag & OB_RIGID_BODY) {
752 ob->body_type = OB_BODY_TYPE_RIGID;
754 ob->body_type = OB_BODY_TYPE_SOFT;
755 /* create the structure here because we display soft body buttons in the main panel */
757 ob->bsoft = bsbNew();
760 return ob->body_type;
763 static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value)
765 Object *ob= (Object*)ptr->id.data;
766 ob->body_type= value;
768 switch (ob->body_type) {
769 case OB_BODY_TYPE_SENSOR:
770 ob->gameflag |= OB_SENSOR|OB_COLLISION|OB_GHOST;
771 ob->gameflag &= ~(OB_OCCLUDER|OB_NAVMESH|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_ACTOR|OB_ANISOTROPIC_FRICTION|OB_DO_FH|OB_ROT_FH|OB_COLLISION_RESPONSE);
773 case OB_BODY_TYPE_OCCLUDER:
774 ob->gameflag |= OB_OCCLUDER;
775 ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_DYNAMIC|OB_NAVMESH);
777 case OB_BODY_TYPE_NAVMESH:
778 ob->gameflag |= OB_NAVMESH;
779 ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_DYNAMIC|OB_OCCLUDER);
781 case OB_BODY_TYPE_NO_COLLISION:
782 ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_OCCLUDER|OB_DYNAMIC|OB_NAVMESH);
784 case OB_BODY_TYPE_STATIC:
785 ob->gameflag |= OB_COLLISION;
786 ob->gameflag &= ~(OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR|OB_NAVMESH);
788 case OB_BODY_TYPE_DYNAMIC:
789 ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_ACTOR;
790 ob->gameflag &= ~(OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR|OB_NAVMESH);
792 case OB_BODY_TYPE_RIGID:
793 ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_RIGID_BODY|OB_ACTOR;
794 ob->gameflag &= ~(OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR|OB_NAVMESH);
797 case OB_BODY_TYPE_SOFT:
798 ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_SOFT_BODY|OB_ACTOR;
799 ob->gameflag &= ~(OB_RIGID_BODY|OB_OCCLUDER|OB_SENSOR|OB_NAVMESH);
801 /* assume triangle mesh, if no bounds chosen for soft body */
802 if ((ob->gameflag & OB_BOUNDS) && (ob->boundtype<OB_BOUND_POLYH))
804 ob->boundtype=OB_BOUND_POLYH;
806 /* create a BulletSoftBody structure if not already existing */
808 ob->bsoft = bsbNew();
813 static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr)
815 Object *ob= (Object*)ptr->id.data;
816 ParticleSystem *psys= psys_get_current(ob);
817 return rna_pointer_inherit_refine(ptr, &RNA_ParticleSystem, psys);
820 static PointerRNA rna_Object_game_settings_get(PointerRNA *ptr)
822 return rna_pointer_inherit_refine(ptr, &RNA_GameObjectSettings, ptr->id.data);
826 static unsigned int rna_Object_layer_validate__internal(const int *values, unsigned int lay)
830 /* ensure we always have some layer selected */
838 for(i=0; i<20; i++) {
839 if(values[i]) lay |= (1<<i);
846 static void rna_Object_layer_set(PointerRNA *ptr, const int *values)
848 Object *ob= (Object*)ptr->data;
851 lay= rna_Object_layer_validate__internal(values, ob->lay);
856 static void rna_Base_layer_set(PointerRNA *ptr, const int *values)
858 Base *base= (Base*)ptr->data;
861 lay= rna_Object_layer_validate__internal(values, base->lay);
865 /* rna_Base_layer_update updates the objects layer */
868 static void rna_GameObjectSettings_state_get(PointerRNA *ptr, int *values)
870 Object *ob= (Object*)ptr->data;
872 int all_states = (ob->scaflag & OB_ALLSTATE?1:0);
874 memset(values, 0, sizeof(int)*OB_MAX_STATES);
875 for(i=0; i<OB_MAX_STATES; i++)
876 values[i] = (ob->state & (1<<i)) | all_states;
879 static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values)
881 Object *ob= (Object*)ptr->data;
884 /* ensure we always have some state selected */
885 for(i=0; i<OB_MAX_STATES; i++)
892 for(i=0; i<OB_MAX_STATES; i++) {
893 if(values[i]) ob->state |= (1<<i);
894 else ob->state &= ~(1<<i);
898 static void rna_GameObjectSettings_used_state_get(PointerRNA *ptr, int *values)
900 Object *ob= (Object*)ptr->data;
903 memset(values, 0, sizeof(int)*OB_MAX_STATES);
904 for (cont=ob->controllers.first; cont; cont=cont->next) {
907 for (i=0; i<OB_MAX_STATES; i++) {
908 if (cont->state_mask & (1<<i))
914 static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max)
916 Object *ob= (Object*)ptr->id.data;
917 Key *key= ob_get_key(ob);
920 *max= (key)? BLI_countlist(&key->block)-1: 0;
924 static int rna_Object_active_shape_key_index_get(PointerRNA *ptr)
926 Object *ob= (Object*)ptr->id.data;
928 return MAX2(ob->shapenr-1, 0);
931 static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value)
933 Object *ob= (Object*)ptr->id.data;
935 ob->shapenr= value+1;
938 static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr)
940 Object *ob= (Object*)ptr->id.data;
941 Key *key= ob_get_key(ob);
946 return PointerRNA_NULL;
948 kb= BLI_findlink(&key->block, ob->shapenr-1);
949 RNA_pointer_create((ID *)key, &RNA_ShapeKey, kb, &keyptr);
953 static PointerRNA rna_Object_field_get(PointerRNA *ptr)
955 Object *ob= (Object*)ptr->id.data;
959 ob->pd= object_add_collision_fields(0);
961 return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, ob->pd);
964 static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
966 Object *ob= (Object*)ptr->id.data;
970 ob->pd= object_add_collision_fields(0);
972 return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd);
975 static PointerRNA rna_Object_active_constraint_get(PointerRNA *ptr)
977 Object *ob= (Object*)ptr->id.data;
978 bConstraint *con= constraints_get_active(&ob->constraints);
979 return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con);
982 static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value)
984 Object *ob= (Object*)ptr->id.data;
985 constraints_set_active(&ob->constraints, (bConstraint *)value.data);
988 static bConstraint *rna_Object_constraint_new(Object *object, int type)
990 WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_ADDED, object);
991 return add_ob_constraint(object, NULL, type);
994 static int rna_Object_constraint_remove(Object *object, int index)
996 int ok = remove_constraint_index(&object->constraints, index);
998 ED_object_constraint_set_active(object, NULL);
999 WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT, object);
1005 static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports, char *name, int type)
1007 return ED_object_modifier_add(reports, CTX_data_scene(C), object, name, type);
1010 static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, ModifierData *md)
1012 ED_object_modifier_remove(reports, CTX_data_scene(C), object, md);
1015 static void rna_Object_boundbox_get(PointerRNA *ptr, float *values)
1017 Object *ob= (Object*)ptr->id.data;
1018 BoundBox *bb= object_get_boundbox(ob);
1020 memcpy(values, bb->vec, sizeof(bb->vec));
1023 memset(values, -1.0f, sizeof(bb->vec));
1030 static void rna_def_vertex_group(BlenderRNA *brna)
1035 srna= RNA_def_struct(brna, "VertexGroup", NULL);
1036 RNA_def_struct_sdna(srna, "bDeformGroup");
1037 RNA_def_struct_ui_text(srna, "Vertex Group", "Group of vertices, used for armature deform and other purposes");
1038 RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX);
1040 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1041 RNA_def_property_ui_text(prop, "Name", "Vertex group name");
1042 RNA_def_struct_name_property(srna, prop);
1043 RNA_def_property_update(prop, NC_GEOM|ND_DATA|NA_RENAME, NULL);
1045 prop= RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
1046 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1047 RNA_def_property_int_funcs(prop, "rna_VertexGroup_index_get", NULL, NULL);
1048 RNA_def_property_ui_text(prop, "Index", "Index number of the vertex group");
1051 static void rna_def_material_slot(BlenderRNA *brna)
1056 static EnumPropertyItem link_items[] = {
1057 {1, "OBJECT", 0, "Object", ""},
1058 {0, "DATA", 0, "Data", ""},
1059 {0, NULL, 0, NULL, NULL}};
1061 /* NOTE: there is no MaterialSlot equivalent in DNA, so the internal
1062 * pointer data points to ob->mat + index, and we manually implement
1063 * get/set for the properties. */
1065 srna= RNA_def_struct(brna, "MaterialSlot", NULL);
1066 RNA_def_struct_ui_text(srna, "Material Slot", "Material slot in an object");
1067 RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
1069 prop= RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
1070 RNA_def_property_struct_type(prop, "Material");
1071 RNA_def_property_flag(prop, PROP_EDITABLE);
1072 RNA_def_property_pointer_funcs(prop, "rna_MaterialSlot_material_get", "rna_MaterialSlot_material_set", NULL);
1073 RNA_def_property_ui_text(prop, "Material", "Material datablock used by this material slot");
1074 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update");
1076 prop= RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE);
1077 RNA_def_property_enum_items(prop, link_items);
1078 RNA_def_property_enum_funcs(prop, "rna_MaterialSlot_link_get", "rna_MaterialSlot_link_set", NULL);
1079 RNA_def_property_ui_text(prop, "Link", "Link material to object or the object's data");
1080 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update");
1082 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1083 RNA_def_property_string_funcs(prop, "rna_MaterialSlot_name_get", "rna_MaterialSlot_name_length", NULL);
1084 RNA_def_property_ui_text(prop, "Name", "Material slot name");
1085 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1086 RNA_def_struct_name_property(srna, prop);
1089 static void rna_def_object_game_settings(BlenderRNA *brna)
1094 static EnumPropertyItem body_type_items[] = {
1095 {OB_BODY_TYPE_NO_COLLISION, "NO_COLLISION", 0, "No Collision", "Disable colision for this object"},
1096 {OB_BODY_TYPE_STATIC, "STATIC", 0, "Static", "Stationary object"},
1097 {OB_BODY_TYPE_DYNAMIC, "DYNAMIC", 0, "Dynamic", "Linear physics"},
1098 {OB_BODY_TYPE_RIGID, "RIGID_BODY", 0, "Rigid Body", "Linear and angular physics"},
1099 {OB_BODY_TYPE_SOFT, "SOFT_BODY", 0, "Soft Body", "Soft body"},
1100 {OB_BODY_TYPE_OCCLUDER, "OCCLUDE", 0, "Occlude", "Occluder for optimizing scene rendering"},
1101 {OB_BODY_TYPE_SENSOR, "SENSOR", 0, "Sensor", "Collision Sensor, detects static and dynamic objects but not the other collision sensor objects"},
1102 {OB_BODY_TYPE_NAVMESH, "NAVMESH", 0, "NavMesh", "Navigation mesh"},
1103 {0, NULL, 0, NULL, NULL}};
1105 srna= RNA_def_struct(brna, "GameObjectSettings", NULL);
1106 RNA_def_struct_sdna(srna, "Object");
1107 RNA_def_struct_nested(brna, srna, "Object");
1108 RNA_def_struct_ui_text(srna, "Game Object Settings", "Game engine related settings for the object");
1109 RNA_def_struct_ui_icon(srna, ICON_GAME);
1113 prop= RNA_def_property(srna, "sensors", PROP_COLLECTION, PROP_NONE);
1114 RNA_def_property_struct_type(prop, "Sensor");
1115 RNA_def_property_ui_text(prop, "Sensors", "Game engine sensor to detect events");
1117 prop= RNA_def_property(srna, "controllers", PROP_COLLECTION, PROP_NONE);
1118 RNA_def_property_struct_type(prop, "Controller");
1119 RNA_def_property_ui_text(prop, "Controllers", "Game engine controllers to process events, connecting sensor to actuators");
1121 prop= RNA_def_property(srna, "actuators", PROP_COLLECTION, PROP_NONE);
1122 RNA_def_property_struct_type(prop, "Actuator");
1123 RNA_def_property_ui_text(prop, "Actuators", "Game engine actuators to act on events");
1125 prop= RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE);
1126 RNA_def_property_collection_sdna(prop, NULL, "prop", NULL);
1127 RNA_def_property_struct_type(prop, "GameProperty"); /* rna_property.c */
1128 RNA_def_property_ui_text(prop, "Properties", "Game engine properties");
1130 prop= RNA_def_property(srna, "show_sensors", PROP_BOOLEAN, PROP_NONE);
1131 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSENS);
1132 RNA_def_property_ui_text(prop, "Show Sensors", "Shows sensors for this object in the user interface");
1134 prop= RNA_def_property(srna, "show_controllers", PROP_BOOLEAN, PROP_NONE);
1135 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWCONT);
1136 RNA_def_property_ui_text(prop, "Show Controllers", "Shows controllers for this object in the user interface");
1138 prop= RNA_def_property(srna, "show_actuators", PROP_BOOLEAN, PROP_NONE);
1139 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWACT);
1140 RNA_def_property_ui_text(prop, "Show Actuators", "Shows actuators for this object in the user interface");
1144 prop= RNA_def_property(srna, "physics_type", PROP_ENUM, PROP_NONE);
1145 RNA_def_property_enum_sdna(prop, NULL, "body_type");
1146 RNA_def_property_enum_items(prop, body_type_items);
1147 RNA_def_property_enum_funcs(prop, "rna_GameObjectSettings_physics_type_get", "rna_GameObjectSettings_physics_type_set", NULL);
1148 RNA_def_property_ui_text(prop, "Physics Type", "Selects the type of physical representation");
1149 RNA_def_property_update(prop, NC_LOGIC, NULL);
1151 prop= RNA_def_property(srna, "actor", PROP_BOOLEAN, PROP_NONE);
1152 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ACTOR);
1153 RNA_def_property_ui_text(prop, "Actor", "Object is detected by the Near and Radar sensor");
1155 prop= RNA_def_property(srna, "ghost", PROP_BOOLEAN, PROP_NONE);
1156 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_GHOST);
1157 RNA_def_property_ui_text(prop, "Ghost", "Object does not restitute collisions, like a ghost");
1159 prop= RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE);
1160 RNA_def_property_range(prop, 0.01, 10000.0);
1161 RNA_def_property_ui_text(prop, "Mass", "Mass of the object");
1163 prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH);
1164 RNA_def_property_float_sdna(prop, NULL, "inertia");
1165 RNA_def_property_range(prop, 0.01, 10.0);
1166 RNA_def_property_ui_text(prop, "Radius", "Radius of bounding sphere and material physics");
1167 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1169 prop= RNA_def_property(srna, "no_sleeping", PROP_BOOLEAN, PROP_NONE);
1170 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_COLLISION_RESPONSE);
1171 RNA_def_property_ui_text(prop, "No Sleeping", "Disable auto (de)activation in physics simulation");
1173 prop= RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE);
1174 RNA_def_property_float_sdna(prop, NULL, "damping");
1175 RNA_def_property_range(prop, 0.0, 1.0);
1176 RNA_def_property_ui_text(prop, "Damping", "General movement damping");
1178 prop= RNA_def_property(srna, "rotation_damping", PROP_FLOAT, PROP_NONE);
1179 RNA_def_property_float_sdna(prop, NULL, "rdamping");
1180 RNA_def_property_range(prop, 0.0, 1.0);
1181 RNA_def_property_ui_text(prop, "Rotation Damping", "General rotation damping");
1183 prop= RNA_def_property(srna, "minimum_velocity", PROP_FLOAT, PROP_NONE);
1184 RNA_def_property_float_sdna(prop, NULL, "min_vel");
1185 RNA_def_property_range(prop, 0.0, 1000.0);
1186 RNA_def_property_ui_text(prop, "Velocity Min", "Clamp velocity to this minimum speed (except when totally still)");
1188 prop= RNA_def_property(srna, "maximum_velocity", PROP_FLOAT, PROP_NONE);
1189 RNA_def_property_float_sdna(prop, NULL, "max_vel");
1190 RNA_def_property_range(prop, 0.0, 1000.0);
1191 RNA_def_property_ui_text(prop, "Velocity Max", "Clamp velocity to this maximum speed");
1194 prop= RNA_def_property(srna, "lock_x_axis", PROP_BOOLEAN, PROP_NONE);
1195 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_AXIS);
1196 RNA_def_property_ui_text(prop, "Lock X Axis", "Disable simulation of linear motion along the X axis");
1198 prop= RNA_def_property(srna, "lock_y_axis", PROP_BOOLEAN, PROP_NONE);
1199 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_AXIS);
1200 RNA_def_property_ui_text(prop, "Lock Y Axis", "Disable simulation of linear motion along the Y axis");
1202 prop= RNA_def_property(srna, "lock_z_axis", PROP_BOOLEAN, PROP_NONE);
1203 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_AXIS);
1204 RNA_def_property_ui_text(prop, "Lock Z Axis", "Disable simulation of linear motion along the Z axis");
1208 prop= RNA_def_property(srna, "lock_x_rot_axis", PROP_BOOLEAN, PROP_NONE);
1209 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_ROT_AXIS);
1210 RNA_def_property_ui_text(prop, "Lock X Rotation Axis", "Disable simulation of angular motion along the X axis");
1212 prop= RNA_def_property(srna, "lock_y_rot_axis", PROP_BOOLEAN, PROP_NONE);
1213 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_ROT_AXIS);
1214 RNA_def_property_ui_text(prop, "Lock Y Rotation Axis", "Disable simulation of angular motion along the Y axis");
1216 prop= RNA_def_property(srna, "lock_z_rot_axis", PROP_BOOLEAN, PROP_NONE);
1217 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_ROT_AXIS);
1218 RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis");
1220 /* is this used anywhere ? */
1221 prop= RNA_def_property(srna, "use_activity_culling", PROP_BOOLEAN, PROP_NONE);
1222 RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflag2", OB_NEVER_DO_ACTIVITY_CULLING);
1223 RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis");
1226 prop= RNA_def_property(srna, "material_physics", PROP_BOOLEAN, PROP_NONE);
1227 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_DO_FH);
1228 RNA_def_property_ui_text(prop, "Use Material Physics", "Use physics settings in materials");
1230 prop= RNA_def_property(srna, "rotate_from_normal", PROP_BOOLEAN, PROP_NONE);
1231 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ROT_FH);
1232 RNA_def_property_ui_text(prop, "Rotate From Normal", "Use face normal to rotate object, so that it points away from the surface");
1234 prop= RNA_def_property(srna, "form_factor", PROP_FLOAT, PROP_NONE);
1235 RNA_def_property_float_sdna(prop, NULL, "formfactor");
1236 RNA_def_property_range(prop, 0.0, 1.0);
1237 RNA_def_property_ui_text(prop, "Form Factor", "Form factor scales the inertia tensor");
1239 prop= RNA_def_property(srna, "anisotropic_friction", PROP_BOOLEAN, PROP_NONE);
1240 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ANISOTROPIC_FRICTION);
1241 RNA_def_property_ui_text(prop, "Anisotropic Friction", "Enable anisotropic friction");
1243 prop= RNA_def_property(srna, "friction_coefficients", PROP_FLOAT, PROP_NONE);
1244 RNA_def_property_float_sdna(prop, NULL, "anisotropicFriction");
1245 RNA_def_property_range(prop, 0.0, 1.0);
1246 RNA_def_property_ui_text(prop, "Friction Coefficients", "Relative friction coefficient in the in the X, Y and Z directions, when anisotropic friction is enabled");
1248 prop= RNA_def_property(srna, "use_collision_bounds", PROP_BOOLEAN, PROP_NONE);
1249 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_BOUNDS);
1250 RNA_def_property_ui_text(prop, "Use Collision Bounds", "Specify a collision bounds type other than the default");
1252 prop= RNA_def_property(srna, "collision_bounds", PROP_ENUM, PROP_NONE);
1253 RNA_def_property_enum_sdna(prop, NULL, "boundtype");
1254 RNA_def_property_enum_items(prop, collision_bounds_items);
1255 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_collision_bounds_itemf");
1256 RNA_def_property_ui_text(prop, "Collision Bounds", "Selects the collision type");
1257 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1259 prop= RNA_def_property(srna, "collision_compound", PROP_BOOLEAN, PROP_NONE);
1260 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_CHILD);
1261 RNA_def_property_ui_text(prop, "Collision Compound", "Add children to form a compound collision object");
1263 prop= RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH);
1264 RNA_def_property_float_sdna(prop, NULL, "margin");
1265 RNA_def_property_range(prop, 0.0, 1.0);
1266 RNA_def_property_ui_text(prop, "Collision Margin", "Extra margin around object for collision detection, small amount required for stability");
1268 prop= RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE);
1269 RNA_def_property_pointer_sdna(prop, NULL, "bsoft");
1270 RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for Bullet soft body simulation");
1272 prop= RNA_def_property(srna, "create_obstacle", PROP_BOOLEAN, PROP_NONE);
1273 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_HASOBSTACLE);
1274 RNA_def_property_ui_text(prop, "Create obstacle", "Create representation for obstacle simulation");
1276 prop= RNA_def_property(srna, "obstacle_radius", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH);
1277 RNA_def_property_float_sdna(prop, NULL, "obstacleRad");
1278 RNA_def_property_range(prop, 0.0, 1000.0);
1279 RNA_def_property_ui_text(prop, "Obstacle Radius", "Radius of object representation in obstacle simulation");
1283 prop= RNA_def_property(srna, "state", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1284 RNA_def_property_boolean_sdna(prop, NULL, "state", 1);
1285 RNA_def_property_array(prop, OB_MAX_STATES);
1286 RNA_def_property_ui_text(prop, "State", "State determining which controllers are displayed");
1287 RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_state_get", "rna_GameObjectSettings_state_set");
1289 prop= RNA_def_property(srna, "used_state", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1290 RNA_def_property_array(prop, OB_MAX_STATES);
1291 RNA_def_property_ui_text(prop, "Used State", "States which are being used by controllers");
1292 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1293 RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_used_state_get", NULL);
1295 prop= RNA_def_property(srna, "initial_state", PROP_BOOLEAN, PROP_NONE);
1296 RNA_def_property_boolean_sdna(prop, NULL, "init_state", 1);
1297 RNA_def_property_array(prop, OB_MAX_STATES);
1298 RNA_def_property_ui_text(prop, "Initial State", "Initial state when the game starts");
1300 prop= RNA_def_property(srna, "debug_state", PROP_BOOLEAN, PROP_NONE);
1301 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_DEBUGSTATE);
1302 RNA_def_property_ui_text(prop, "Debug State", "Print state debug info in the game engine");
1303 RNA_def_property_ui_icon(prop, ICON_INFO, 0);
1305 prop= RNA_def_property(srna, "all_states", PROP_BOOLEAN, PROP_NONE);
1306 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_ALLSTATE);
1307 RNA_def_property_ui_text(prop, "All", "Set all state bits");
1309 prop= RNA_def_property(srna, "show_state_panel", PROP_BOOLEAN, PROP_NONE);
1310 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSTATE);
1311 RNA_def_property_ui_text(prop, "States", "Show state panel");
1312 RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
1315 static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
1323 RNA_def_property_srna(cprop, "ObjectConstraints");
1324 srna= RNA_def_struct(brna, "ObjectConstraints", NULL);
1325 RNA_def_struct_sdna(srna, "Object");
1326 RNA_def_struct_ui_text(srna, "Object Constraints", "Collection of object constraints");
1329 /* Collection active property */
1330 prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1331 RNA_def_property_struct_type(prop, "Constraint");
1332 RNA_def_property_pointer_funcs(prop, "rna_Object_active_constraint_get", "rna_Object_active_constraint_set", NULL);
1333 RNA_def_property_flag(prop, PROP_EDITABLE);
1334 RNA_def_property_ui_text(prop, "Active Constraint", "Active Object constraint");
1337 /* Constraint collection */
1338 func= RNA_def_function(srna, "new", "rna_Object_constraint_new");
1339 RNA_def_function_ui_description(func, "Add a new constraint to this object");
1341 parm= RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint.");
1342 RNA_def_function_return(func, parm);
1344 parm= RNA_def_enum(func, "type", constraint_type_items, 1, "", "Constraint type to add.");
1345 RNA_def_property_flag(parm, PROP_REQUIRED);
1347 func= RNA_def_function(srna, "remove", "rna_Object_constraint_remove");
1348 RNA_def_function_ui_description(func, "Remove a constraint from this object.");
1350 parm= RNA_def_boolean(func, "success", 0, "Success", "Removed the constraint successfully.");
1351 RNA_def_function_return(func, parm);
1353 parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX);
1354 RNA_def_property_flag(parm, PROP_REQUIRED);
1357 /* armature.bones.* */
1358 static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
1365 RNA_def_property_srna(cprop, "ObjectModifiers");
1366 srna= RNA_def_struct(brna, "ObjectModifiers", NULL);
1367 RNA_def_struct_sdna(srna, "Object");
1368 RNA_def_struct_ui_text(srna, "Object Modifiers", "Collection of object modifiers");
1371 prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1372 RNA_def_property_struct_type(prop, "EditBone");
1373 RNA_def_property_pointer_sdna(prop, NULL, "act_edbone");
1374 RNA_def_property_flag(prop, PROP_EDITABLE);
1375 RNA_def_property_ui_text(prop, "Active EditBone", "Armatures active edit bone");
1376 //RNA_def_property_update(prop, 0, "rna_Armature_act_editbone_update");
1377 RNA_def_property_pointer_funcs(prop, NULL, "rna_Armature_act_edit_bone_set", NULL);
1380 // RNA_def_property_collection_active(prop, prop_act);
1384 func= RNA_def_function(srna, "new", "rna_Object_modifier_new");
1385 RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
1386 RNA_def_function_ui_description(func, "Add a new modifier.");
1387 parm= RNA_def_string(func, "name", "Name", 0, "", "New name for the bone.");
1388 RNA_def_property_flag(parm, PROP_REQUIRED);
1389 /* modifier to add */
1390 parm= RNA_def_enum(func, "type", modifier_type_items, 1, "", "Modifier type to add.");
1391 RNA_def_property_flag(parm, PROP_REQUIRED);
1393 parm= RNA_def_pointer(func, "modifier", "Modifier", "", "Newly created modifier.");
1394 RNA_def_function_return(func, parm);
1397 func= RNA_def_function(srna, "remove", "rna_Object_modifier_remove");
1398 RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
1399 RNA_def_function_ui_description(func, "Remove an existing modifier from the object.");
1400 /* target to remove*/
1401 parm= RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove.");
1402 RNA_def_property_flag(parm, PROP_REQUIRED);
1405 static void rna_def_object(BlenderRNA *brna)
1410 static EnumPropertyItem object_type_items[] = {
1411 {OB_EMPTY, "EMPTY", 0, "Empty", ""},
1412 {OB_MESH, "MESH", 0, "Mesh", ""},
1413 {OB_CURVE, "CURVE", 0, "Curve", ""},
1414 {OB_SURF, "SURFACE", 0, "Surface", ""},
1415 {OB_FONT, "TEXT", 0, "Text", ""},
1416 {OB_MBALL, "META", 0, "Meta", ""},
1417 {OB_LAMP, "LAMP", 0, "Lamp", ""},
1418 {OB_CAMERA, "CAMERA", 0, "Camera", ""},
1419 {OB_WAVE, "WAVE", 0, "Wave", ""},
1420 {OB_LATTICE, "LATTICE", 0, "Lattice", ""},
1421 {OB_ARMATURE, "ARMATURE", 0, "Armature", ""},
1422 {0, NULL, 0, NULL, NULL}};
1424 static EnumPropertyItem empty_drawtype_items[] = {
1425 {OB_ARROWS, "ARROWS", 0, "Arrows", ""},
1426 {OB_SINGLE_ARROW, "SINGLE_ARROW", 0, "Single Arrow", ""},
1427 {OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""},
1428 {OB_CIRCLE, "CIRCLE", 0, "Circle", ""},
1429 {OB_CUBE, "CUBE", 0, "Cube", ""},
1430 {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""},
1431 {OB_EMPTY_CONE, "CONE", 0, "Cone", ""},
1432 {0, NULL, 0, NULL, NULL}};
1434 static EnumPropertyItem track_items[] = {
1435 {OB_POSX, "POS_X", 0, "+X", ""},
1436 {OB_POSY, "POS_Y", 0, "+Y", ""},
1437 {OB_POSZ, "POS_Z", 0, "+Z", ""},
1438 {OB_NEGX, "NEG_X", 0, "-X", ""},
1439 {OB_NEGY, "NEG_Y", 0, "-Y", ""},
1440 {OB_NEGZ, "NEG_Z", 0, "-Z", ""},
1441 {0, NULL, 0, NULL, NULL}};
1443 static EnumPropertyItem up_items[] = {
1444 {OB_POSX, "X", 0, "X", ""},
1445 {OB_POSY, "Y", 0, "Y", ""},
1446 {OB_POSZ, "Z", 0, "Z", ""},
1447 {0, NULL, 0, NULL, NULL}};
1449 static EnumPropertyItem drawtype_items[] = {
1450 {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", ""},
1451 {OB_WIRE, "WIRE", 0, "Wire", ""},
1452 {OB_SOLID, "SOLID", 0, "Solid", ""},
1453 // disabled {OB_SHADED, "SHADED", 0, "Shaded", ""},
1454 {OB_TEXTURE, "TEXTURED", 0, "Textured", ""},
1455 {0, NULL, 0, NULL, NULL}};
1457 static EnumPropertyItem boundtype_items[] = {
1458 {OB_BOUND_BOX, "BOX", 0, "Box", ""},
1459 {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""},
1460 {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", ""},
1461 {OB_BOUND_CONE, "CONE", 0, "Cone", ""},
1462 {OB_BOUND_POLYH, "POLYHEDER", 0, "Polyheder", ""},
1463 {0, NULL, 0, NULL, NULL}};
1465 static EnumPropertyItem dupli_items[] = {
1466 {0, "NONE", 0, "None", ""},
1467 {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"},
1468 {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"},
1469 {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"},
1470 {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"},
1471 {0, NULL, 0, NULL, NULL}};
1473 // XXX: this RNA enum define is currently duplicated for objects, since there is some text here which is not applicable
1474 static EnumPropertyItem prop_rotmode_items[] = {
1475 {ROT_MODE_QUAT, "QUATERNION", 0, "Quaternion (WXYZ)", "No Gimbal Lock"},
1476 {ROT_MODE_XYZ, "XYZ", 0, "XYZ Euler", "XYZ Rotation Order. Prone to Gimbal Lock. (Default)"},
1477 {ROT_MODE_XZY, "XZY", 0, "XZY Euler", "XZY Rotation Order. Prone to Gimbal Lock"},
1478 {ROT_MODE_YXZ, "YXZ", 0, "YXZ Euler", "YXZ Rotation Order. Prone to Gimbal Lock"},
1479 {ROT_MODE_YZX, "YZX", 0, "YZX Euler", "YZX Rotation Order. Prone to Gimbal Lock"},
1480 {ROT_MODE_ZXY, "ZXY", 0, "ZXY Euler", "ZXY Rotation Order. Prone to Gimbal Lock"},
1481 {ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order. Prone to Gimbal Lock"},
1482 {ROT_MODE_AXISANGLE, "AXIS_ANGLE", 0, "Axis Angle", "Axis Angle (W+XYZ). Defines a rotation around some axis defined by 3D-Vector"},
1483 {0, NULL, 0, NULL, NULL}};
1485 static float default_quat[4] = {1,0,0,0}; /* default quaternion values */
1486 static float default_axisAngle[4] = {0,0,1,0}; /* default axis-angle rotation values */
1487 static float default_scale[3] = {1,1,1}; /* default scale values */
1488 int matrix_dimsize[]= {4, 4};
1489 int boundbox_dimsize[]= {8, 3};
1491 srna= RNA_def_struct(brna, "Object", "ID");
1492 RNA_def_struct_ui_text(srna, "Object", "Object datablock defining an object in a scene");
1493 RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
1494 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
1496 prop= RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
1497 RNA_def_property_struct_type(prop, "ID");
1498 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_set", "rna_Object_data_typef");
1499 RNA_def_property_editable_func(prop, "rna_Object_data_editable");
1500 RNA_def_property_flag(prop, PROP_EDITABLE);
1501 RNA_def_property_ui_text(prop, "Data", "Object data");
1502 RNA_def_property_update(prop, 0, "rna_Object_update_data");
1504 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1505 RNA_def_property_enum_sdna(prop, NULL, "type");
1506 RNA_def_property_enum_items(prop, object_type_items);
1507 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1508 RNA_def_property_ui_text(prop, "Type", "Type of Object");
1510 prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
1511 RNA_def_property_enum_sdna(prop, NULL, "mode");
1512 RNA_def_property_enum_items(prop, object_mode_items);
1513 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1514 RNA_def_property_ui_text(prop, "Mode", "Object interaction mode");
1516 prop= RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1517 RNA_def_property_boolean_sdna(prop, NULL, "lay", 1);
1518 RNA_def_property_array(prop, 20);
1519 RNA_def_property_ui_text(prop, "Layers", "Layers the object is on");
1520 RNA_def_property_boolean_funcs(prop, NULL, "rna_Object_layer_set");
1521 RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
1522 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_layer_update");
1524 prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
1525 RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
1526 RNA_def_property_ui_text(prop, "Selected", "Object selection state");
1527 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_select_update");
1529 /* for data access */
1530 prop= RNA_def_property(srna, "bound_box", PROP_FLOAT, PROP_NONE);
1531 RNA_def_property_multi_array(prop, 2, boundbox_dimsize);
1532 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1533 RNA_def_property_float_funcs(prop, "rna_Object_boundbox_get", NULL, NULL);
1534 RNA_def_property_ui_text(prop, "Bound Box", "Objects bound box in object-space coordinates");
1537 prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
1538 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_parent_set", NULL);
1539 RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
1540 RNA_def_property_ui_text(prop, "Parent", "Parent Object");
1541 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
1543 prop= RNA_def_property(srna, "parent_type", PROP_ENUM, PROP_NONE);
1544 RNA_def_property_enum_bitflag_sdna(prop, NULL, "partype");
1545 RNA_def_property_enum_items(prop, parent_type_items);
1546 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_parent_type_set", "rna_Object_parent_type_itemf");
1547 RNA_def_property_ui_text(prop, "Parent Type", "Type of parent relation");
1548 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
1550 prop= RNA_def_property(srna, "parent_vertices", PROP_INT, PROP_UNSIGNED);
1551 RNA_def_property_int_sdna(prop, NULL, "par1");
1552 RNA_def_property_array(prop, 3);
1553 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1554 RNA_def_property_ui_text(prop, "Parent Vertices", "Indices of vertices in cases of a vertex parenting relation");
1555 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update");
1557 prop= RNA_def_property(srna, "parent_bone", PROP_STRING, PROP_NONE);
1558 RNA_def_property_string_sdna(prop, NULL, "parsubstr");
1559 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Object_parent_bone_set");
1560 RNA_def_property_ui_text(prop, "Parent Bone", "Name of parent bone in case of a bone parenting relation");
1561 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
1563 /* Track and Up flags */
1564 // XXX: these have been saved here for a bit longer (after old track was removed), since some other tools still refer to this
1565 prop= RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
1566 RNA_def_property_enum_sdna(prop, NULL, "trackflag");
1567 RNA_def_property_enum_items(prop, track_items);
1568 RNA_def_property_ui_text(prop, "Track Axis", "Axis that points in 'forward' direction");
1569 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update");
1571 prop= RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE);
1572 RNA_def_property_enum_sdna(prop, NULL, "upflag");
1573 RNA_def_property_enum_items(prop, up_items);
1574 RNA_def_property_ui_text(prop, "Up Axis", "Axis that points in the upward direction");
1575 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update");
1578 prop= RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE);
1579 RNA_def_property_ui_text(prop, "Proxy", "Library object this proxy object controls");
1581 prop= RNA_def_property(srna, "proxy_group", PROP_POINTER, PROP_NONE);
1582 RNA_def_property_ui_text(prop, "Proxy Group", "Library group duplicator object this proxy object controls");
1585 prop= RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE);
1586 RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
1587 RNA_def_property_struct_type(prop, "MaterialSlot");
1588 RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", 0, 0, 0); /* don't dereference pointer! */
1589 RNA_def_property_ui_text(prop, "Material Slots", "Material slots in the object");
1591 prop= RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE);
1592 RNA_def_property_struct_type(prop, "Material");
1593 RNA_def_property_pointer_funcs(prop, "rna_Object_active_material_get", "rna_Object_active_material_set", NULL);
1594 RNA_def_property_flag(prop, PROP_EDITABLE);
1595 RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed");
1596 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update");
1598 prop= RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
1599 RNA_def_property_int_sdna(prop, NULL, "actcol");
1600 RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set", "rna_Object_active_material_index_range");
1601 RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot");
1602 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1605 prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
1606 RNA_def_property_float_sdna(prop, NULL, "loc");
1607 RNA_def_property_editable_array_func(prop, "rna_Object_location_editable");
1608 RNA_def_property_ui_text(prop, "Location", "Location of the object");
1609 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1611 prop= RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
1612 RNA_def_property_float_sdna(prop, NULL, "quat");
1613 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
1614 RNA_def_property_float_array_default(prop, default_quat);
1615 RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions");
1616 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1618 /* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but
1619 * having a single one is better for Keyframing and other property-management situations...
1621 prop= RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
1622 RNA_def_property_array(prop, 4);
1623 RNA_def_property_float_funcs(prop, "rna_Object_rotation_axis_angle_get", "rna_Object_rotation_axis_angle_set", NULL);
1624 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
1625 RNA_def_property_float_array_default(prop, default_axisAngle);
1626 RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
1627 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1629 prop= RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
1630 RNA_def_property_float_sdna(prop, NULL, "rot");
1631 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_euler_editable");
1632 RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers");
1633 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1635 prop= RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
1636 RNA_def_property_enum_sdna(prop, NULL, "rotmode");
1637 RNA_def_property_enum_items(prop, prop_rotmode_items); // XXX move to using a single define of this someday
1638 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_rotation_mode_set", NULL);
1639 RNA_def_property_ui_text(prop, "Rotation Mode", "");
1640 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1642 prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
1643 RNA_def_property_float_sdna(prop, NULL, "size");
1644 RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable");
1645 RNA_def_property_float_array_default(prop, default_scale);
1646 RNA_def_property_ui_text(prop, "Scale", "Scaling of the object");
1647 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1649 prop= RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ|PROP_UNIT_LENGTH);
1650 RNA_def_property_array(prop, 3);
1651 RNA_def_property_float_funcs(prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", NULL);
1652 RNA_def_property_ui_text(prop, "Dimensions", "Absolute bounding box dimensions of the object");
1653 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1656 /* delta transforms */
1657 prop= RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_TRANSLATION);
1658 RNA_def_property_float_sdna(prop, NULL, "dloc");
1659 RNA_def_property_ui_text(prop, "Delta Location", "Extra translation added to the location of the object");
1660 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1662 prop= RNA_def_property(srna, "delta_rotation_euler", PROP_FLOAT, PROP_EULER);
1663 RNA_def_property_float_sdna(prop, NULL, "drot");
1664 RNA_def_property_ui_text(prop, "Delta Rotation (Euler)", "Extra rotation added to the rotation of the object (when using Euler rotations)");
1665 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1667 prop= RNA_def_property(srna, "delta_rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
1668 RNA_def_property_float_sdna(prop, NULL, "dquat");
1669 RNA_def_property_float_array_default(prop, default_quat);
1670 RNA_def_property_ui_text(prop, "Delta Rotation (Quaternion)", "Extra rotation added to the rotation of the object (when using Quaternion rotations)");
1671 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1673 #if 0 // XXX not supported well yet...
1674 prop= RNA_def_property(srna, "delta_rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
1675 RNA_def_property_float_sdna(prop, NULL, "dquat"); // FIXME: this is not a single field any more! (drotAxis and drotAngle)
1676 RNA_def_property_float_array_default(prop, default_axisAngle);
1677 RNA_def_property_ui_text(prop, "Delta Rotation (Axis Angle)", "Extra rotation added to the rotation of the object (when using Axis-Angle rotations)");
1678 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1681 prop= RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_XYZ);
1682 RNA_def_property_float_sdna(prop, NULL, "dsize");
1683 RNA_def_property_ui_text(prop, "Delta Scale", "Extra scaling added to the scale of the object");
1684 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1686 /* transform locks */
1687 prop= RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_XYZ);
1688 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX);
1689 RNA_def_property_array(prop, 3);
1690 RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface");
1691 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
1692 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1694 prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_XYZ);
1695 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX);
1696 RNA_def_property_array(prop, 3);
1697 RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface");
1698 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
1699 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1701 // XXX this is sub-optimal - it really should be included above, but due to technical reasons we can't do this!
1702 prop= RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE);
1703 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTW);
1704 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
1705 RNA_def_property_ui_text(prop, "Lock Rotation (4D Angle)", "Lock editing of 'angle' component of four-component rotations in the interface");
1706 // XXX this needs a better name
1707 prop= RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE);
1708 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROT4D);
1709 RNA_def_property_ui_text(prop, "Lock Rotations (4D)", "Lock editing of four component rotations by components (instead of as Eulers)");
1711 prop= RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_XYZ);
1712 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX);
1713 RNA_def_property_array(prop, 3);
1714 RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface");
1715 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
1716 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1719 prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
1720 RNA_def_property_float_sdna(prop, NULL, "obmat");
1721 RNA_def_property_multi_array(prop, 2, matrix_dimsize);
1722 RNA_def_property_ui_text(prop, "Matrix", "Transformation matrix");
1723 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_matrix_update");
1726 prop= RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE);
1727 RNA_def_property_struct_type(prop, "Constraint");
1728 RNA_def_property_ui_text(prop, "Constraints", "Constraints affecting the transformation of the object");
1729 // RNA_def_property_collection_funcs(prop, 0, 0, 0, 0, 0, 0, 0, "constraints__add", "constraints__remove");
1730 rna_def_object_constraints(brna, prop);
1732 prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
1733 RNA_def_property_struct_type(prop, "Modifier");
1734 RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the geometric data of the object");
1735 rna_def_object_modifiers(brna, prop);
1738 prop= RNA_def_property(srna, "game", PROP_POINTER, PROP_NONE);
1739 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1740 RNA_def_property_struct_type(prop, "GameObjectSettings");
1741 RNA_def_property_pointer_funcs(prop, "rna_Object_game_settings_get", NULL, NULL);
1742 RNA_def_property_ui_text(prop, "Game Settings", "Game engine related settings for the object");
1745 prop= RNA_def_property(srna, "vertex_groups", PROP_COLLECTION, PROP_NONE);
1746 RNA_def_property_collection_sdna(prop, NULL, "defbase", NULL);
1747 RNA_def_property_struct_type(prop, "VertexGroup");
1748 RNA_def_property_ui_text(prop, "Vertex Groups", "Vertex groups of the object");
1750 prop= RNA_def_property(srna, "active_vertex_group", PROP_POINTER, PROP_NONE);
1751 RNA_def_property_struct_type(prop, "VertexGroup");
1752 RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get", "rna_Object_active_vertex_group_set", NULL);
1753 RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object");
1754 RNA_def_property_update(prop, NC_GEOM|ND_DATA, "rna_Object_update_data");
1756 prop= RNA_def_property(srna, "active_vertex_group_index", PROP_INT, PROP_NONE);
1757 RNA_def_property_int_sdna(prop, NULL, "actdef");
1758 RNA_def_property_int_funcs(prop, "rna_Object_active_vertex_group_index_get", "rna_Object_active_vertex_group_index_set", "rna_Object_active_vertex_group_index_range");
1759 RNA_def_property_ui_text(prop, "Active Vertex Group Index", "Active index in vertex group array");
1760 RNA_def_property_update(prop, NC_GEOM|ND_DATA, "rna_Object_update_data");
1763 prop= RNA_def_property(srna, "empty_draw_type", PROP_ENUM, PROP_NONE);
1764 RNA_def_property_enum_sdna(prop, NULL, "empty_drawtype");
1765 RNA_def_property_enum_items(prop, empty_drawtype_items);
1766 RNA_def_property_ui_text(prop, "Empty Display Type", "Viewport display style for empties");
1767 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1769 prop= RNA_def_property(srna, "empty_draw_size", PROP_FLOAT, PROP_DISTANCE);
1770 RNA_def_property_float_sdna(prop, NULL, "empty_drawsize");
1771 RNA_def_property_range(prop, 0.0001f, 1000.0f);
1772 RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);
1773 RNA_def_property_ui_text(prop, "Empty Display Size", "Size of display for empties in the viewport");
1774 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1777 prop= RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
1778 RNA_def_property_int_sdna(prop, NULL, "index");
1779 RNA_def_property_ui_text(prop, "Pass Index", "Index # for the IndexOB render pass");
1780 RNA_def_property_update(prop, NC_OBJECT, NULL);
1782 prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1783 RNA_def_property_float_sdna(prop, NULL, "col");
1784 RNA_def_property_ui_text(prop, "Color", "Object color and alpha, used when faces have the ObColor mode enabled");
1785 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1788 prop= RNA_def_property(srna, "field", PROP_POINTER, PROP_NONE);
1789 RNA_def_property_pointer_sdna(prop, NULL, "pd");
1790 RNA_def_property_struct_type(prop, "FieldSettings");
1791 RNA_def_property_pointer_funcs(prop, "rna_Object_field_get", NULL, NULL);
1792 RNA_def_property_ui_text(prop, "Field Settings", "Settings for using the objects as a field in physics simulation");
1794 prop= RNA_def_property(srna, "collision", PROP_POINTER, PROP_NONE);
1795 RNA_def_property_pointer_sdna(prop, NULL, "pd");
1796 RNA_def_property_struct_type(prop, "CollisionSettings");
1797 RNA_def_property_pointer_funcs(prop, "rna_Object_collision_get", NULL, NULL);
1798 RNA_def_property_ui_text(prop, "Collision Settings", "Settings for using the objects as a collider in physics simulation");
1800 prop= RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE);
1801 RNA_def_property_pointer_sdna(prop, NULL, "soft");
1802 RNA_def_property_struct_type(prop, "SoftBodySettings");
1803 RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for soft body simulation");
1805 prop= RNA_def_property(srna, "particle_systems", PROP_COLLECTION, PROP_NONE);
1806 RNA_def_property_collection_sdna(prop, NULL, "particlesystem", NULL);
1807 RNA_def_property_struct_type(prop, "ParticleSystem");
1808 RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object");
1810 prop= RNA_def_property(srna, "active_particle_system", PROP_POINTER, PROP_NONE);
1811 RNA_def_property_struct_type(prop, "ParticleSystem");
1812 RNA_def_property_pointer_funcs(prop, "rna_Object_active_particle_system_get", NULL, NULL);
1813 RNA_def_property_ui_text(prop, "Active Particle System", "Active particle system being displayed");
1814 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1816 prop= RNA_def_property(srna, "active_particle_system_index", PROP_INT, PROP_UNSIGNED);
1817 RNA_def_property_int_funcs(prop, "rna_Object_active_particle_system_index_get", "rna_Object_active_particle_system_index_set", "rna_Object_active_particle_system_index_range");
1818 RNA_def_property_ui_text(prop, "Active Particle System Index", "Index of active particle system slot");
1819 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_particle_update");
1822 prop= RNA_def_property(srna, "restrict_view", PROP_BOOLEAN, PROP_NONE);
1823 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW);
1824 RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport");
1825 RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1);
1826 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1828 prop= RNA_def_property(srna, "restrict_select", PROP_BOOLEAN, PROP_NONE);
1829 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT);
1830 RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection in the viewport");
1831 RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1);
1832 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1834 prop= RNA_def_property(srna, "restrict_render", PROP_BOOLEAN, PROP_NONE);
1835 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER);
1836 RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability");
1837 RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
1838 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1841 rna_def_animdata_common(srna);
1843 rna_def_animviz_common(srna);
1844 rna_def_motionpath_common(srna);
1847 // XXX: evil old crap
1848 prop= RNA_def_property(srna, "slow_parent", PROP_BOOLEAN, PROP_NONE);
1849 RNA_def_property_boolean_sdna(prop, NULL, "partype", PARSLOW);
1850 RNA_def_property_ui_text(prop, "Slow Parent", "Create a delay in the parent relationship");
1851 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update");
1853 prop= RNA_def_property(srna, "dupli_type", PROP_ENUM, PROP_NONE);
1854 RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag");
1855 RNA_def_property_enum_items(prop, dupli_items);
1856 RNA_def_property_ui_text(prop, "Dupli Type", "If not None, object duplication method to use");
1857 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
1859 prop= RNA_def_property(srna, "use_dupli_frames_speed", PROP_BOOLEAN, PROP_NONE);
1860 RNA_def_property_boolean_negative_sdna(prop, NULL, "transflag", OB_DUPLINOSPEED);
1861 RNA_def_property_ui_text(prop, "Dupli Frames Speed", "Set dupliframes to use the frame"); // TODO, better descriptio!
1862 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update");
1864 prop= RNA_def_property(srna, "use_dupli_verts_rotation", PROP_BOOLEAN, PROP_NONE);
1865 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIROT);
1866 RNA_def_property_ui_text(prop, "Dupli Verts Rotation", "Rotate dupli according to vertex normal");
1867 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1869 prop= RNA_def_property(srna, "use_dupli_faces_scale", PROP_BOOLEAN, PROP_NONE);
1870 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIFACES_SCALE);
1871 RNA_def_property_ui_text(prop, "Dupli Faces Inherit Scale", "Scale dupli based on face size");
1872 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update");
1874 prop= RNA_def_property(srna, "dupli_faces_scale", PROP_FLOAT, PROP_NONE);
1875 RNA_def_property_float_sdna(prop, NULL, "dupfacesca");
1876 RNA_def_property_range(prop, 0.001f, 10000.0f);
1877 RNA_def_property_ui_text(prop, "Dupli Faces Scale", "Scale the DupliFace objects");
1878 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1880 prop= RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE);
1881 RNA_def_property_pointer_sdna(prop, NULL, "dup_group");
1882 RNA_def_property_flag(prop, PROP_EDITABLE);
1883 RNA_def_property_ui_text(prop, "Dupli Group", "Instance an existing group");
1884 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
1886 prop= RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE|PROP_UNIT_TIME);
1887 RNA_def_property_int_sdna(prop, NULL, "dupsta");
1888 RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
1889 RNA_def_property_ui_text(prop, "Dupli Frames Start", "Start frame for DupliFrames");
1890 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update");
1892 prop= RNA_def_property(srna, "dupli_frames_end", PROP_INT, PROP_NONE|PROP_UNIT_TIME);
1893 RNA_def_property_int_sdna(prop, NULL, "dupend");
1894 RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
1895 RNA_def_property_ui_text(prop, "Dupli Frames End", "End frame for DupliFrames");
1896 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update");
1898 prop= RNA_def_property(srna, "dupli_frames_on", PROP_INT, PROP_NONE|PROP_UNIT_TIME);
1899 RNA_def_property_int_sdna(prop, NULL, "dupon");
1900 RNA_def_property_range(prop, MINFRAME, MAXFRAME);
1901 RNA_def_property_ui_range(prop, 1, 1500, 1, 0);
1902 RNA_def_property_ui_text(prop, "Dupli Frames On", "Number of frames to use between DupOff frames");
1903 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update");
1905 prop= RNA_def_property(srna, "dupli_frames_off", PROP_INT, PROP_NONE|PROP_UNIT_TIME);
1906 RNA_def_property_int_sdna(prop, NULL, "dupoff");
1907 RNA_def_property_range(prop, 0, MAXFRAME);
1908 RNA_def_property_ui_range(prop, 0, 1500, 1, 0);
1909 RNA_def_property_ui_text(prop, "Dupli Frames Off", "Recurring frames to exclude from the Dupliframes");
1910 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update");
1912 prop= RNA_def_property(srna, "dupli_list", PROP_COLLECTION, PROP_NONE);
1913 RNA_def_property_collection_sdna(prop, NULL, "duplilist", NULL);
1914 RNA_def_property_struct_type(prop, "DupliObject");
1915 RNA_def_property_ui_text(prop, "Dupli list", "Object duplis");
1917 prop= RNA_def_property(srna, "duplis_used", PROP_BOOLEAN, PROP_NONE);
1918 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLI);
1919 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1922 prop= RNA_def_property(srna, "time_offset", PROP_FLOAT, PROP_NONE|PROP_UNIT_TIME);
1923 RNA_def_property_float_sdna(prop, NULL, "sf");
1924 RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
1925 RNA_def_property_ui_text(prop, "Time Offset", "Animation offset in frames for F-Curve and dupligroup instances");
1926 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1928 prop= RNA_def_property(srna, "time_offset_edit", PROP_BOOLEAN, PROP_NONE);
1929 RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_OB);
1930 RNA_def_property_ui_text(prop, "Time Offset Edit", "Use time offset when inserting keys and display time offset for F-Curve and action views");
1932 prop= RNA_def_property(srna, "time_offset_parent", PROP_BOOLEAN, PROP_NONE);
1933 RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_PARENT);
1934 RNA_def_property_ui_text(prop, "Time Offset Parent", "Apply the time offset to this objects parent relationship");
1935 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1937 prop= RNA_def_property(srna, "time_offset_particle", PROP_BOOLEAN, PROP_NONE);
1938 RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_PARTICLE);
1939 RNA_def_property_ui_text(prop, "Time Offset Particle", "Let the time offset work on the particle effect");
1940 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1942 prop= RNA_def_property(srna, "time_offset_add_parent", PROP_BOOLEAN, PROP_NONE);
1943 RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_PARENTADD);
1944 RNA_def_property_ui_text(prop, "Time Offset Add Parent", "Add the parents time offset value");
1945 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
1948 prop= RNA_def_property(srna, "max_draw_type", PROP_ENUM, PROP_NONE);
1949 RNA_def_property_enum_sdna(prop, NULL, "dt");
1950 RNA_def_property_enum_items(prop, drawtype_items);
1951 RNA_def_property_ui_text(prop, "Maximum Draw Type", "Maximum draw type to display object with in viewport");
1952 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1954 prop= RNA_def_property(srna, "draw_bounds", PROP_BOOLEAN, PROP_NONE);
1955 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_BOUNDBOX);
1956 RNA_def_property_ui_text(prop, "Draw Bounds", "Displays the object's bounds");
1957 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1959 prop= RNA_def_property(srna, "draw_bounds_type", PROP_ENUM, PROP_NONE);
1960 RNA_def_property_enum_sdna(prop, NULL, "boundtype");
1961 RNA_def_property_enum_items(prop, boundtype_items);
1962 RNA_def_property_ui_text(prop, "Draw Bounds Type", "Object boundary display type");
1963 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1965 prop= RNA_def_property(srna, "draw_name", PROP_BOOLEAN, PROP_NONE);
1966 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWNAME);
1967 RNA_def_property_ui_text(prop, "Draw Name", "Displays the object's name");
1968 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1970 prop= RNA_def_property(srna, "draw_axis", PROP_BOOLEAN, PROP_NONE);
1971 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_AXIS);
1972 RNA_def_property_ui_text(prop, "Draw Axis", "Displays the object's origin and axis");
1973 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1975 prop= RNA_def_property(srna, "draw_texture_space", PROP_BOOLEAN, PROP_NONE);
1976 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_TEXSPACE);
1977 RNA_def_property_ui_text(prop, "Draw Texture Space", "Displays the object's texture space");
1978 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1980 prop= RNA_def_property(srna, "draw_wire", PROP_BOOLEAN, PROP_NONE);
1981 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWWIRE);
1982 RNA_def_property_ui_text(prop, "Draw Wire", "Adds the object's wireframe over solid drawing");
1983 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1985 prop= RNA_def_property(srna, "draw_transparent", PROP_BOOLEAN, PROP_NONE);
1986 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWTRANSP);
1987 RNA_def_property_ui_text(prop, "Draw Transparent", "Enables transparent materials for the object (Mesh only)");
1988 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1990 prop= RNA_def_property(srna, "x_ray", PROP_BOOLEAN, PROP_NONE);
1991 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWXRAY);
1992 RNA_def_property_ui_text(prop, "X-Ray", "Makes the object draw in front of others");
1993 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1996 prop= RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
1997 RNA_def_property_pointer_sdna(prop, NULL, "gpd");
1998 RNA_def_property_flag(prop, PROP_EDITABLE);
1999 RNA_def_property_struct_type(prop, "GreasePencil");
2000 RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock");
2003 prop= RNA_def_property(srna, "pose_library", PROP_POINTER, PROP_NONE);
2004 RNA_def_property_pointer_sdna(prop, NULL, "poselib");
2005 RNA_def_property_struct_type(prop, "Action");
2006 RNA_def_property_ui_text(prop, "Pose Library", "Action used as a pose library for armatures");
2008 prop= RNA_def_property(srna, "pose", PROP_POINTER, PROP_NONE);
2009 RNA_def_property_pointer_sdna(prop, NULL, "pose");
2010 RNA_def_property_struct_type(prop, "Pose");
2011 RNA_def_property_ui_text(prop, "Pose", "Current pose for armatures");
2014 prop= RNA_def_property(srna, "shape_key_lock", PROP_BOOLEAN, PROP_NONE);
2015 RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_LOCK);
2016 RNA_def_property_ui_text(prop, "Shape Key Lock", "Always show the current Shape for this Object");
2017 RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
2018 RNA_def_property_update(prop, 0, "rna_Object_update_data");
2020 prop= RNA_def_property(srna, "shape_key_edit_mode", PROP_BOOLEAN, PROP_NONE);
2021 RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_EDIT_MODE);
2022 RNA_def_property_ui_text(prop, "Shape Key Edit Mode", "Apply shape keys in edit mode (for Meshes only)");
2023 RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0);
2024 RNA_def_property_update(prop, 0, "rna_Object_update_data");
2026 prop= RNA_def_property(srna, "active_shape_key", PROP_POINTER, PROP_NONE);
2027 RNA_def_property_struct_type(prop, "ShapeKey");
2028 RNA_def_property_pointer_funcs(prop, "rna_Object_active_shape_key_get", NULL, NULL);
2029 RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key");
2031 prop= RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE);
2032 RNA_def_property_int_sdna(prop, NULL, "shapenr");
2033 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); // XXX this is really unpredictable...
2034 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");
2035 RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index");
2036 RNA_def_property_update(prop, 0, "rna_Object_active_shape_update");
2038 RNA_api_object(srna);
2041 static void rna_def_dupli_object(BlenderRNA *brna)
2046 srna= RNA_def_struct(brna, "DupliObject", NULL);
2047 RNA_def_struct_sdna(srna, "DupliObject");
2048 RNA_def_struct_ui_text(srna, "Object Duplicate", "An object duplicate");
2049 /* RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); */
2051 prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2052 RNA_def_property_pointer_sdna(prop, NULL, "ob");
2053 /* RNA_def_property_pointer_funcs(prop, "rna_DupliObject_object_get", NULL, NULL); */
2054 RNA_def_property_ui_text(prop, "Object", "Object being duplicated");
2056 prop= RNA_def_property(srna, "object_matrix", PROP_FLOAT, PROP_MATRIX);
2057 RNA_def_property_float_sdna(prop, NULL, "omat");
2058 RNA_def_property_array(prop, 16);
2059 RNA_def_property_ui_text(prop, "Object Matrix", "Duplicated object transformation matrix");
2061 prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
2062 RNA_def_property_float_sdna(prop, NULL, "mat");
2063 RNA_def_property_array(prop, 16);
2064 RNA_def_property_ui_text(prop, "Object Duplicate Matrix", "Object duplicate transformation matrix");
2066 /* TODO: DupliObject has more properties that can be wrapped */
2069 static void rna_def_object_base(BlenderRNA *brna)
2074 srna= RNA_def_struct(brna, "ObjectBase", NULL);
2075 RNA_def_struct_sdna(srna, "Base");
2076 RNA_def_struct_ui_text(srna, "Object Base", "An object instance in a scene");
2077 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
2079 prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2080 RNA_def_property_pointer_sdna(prop, NULL, "object");
2081 RNA_def_property_ui_text(prop, "Object", "Object this base links to");
2083 /* same as object layer */
2084 prop= RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER);
2085 RNA_def_property_boolean_sdna(prop, NULL, "lay", 1);
2086 RNA_def_property_array(prop, 20);
2087 RNA_def_property_ui_text(prop, "Layers", "Layers the object base is on");
2088 RNA_def_property_boolean_funcs(prop, NULL, "rna_Base_layer_set");
2089 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Base_layer_update");
2091 prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
2092 RNA_def_property_boolean_sdna(prop, NULL, "flag", BA_SELECT);
2093 RNA_def_property_ui_text(prop, "Selected", "Object base selection state");
2094 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Base_select_update");
2096 prop= RNA_def_property(srna, "selected_user", PROP_BOOLEAN, PROP_NONE);
2097 RNA_def_property_boolean_sdna(prop, NULL, "flag", BA_WAS_SEL);
2098 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2099 RNA_def_property_ui_text(prop, "User Selected", "Object base user selection state, used to restore user selection after transformations");
2101 RNA_api_object_base(srna);
2104 void RNA_def_object(BlenderRNA *brna)
2106 rna_def_object(brna);
2107 rna_def_object_game_settings(brna);
2108 rna_def_object_base(brna);
2109 rna_def_vertex_group(brna);
2110 rna_def_material_slot(brna);
2111 rna_def_dupli_object(brna);