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_internal_update(Main *bmain, Scene *scene, PointerRNA *ptr)
134 DAG_id_flush_update(ptr->id.data, OB_RECALC_OB);
137 void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr)
139 object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat);
140 rna_Object_internal_update(bmain, scene, ptr);
143 void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
145 Object *ob= ptr->id.data;
148 float invmat[4][4]; /* for inverse of parent's matrix */
149 invert_m4_m4(invmat, ob->parent->obmat);
150 mul_m4_m4m4((float(*)[4])values, ob->obmat, invmat);
153 copy_m4_m4((float(*)[4])values, ob->obmat);
157 void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])
159 Object *ob= ptr->id.data;
161 /* localspace matrix is truly relative to the parent, but parameters
162 * stored in object are relative to parentinv matrix. Undo the parent
163 * inverse part before updating obmat and calling apply_obmat() */
166 invert_m4_m4(invmat, ob->parentinv);
167 mul_m4_m4m4(ob->obmat, (float(*)[4])values, invmat);
170 copy_m4_m4(ob->obmat, (float(*)[4])values);
173 object_apply_mat4(ob, ob->obmat);
176 void rna_Object_internal_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
178 DAG_id_flush_update(ptr->id.data, OB_RECALC_DATA);
179 WM_main_add_notifier(NC_OBJECT|ND_DRAW, ptr->id.data);
182 void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
184 Object *ob= ptr->id.data;
185 int editmode= (scene->obedit == ob && ob->type == OB_MESH);
188 /* exit/enter editmode to get new shape */
189 load_editMesh(scene, ob);
190 make_editMesh(scene, ob);
193 rna_Object_internal_update_data(bmain, scene, ptr);
196 static void rna_Object_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
198 DAG_id_flush_update(ptr->id.data, OB_RECALC_OB);
199 DAG_scene_sort(scene);
202 /* when changing the selection flag the scene needs updating */
203 static void rna_Object_select_update(Main *bmain, Scene *scene, PointerRNA *ptr)
205 Object *ob= (Object*)ptr->id.data;
206 short mode = ob->flag & SELECT ? BA_SELECT : BA_DESELECT;
207 ED_base_object_select(object_in_scene(ob, scene), mode);
210 static void rna_Base_select_update(Main *bmain, Scene *scene, PointerRNA *ptr)
212 Base *base= (Base*)ptr->data;
213 short mode = base->flag & BA_SELECT ? BA_SELECT : BA_DESELECT;
214 ED_base_object_select(base, mode);
217 static void rna_Object_layer_update__internal(Scene *scene, Base *base, Object *ob)
219 /* try to avoid scene sort */
220 if((ob->lay & scene->lay) && (base->lay & scene->lay)) {
222 } else if((ob->lay & scene->lay)==0 && (base->lay & scene->lay)==0) {
225 DAG_scene_sort(scene);
229 static void rna_Object_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
231 Object *ob= (Object*)ptr->id.data;
234 base= object_in_scene(ob, scene);
238 SWAP(int, base->lay, ob->lay);
240 rna_Object_layer_update__internal(scene, base, ob);
244 static void rna_Base_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
246 Base *base= (Base*)ptr->data;
247 Object *ob= (Object*)base->object;
249 rna_Object_layer_update__internal(scene, base, ob);
253 static int rna_Object_data_editable(PointerRNA *ptr)
255 Object *ob= (Object*)ptr->data;
257 return (ob->type == OB_EMPTY)? 0: PROP_EDITABLE;
260 static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
262 Object *ob= (Object*)ptr->data;
265 if(ob->type == OB_EMPTY || id == NULL || ob->mode & OB_MODE_EDIT)
268 if(ob->type == OB_MESH) {
269 set_mesh(ob, (Mesh*)id);
273 id_us_min((ID*)ob->data);
278 test_object_materials(id);
280 if(GS(id->name)==ID_CU)
282 else if(ob->type==OB_ARMATURE)
283 armature_rebuild_pose(ob, ob->data);
287 static StructRNA *rna_Object_data_typef(PointerRNA *ptr)
289 Object *ob= (Object*)ptr->data;
292 case OB_MESH: return &RNA_Mesh;
293 case OB_CURVE: return &RNA_Curve;
294 case OB_SURF: return &RNA_Curve;
295 case OB_FONT: return &RNA_Curve;
296 case OB_MBALL: return &RNA_MetaBall;
297 case OB_LAMP: return &RNA_Lamp;
298 case OB_CAMERA: return &RNA_Camera;
299 case OB_LATTICE: return &RNA_Lattice;
300 case OB_ARMATURE: return &RNA_Armature;
301 default: return &RNA_ID;
305 static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value)
307 Object *ob= (Object*)ptr->data;
308 Object *par= (Object*)value.data;
310 ED_object_parent(ob, par, ob->partype, ob->parsubstr);
313 static void rna_Object_parent_type_set(PointerRNA *ptr, int value)
315 Object *ob= (Object*)ptr->data;
317 ED_object_parent(ob, ob->parent, value, ob->parsubstr);
320 static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *C, PointerRNA *ptr, int *free)
322 Object *ob= (Object*)ptr->data;
323 EnumPropertyItem *item= NULL;
326 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PAROBJECT);
329 Object *par= ob->parent;
331 if(par->type == OB_CURVE)
332 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARCURVE);
333 else if(par->type == OB_LATTICE)
334 RNA_enum_items_add_value(&item, &totitem, &parent_type_items[4], PARSKEL); // special hack: prevents this overriding others
335 else if(par->type == OB_ARMATURE) {
336 RNA_enum_items_add_value(&item, &totitem, &parent_type_items[3], PARSKEL); // special hack: prevents this being overrided
337 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARBONE);
339 else if(par->type == OB_MESH) {
340 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT1);
341 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT3);
345 RNA_enum_item_end(&item, &totitem);
351 static EnumPropertyItem *rna_Object_collision_bounds_itemf(bContext *C, PointerRNA *ptr, int *free)
353 Object *ob= (Object*)ptr->data;
354 EnumPropertyItem *item= NULL;
357 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_POLYH);
358 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_POLYT);
360 if(ob->body_type!=OB_BODY_TYPE_SOFT) {
361 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CONE);
362 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CYLINDER);
363 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_SPHERE);
364 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_BOX);
367 RNA_enum_item_end(&item, &totitem);
373 static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value)
375 Object *ob= (Object*)ptr->data;
377 ED_object_parent(ob, ob->parent, ob->partype, value);
380 static int rna_VertexGroup_index_get(PointerRNA *ptr)
382 Object *ob= (Object*)ptr->id.data;
384 return BLI_findindex(&ob->defbase, ptr->data);
387 static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr)
389 Object *ob= (Object*)ptr->id.data;
390 return rna_pointer_inherit_refine(ptr, &RNA_VertexGroup, BLI_findlink(&ob->defbase, ob->actdef-1));
393 static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr)
395 Object *ob= (Object*)ptr->id.data;
396 return MAX2(ob->actdef-1, 0);
399 static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value)
401 Object *ob= (Object*)ptr->id.data;
405 static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min, int *max)
407 Object *ob= (Object*)ptr->id.data;
410 *max= BLI_countlist(&ob->defbase)-1;
414 void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
416 Object *ob= (Object*)ptr->id.data;
419 dg= BLI_findlink(&ob->defbase, index-1);
421 if(dg) BLI_strncpy(value, dg->name, sizeof(dg->name));
422 else BLI_strncpy(value, "", sizeof(dg->name));
425 int rna_object_vgroup_name_index_length(PointerRNA *ptr, int index)
427 Object *ob= (Object*)ptr->id.data;
430 dg= BLI_findlink(&ob->defbase, index-1);
431 return (dg)? strlen(dg->name): 0;
434 void rna_object_vgroup_name_index_set(PointerRNA *ptr, const char *value, short *index)
436 Object *ob= (Object*)ptr->id.data;
440 for(a=1, dg=ob->defbase.first; dg; dg=dg->next, a++) {
441 if(strcmp(dg->name, value) == 0) {
450 void rna_object_vgroup_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
452 Object *ob= (Object*)ptr->id.data;
455 for(dg=ob->defbase.first; dg; dg=dg->next) {
456 if(strcmp(dg->name, value) == 0) {
457 BLI_strncpy(result, value, maxlen);
462 BLI_strncpy(result, "", maxlen);
465 void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
467 Object *ob= (Object*)ptr->id.data;
469 CustomDataLayer *layer;
472 if(ob->type == OB_MESH && ob->data) {
475 for(a=0; a<me->fdata.totlayer; a++) {
476 layer= &me->fdata.layers[a];
478 if(layer->type == CD_MTFACE && strcmp(layer->name, value) == 0) {
479 BLI_strncpy(result, value, maxlen);
485 BLI_strncpy(result, "", maxlen);
488 void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
490 Object *ob= (Object*)ptr->id.data;
492 CustomDataLayer *layer;
495 if(ob->type == OB_MESH && ob->data) {
498 for(a=0; a<me->fdata.totlayer; a++) {
499 layer= &me->fdata.layers[a];
501 if(layer->type == CD_MCOL && strcmp(layer->name, value) == 0) {
502 BLI_strncpy(result, value, maxlen);
508 BLI_strncpy(result, "", maxlen);
511 static int rna_Object_active_material_index_get(PointerRNA *ptr)
513 Object *ob= (Object*)ptr->id.data;
514 return MAX2(ob->actcol-1, 0);
517 static void rna_Object_active_material_index_set(PointerRNA *ptr, int value)
519 Object *ob= (Object*)ptr->id.data;
522 if(ob->type==OB_MESH) {
526 me->edit_mesh->mat_nr= value;
530 static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, int *max)
532 Object *ob= (Object*)ptr->id.data;
534 *max= MAX2(ob->totcol-1, 0);
537 static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
539 Object *ob= (Object*)ptr->id.data;
542 ma= (ob->totcol)? give_current_material(ob, ob->actcol): NULL;
543 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
546 static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value)
548 Object *ob= (Object*)ptr->id.data;
550 assign_material(ob, value.data, ob->actcol);
553 static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int *min, int *max)
555 Object *ob= (Object*)ptr->id.data;
557 *max= BLI_countlist(&ob->particlesystem)-1;
561 static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
563 Object *ob= (Object*)ptr->id.data;
564 return psys_get_current_num(ob);
567 static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int value)
569 Object *ob= (Object*)ptr->id.data;
570 psys_set_current_num(ob, value);
573 static void rna_Object_particle_update(Main *bmain, Scene *scene, PointerRNA *ptr)
575 Object *ob= (Object*)ptr->id.data;
577 PE_current_changed(scene, ob);
580 /* rotation - axis-angle */
581 static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value)
583 Object *ob= ptr->data;
585 /* for now, assume that rotation mode is axis-angle */
586 value[0]= ob->rotAngle;
587 copy_v3_v3(&value[1], ob->rotAxis);
590 /* rotation - axis-angle */
591 static void rna_Object_rotation_axis_angle_set(PointerRNA *ptr, const float *value)
593 Object *ob= ptr->data;
595 /* for now, assume that rotation mode is axis-angle */
596 ob->rotAngle= value[0];
597 copy_v3_v3(ob->rotAxis, (float *)&value[1]);
599 // TODO: validate axis?
602 static void rna_Object_rotation_mode_set(PointerRNA *ptr, int value)
604 Object *ob= ptr->data;
606 /* use API Method for conversions... */
607 BKE_rotMode_change_values(ob->quat, ob->rot, ob->rotAxis, &ob->rotAngle, ob->rotmode, (short)value);
609 /* finally, set the new rotation type */
613 static void rna_Object_dimensions_get(PointerRNA *ptr, float *value)
615 Object *ob= ptr->data;
616 object_get_dimensions(ob, value);
619 static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value)
621 Object *ob= ptr->data;
622 object_set_dimensions(ob, value);
625 static int rna_Object_location_editable(PointerRNA *ptr, int index)
627 Object *ob= (Object *)ptr->data;
629 /* only if the axis in question is locked, not editable... */
630 if ((index == 0) && (ob->protectflag & OB_LOCK_LOCX))
632 else if ((index == 1) && (ob->protectflag & OB_LOCK_LOCY))
634 else if ((index == 2) && (ob->protectflag & OB_LOCK_LOCZ))
637 return PROP_EDITABLE;
640 static int rna_Object_scale_editable(PointerRNA *ptr, int index)
642 Object *ob= (Object *)ptr->data;
644 /* only if the axis in question is locked, not editable... */
645 if ((index == 0) && (ob->protectflag & OB_LOCK_SCALEX))
647 else if ((index == 1) && (ob->protectflag & OB_LOCK_SCALEY))
649 else if ((index == 2) && (ob->protectflag & OB_LOCK_SCALEZ))
652 return PROP_EDITABLE;
655 static int rna_Object_rotation_euler_editable(PointerRNA *ptr, int index)
657 Object *ob= (Object *)ptr->data;
659 /* only if the axis in question is locked, not editable... */
660 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTX))
662 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTY))
664 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTZ))
667 return PROP_EDITABLE;
670 static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index)
672 Object *ob= (Object *)ptr->data;
674 /* only consider locks if locking components individually... */
675 if (ob->protectflag & OB_LOCK_ROT4D) {
676 /* only if the axis in question is locked, not editable... */
677 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTW))
679 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTX))
681 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTY))
683 else if ((index == 3) && (ob->protectflag & OB_LOCK_ROTZ))
687 return PROP_EDITABLE;
691 static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr)
693 Object *ob= (Object*)ptr->id.data;
695 int index= (Material**)ptr->data - ob->mat;
697 ma= give_current_material(ob, index+1);
698 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
701 static void rna_MaterialSlot_material_set(PointerRNA *ptr, PointerRNA value)
703 Object *ob= (Object*)ptr->id.data;
704 int index= (Material**)ptr->data - ob->mat;
706 assign_material(ob, value.data, index+1);
709 static int rna_MaterialSlot_link_get(PointerRNA *ptr)
711 Object *ob= (Object*)ptr->id.data;
712 int index= (Material**)ptr->data - ob->mat;
714 return ob->matbits[index] != 0;
717 static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value)
719 Object *ob= (Object*)ptr->id.data;
720 int index= (Material**)ptr->data - ob->mat;
723 ob->matbits[index]= 1;
724 ob->colbits |= (1<<index);
727 ob->matbits[index]= 0;
728 ob->colbits &= ~(1<<index);
732 static int rna_MaterialSlot_name_length(PointerRNA *ptr)
734 Object *ob= (Object*)ptr->id.data;
736 int index= (Material**)ptr->data - ob->mat;
738 ma= give_current_material(ob, index+1);
741 return strlen(ma->id.name+2);
746 static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str)
748 Object *ob= (Object*)ptr->id.data;
750 int index= (Material**)ptr->data - ob->mat;
752 ma= give_current_material(ob, index+1);
755 strcpy(str, ma->id.name+2);
760 /* why does this have to be so complicated?, can't all this crap be
761 * moved to in BGE conversion function? - Campbell *
763 * logic from check_body_type()
765 static int rna_GameObjectSettings_physics_type_get(PointerRNA *ptr)
767 Object *ob= (Object*)ptr->id.data;
769 /* determine the body_type setting based on flags */
770 if (!(ob->gameflag & OB_COLLISION)) {
771 if (ob->gameflag & OB_OCCLUDER) {
772 ob->body_type = OB_BODY_TYPE_OCCLUDER;
773 } else if (ob->gameflag & OB_NAVMESH){
774 ob->body_type = OB_BODY_TYPE_NAVMESH;
776 ob->body_type = OB_BODY_TYPE_NO_COLLISION;
778 } else if (ob->gameflag & OB_SENSOR) {
779 ob->body_type = OB_BODY_TYPE_SENSOR;
780 } else if (!(ob->gameflag & OB_DYNAMIC)) {
781 ob->body_type = OB_BODY_TYPE_STATIC;
782 } else if (!(ob->gameflag & (OB_RIGID_BODY|OB_SOFT_BODY))) {
783 ob->body_type = OB_BODY_TYPE_DYNAMIC;
784 } else if (ob->gameflag & OB_RIGID_BODY) {
785 ob->body_type = OB_BODY_TYPE_RIGID;
787 ob->body_type = OB_BODY_TYPE_SOFT;
788 /* create the structure here because we display soft body buttons in the main panel */
790 ob->bsoft = bsbNew();
793 return ob->body_type;
796 static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value)
798 Object *ob= (Object*)ptr->id.data;
799 ob->body_type= value;
801 switch (ob->body_type) {
802 case OB_BODY_TYPE_SENSOR:
803 ob->gameflag |= OB_SENSOR|OB_COLLISION|OB_GHOST;
804 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);
806 case OB_BODY_TYPE_OCCLUDER:
807 ob->gameflag |= OB_OCCLUDER;
808 ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_DYNAMIC|OB_NAVMESH);
810 case OB_BODY_TYPE_NAVMESH:
811 ob->gameflag |= OB_NAVMESH;
812 ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_DYNAMIC|OB_OCCLUDER);
814 case OB_BODY_TYPE_NO_COLLISION:
815 ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_OCCLUDER|OB_DYNAMIC|OB_NAVMESH);
817 case OB_BODY_TYPE_STATIC:
818 ob->gameflag |= OB_COLLISION;
819 ob->gameflag &= ~(OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR|OB_NAVMESH);
821 case OB_BODY_TYPE_DYNAMIC:
822 ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_ACTOR;
823 ob->gameflag &= ~(OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR|OB_NAVMESH);
825 case OB_BODY_TYPE_RIGID:
826 ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_RIGID_BODY|OB_ACTOR;
827 ob->gameflag &= ~(OB_SOFT_BODY|OB_OCCLUDER|OB_SENSOR|OB_NAVMESH);
830 case OB_BODY_TYPE_SOFT:
831 ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_SOFT_BODY|OB_ACTOR;
832 ob->gameflag &= ~(OB_RIGID_BODY|OB_OCCLUDER|OB_SENSOR|OB_NAVMESH);
834 /* assume triangle mesh, if no bounds chosen for soft body */
835 if ((ob->gameflag & OB_BOUNDS) && (ob->boundtype<OB_BOUND_POLYH))
837 ob->boundtype=OB_BOUND_POLYH;
839 /* create a BulletSoftBody structure if not already existing */
841 ob->bsoft = bsbNew();
846 static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr)
848 Object *ob= (Object*)ptr->id.data;
849 ParticleSystem *psys= psys_get_current(ob);
850 return rna_pointer_inherit_refine(ptr, &RNA_ParticleSystem, psys);
853 static PointerRNA rna_Object_game_settings_get(PointerRNA *ptr)
855 return rna_pointer_inherit_refine(ptr, &RNA_GameObjectSettings, ptr->id.data);
859 static unsigned int rna_Object_layer_validate__internal(const int *values, unsigned int lay)
863 /* ensure we always have some layer selected */
871 for(i=0; i<20; i++) {
872 if(values[i]) lay |= (1<<i);
879 static void rna_Object_layer_set(PointerRNA *ptr, const int *values)
881 Object *ob= (Object*)ptr->data;
884 lay= rna_Object_layer_validate__internal(values, ob->lay);
889 static void rna_Base_layer_set(PointerRNA *ptr, const int *values)
891 Base *base= (Base*)ptr->data;
894 lay= rna_Object_layer_validate__internal(values, base->lay);
898 /* rna_Base_layer_update updates the objects layer */
901 static void rna_GameObjectSettings_state_get(PointerRNA *ptr, int *values)
903 Object *ob= (Object*)ptr->data;
905 int all_states = (ob->scaflag & OB_ALLSTATE?1:0);
907 memset(values, 0, sizeof(int)*OB_MAX_STATES);
908 for(i=0; i<OB_MAX_STATES; i++)
909 values[i] = (ob->state & (1<<i)) | all_states;
912 static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values)
914 Object *ob= (Object*)ptr->data;
917 /* ensure we always have some state selected */
918 for(i=0; i<OB_MAX_STATES; i++)
925 for(i=0; i<OB_MAX_STATES; i++) {
926 if(values[i]) ob->state |= (1<<i);
927 else ob->state &= ~(1<<i);
931 static void rna_GameObjectSettings_used_state_get(PointerRNA *ptr, int *values)
933 Object *ob= (Object*)ptr->data;
936 memset(values, 0, sizeof(int)*OB_MAX_STATES);
937 for (cont=ob->controllers.first; cont; cont=cont->next) {
940 for (i=0; i<OB_MAX_STATES; i++) {
941 if (cont->state_mask & (1<<i))
947 static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max)
949 Object *ob= (Object*)ptr->id.data;
950 Key *key= ob_get_key(ob);
953 *max= (key)? BLI_countlist(&key->block)-1: 0;
957 static int rna_Object_active_shape_key_index_get(PointerRNA *ptr)
959 Object *ob= (Object*)ptr->id.data;
961 return MAX2(ob->shapenr-1, 0);
964 static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value)
966 Object *ob= (Object*)ptr->id.data;
968 ob->shapenr= value+1;
971 static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr)
973 Object *ob= (Object*)ptr->id.data;
974 Key *key= ob_get_key(ob);
979 return PointerRNA_NULL;
981 kb= BLI_findlink(&key->block, ob->shapenr-1);
982 RNA_pointer_create((ID *)key, &RNA_ShapeKey, kb, &keyptr);
986 static PointerRNA rna_Object_field_get(PointerRNA *ptr)
988 Object *ob= (Object*)ptr->id.data;
992 ob->pd= object_add_collision_fields(0);
994 return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, ob->pd);
997 static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
999 Object *ob= (Object*)ptr->id.data;
1003 ob->pd= object_add_collision_fields(0);
1005 return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd);
1008 static PointerRNA rna_Object_active_constraint_get(PointerRNA *ptr)
1010 Object *ob= (Object*)ptr->id.data;
1011 bConstraint *con= constraints_get_active(&ob->constraints);
1012 return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con);
1015 static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value)
1017 Object *ob= (Object*)ptr->id.data;
1018 constraints_set_active(&ob->constraints, (bConstraint *)value.data);
1021 static bConstraint *rna_Object_constraint_new(Object *object, int type)
1023 WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_ADDED, object);
1024 return add_ob_constraint(object, NULL, type);
1027 static int rna_Object_constraint_remove(Object *object, int index)
1029 int ok = remove_constraint_index(&object->constraints, index);
1031 ED_object_constraint_set_active(object, NULL);
1032 WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT, object);
1038 static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports, char *name, int type)
1040 return ED_object_modifier_add(reports, CTX_data_scene(C), object, name, type);
1043 static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, ModifierData *md)
1045 ED_object_modifier_remove(reports, CTX_data_scene(C), object, md);
1048 static void rna_Object_boundbox_get(PointerRNA *ptr, float *values)
1050 Object *ob= (Object*)ptr->id.data;
1051 BoundBox *bb= object_get_boundbox(ob);
1053 memcpy(values, bb->vec, sizeof(bb->vec));
1056 memset(values, -1.0f, sizeof(bb->vec));
1063 static void rna_def_vertex_group(BlenderRNA *brna)
1068 srna= RNA_def_struct(brna, "VertexGroup", NULL);
1069 RNA_def_struct_sdna(srna, "bDeformGroup");
1070 RNA_def_struct_ui_text(srna, "Vertex Group", "Group of vertices, used for armature deform and other purposes");
1071 RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX);
1073 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1074 RNA_def_property_ui_text(prop, "Name", "Vertex group name");
1075 RNA_def_struct_name_property(srna, prop);
1076 RNA_def_property_update(prop, NC_GEOM|ND_DATA|NA_RENAME, NULL);
1078 prop= RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
1079 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1080 RNA_def_property_int_funcs(prop, "rna_VertexGroup_index_get", NULL, NULL);
1081 RNA_def_property_ui_text(prop, "Index", "Index number of the vertex group");
1084 static void rna_def_material_slot(BlenderRNA *brna)
1089 static EnumPropertyItem link_items[] = {
1090 {1, "OBJECT", 0, "Object", ""},
1091 {0, "DATA", 0, "Data", ""},
1092 {0, NULL, 0, NULL, NULL}};
1094 /* NOTE: there is no MaterialSlot equivalent in DNA, so the internal
1095 * pointer data points to ob->mat + index, and we manually implement
1096 * get/set for the properties. */
1098 srna= RNA_def_struct(brna, "MaterialSlot", NULL);
1099 RNA_def_struct_ui_text(srna, "Material Slot", "Material slot in an object");
1100 RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
1102 prop= RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
1103 RNA_def_property_struct_type(prop, "Material");
1104 RNA_def_property_flag(prop, PROP_EDITABLE);
1105 RNA_def_property_pointer_funcs(prop, "rna_MaterialSlot_material_get", "rna_MaterialSlot_material_set", NULL);
1106 RNA_def_property_ui_text(prop, "Material", "Material datablock used by this material slot");
1107 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
1109 prop= RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE);
1110 RNA_def_property_enum_items(prop, link_items);
1111 RNA_def_property_enum_funcs(prop, "rna_MaterialSlot_link_get", "rna_MaterialSlot_link_set", NULL);
1112 RNA_def_property_ui_text(prop, "Link", "Link material to object or the object's data");
1113 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
1115 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1116 RNA_def_property_string_funcs(prop, "rna_MaterialSlot_name_get", "rna_MaterialSlot_name_length", NULL);
1117 RNA_def_property_ui_text(prop, "Name", "Material slot name");
1118 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1119 RNA_def_struct_name_property(srna, prop);
1122 static void rna_def_object_game_settings(BlenderRNA *brna)
1127 static EnumPropertyItem body_type_items[] = {
1128 {OB_BODY_TYPE_NO_COLLISION, "NO_COLLISION", 0, "No Collision", "Disable colision for this object"},
1129 {OB_BODY_TYPE_STATIC, "STATIC", 0, "Static", "Stationary object"},
1130 {OB_BODY_TYPE_DYNAMIC, "DYNAMIC", 0, "Dynamic", "Linear physics"},
1131 {OB_BODY_TYPE_RIGID, "RIGID_BODY", 0, "Rigid Body", "Linear and angular physics"},
1132 {OB_BODY_TYPE_SOFT, "SOFT_BODY", 0, "Soft Body", "Soft body"},
1133 {OB_BODY_TYPE_OCCLUDER, "OCCLUDE", 0, "Occlude", "Occluder for optimizing scene rendering"},
1134 {OB_BODY_TYPE_SENSOR, "SENSOR", 0, "Sensor", "Collision Sensor, detects static and dynamic objects but not the other collision sensor objects"},
1135 {OB_BODY_TYPE_NAVMESH, "NAVMESH", 0, "NavMesh", "Navigation mesh"},
1136 {0, NULL, 0, NULL, NULL}};
1138 srna= RNA_def_struct(brna, "GameObjectSettings", NULL);
1139 RNA_def_struct_sdna(srna, "Object");
1140 RNA_def_struct_nested(brna, srna, "Object");
1141 RNA_def_struct_ui_text(srna, "Game Object Settings", "Game engine related settings for the object");
1142 RNA_def_struct_ui_icon(srna, ICON_GAME);
1146 prop= RNA_def_property(srna, "sensors", PROP_COLLECTION, PROP_NONE);
1147 RNA_def_property_struct_type(prop, "Sensor");
1148 RNA_def_property_ui_text(prop, "Sensors", "Game engine sensor to detect events");
1150 prop= RNA_def_property(srna, "controllers", PROP_COLLECTION, PROP_NONE);
1151 RNA_def_property_struct_type(prop, "Controller");
1152 RNA_def_property_ui_text(prop, "Controllers", "Game engine controllers to process events, connecting sensor to actuators");
1154 prop= RNA_def_property(srna, "actuators", PROP_COLLECTION, PROP_NONE);
1155 RNA_def_property_struct_type(prop, "Actuator");
1156 RNA_def_property_ui_text(prop, "Actuators", "Game engine actuators to act on events");
1158 prop= RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE);
1159 RNA_def_property_collection_sdna(prop, NULL, "prop", NULL);
1160 RNA_def_property_struct_type(prop, "GameProperty"); /* rna_property.c */
1161 RNA_def_property_ui_text(prop, "Properties", "Game engine properties");
1163 prop= RNA_def_property(srna, "show_sensors", PROP_BOOLEAN, PROP_NONE);
1164 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSENS);
1165 RNA_def_property_ui_text(prop, "Show Sensors", "Shows sensors for this object in the user interface");
1167 prop= RNA_def_property(srna, "show_controllers", PROP_BOOLEAN, PROP_NONE);
1168 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWCONT);
1169 RNA_def_property_ui_text(prop, "Show Controllers", "Shows controllers for this object in the user interface");
1171 prop= RNA_def_property(srna, "show_actuators", PROP_BOOLEAN, PROP_NONE);
1172 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWACT);
1173 RNA_def_property_ui_text(prop, "Show Actuators", "Shows actuators for this object in the user interface");
1177 prop= RNA_def_property(srna, "physics_type", PROP_ENUM, PROP_NONE);
1178 RNA_def_property_enum_sdna(prop, NULL, "body_type");
1179 RNA_def_property_enum_items(prop, body_type_items);
1180 RNA_def_property_enum_funcs(prop, "rna_GameObjectSettings_physics_type_get", "rna_GameObjectSettings_physics_type_set", NULL);
1181 RNA_def_property_ui_text(prop, "Physics Type", "Selects the type of physical representation");
1182 RNA_def_property_update(prop, NC_LOGIC, NULL);
1184 prop= RNA_def_property(srna, "actor", PROP_BOOLEAN, PROP_NONE);
1185 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ACTOR);
1186 RNA_def_property_ui_text(prop, "Actor", "Object is detected by the Near and Radar sensor");
1188 prop= RNA_def_property(srna, "ghost", PROP_BOOLEAN, PROP_NONE);
1189 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_GHOST);
1190 RNA_def_property_ui_text(prop, "Ghost", "Object does not restitute collisions, like a ghost");
1192 prop= RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE);
1193 RNA_def_property_range(prop, 0.01, 10000.0);
1194 RNA_def_property_ui_text(prop, "Mass", "Mass of the object");
1196 prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH);
1197 RNA_def_property_float_sdna(prop, NULL, "inertia");
1198 RNA_def_property_range(prop, 0.01, 10.0);
1199 RNA_def_property_ui_text(prop, "Radius", "Radius of bounding sphere and material physics");
1200 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1202 prop= RNA_def_property(srna, "no_sleeping", PROP_BOOLEAN, PROP_NONE);
1203 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_COLLISION_RESPONSE);
1204 RNA_def_property_ui_text(prop, "No Sleeping", "Disable auto (de)activation in physics simulation");
1206 prop= RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE);
1207 RNA_def_property_float_sdna(prop, NULL, "damping");
1208 RNA_def_property_range(prop, 0.0, 1.0);
1209 RNA_def_property_ui_text(prop, "Damping", "General movement damping");
1211 prop= RNA_def_property(srna, "rotation_damping", PROP_FLOAT, PROP_NONE);
1212 RNA_def_property_float_sdna(prop, NULL, "rdamping");
1213 RNA_def_property_range(prop, 0.0, 1.0);
1214 RNA_def_property_ui_text(prop, "Rotation Damping", "General rotation damping");
1216 prop= RNA_def_property(srna, "minimum_velocity", PROP_FLOAT, PROP_NONE);
1217 RNA_def_property_float_sdna(prop, NULL, "min_vel");
1218 RNA_def_property_range(prop, 0.0, 1000.0);
1219 RNA_def_property_ui_text(prop, "Velocity Min", "Clamp velocity to this minimum speed (except when totally still)");
1221 prop= RNA_def_property(srna, "maximum_velocity", PROP_FLOAT, PROP_NONE);
1222 RNA_def_property_float_sdna(prop, NULL, "max_vel");
1223 RNA_def_property_range(prop, 0.0, 1000.0);
1224 RNA_def_property_ui_text(prop, "Velocity Max", "Clamp velocity to this maximum speed");
1227 prop= RNA_def_property(srna, "lock_x_axis", PROP_BOOLEAN, PROP_NONE);
1228 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_AXIS);
1229 RNA_def_property_ui_text(prop, "Lock X Axis", "Disable simulation of linear motion along the X axis");
1231 prop= RNA_def_property(srna, "lock_y_axis", PROP_BOOLEAN, PROP_NONE);
1232 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_AXIS);
1233 RNA_def_property_ui_text(prop, "Lock Y Axis", "Disable simulation of linear motion along the Y axis");
1235 prop= RNA_def_property(srna, "lock_z_axis", PROP_BOOLEAN, PROP_NONE);
1236 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_AXIS);
1237 RNA_def_property_ui_text(prop, "Lock Z Axis", "Disable simulation of linear motion along the Z axis");
1241 prop= RNA_def_property(srna, "lock_x_rot_axis", PROP_BOOLEAN, PROP_NONE);
1242 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_ROT_AXIS);
1243 RNA_def_property_ui_text(prop, "Lock X Rotation Axis", "Disable simulation of angular motion along the X axis");
1245 prop= RNA_def_property(srna, "lock_y_rot_axis", PROP_BOOLEAN, PROP_NONE);
1246 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_ROT_AXIS);
1247 RNA_def_property_ui_text(prop, "Lock Y Rotation Axis", "Disable simulation of angular motion along the Y axis");
1249 prop= RNA_def_property(srna, "lock_z_rot_axis", PROP_BOOLEAN, PROP_NONE);
1250 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_ROT_AXIS);
1251 RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis");
1253 /* is this used anywhere ? */
1254 prop= RNA_def_property(srna, "use_activity_culling", PROP_BOOLEAN, PROP_NONE);
1255 RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflag2", OB_NEVER_DO_ACTIVITY_CULLING);
1256 RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis");
1259 prop= RNA_def_property(srna, "material_physics", PROP_BOOLEAN, PROP_NONE);
1260 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_DO_FH);
1261 RNA_def_property_ui_text(prop, "Use Material Physics", "Use physics settings in materials");
1263 prop= RNA_def_property(srna, "rotate_from_normal", PROP_BOOLEAN, PROP_NONE);
1264 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ROT_FH);
1265 RNA_def_property_ui_text(prop, "Rotate From Normal", "Use face normal to rotate object, so that it points away from the surface");
1267 prop= RNA_def_property(srna, "form_factor", PROP_FLOAT, PROP_NONE);
1268 RNA_def_property_float_sdna(prop, NULL, "formfactor");
1269 RNA_def_property_range(prop, 0.0, 1.0);
1270 RNA_def_property_ui_text(prop, "Form Factor", "Form factor scales the inertia tensor");
1272 prop= RNA_def_property(srna, "anisotropic_friction", PROP_BOOLEAN, PROP_NONE);
1273 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ANISOTROPIC_FRICTION);
1274 RNA_def_property_ui_text(prop, "Anisotropic Friction", "Enable anisotropic friction");
1276 prop= RNA_def_property(srna, "friction_coefficients", PROP_FLOAT, PROP_NONE);
1277 RNA_def_property_float_sdna(prop, NULL, "anisotropicFriction");
1278 RNA_def_property_range(prop, 0.0, 1.0);
1279 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");
1281 prop= RNA_def_property(srna, "use_collision_bounds", PROP_BOOLEAN, PROP_NONE);
1282 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_BOUNDS);
1283 RNA_def_property_ui_text(prop, "Use Collision Bounds", "Specify a collision bounds type other than the default");
1285 prop= RNA_def_property(srna, "collision_bounds", PROP_ENUM, PROP_NONE);
1286 RNA_def_property_enum_sdna(prop, NULL, "boundtype");
1287 RNA_def_property_enum_items(prop, collision_bounds_items);
1288 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_collision_bounds_itemf");
1289 RNA_def_property_ui_text(prop, "Collision Bounds", "Selects the collision type");
1290 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1292 prop= RNA_def_property(srna, "collision_compound", PROP_BOOLEAN, PROP_NONE);
1293 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_CHILD);
1294 RNA_def_property_ui_text(prop, "Collision Compound", "Add children to form a compound collision object");
1296 prop= RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH);
1297 RNA_def_property_float_sdna(prop, NULL, "margin");
1298 RNA_def_property_range(prop, 0.0, 1.0);
1299 RNA_def_property_ui_text(prop, "Collision Margin", "Extra margin around object for collision detection, small amount required for stability");
1301 prop= RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE);
1302 RNA_def_property_pointer_sdna(prop, NULL, "bsoft");
1303 RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for Bullet soft body simulation");
1305 prop= RNA_def_property(srna, "create_obstacle", PROP_BOOLEAN, PROP_NONE);
1306 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_HASOBSTACLE);
1307 RNA_def_property_ui_text(prop, "Create obstacle", "Create representation for obstacle simulation");
1309 prop= RNA_def_property(srna, "obstacle_radius", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH);
1310 RNA_def_property_float_sdna(prop, NULL, "obstacleRad");
1311 RNA_def_property_range(prop, 0.0, 1000.0);
1312 RNA_def_property_ui_text(prop, "Obstacle Radius", "Radius of object representation in obstacle simulation");
1316 prop= RNA_def_property(srna, "visible_state", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1317 RNA_def_property_boolean_sdna(prop, NULL, "state", 1);
1318 RNA_def_property_array(prop, OB_MAX_STATES);
1319 RNA_def_property_ui_text(prop, "State", "State determining which controllers are displayed");
1320 RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_state_get", "rna_GameObjectSettings_state_set");
1322 prop= RNA_def_property(srna, "used_state", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1323 RNA_def_property_array(prop, OB_MAX_STATES);
1324 RNA_def_property_ui_text(prop, "Used State", "States which are being used by controllers");
1325 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1326 RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_used_state_get", NULL);
1328 prop= RNA_def_property(srna, "initial_state", PROP_BOOLEAN, PROP_NONE);
1329 RNA_def_property_boolean_sdna(prop, NULL, "init_state", 1);
1330 RNA_def_property_array(prop, OB_MAX_STATES);
1331 RNA_def_property_ui_text(prop, "Initial State", "Initial state when the game starts");
1333 prop= RNA_def_property(srna, "debug_state", PROP_BOOLEAN, PROP_NONE);
1334 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_DEBUGSTATE);
1335 RNA_def_property_ui_text(prop, "Debug State", "Print state debug info in the game engine");
1336 RNA_def_property_ui_icon(prop, ICON_INFO, 0);
1338 prop= RNA_def_property(srna, "all_states", PROP_BOOLEAN, PROP_NONE);
1339 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_ALLSTATE);
1340 RNA_def_property_ui_text(prop, "All", "Set all state bits");
1342 prop= RNA_def_property(srna, "show_state_panel", PROP_BOOLEAN, PROP_NONE);
1343 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSTATE);
1344 RNA_def_property_ui_text(prop, "States", "Show state panel");
1345 RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
1348 static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
1356 RNA_def_property_srna(cprop, "ObjectConstraints");
1357 srna= RNA_def_struct(brna, "ObjectConstraints", NULL);
1358 RNA_def_struct_sdna(srna, "Object");
1359 RNA_def_struct_ui_text(srna, "Object Constraints", "Collection of object constraints");
1362 /* Collection active property */
1363 prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1364 RNA_def_property_struct_type(prop, "Constraint");
1365 RNA_def_property_pointer_funcs(prop, "rna_Object_active_constraint_get", "rna_Object_active_constraint_set", NULL);
1366 RNA_def_property_flag(prop, PROP_EDITABLE);
1367 RNA_def_property_ui_text(prop, "Active Constraint", "Active Object constraint");
1370 /* Constraint collection */
1371 func= RNA_def_function(srna, "new", "rna_Object_constraint_new");
1372 RNA_def_function_ui_description(func, "Add a new constraint to this object");
1374 parm= RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint.");
1375 RNA_def_function_return(func, parm);
1377 parm= RNA_def_enum(func, "type", constraint_type_items, 1, "", "Constraint type to add.");
1378 RNA_def_property_flag(parm, PROP_REQUIRED);
1380 func= RNA_def_function(srna, "remove", "rna_Object_constraint_remove");
1381 RNA_def_function_ui_description(func, "Remove a constraint from this object.");
1383 parm= RNA_def_boolean(func, "success", 0, "Success", "Removed the constraint successfully.");
1384 RNA_def_function_return(func, parm);
1386 parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX);
1387 RNA_def_property_flag(parm, PROP_REQUIRED);
1390 /* armature.bones.* */
1391 static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
1398 RNA_def_property_srna(cprop, "ObjectModifiers");
1399 srna= RNA_def_struct(brna, "ObjectModifiers", NULL);
1400 RNA_def_struct_sdna(srna, "Object");
1401 RNA_def_struct_ui_text(srna, "Object Modifiers", "Collection of object modifiers");
1404 prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1405 RNA_def_property_struct_type(prop, "EditBone");
1406 RNA_def_property_pointer_sdna(prop, NULL, "act_edbone");
1407 RNA_def_property_flag(prop, PROP_EDITABLE);
1408 RNA_def_property_ui_text(prop, "Active EditBone", "Armatures active edit bone");
1409 //RNA_def_property_update(prop, 0, "rna_Armature_act_editbone_update");
1410 RNA_def_property_pointer_funcs(prop, NULL, "rna_Armature_act_edit_bone_set", NULL);
1413 // RNA_def_property_collection_active(prop, prop_act);
1417 func= RNA_def_function(srna, "new", "rna_Object_modifier_new");
1418 RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
1419 RNA_def_function_ui_description(func, "Add a new modifier.");
1420 parm= RNA_def_string(func, "name", "Name", 0, "", "New name for the bone.");
1421 RNA_def_property_flag(parm, PROP_REQUIRED);
1422 /* modifier to add */
1423 parm= RNA_def_enum(func, "type", modifier_type_items, 1, "", "Modifier type to add.");
1424 RNA_def_property_flag(parm, PROP_REQUIRED);
1426 parm= RNA_def_pointer(func, "modifier", "Modifier", "", "Newly created modifier.");
1427 RNA_def_function_return(func, parm);
1430 func= RNA_def_function(srna, "remove", "rna_Object_modifier_remove");
1431 RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
1432 RNA_def_function_ui_description(func, "Remove an existing modifier from the object.");
1433 /* target to remove*/
1434 parm= RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove.");
1435 RNA_def_property_flag(parm, PROP_REQUIRED);
1438 static void rna_def_object(BlenderRNA *brna)
1443 static EnumPropertyItem object_type_items[] = {
1444 {OB_EMPTY, "EMPTY", 0, "Empty", ""},
1445 {OB_MESH, "MESH", 0, "Mesh", ""},
1446 {OB_CURVE, "CURVE", 0, "Curve", ""},
1447 {OB_SURF, "SURFACE", 0, "Surface", ""},
1448 {OB_FONT, "TEXT", 0, "Text", ""},
1449 {OB_MBALL, "META", 0, "Meta", ""},
1450 {OB_LAMP, "LAMP", 0, "Lamp", ""},
1451 {OB_CAMERA, "CAMERA", 0, "Camera", ""},
1452 {OB_WAVE, "WAVE", 0, "Wave", ""},
1453 {OB_LATTICE, "LATTICE", 0, "Lattice", ""},
1454 {OB_ARMATURE, "ARMATURE", 0, "Armature", ""},
1455 {0, NULL, 0, NULL, NULL}};
1457 static EnumPropertyItem empty_drawtype_items[] = {
1458 {OB_ARROWS, "ARROWS", 0, "Arrows", ""},
1459 {OB_SINGLE_ARROW, "SINGLE_ARROW", 0, "Single Arrow", ""},
1460 {OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""},
1461 {OB_CIRCLE, "CIRCLE", 0, "Circle", ""},
1462 {OB_CUBE, "CUBE", 0, "Cube", ""},
1463 {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""},
1464 {OB_EMPTY_CONE, "CONE", 0, "Cone", ""},
1465 {0, NULL, 0, NULL, NULL}};
1467 static EnumPropertyItem track_items[] = {
1468 {OB_POSX, "POS_X", 0, "+X", ""},
1469 {OB_POSY, "POS_Y", 0, "+Y", ""},
1470 {OB_POSZ, "POS_Z", 0, "+Z", ""},
1471 {OB_NEGX, "NEG_X", 0, "-X", ""},
1472 {OB_NEGY, "NEG_Y", 0, "-Y", ""},
1473 {OB_NEGZ, "NEG_Z", 0, "-Z", ""},
1474 {0, NULL, 0, NULL, NULL}};
1476 static EnumPropertyItem up_items[] = {
1477 {OB_POSX, "X", 0, "X", ""},
1478 {OB_POSY, "Y", 0, "Y", ""},
1479 {OB_POSZ, "Z", 0, "Z", ""},
1480 {0, NULL, 0, NULL, NULL}};
1482 static EnumPropertyItem drawtype_items[] = {
1483 {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", ""},
1484 {OB_WIRE, "WIRE", 0, "Wire", ""},
1485 {OB_SOLID, "SOLID", 0, "Solid", ""},
1486 // disabled {OB_SHADED, "SHADED", 0, "Shaded", ""},
1487 {OB_TEXTURE, "TEXTURED", 0, "Textured", ""},
1488 {0, NULL, 0, NULL, NULL}};
1490 static EnumPropertyItem boundtype_items[] = {
1491 {OB_BOUND_BOX, "BOX", 0, "Box", ""},
1492 {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""},
1493 {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", ""},
1494 {OB_BOUND_CONE, "CONE", 0, "Cone", ""},
1495 {OB_BOUND_POLYH, "POLYHEDRON", 0, "Polyhedron", ""},
1496 {0, NULL, 0, NULL, NULL}};
1498 static EnumPropertyItem dupli_items[] = {
1499 {0, "NONE", 0, "None", ""},
1500 {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"},
1501 {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"},
1502 {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"},
1503 {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"},
1504 {0, NULL, 0, NULL, NULL}};
1506 // XXX: this RNA enum define is currently duplicated for objects, since there is some text here which is not applicable
1507 static EnumPropertyItem prop_rotmode_items[] = {
1508 {ROT_MODE_QUAT, "QUATERNION", 0, "Quaternion (WXYZ)", "No Gimbal Lock"},
1509 {ROT_MODE_XYZ, "XYZ", 0, "XYZ Euler", "XYZ Rotation Order. Prone to Gimbal Lock. (Default)"},
1510 {ROT_MODE_XZY, "XZY", 0, "XZY Euler", "XZY Rotation Order. Prone to Gimbal Lock"},
1511 {ROT_MODE_YXZ, "YXZ", 0, "YXZ Euler", "YXZ Rotation Order. Prone to Gimbal Lock"},
1512 {ROT_MODE_YZX, "YZX", 0, "YZX Euler", "YZX Rotation Order. Prone to Gimbal Lock"},
1513 {ROT_MODE_ZXY, "ZXY", 0, "ZXY Euler", "ZXY Rotation Order. Prone to Gimbal Lock"},
1514 {ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order. Prone to Gimbal Lock"},
1515 {ROT_MODE_AXISANGLE, "AXIS_ANGLE", 0, "Axis Angle", "Axis Angle (W+XYZ). Defines a rotation around some axis defined by 3D-Vector"},
1516 {0, NULL, 0, NULL, NULL}};
1518 static float default_quat[4] = {1,0,0,0}; /* default quaternion values */
1519 static float default_axisAngle[4] = {0,0,1,0}; /* default axis-angle rotation values */
1520 static float default_scale[3] = {1,1,1}; /* default scale values */
1521 int matrix_dimsize[]= {4, 4};
1522 int boundbox_dimsize[]= {8, 3};
1524 srna= RNA_def_struct(brna, "Object", "ID");
1525 RNA_def_struct_ui_text(srna, "Object", "Object datablock defining an object in a scene");
1526 RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
1527 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
1529 prop= RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
1530 RNA_def_property_struct_type(prop, "ID");
1531 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_set", "rna_Object_data_typef");
1532 RNA_def_property_editable_func(prop, "rna_Object_data_editable");
1533 RNA_def_property_flag(prop, PROP_EDITABLE);
1534 RNA_def_property_ui_text(prop, "Data", "Object data");
1535 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
1537 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1538 RNA_def_property_enum_sdna(prop, NULL, "type");
1539 RNA_def_property_enum_items(prop, object_type_items);
1540 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1541 RNA_def_property_ui_text(prop, "Type", "Type of Object");
1543 prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
1544 RNA_def_property_enum_sdna(prop, NULL, "mode");
1545 RNA_def_property_enum_items(prop, object_mode_items);
1546 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1547 RNA_def_property_ui_text(prop, "Mode", "Object interaction mode");
1549 prop= RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1550 RNA_def_property_boolean_sdna(prop, NULL, "lay", 1);
1551 RNA_def_property_array(prop, 20);
1552 RNA_def_property_ui_text(prop, "Layers", "Layers the object is on");
1553 RNA_def_property_boolean_funcs(prop, NULL, "rna_Object_layer_set");
1554 RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
1555 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_layer_update");
1557 prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
1558 RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
1559 RNA_def_property_ui_text(prop, "Selected", "Object selection state");
1560 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_select_update");
1562 /* for data access */
1563 prop= RNA_def_property(srna, "bound_box", PROP_FLOAT, PROP_NONE);
1564 RNA_def_property_multi_array(prop, 2, boundbox_dimsize);
1565 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1566 RNA_def_property_float_funcs(prop, "rna_Object_boundbox_get", NULL, NULL);
1567 RNA_def_property_ui_text(prop, "Bound Box", "Objects bound box in object-space coordinates");
1570 prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
1571 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_parent_set", NULL);
1572 RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
1573 RNA_def_property_ui_text(prop, "Parent", "Parent Object");
1574 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
1576 prop= RNA_def_property(srna, "parent_type", PROP_ENUM, PROP_NONE);
1577 RNA_def_property_enum_bitflag_sdna(prop, NULL, "partype");
1578 RNA_def_property_enum_items(prop, parent_type_items);
1579 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_parent_type_set", "rna_Object_parent_type_itemf");
1580 RNA_def_property_ui_text(prop, "Parent Type", "Type of parent relation");
1581 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
1583 prop= RNA_def_property(srna, "parent_vertices", PROP_INT, PROP_UNSIGNED);
1584 RNA_def_property_int_sdna(prop, NULL, "par1");
1585 RNA_def_property_array(prop, 3);
1586 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1587 RNA_def_property_ui_text(prop, "Parent Vertices", "Indices of vertices in cases of a vertex parenting relation");
1588 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
1590 prop= RNA_def_property(srna, "parent_bone", PROP_STRING, PROP_NONE);
1591 RNA_def_property_string_sdna(prop, NULL, "parsubstr");
1592 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Object_parent_bone_set");
1593 RNA_def_property_ui_text(prop, "Parent Bone", "Name of parent bone in case of a bone parenting relation");
1594 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
1596 /* Track and Up flags */
1597 // XXX: these have been saved here for a bit longer (after old track was removed), since some other tools still refer to this
1598 prop= RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
1599 RNA_def_property_enum_sdna(prop, NULL, "trackflag");
1600 RNA_def_property_enum_items(prop, track_items);
1601 RNA_def_property_ui_text(prop, "Track Axis", "Axis that points in 'forward' direction");
1602 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
1604 prop= RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE);
1605 RNA_def_property_enum_sdna(prop, NULL, "upflag");
1606 RNA_def_property_enum_items(prop, up_items);
1607 RNA_def_property_ui_text(prop, "Up Axis", "Axis that points in the upward direction");
1608 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
1611 prop= RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE);
1612 RNA_def_property_ui_text(prop, "Proxy", "Library object this proxy object controls");
1614 prop= RNA_def_property(srna, "proxy_group", PROP_POINTER, PROP_NONE);
1615 RNA_def_property_ui_text(prop, "Proxy Group", "Library group duplicator object this proxy object controls");
1618 prop= RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE);
1619 RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
1620 RNA_def_property_struct_type(prop, "MaterialSlot");
1621 RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", 0, 0, 0); /* don't dereference pointer! */
1622 RNA_def_property_ui_text(prop, "Material Slots", "Material slots in the object");
1624 prop= RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE);
1625 RNA_def_property_struct_type(prop, "Material");
1626 RNA_def_property_pointer_funcs(prop, "rna_Object_active_material_get", "rna_Object_active_material_set", NULL);
1627 RNA_def_property_flag(prop, PROP_EDITABLE);
1628 RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed");
1629 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
1631 prop= RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
1632 RNA_def_property_int_sdna(prop, NULL, "actcol");
1633 RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set", "rna_Object_active_material_index_range");
1634 RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot");
1635 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1638 prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
1639 RNA_def_property_float_sdna(prop, NULL, "loc");
1640 RNA_def_property_editable_array_func(prop, "rna_Object_location_editable");
1641 RNA_def_property_ui_text(prop, "Location", "Location of the object");
1642 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1644 prop= RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
1645 RNA_def_property_float_sdna(prop, NULL, "quat");
1646 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
1647 RNA_def_property_float_array_default(prop, default_quat);
1648 RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions");
1649 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1651 /* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but
1652 * having a single one is better for Keyframing and other property-management situations...
1654 prop= RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
1655 RNA_def_property_array(prop, 4);
1656 RNA_def_property_float_funcs(prop, "rna_Object_rotation_axis_angle_get", "rna_Object_rotation_axis_angle_set", NULL);
1657 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
1658 RNA_def_property_float_array_default(prop, default_axisAngle);
1659 RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
1660 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1662 prop= RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
1663 RNA_def_property_float_sdna(prop, NULL, "rot");
1664 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_euler_editable");
1665 RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers");
1666 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1668 prop= RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
1669 RNA_def_property_enum_sdna(prop, NULL, "rotmode");
1670 RNA_def_property_enum_items(prop, prop_rotmode_items); // XXX move to using a single define of this someday
1671 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_rotation_mode_set", NULL);
1672 RNA_def_property_ui_text(prop, "Rotation Mode", "");
1673 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1675 prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
1676 RNA_def_property_float_sdna(prop, NULL, "size");
1677 RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable");
1678 RNA_def_property_float_array_default(prop, default_scale);
1679 RNA_def_property_ui_text(prop, "Scale", "Scaling of the object");
1680 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1682 prop= RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ_LENGTH);
1683 RNA_def_property_array(prop, 3);
1684 RNA_def_property_float_funcs(prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", NULL);
1685 RNA_def_property_ui_text(prop, "Dimensions", "Absolute bounding box dimensions of the object");
1686 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1689 /* delta transforms */
1690 prop= RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_TRANSLATION);
1691 RNA_def_property_float_sdna(prop, NULL, "dloc");
1692 RNA_def_property_ui_text(prop, "Delta Location", "Extra translation added to the location of the object");
1693 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1695 prop= RNA_def_property(srna, "delta_rotation_euler", PROP_FLOAT, PROP_EULER);
1696 RNA_def_property_float_sdna(prop, NULL, "drot");
1697 RNA_def_property_ui_text(prop, "Delta Rotation (Euler)", "Extra rotation added to the rotation of the object (when using Euler rotations)");
1698 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1700 prop= RNA_def_property(srna, "delta_rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
1701 RNA_def_property_float_sdna(prop, NULL, "dquat");
1702 RNA_def_property_float_array_default(prop, default_quat);
1703 RNA_def_property_ui_text(prop, "Delta Rotation (Quaternion)", "Extra rotation added to the rotation of the object (when using Quaternion rotations)");
1704 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1706 #if 0 // XXX not supported well yet...
1707 prop= RNA_def_property(srna, "delta_rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
1708 RNA_def_property_float_sdna(prop, NULL, "dquat"); // FIXME: this is not a single field any more! (drotAxis and drotAngle)
1709 RNA_def_property_float_array_default(prop, default_axisAngle);
1710 RNA_def_property_ui_text(prop, "Delta Rotation (Axis Angle)", "Extra rotation added to the rotation of the object (when using Axis-Angle rotations)");
1711 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1714 prop= RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_XYZ);
1715 RNA_def_property_float_sdna(prop, NULL, "dsize");
1716 RNA_def_property_ui_text(prop, "Delta Scale", "Extra scaling added to the scale of the object");
1717 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1719 /* transform locks */
1720 prop= RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_XYZ);
1721 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX);
1722 RNA_def_property_array(prop, 3);
1723 RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface");
1724 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
1725 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1727 prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_XYZ);
1728 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX);
1729 RNA_def_property_array(prop, 3);
1730 RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface");
1731 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
1732 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1734 // XXX this is sub-optimal - it really should be included above, but due to technical reasons we can't do this!
1735 prop= RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE);
1736 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTW);
1737 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
1738 RNA_def_property_ui_text(prop, "Lock Rotation (4D Angle)", "Lock editing of 'angle' component of four-component rotations in the interface");
1739 // XXX this needs a better name
1740 prop= RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE);
1741 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROT4D);
1742 RNA_def_property_ui_text(prop, "Lock Rotations (4D)", "Lock editing of four component rotations by components (instead of as Eulers)");
1744 prop= RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_XYZ);
1745 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX);
1746 RNA_def_property_array(prop, 3);
1747 RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface");
1748 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
1749 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1752 prop= RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
1753 RNA_def_property_float_sdna(prop, NULL, "obmat");
1754 RNA_def_property_multi_array(prop, 2, matrix_dimsize);
1755 RNA_def_property_ui_text(prop, "Matrix World", "Worldspace transformation matrix");
1756 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_matrix_world_update");
1758 prop= RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX);
1759 RNA_def_property_multi_array(prop, 2, matrix_dimsize);
1760 RNA_def_property_ui_text(prop, "Local Matrix", "Parent relative transformation matrix");
1761 RNA_def_property_float_funcs(prop, "rna_Object_matrix_local_get", "rna_Object_matrix_local_set", NULL);
1762 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, NULL);
1765 prop= RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE);
1766 RNA_def_property_struct_type(prop, "Constraint");
1767 RNA_def_property_ui_text(prop, "Constraints", "Constraints affecting the transformation of the object");
1768 // RNA_def_property_collection_funcs(prop, 0, 0, 0, 0, 0, 0, 0, "constraints__add", "constraints__remove");
1769 rna_def_object_constraints(brna, prop);
1771 prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
1772 RNA_def_property_struct_type(prop, "Modifier");
1773 RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the geometric data of the object");
1774 rna_def_object_modifiers(brna, prop);
1777 prop= RNA_def_property(srna, "game", PROP_POINTER, PROP_NONE);
1778 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1779 RNA_def_property_struct_type(prop, "GameObjectSettings");
1780 RNA_def_property_pointer_funcs(prop, "rna_Object_game_settings_get", NULL, NULL);
1781 RNA_def_property_ui_text(prop, "Game Settings", "Game engine related settings for the object");
1784 prop= RNA_def_property(srna, "vertex_groups", PROP_COLLECTION, PROP_NONE);
1785 RNA_def_property_collection_sdna(prop, NULL, "defbase", NULL);
1786 RNA_def_property_struct_type(prop, "VertexGroup");
1787 RNA_def_property_ui_text(prop, "Vertex Groups", "Vertex groups of the object");
1789 prop= RNA_def_property(srna, "active_vertex_group", PROP_POINTER, PROP_NONE);
1790 RNA_def_property_struct_type(prop, "VertexGroup");
1791 RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get", "rna_Object_active_vertex_group_set", NULL);
1792 RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object");
1793 RNA_def_property_update(prop, NC_GEOM|ND_DATA, "rna_Object_internal_update_data");
1795 prop= RNA_def_property(srna, "active_vertex_group_index", PROP_INT, PROP_NONE);
1796 RNA_def_property_int_sdna(prop, NULL, "actdef");
1797 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");
1798 RNA_def_property_ui_text(prop, "Active Vertex Group Index", "Active index in vertex group array");
1799 RNA_def_property_update(prop, NC_GEOM|ND_DATA, "rna_Object_internal_update_data");
1802 prop= RNA_def_property(srna, "empty_draw_type", PROP_ENUM, PROP_NONE);
1803 RNA_def_property_enum_sdna(prop, NULL, "empty_drawtype");
1804 RNA_def_property_enum_items(prop, empty_drawtype_items);
1805 RNA_def_property_ui_text(prop, "Empty Display Type", "Viewport display style for empties");
1806 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1808 prop= RNA_def_property(srna, "empty_draw_size", PROP_FLOAT, PROP_DISTANCE);
1809 RNA_def_property_float_sdna(prop, NULL, "empty_drawsize");
1810 RNA_def_property_range(prop, 0.0001f, 1000.0f);
1811 RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);
1812 RNA_def_property_ui_text(prop, "Empty Display Size", "Size of display for empties in the viewport");
1813 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1816 prop= RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
1817 RNA_def_property_int_sdna(prop, NULL, "index");
1818 RNA_def_property_ui_text(prop, "Pass Index", "Index # for the IndexOB render pass");
1819 RNA_def_property_update(prop, NC_OBJECT, NULL);
1821 prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1822 RNA_def_property_float_sdna(prop, NULL, "col");
1823 RNA_def_property_ui_text(prop, "Color", "Object color and alpha, used when faces have the ObColor mode enabled");
1824 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1827 prop= RNA_def_property(srna, "field", PROP_POINTER, PROP_NONE);
1828 RNA_def_property_pointer_sdna(prop, NULL, "pd");
1829 RNA_def_property_struct_type(prop, "FieldSettings");
1830 RNA_def_property_pointer_funcs(prop, "rna_Object_field_get", NULL, NULL);
1831 RNA_def_property_ui_text(prop, "Field Settings", "Settings for using the objects as a field in physics simulation");
1833 prop= RNA_def_property(srna, "collision", PROP_POINTER, PROP_NONE);
1834 RNA_def_property_pointer_sdna(prop, NULL, "pd");
1835 RNA_def_property_struct_type(prop, "CollisionSettings");
1836 RNA_def_property_pointer_funcs(prop, "rna_Object_collision_get", NULL, NULL);
1837 RNA_def_property_ui_text(prop, "Collision Settings", "Settings for using the objects as a collider in physics simulation");
1839 prop= RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE);
1840 RNA_def_property_pointer_sdna(prop, NULL, "soft");
1841 RNA_def_property_struct_type(prop, "SoftBodySettings");
1842 RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for soft body simulation");
1844 prop= RNA_def_property(srna, "particle_systems", PROP_COLLECTION, PROP_NONE);
1845 RNA_def_property_collection_sdna(prop, NULL, "particlesystem", NULL);
1846 RNA_def_property_struct_type(prop, "ParticleSystem");
1847 RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object");
1849 prop= RNA_def_property(srna, "active_particle_system", PROP_POINTER, PROP_NONE);
1850 RNA_def_property_struct_type(prop, "ParticleSystem");
1851 RNA_def_property_pointer_funcs(prop, "rna_Object_active_particle_system_get", NULL, NULL);
1852 RNA_def_property_ui_text(prop, "Active Particle System", "Active particle system being displayed");
1853 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1855 prop= RNA_def_property(srna, "active_particle_system_index", PROP_INT, PROP_UNSIGNED);
1856 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");
1857 RNA_def_property_ui_text(prop, "Active Particle System Index", "Index of active particle system slot");
1858 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_particle_update");
1861 prop= RNA_def_property(srna, "restrict_view", PROP_BOOLEAN, PROP_NONE);
1862 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW);
1863 RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport");
1864 RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1);
1865 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1867 prop= RNA_def_property(srna, "restrict_select", PROP_BOOLEAN, PROP_NONE);
1868 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT);
1869 RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection in the viewport");
1870 RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1);
1871 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1873 prop= RNA_def_property(srna, "restrict_render", PROP_BOOLEAN, PROP_NONE);
1874 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER);
1875 RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability");
1876 RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
1877 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1880 rna_def_animdata_common(srna);
1882 rna_def_animviz_common(srna);
1883 rna_def_motionpath_common(srna);
1886 // XXX: evil old crap
1887 prop= RNA_def_property(srna, "slow_parent", PROP_BOOLEAN, PROP_NONE);
1888 RNA_def_property_boolean_sdna(prop, NULL, "partype", PARSLOW);
1889 RNA_def_property_ui_text(prop, "Slow Parent", "Create a delay in the parent relationship");
1890 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
1892 prop= RNA_def_property(srna, "dupli_type", PROP_ENUM, PROP_NONE);
1893 RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag");
1894 RNA_def_property_enum_items(prop, dupli_items);
1895 RNA_def_property_ui_text(prop, "Dupli Type", "If not None, object duplication method to use");
1896 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
1898 prop= RNA_def_property(srna, "use_dupli_frames_speed", PROP_BOOLEAN, PROP_NONE);
1899 RNA_def_property_boolean_negative_sdna(prop, NULL, "transflag", OB_DUPLINOSPEED);
1900 RNA_def_property_ui_text(prop, "Dupli Frames Speed", "Set dupliframes to use the frame"); // TODO, better descriptio!
1901 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
1903 prop= RNA_def_property(srna, "use_dupli_verts_rotation", PROP_BOOLEAN, PROP_NONE);
1904 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIROT);
1905 RNA_def_property_ui_text(prop, "Dupli Verts Rotation", "Rotate dupli according to vertex normal");
1906 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1908 prop= RNA_def_property(srna, "use_dupli_faces_scale", PROP_BOOLEAN, PROP_NONE);
1909 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIFACES_SCALE);
1910 RNA_def_property_ui_text(prop, "Dupli Faces Inherit Scale", "Scale dupli based on face size");
1911 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
1913 prop= RNA_def_property(srna, "dupli_faces_scale", PROP_FLOAT, PROP_NONE);
1914 RNA_def_property_float_sdna(prop, NULL, "dupfacesca");
1915 RNA_def_property_range(prop, 0.001f, 10000.0f);
1916 RNA_def_property_ui_text(prop, "Dupli Faces Scale", "Scale the DupliFace objects");
1917 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1919 prop= RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE);
1920 RNA_def_property_pointer_sdna(prop, NULL, "dup_group");
1921 RNA_def_property_flag(prop, PROP_EDITABLE);
1922 RNA_def_property_ui_text(prop, "Dupli Group", "Instance an existing group");
1923 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
1925 prop= RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE|PROP_UNIT_TIME);
1926 RNA_def_property_int_sdna(prop, NULL, "dupsta");
1927 RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
1928 RNA_def_property_ui_text(prop, "Dupli Frames Start", "Start frame for DupliFrames");
1929 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
1931 prop= RNA_def_property(srna, "dupli_frames_end", PROP_INT, PROP_NONE|PROP_UNIT_TIME);
1932 RNA_def_property_int_sdna(prop, NULL, "dupend");
1933 RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
1934 RNA_def_property_ui_text(prop, "Dupli Frames End", "End frame for DupliFrames");
1935 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
1937 prop= RNA_def_property(srna, "dupli_frames_on", PROP_INT, PROP_NONE|PROP_UNIT_TIME);
1938 RNA_def_property_int_sdna(prop, NULL, "dupon");
1939 RNA_def_property_range(prop, MINFRAME, MAXFRAME);
1940 RNA_def_property_ui_range(prop, 1, 1500, 1, 0);
1941 RNA_def_property_ui_text(prop, "Dupli Frames On", "Number of frames to use between DupOff frames");
1942 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
1944 prop= RNA_def_property(srna, "dupli_frames_off", PROP_INT, PROP_NONE|PROP_UNIT_TIME);
1945 RNA_def_property_int_sdna(prop, NULL, "dupoff");
1946 RNA_def_property_range(prop, 0, MAXFRAME);
1947 RNA_def_property_ui_range(prop, 0, 1500, 1, 0);
1948 RNA_def_property_ui_text(prop, "Dupli Frames Off", "Recurring frames to exclude from the Dupliframes");
1949 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update");
1951 prop= RNA_def_property(srna, "dupli_list", PROP_COLLECTION, PROP_NONE);
1952 RNA_def_property_collection_sdna(prop, NULL, "duplilist", NULL);
1953 RNA_def_property_struct_type(prop, "DupliObject");
1954 RNA_def_property_ui_text(prop, "Dupli list", "Object duplis");
1956 prop= RNA_def_property(srna, "duplis_used", PROP_BOOLEAN, PROP_NONE);
1957 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLI);
1958 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1961 prop= RNA_def_property(srna, "time_offset", PROP_FLOAT, PROP_NONE|PROP_UNIT_TIME);
1962 RNA_def_property_float_sdna(prop, NULL, "sf");
1963 RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
1964 RNA_def_property_ui_text(prop, "Time Offset", "Animation offset in frames for F-Curve and dupligroup instances");
1965 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1967 prop= RNA_def_property(srna, "time_offset_edit", PROP_BOOLEAN, PROP_NONE);
1968 RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_OB);
1969 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");
1971 prop= RNA_def_property(srna, "time_offset_parent", PROP_BOOLEAN, PROP_NONE);
1972 RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_PARENT);
1973 RNA_def_property_ui_text(prop, "Time Offset Parent", "Apply the time offset to this objects parent relationship");
1974 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1976 prop= RNA_def_property(srna, "time_offset_particle", PROP_BOOLEAN, PROP_NONE);
1977 RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_PARTICLE);
1978 RNA_def_property_ui_text(prop, "Time Offset Particle", "Let the time offset work on the particle effect");
1979 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1981 prop= RNA_def_property(srna, "time_offset_add_parent", PROP_BOOLEAN, PROP_NONE);
1982 RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_PARENTADD);
1983 RNA_def_property_ui_text(prop, "Time Offset Add Parent", "Add the parents time offset value");
1984 RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update");
1987 prop= RNA_def_property(srna, "max_draw_type", PROP_ENUM, PROP_NONE);
1988 RNA_def_property_enum_sdna(prop, NULL, "dt");
1989 RNA_def_property_enum_items(prop, drawtype_items);
1990 RNA_def_property_ui_text(prop, "Maximum Draw Type", "Maximum draw type to display object with in viewport");
1991 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1993 prop= RNA_def_property(srna, "draw_bounds", PROP_BOOLEAN, PROP_NONE);
1994 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_BOUNDBOX);
1995 RNA_def_property_ui_text(prop, "Draw Bounds", "Displays the object's bounds");
1996 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
1998 prop= RNA_def_property(srna, "draw_bounds_type", PROP_ENUM, PROP_NONE);
1999 RNA_def_property_enum_sdna(prop, NULL, "boundtype");
2000 RNA_def_property_enum_items(prop, boundtype_items);
2001 RNA_def_property_ui_text(prop, "Draw Bounds Type", "Object boundary display type");
2002 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
2004 prop= RNA_def_property(srna, "draw_name", PROP_BOOLEAN, PROP_NONE);
2005 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWNAME);
2006 RNA_def_property_ui_text(prop, "Draw Name", "Displays the object's name");
2007 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
2009 prop= RNA_def_property(srna, "draw_axis", PROP_BOOLEAN, PROP_NONE);
2010 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_AXIS);
2011 RNA_def_property_ui_text(prop, "Draw Axis", "Displays the object's origin and axis");
2012 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
2014 prop= RNA_def_property(srna, "draw_texture_space", PROP_BOOLEAN, PROP_NONE);
2015 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_TEXSPACE);
2016 RNA_def_property_ui_text(prop, "Draw Texture Space", "Displays the object's texture space");
2017 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
2019 prop= RNA_def_property(srna, "draw_wire", PROP_BOOLEAN, PROP_NONE);
2020 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWWIRE);
2021 RNA_def_property_ui_text(prop, "Draw Wire", "Adds the object's wireframe over solid drawing");
2022 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
2024 prop= RNA_def_property(srna, "draw_transparent", PROP_BOOLEAN, PROP_NONE);
2025 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWTRANSP);
2026 RNA_def_property_ui_text(prop, "Draw Transparent", "Enables transparent materials for the object (Mesh only)");
2027 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
2029 prop= RNA_def_property(srna, "x_ray", PROP_BOOLEAN, PROP_NONE);
2030 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWXRAY);
2031 RNA_def_property_ui_text(prop, "X-Ray", "Makes the object draw in front of others");
2032 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
2035 prop= RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
2036 RNA_def_property_pointer_sdna(prop, NULL, "gpd");
2037 RNA_def_property_flag(prop, PROP_EDITABLE);
2038 RNA_def_property_struct_type(prop, "GreasePencil");
2039 RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock");
2042 prop= RNA_def_property(srna, "pose_library", PROP_POINTER, PROP_NONE);
2043 RNA_def_property_pointer_sdna(prop, NULL, "poselib");
2044 RNA_def_property_struct_type(prop, "Action");
2045 RNA_def_property_ui_text(prop, "Pose Library", "Action used as a pose library for armatures");
2047 prop= RNA_def_property(srna, "pose", PROP_POINTER, PROP_NONE);
2048 RNA_def_property_pointer_sdna(prop, NULL, "pose");
2049 RNA_def_property_struct_type(prop, "Pose");
2050 RNA_def_property_ui_text(prop, "Pose", "Current pose for armatures");
2053 prop= RNA_def_property(srna, "shape_key_lock", PROP_BOOLEAN, PROP_NONE);
2054 RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_LOCK);
2055 RNA_def_property_ui_text(prop, "Shape Key Lock", "Always show the current Shape for this Object");
2056 RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
2057 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
2059 prop= RNA_def_property(srna, "shape_key_edit_mode", PROP_BOOLEAN, PROP_NONE);
2060 RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_EDIT_MODE);
2061 RNA_def_property_ui_text(prop, "Shape Key Edit Mode", "Apply shape keys in edit mode (for Meshes only)");
2062 RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0);
2063 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
2065 prop= RNA_def_property(srna, "active_shape_key", PROP_POINTER, PROP_NONE);
2066 RNA_def_property_struct_type(prop, "ShapeKey");
2067 RNA_def_property_pointer_funcs(prop, "rna_Object_active_shape_key_get", NULL, NULL);
2068 RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key");
2070 prop= RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE);
2071 RNA_def_property_int_sdna(prop, NULL, "shapenr");
2072 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); // XXX this is really unpredictable...
2073 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");
2074 RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index");
2075 RNA_def_property_update(prop, 0, "rna_Object_active_shape_update");
2077 RNA_api_object(srna);
2080 static void rna_def_dupli_object(BlenderRNA *brna)
2085 srna= RNA_def_struct(brna, "DupliObject", NULL);
2086 RNA_def_struct_sdna(srna, "DupliObject");
2087 RNA_def_struct_ui_text(srna, "Object Duplicate", "An object duplicate");
2088 /* RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); */
2090 prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2091 RNA_def_property_pointer_sdna(prop, NULL, "ob");
2092 /* RNA_def_property_pointer_funcs(prop, "rna_DupliObject_object_get", NULL, NULL); */
2093 RNA_def_property_ui_text(prop, "Object", "Object being duplicated");
2095 prop= RNA_def_property(srna, "object_matrix", PROP_FLOAT, PROP_MATRIX);
2096 RNA_def_property_float_sdna(prop, NULL, "omat");
2097 RNA_def_property_array(prop, 16);
2098 RNA_def_property_ui_text(prop, "Object Matrix", "Duplicated object transformation matrix");
2100 prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
2101 RNA_def_property_float_sdna(prop, NULL, "mat");
2102 RNA_def_property_array(prop, 16);
2103 RNA_def_property_ui_text(prop, "Object Duplicate Matrix", "Object duplicate transformation matrix");
2105 /* TODO: DupliObject has more properties that can be wrapped */
2108 static void rna_def_object_base(BlenderRNA *brna)
2113 srna= RNA_def_struct(brna, "ObjectBase", NULL);
2114 RNA_def_struct_sdna(srna, "Base");
2115 RNA_def_struct_ui_text(srna, "Object Base", "An object instance in a scene");
2116 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
2118 prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2119 RNA_def_property_pointer_sdna(prop, NULL, "object");
2120 RNA_def_property_ui_text(prop, "Object", "Object this base links to");
2122 /* same as object layer */
2123 prop= RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER);
2124 RNA_def_property_boolean_sdna(prop, NULL, "lay", 1);
2125 RNA_def_property_array(prop, 20);
2126 RNA_def_property_ui_text(prop, "Layers", "Layers the object base is on");
2127 RNA_def_property_boolean_funcs(prop, NULL, "rna_Base_layer_set");
2128 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Base_layer_update");
2130 prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
2131 RNA_def_property_boolean_sdna(prop, NULL, "flag", BA_SELECT);
2132 RNA_def_property_ui_text(prop, "Selected", "Object base selection state");
2133 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Base_select_update");
2135 prop= RNA_def_property(srna, "selected_user", PROP_BOOLEAN, PROP_NONE);
2136 RNA_def_property_boolean_sdna(prop, NULL, "flag", BA_WAS_SEL);
2137 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2138 RNA_def_property_ui_text(prop, "User Selected", "Object base user selection state, used to restore user selection after transformations");
2140 RNA_api_object_base(srna);
2143 void RNA_def_object(BlenderRNA *brna)
2145 rna_def_object(brna);
2146 rna_def_object_game_settings(brna);
2147 rna_def_object_base(brna);
2148 rna_def_vertex_group(brna);
2149 rna_def_material_slot(brna);
2150 rna_def_dupli_object(brna);