2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Blender Foundation (2008).
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file blender/makesrna/intern/rna_object.c
31 #include "RNA_access.h"
32 #include "RNA_define.h"
33 #include "RNA_enum_types.h"
35 #include "rna_internal.h"
37 #include "DNA_action_types.h"
38 #include "DNA_customdata_types.h"
39 #include "DNA_controller_types.h"
40 #include "DNA_group_types.h"
41 #include "DNA_material_types.h"
42 #include "DNA_mesh_types.h"
43 #include "DNA_object_force.h"
44 #include "DNA_object_types.h"
45 #include "DNA_property_types.h"
46 #include "DNA_scene_types.h"
47 #include "DNA_meta_types.h"
49 #include "BLI_utildefines.h"
51 #include "BKE_tessmesh.h"
52 #include "BKE_group.h" /* needed for object_in_group() */
54 #include "BLO_sys_types.h" /* needed for intptr_t used in ED_mesh.h */
60 EnumPropertyItem object_mode_items[] = {
61 {OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object", ""},
62 {OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit", ""},
63 {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""},
64 {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
65 {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
66 {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
67 {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""},
68 {OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose", ""},
69 {0, NULL, 0, NULL, NULL}
72 static EnumPropertyItem parent_type_items[] = {
73 {PAROBJECT, "OBJECT", 0, "Object", "The object is parented to an object"},
74 {PARCURVE, "CURVE", 0, "Curve", "The object is parented to a curve"},
75 {PARKEY, "KEY", 0, "Key", ""},
76 {PARSKEL, "ARMATURE", 0, "Armature", ""},
77 {PARSKEL, "LATTICE", 0, "Lattice", "The object is parented to a lattice"}, /* PARSKEL reuse will give issues */
78 {PARVERT1, "VERTEX", 0, "Vertex", "The object is parented to a vertex"},
79 {PARVERT3, "VERTEX_3", 0, "3 Vertices", ""},
80 {PARBONE, "BONE", 0, "Bone", "The object is parented to a bone"},
81 {0, NULL, 0, NULL, NULL}
84 static EnumPropertyItem collision_bounds_items[] = {
85 {OB_BOUND_BOX, "BOX", 0, "Box", ""},
86 {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""},
87 {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", ""},
88 {OB_BOUND_CONE, "CONE", 0, "Cone", ""},
89 {OB_BOUND_CONVEX_HULL, "CONVEX_HULL", 0, "Convex Hull", ""},
90 {OB_BOUND_TRIANGLE_MESH, "TRIANGLE_MESH", 0, "Triangle Mesh", ""},
91 {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", ""},
92 /*{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""}, */
93 {0, NULL, 0, NULL, NULL}
96 EnumPropertyItem metaelem_type_items[] = {
97 {MB_BALL, "BALL", ICON_META_BALL, "Ball", ""},
98 {MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""},
99 {MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""},
100 {MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""}, /* NOTE: typo at original definition! */
101 {MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""},
102 {0, NULL, 0, NULL, NULL}
105 /* used for 2 enums */
106 #define OBTYPE_CU_CURVE {OB_CURVE, "CURVE", 0, "Curve", ""}
107 #define OBTYPE_CU_SURF {OB_SURF, "SURFACE", 0, "Surface", ""}
108 #define OBTYPE_CU_FONT {OB_FONT, "FONT", 0, "Font", ""}
110 EnumPropertyItem object_type_items[] = {
111 {OB_MESH, "MESH", 0, "Mesh", ""},
114 {OB_MBALL, "META", 0, "Meta", ""},
116 {0, "", 0, NULL, NULL},
117 {OB_ARMATURE, "ARMATURE", 0, "Armature", ""},
118 {OB_LATTICE, "LATTICE", 0, "Lattice", ""},
119 {OB_EMPTY, "EMPTY", 0, "Empty", ""},
120 {0, "", 0, NULL, NULL},
121 {OB_CAMERA, "CAMERA", 0, "Camera", ""},
122 {OB_LAMP, "LAMP", 0, "Lamp", ""},
123 {OB_SPEAKER, "SPEAKER", 0, "Speaker", ""},
124 {0, NULL, 0, NULL, NULL}
127 EnumPropertyItem object_type_curve_items[] = {
131 {0, NULL, 0, NULL, NULL}
137 #include "BLI_math.h"
139 #include "DNA_key_types.h"
140 #include "DNA_constraint_types.h"
141 #include "DNA_lattice_types.h"
142 #include "DNA_node_types.h"
144 #include "BKE_armature.h"
145 #include "BKE_bullet.h"
146 #include "BKE_constraint.h"
147 #include "BKE_context.h"
148 #include "BKE_curve.h"
149 #include "BKE_depsgraph.h"
150 #include "BKE_effect.h"
152 #include "BKE_object.h"
153 #include "BKE_material.h"
154 #include "BKE_mesh.h"
155 #include "BKE_particle.h"
156 #include "BKE_scene.h"
157 #include "BKE_deform.h"
160 #include "ED_object.h"
161 #include "ED_particle.h"
162 #include "ED_curve.h"
163 #include "ED_lattice.h"
165 static void rna_Object_internal_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
167 DAG_id_tag_update(ptr->id.data, OB_RECALC_OB);
170 static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr)
172 /* don't use compat so we get predictable rotation */
173 BKE_object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat, FALSE, TRUE);
174 rna_Object_internal_update(bmain, scene, ptr);
177 static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
179 DAG_id_type_tag(bmain, ID_OB);
182 static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
184 Object *ob = ptr->id.data;
187 float invmat[4][4]; /* for inverse of parent's matrix */
188 invert_m4_m4(invmat, ob->parent->obmat);
189 mult_m4_m4m4((float(*)[4])values, invmat, ob->obmat);
192 copy_m4_m4((float(*)[4])values, ob->obmat);
196 static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])
198 Object *ob = ptr->id.data;
200 /* localspace matrix is truly relative to the parent, but parameters
201 * stored in object are relative to parentinv matrix. Undo the parent
202 * inverse part before updating obmat and calling apply_obmat() */
205 invert_m4_m4(invmat, ob->parentinv);
206 mult_m4_m4m4(ob->obmat, invmat, (float(*)[4])values);
209 copy_m4_m4(ob->obmat, (float(*)[4])values);
212 /* don't use compat so we get predictable rotation */
213 BKE_object_apply_mat4(ob, ob->obmat, FALSE, FALSE);
216 static void rna_Object_matrix_basis_get(PointerRNA *ptr, float values[16])
218 Object *ob = ptr->id.data;
219 BKE_object_to_mat4(ob, (float(*)[4])values);
222 static void rna_Object_matrix_basis_set(PointerRNA *ptr, const float values[16])
224 Object *ob = ptr->id.data;
225 BKE_object_apply_mat4(ob, (float(*)[4])values, FALSE, FALSE);
228 void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
230 DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
231 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
234 void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
236 Object *ob = ptr->id.data;
238 if (scene->obedit == ob) {
239 /* exit/enter editmode to get new shape */
243 EDBM_mesh_make(scene->toolsettings, scene, ob);
244 EDBM_mesh_normals_update(((Mesh *)ob->data)->edit_btmesh);
245 BMEdit_RecalcTessellation(((Mesh *)ob->data)->edit_btmesh);
259 rna_Object_internal_update_data(bmain, scene, ptr);
262 static void rna_Object_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
264 DAG_id_tag_update(ptr->id.data, OB_RECALC_OB);
266 DAG_scene_sort(bmain, scene);
268 WM_main_add_notifier(NC_OBJECT | ND_PARENT, ptr->id.data);
271 /* when changing the selection flag the scene needs updating */
272 static void rna_Object_select_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
275 Object *ob = (Object *)ptr->id.data;
276 short mode = ob->flag & SELECT ? BA_SELECT : BA_DESELECT;
277 ED_base_object_select(BKE_scene_base_find(scene, ob), mode);
281 static void rna_Base_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
283 Base *base = (Base *)ptr->data;
284 short mode = base->flag & BA_SELECT ? BA_SELECT : BA_DESELECT;
285 ED_base_object_select(base, mode);
288 static void rna_Object_layer_update__internal(Main *bmain, Scene *scene, Base *base, Object *ob)
290 /* try to avoid scene sort */
292 /* pass - unlikely but when running scripts on startup it happens */
294 else if ((ob->lay & scene->lay) && (base->lay & scene->lay)) {
297 else if ((ob->lay & scene->lay) == 0 && (base->lay & scene->lay) == 0) {
301 DAG_scene_sort(bmain, scene);
304 DAG_id_type_tag(bmain, ID_OB);
307 static void rna_Object_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
309 Object *ob = (Object *)ptr->id.data;
312 base = scene ? BKE_scene_base_find(scene, ob) : NULL;
316 SWAP(int, base->lay, ob->lay);
318 rna_Object_layer_update__internal(bmain, scene, base, ob);
321 WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, scene);
324 static void rna_Base_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
326 Base *base = (Base *)ptr->data;
327 Object *ob = (Object *)base->object;
329 rna_Object_layer_update__internal(bmain, scene, base, ob);
332 WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, scene);
335 static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
337 Object *ob = (Object *)ptr->data;
340 if (id == NULL || ob->mode & OB_MODE_EDIT)
343 if (ob->type == OB_EMPTY) {
345 id_us_min((ID *)ob->data);
349 if (id && GS(id->name) == ID_IM) {
354 else if (ob->type == OB_MESH) {
355 set_mesh(ob, (Mesh *)id);
359 id_us_min((ID *)ob->data);
362 /* no need to type-check here ID. this is done in the _typef() function */
363 BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name)));
368 test_object_materials(id);
370 if (GS(id->name) == ID_CU)
371 BKE_curve_type_test(ob);
372 else if (ob->type == OB_ARMATURE)
373 BKE_pose_rebuild(ob, ob->data);
377 static StructRNA *rna_Object_data_typef(PointerRNA *ptr)
379 Object *ob = (Object *)ptr->data;
381 /* keep in sync with OB_DATA_SUPPORT_ID() macro */
383 case OB_EMPTY: return &RNA_Image;
384 case OB_MESH: return &RNA_Mesh;
385 case OB_CURVE: return &RNA_Curve;
386 case OB_SURF: return &RNA_Curve;
387 case OB_FONT: return &RNA_Curve;
388 case OB_MBALL: return &RNA_MetaBall;
389 case OB_LAMP: return &RNA_Lamp;
390 case OB_CAMERA: return &RNA_Camera;
391 case OB_LATTICE: return &RNA_Lattice;
392 case OB_ARMATURE: return &RNA_Armature;
393 case OB_SPEAKER: return &RNA_Speaker;
394 default: return &RNA_ID;
398 static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value)
400 Object *ob = (Object *)ptr->data;
401 Object *par = (Object *)value.data;
404 /* NOTE: this dummy check here prevents this method causing weird runtime errors on mingw 4.6.2 */
408 ED_object_parent(ob, par, ob->partype, ob->parsubstr);
412 static void rna_Object_parent_type_set(PointerRNA *ptr, int value)
414 Object *ob = (Object *)ptr->data;
416 ED_object_parent(ob, ob->parent, value, ob->parsubstr);
419 static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *UNUSED(C), PointerRNA *ptr,
420 PropertyRNA *UNUSED(prop), int *free)
422 Object *ob = (Object *)ptr->data;
423 EnumPropertyItem *item = NULL;
426 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PAROBJECT);
429 Object *par = ob->parent;
431 if (par->type == OB_CURVE)
432 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARCURVE);
433 else if (par->type == OB_LATTICE)
434 /* special hack: prevents this overriding others */
435 RNA_enum_items_add_value(&item, &totitem, &parent_type_items[4], PARSKEL);
436 else if (par->type == OB_ARMATURE) {
437 /* special hack: prevents this being overrided */
438 RNA_enum_items_add_value(&item, &totitem, &parent_type_items[3], PARSKEL);
439 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARBONE);
441 else if (par->type == OB_MESH) {
442 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT1);
443 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT3);
447 RNA_enum_item_end(&item, &totitem);
453 static EnumPropertyItem *rna_Object_collision_bounds_itemf(bContext *UNUSED(C), PointerRNA *ptr,
454 PropertyRNA *UNUSED(prop), int *free)
456 Object *ob = (Object *)ptr->data;
457 EnumPropertyItem *item = NULL;
460 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_TRIANGLE_MESH);
461 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CONVEX_HULL);
463 if (ob->body_type != OB_BODY_TYPE_SOFT) {
464 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CONE);
465 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CYLINDER);
466 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_SPHERE);
467 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_BOX);
468 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CAPSULE);
471 RNA_enum_item_end(&item, &totitem);
477 static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value)
479 Object *ob = (Object *)ptr->data;
481 ED_object_parent(ob, ob->parent, ob->partype, value);
484 static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value)
486 Object *ob = (Object *)ptr->data;
487 Group *grp = (Group *)value.data;
489 /* must not let this be set if the object belongs in this group already,
490 * thus causing a cycle/infinite-recursion leading to crashes on load [#25298]
492 if (object_in_group(ob, grp) == 0)
495 BKE_report(NULL, RPT_ERROR,
496 "Cannot set dupli-group as object belongs in group being instanced thus causing a cycle");
499 void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
501 Object *ob = (Object *)ptr->id.data;
502 bDeformGroup *dg = (bDeformGroup *)ptr->data;
503 BLI_strncpy_utf8(dg->name, value, sizeof(dg->name));
504 defgroup_unique_name(dg, ob);
507 static int rna_VertexGroup_index_get(PointerRNA *ptr)
509 Object *ob = (Object *)ptr->id.data;
511 return BLI_findindex(&ob->defbase, ptr->data);
514 static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr)
516 Object *ob = (Object *)ptr->id.data;
517 return rna_pointer_inherit_refine(ptr, &RNA_VertexGroup, BLI_findlink(&ob->defbase, ob->actdef - 1));
520 static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr)
522 Object *ob = (Object *)ptr->id.data;
523 return ob->actdef - 1;
526 static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value)
528 Object *ob = (Object *)ptr->id.data;
529 ob->actdef = value + 1;
532 static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
534 Object *ob = (Object *)ptr->id.data;
537 *max = BLI_countlist(&ob->defbase) - 1;
538 *max = MAX2(0, *max);
541 void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
543 Object *ob = (Object *)ptr->id.data;
546 dg = BLI_findlink(&ob->defbase, index - 1);
548 if (dg) BLI_strncpy(value, dg->name, sizeof(dg->name));
549 else value[0] = '\0';
552 int rna_object_vgroup_name_index_length(PointerRNA *ptr, int index)
554 Object *ob = (Object *)ptr->id.data;
557 dg = BLI_findlink(&ob->defbase, index - 1);
558 return (dg) ? strlen(dg->name) : 0;
561 void rna_object_vgroup_name_index_set(PointerRNA *ptr, const char *value, short *index)
563 Object *ob = (Object *)ptr->id.data;
564 *index = defgroup_name_index(ob, value) + 1;
567 void rna_object_vgroup_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
569 Object *ob = (Object *)ptr->id.data;
570 bDeformGroup *dg = defgroup_find_name(ob, value);
572 BLI_strncpy(result, value, maxlen); /* no need for BLI_strncpy_utf8, since this matches an existing group */
579 void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
581 Object *ob = (Object *)ptr->id.data;
583 CustomDataLayer *layer;
586 if (ob->type == OB_MESH && ob->data) {
587 me = (Mesh *)ob->data;
589 for (a = 0; a < me->pdata.totlayer; a++) {
590 layer = &me->pdata.layers[a];
592 if (layer->type == CD_MTEXPOLY && strcmp(layer->name, value) == 0) {
593 BLI_strncpy(result, value, maxlen);
602 void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
604 Object *ob = (Object *)ptr->id.data;
606 CustomDataLayer *layer;
609 if (ob->type == OB_MESH && ob->data) {
610 me = (Mesh *)ob->data;
612 for (a = 0; a < me->fdata.totlayer; a++) {
613 layer = &me->fdata.layers[a];
615 if (layer->type == CD_MCOL && strcmp(layer->name, value) == 0) {
616 BLI_strncpy(result, value, maxlen);
625 static int rna_Object_active_material_index_get(PointerRNA *ptr)
627 Object *ob = (Object *)ptr->id.data;
628 return MAX2(ob->actcol - 1, 0);
631 static void rna_Object_active_material_index_set(PointerRNA *ptr, int value)
633 Object *ob = (Object *)ptr->id.data;
634 ob->actcol = value + 1;
636 if (ob->type == OB_MESH) {
640 me->edit_btmesh->mat_nr = value;
644 static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
646 Object *ob = (Object *)ptr->id.data;
648 *max = MAX2(ob->totcol - 1, 0);
651 /* returns active base material */
652 static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
654 Object *ob = (Object *)ptr->id.data;
657 ma = (ob->totcol) ? give_current_material(ob, ob->actcol) : NULL;
658 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
661 static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value)
663 Object *ob = (Object *)ptr->id.data;
665 DAG_id_tag_update(value.data, 0);
666 assign_material(ob, value.data, ob->actcol);
669 static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int *min, int *max,
670 int *softmin, int *softmax)
672 Object *ob = (Object *)ptr->id.data;
674 *max = BLI_countlist(&ob->particlesystem) - 1;
675 *max = MAX2(0, *max);
678 static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
680 Object *ob = (Object *)ptr->id.data;
681 return psys_get_current_num(ob);
684 static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int value)
686 Object *ob = (Object *)ptr->id.data;
687 psys_set_current_num(ob, value);
690 static void rna_Object_particle_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
692 Object *ob = (Object *)ptr->id.data;
694 PE_current_changed(scene, ob);
697 /* rotation - axis-angle */
698 static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value)
700 Object *ob = ptr->data;
702 /* for now, assume that rotation mode is axis-angle */
703 value[0] = ob->rotAngle;
704 copy_v3_v3(&value[1], ob->rotAxis);
707 /* rotation - axis-angle */
708 static void rna_Object_rotation_axis_angle_set(PointerRNA *ptr, const float *value)
710 Object *ob = ptr->data;
712 /* for now, assume that rotation mode is axis-angle */
713 ob->rotAngle = value[0];
714 copy_v3_v3(ob->rotAxis, (float *)&value[1]);
716 /* TODO: validate axis? */
719 static void rna_Object_rotation_mode_set(PointerRNA *ptr, int value)
721 Object *ob = ptr->data;
723 /* use API Method for conversions... */
724 BKE_rotMode_change_values(ob->quat, ob->rot, ob->rotAxis, &ob->rotAngle, ob->rotmode, (short)value);
726 /* finally, set the new rotation type */
730 static void rna_Object_dimensions_get(PointerRNA *ptr, float *value)
732 Object *ob = ptr->data;
733 BKE_object_dimensions_get(ob, value);
736 static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value)
738 Object *ob = ptr->data;
739 BKE_object_dimensions_set(ob, value);
742 static int rna_Object_location_editable(PointerRNA *ptr, int index)
744 Object *ob = (Object *)ptr->data;
746 /* only if the axis in question is locked, not editable... */
747 if ((index == 0) && (ob->protectflag & OB_LOCK_LOCX))
749 else if ((index == 1) && (ob->protectflag & OB_LOCK_LOCY))
751 else if ((index == 2) && (ob->protectflag & OB_LOCK_LOCZ))
754 return PROP_EDITABLE;
757 static int rna_Object_scale_editable(PointerRNA *ptr, int index)
759 Object *ob = (Object *)ptr->data;
761 /* only if the axis in question is locked, not editable... */
762 if ((index == 0) && (ob->protectflag & OB_LOCK_SCALEX))
764 else if ((index == 1) && (ob->protectflag & OB_LOCK_SCALEY))
766 else if ((index == 2) && (ob->protectflag & OB_LOCK_SCALEZ))
769 return PROP_EDITABLE;
772 static int rna_Object_rotation_euler_editable(PointerRNA *ptr, int index)
774 Object *ob = (Object *)ptr->data;
776 /* only if the axis in question is locked, not editable... */
777 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTX))
779 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTY))
781 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTZ))
784 return PROP_EDITABLE;
787 static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index)
789 Object *ob = (Object *)ptr->data;
791 /* only consider locks if locking components individually... */
792 if (ob->protectflag & OB_LOCK_ROT4D) {
793 /* only if the axis in question is locked, not editable... */
794 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTW))
796 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTX))
798 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTY))
800 else if ((index == 3) && (ob->protectflag & OB_LOCK_ROTZ))
804 return PROP_EDITABLE;
808 static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr)
810 Object *ob = (Object *)ptr->id.data;
812 int index = (Material **)ptr->data - ob->mat;
814 ma = give_current_material(ob, index + 1);
815 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
818 static void rna_MaterialSlot_material_set(PointerRNA *ptr, PointerRNA value)
820 Object *ob = (Object *)ptr->id.data;
821 int index = (Material **)ptr->data - ob->mat;
823 assign_material(ob, value.data, index + 1);
826 static int rna_MaterialSlot_link_get(PointerRNA *ptr)
828 Object *ob = (Object *)ptr->id.data;
829 int index = (Material **)ptr->data - ob->mat;
831 return ob->matbits[index] != 0;
834 static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value)
836 Object *ob = (Object *)ptr->id.data;
837 int index = (Material **)ptr->data - ob->mat;
840 ob->matbits[index] = 1;
841 /* ob->colbits |= (1<<index); */ /* DEPRECATED */
844 ob->matbits[index] = 0;
845 /* ob->colbits &= ~(1<<index); */ /* DEPRECATED */
849 static int rna_MaterialSlot_name_length(PointerRNA *ptr)
851 Object *ob = (Object *)ptr->id.data;
853 int index = (Material **)ptr->data - ob->mat;
855 ma = give_current_material(ob, index + 1);
858 return strlen(ma->id.name + 2);
863 static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str)
865 Object *ob = (Object *)ptr->id.data;
867 int index = (Material **)ptr->data - ob->mat;
869 ma = give_current_material(ob, index + 1);
872 strcpy(str, ma->id.name + 2);
877 static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr)
879 rna_Object_internal_update(bmain, scene, ptr);
880 WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, ptr->id.data);
883 /* why does this have to be so complicated?, can't all this crap be
884 * moved to in BGE conversion function? - Campbell *
886 * logic from check_body_type()
888 static int rna_GameObjectSettings_physics_type_get(PointerRNA *ptr)
890 Object *ob = (Object *)ptr->id.data;
892 /* determine the body_type setting based on flags */
893 if (!(ob->gameflag & OB_COLLISION)) {
894 if (ob->gameflag & OB_OCCLUDER) {
895 ob->body_type = OB_BODY_TYPE_OCCLUDER;
897 else if (ob->gameflag & OB_NAVMESH) {
898 ob->body_type = OB_BODY_TYPE_NAVMESH;
901 ob->body_type = OB_BODY_TYPE_NO_COLLISION;
904 else if (ob->gameflag & OB_CHARACTER) {
905 ob->body_type = OB_BODY_TYPE_CHARACTER;
907 else if (ob->gameflag & OB_SENSOR) {
908 ob->body_type = OB_BODY_TYPE_SENSOR;
910 else if (!(ob->gameflag & OB_DYNAMIC)) {
911 ob->body_type = OB_BODY_TYPE_STATIC;
913 else if (!(ob->gameflag & (OB_RIGID_BODY | OB_SOFT_BODY))) {
914 ob->body_type = OB_BODY_TYPE_DYNAMIC;
916 else if (ob->gameflag & OB_RIGID_BODY) {
917 ob->body_type = OB_BODY_TYPE_RIGID;
920 ob->body_type = OB_BODY_TYPE_SOFT;
921 /* create the structure here because we display soft body buttons in the main panel */
923 ob->bsoft = bsbNew();
926 return ob->body_type;
929 static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value)
931 Object *ob = (Object *)ptr->id.data;
932 const int was_navmesh = (ob->gameflag & OB_NAVMESH);
933 ob->body_type = value;
935 switch (ob->body_type) {
936 case OB_BODY_TYPE_SENSOR:
937 ob->gameflag |= OB_SENSOR | OB_COLLISION | OB_GHOST;
938 ob->gameflag &= ~(OB_OCCLUDER | OB_CHARACTER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR |
939 OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH);
941 case OB_BODY_TYPE_OCCLUDER:
942 ob->gameflag |= OB_OCCLUDER;
943 ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_DYNAMIC | OB_NAVMESH);
945 case OB_BODY_TYPE_NAVMESH:
946 ob->gameflag |= OB_NAVMESH;
947 ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_DYNAMIC | OB_OCCLUDER);
949 if (ob->type == OB_MESH) {
950 /* could be moved into mesh UI but for now ensure mesh data layer */
951 BKE_mesh_ensure_navmesh(ob->data);
955 case OB_BODY_TYPE_NO_COLLISION:
956 ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH);
958 case OB_BODY_TYPE_CHARACTER:
959 ob->gameflag |= OB_COLLISION | OB_GHOST | OB_CHARACTER;
960 ob->gameflag &= ~(OB_SENSOR | OB_OCCLUDER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR |
961 OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH);
963 case OB_BODY_TYPE_STATIC:
964 ob->gameflag |= OB_COLLISION;
965 ob->gameflag &= ~(OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
967 case OB_BODY_TYPE_DYNAMIC:
968 ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_ACTOR;
969 ob->gameflag &= ~(OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
971 case OB_BODY_TYPE_RIGID:
972 ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_RIGID_BODY | OB_ACTOR;
973 ob->gameflag &= ~(OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
976 case OB_BODY_TYPE_SOFT:
977 ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_SOFT_BODY | OB_ACTOR;
978 ob->gameflag &= ~(OB_RIGID_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
980 /* assume triangle mesh, if no bounds chosen for soft body */
981 if ((ob->gameflag & OB_BOUNDS) && (ob->boundtype < OB_BOUND_TRIANGLE_MESH)) {
982 ob->boundtype = OB_BOUND_TRIANGLE_MESH;
984 /* create a BulletSoftBody structure if not already existing */
986 ob->bsoft = bsbNew();
990 if (was_navmesh != (ob->gameflag & OB_NAVMESH)) {
991 if (ob->type == OB_MESH) {
992 /* this is needed to refresh the derived meshes draw func */
993 DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
997 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
1000 static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr)
1002 Object *ob = (Object *)ptr->id.data;
1003 ParticleSystem *psys = psys_get_current(ob);
1004 return rna_pointer_inherit_refine(ptr, &RNA_ParticleSystem, psys);
1007 static PointerRNA rna_Object_game_settings_get(PointerRNA *ptr)
1009 return rna_pointer_inherit_refine(ptr, &RNA_GameObjectSettings, ptr->id.data);
1013 static unsigned int rna_Object_layer_validate__internal(const int *values, unsigned int lay)
1017 /* ensure we always have some layer selected */
1018 for (i = 0; i < 20; i++)
1025 for (i = 0; i < 20; i++) {
1026 if (values[i]) lay |= (1 << i);
1027 else lay &= ~(1 << i);
1033 static void rna_Object_layer_set(PointerRNA *ptr, const int *values)
1035 Object *ob = (Object *)ptr->data;
1038 lay = rna_Object_layer_validate__internal(values, ob->lay);
1043 static void rna_Base_layer_set(PointerRNA *ptr, const int *values)
1045 Base *base = (Base *)ptr->data;
1048 lay = rna_Object_layer_validate__internal(values, base->lay);
1052 /* rna_Base_layer_update updates the objects layer */
1055 static void rna_GameObjectSettings_state_get(PointerRNA *ptr, int *values)
1057 Object *ob = (Object *)ptr->data;
1059 int all_states = (ob->scaflag & OB_ALLSTATE ? 1 : 0);
1061 memset(values, 0, sizeof(int) * OB_MAX_STATES);
1062 for (i = 0; i < OB_MAX_STATES; i++)
1063 values[i] = (ob->state & (1 << i)) | all_states;
1066 static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values)
1068 Object *ob = (Object *)ptr->data;
1071 /* ensure we always have some state selected */
1072 for (i = 0; i < OB_MAX_STATES; i++)
1079 for (i = 0; i < OB_MAX_STATES; i++) {
1080 if (values[i]) ob->state |= (1 << i);
1081 else ob->state &= ~(1 << i);
1085 static void rna_GameObjectSettings_used_state_get(PointerRNA *ptr, int *values)
1087 Object *ob = (Object *)ptr->data;
1090 memset(values, 0, sizeof(int) * OB_MAX_STATES);
1091 for (cont = ob->controllers.first; cont; cont = cont->next) {
1094 for (i = 0; i < OB_MAX_STATES; i++) {
1095 if (cont->state_mask & (1 << i))
1101 static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
1103 Object *ob = (Object *)ptr->id.data;
1104 Key *key = ob_get_key(ob);
1108 *max = BLI_countlist(&key->block) - 1;
1109 if (*max < 0) *max = 0;
1116 static int rna_Object_active_shape_key_index_get(PointerRNA *ptr)
1118 Object *ob = (Object *)ptr->id.data;
1120 return MAX2(ob->shapenr - 1, 0);
1123 static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value)
1125 Object *ob = (Object *)ptr->id.data;
1127 ob->shapenr = value + 1;
1130 static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr)
1132 Object *ob = (Object *)ptr->id.data;
1133 Key *key = ob_get_key(ob);
1138 return PointerRNA_NULL;
1140 kb = BLI_findlink(&key->block, ob->shapenr - 1);
1141 RNA_pointer_create((ID *)key, &RNA_ShapeKey, kb, &keyptr);
1145 static PointerRNA rna_Object_field_get(PointerRNA *ptr)
1147 Object *ob = (Object *)ptr->id.data;
1151 ob->pd = object_add_collision_fields(0);
1153 return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, ob->pd);
1156 static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
1158 Object *ob = (Object *)ptr->id.data;
1160 if (ob->type != OB_MESH)
1161 return PointerRNA_NULL;
1165 ob->pd = object_add_collision_fields(0);
1167 return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd);
1170 static PointerRNA rna_Object_active_constraint_get(PointerRNA *ptr)
1172 Object *ob = (Object *)ptr->id.data;
1173 bConstraint *con = constraints_get_active(&ob->constraints);
1174 return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con);
1177 static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value)
1179 Object *ob = (Object *)ptr->id.data;
1180 constraints_set_active(&ob->constraints, (bConstraint *)value.data);
1183 static bConstraint *rna_Object_constraints_new(Object *object, int type)
1185 WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, object);
1186 return add_ob_constraint(object, NULL, type);
1189 static void rna_Object_constraints_remove(Object *object, ReportList *reports, bConstraint *con)
1191 if (BLI_findindex(&object->constraints, con) == -1) {
1192 BKE_reportf(reports, RPT_ERROR, "Constraint '%s' not found in object '%s'", con->name, object->id.name + 2);
1196 remove_constraint(&object->constraints, con);
1197 ED_object_constraint_update(object);
1198 ED_object_constraint_set_active(object, NULL);
1199 WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
1202 static void rna_Object_constraints_clear(Object *object)
1204 free_constraints(&object->constraints);
1206 ED_object_constraint_update(object);
1207 ED_object_constraint_set_active(object, NULL);
1209 WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
1212 static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports,
1213 const char *name, int type)
1215 return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
1218 static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, ModifierData *md)
1220 ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md);
1222 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1225 static void rna_Object_modifier_clear(Object *object, bContext *C)
1227 ED_object_modifier_clear(CTX_data_main(C), CTX_data_scene(C), object);
1229 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1232 static void rna_Object_boundbox_get(PointerRNA *ptr, float *values)
1234 Object *ob = (Object *)ptr->id.data;
1235 BoundBox *bb = BKE_object_boundbox_get(ob);
1237 memcpy(values, bb->vec, sizeof(bb->vec));
1240 fill_vn_fl(values, sizeof(bb->vec) / sizeof(float), 0.0f);
1245 static bDeformGroup *rna_Object_vgroup_new(Object *ob, const char *name)
1247 bDeformGroup *defgroup = ED_vgroup_add_name(ob, name);
1249 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1254 static void rna_Object_vgroup_remove(Object *ob, bDeformGroup *defgroup)
1256 ED_vgroup_delete(ob, defgroup);
1258 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1261 static void rna_Object_vgroup_clear(Object *ob)
1263 ED_vgroup_clear(ob);
1265 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1268 static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *reports, int index_len,
1269 int *index, float weight, int assignmode)
1271 Object *ob = (Object *)id;
1273 if (ED_vgroup_object_is_edit_mode(ob)) {
1274 BKE_reportf(reports, RPT_ERROR, "VertexGroup.add(): Can't be called while object is in edit mode");
1279 ED_vgroup_vert_add(ob, def, *index++, weight, assignmode); /* XXX, not efficient calling within loop*/
1281 WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
1284 static void rna_VertexGroup_vertex_remove(ID *id, bDeformGroup *dg, ReportList *reports, int index_len, int *index)
1286 Object *ob = (Object *)id;
1288 if (ED_vgroup_object_is_edit_mode(ob)) {
1289 BKE_reportf(reports, RPT_ERROR, "VertexGroup.remove(): Can't be called while object is in edit mode");
1294 ED_vgroup_vert_remove(ob, dg, *index++);
1296 WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
1299 static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *reports, int index)
1301 float weight = ED_vgroup_vert_weight((Object *)id, dg, index);
1304 BKE_reportf(reports, RPT_ERROR, "Vertex not in group");
1309 /* generic poll functions */
1310 int rna_Lattice_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1312 return ((Object *)value.id.data)->type == OB_LATTICE;
1315 int rna_Curve_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1317 return ((Object *)value.id.data)->type == OB_CURVE;
1320 int rna_Armature_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1322 return ((Object *)value.id.data)->type == OB_ARMATURE;
1325 int rna_Mesh_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1327 return ((Object *)value.id.data)->type == OB_MESH;
1330 int rna_Camera_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1332 return ((Object *)value.id.data)->type == OB_CAMERA;
1337 static int rna_matrix_dimsize_4x4[] = {4, 4};
1339 static void rna_def_vertex_group(BlenderRNA *brna)
1345 static EnumPropertyItem assign_mode_items[] = {
1346 {WEIGHT_REPLACE, "REPLACE", 0, "Replace", "Replace"},
1347 {WEIGHT_ADD, "ADD", 0, "Add", "Add"},
1348 {WEIGHT_SUBTRACT, "SUBTRACT", 0, "Subtract", "Subtract"},
1349 {0, NULL, 0, NULL, NULL}
1352 srna = RNA_def_struct(brna, "VertexGroup", NULL);
1353 RNA_def_struct_sdna(srna, "bDeformGroup");
1354 RNA_def_struct_ui_text(srna, "Vertex Group", "Group of vertices, used for armature deform and other purposes");
1355 RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX);
1357 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1358 RNA_def_property_ui_text(prop, "Name", "Vertex group name");
1359 RNA_def_struct_name_property(srna, prop);
1360 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_VertexGroup_name_set");
1361 /* update data because modifiers may use [#24761] */
1362 RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
1364 prop = RNA_def_property(srna, "lock_weight", PROP_BOOLEAN, PROP_NONE);
1365 RNA_def_property_ui_text(prop, "", "Maintain the relative weights for the group");
1366 RNA_def_property_boolean_sdna(prop, NULL, "flag", 0);
1367 /* update data because modifiers may use [#24761] */
1368 RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
1370 prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
1371 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1372 RNA_def_property_int_funcs(prop, "rna_VertexGroup_index_get", NULL, NULL);
1373 RNA_def_property_ui_text(prop, "Index", "Index number of the vertex group");
1375 func = RNA_def_function(srna, "add", "rna_VertexGroup_vertex_add");
1376 RNA_def_function_ui_description(func, "Add vertices to the group");
1377 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
1378 /* TODO, see how array size of 0 works, this shouldnt be used */
1379 prop = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
1380 RNA_def_property_flag(prop, PROP_DYNAMIC | PROP_REQUIRED);
1381 prop = RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight", 0.0f, 1.0f);
1382 RNA_def_property_flag(prop, PROP_REQUIRED);
1383 prop = RNA_def_enum(func, "type", assign_mode_items, 0, "", "Vertex assign mode");
1384 RNA_def_property_flag(prop, PROP_REQUIRED);
1386 func = RNA_def_function(srna, "remove", "rna_VertexGroup_vertex_remove");
1387 RNA_def_function_ui_description(func, "Remove a vertex from the group");
1388 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
1389 /* TODO, see how array size of 0 works, this shouldnt be used */
1390 prop = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
1391 RNA_def_property_flag(prop, PROP_DYNAMIC | PROP_REQUIRED);
1393 func = RNA_def_function(srna, "weight", "rna_VertexGroup_weight");
1394 RNA_def_function_ui_description(func, "Get a vertex weight from the group");
1395 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
1396 prop = RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "The index of the vertex", 0, INT_MAX);
1397 RNA_def_property_flag(prop, PROP_REQUIRED);
1398 prop = RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight", 0.0f, 1.0f);
1399 RNA_def_function_return(func, prop);
1402 static void rna_def_material_slot(BlenderRNA *brna)
1407 static EnumPropertyItem link_items[] = {
1408 {1, "OBJECT", 0, "Object", ""},
1409 {0, "DATA", 0, "Data", ""},
1410 {0, NULL, 0, NULL, NULL}
1413 /* NOTE: there is no MaterialSlot equivalent in DNA, so the internal
1414 * pointer data points to ob->mat + index, and we manually implement
1415 * get/set for the properties. */
1417 srna = RNA_def_struct(brna, "MaterialSlot", NULL);
1418 RNA_def_struct_ui_text(srna, "Material Slot", "Material slot in an object");
1419 RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
1421 prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
1422 RNA_def_property_struct_type(prop, "Material");
1423 RNA_def_property_flag(prop, PROP_EDITABLE);
1424 RNA_def_property_pointer_funcs(prop, "rna_MaterialSlot_material_get", "rna_MaterialSlot_material_set", NULL, NULL);
1425 RNA_def_property_ui_text(prop, "Material", "Material datablock used by this material slot");
1426 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
1428 prop = RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE);
1429 RNA_def_property_enum_items(prop, link_items);
1430 RNA_def_property_enum_funcs(prop, "rna_MaterialSlot_link_get", "rna_MaterialSlot_link_set", NULL);
1431 RNA_def_property_ui_text(prop, "Link", "Link material to object or the object's data");
1432 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
1434 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1435 RNA_def_property_string_funcs(prop, "rna_MaterialSlot_name_get", "rna_MaterialSlot_name_length", NULL);
1436 RNA_def_property_ui_text(prop, "Name", "Material slot name");
1437 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1438 RNA_def_struct_name_property(srna, prop);
1441 static void rna_def_object_game_settings(BlenderRNA *brna)
1446 static EnumPropertyItem body_type_items[] = {
1447 {OB_BODY_TYPE_NO_COLLISION, "NO_COLLISION", 0, "No Collision", "Disable collision for this object"},
1448 {OB_BODY_TYPE_STATIC, "STATIC", 0, "Static", "Stationary object"},
1449 {OB_BODY_TYPE_DYNAMIC, "DYNAMIC", 0, "Dynamic", "Linear physics"},
1450 {OB_BODY_TYPE_RIGID, "RIGID_BODY", 0, "Rigid Body", "Linear and angular physics"},
1451 {OB_BODY_TYPE_SOFT, "SOFT_BODY", 0, "Soft Body", "Soft body"},
1452 {OB_BODY_TYPE_OCCLUDER, "OCCLUDE", 0, "Occlude", "Occluder for optimizing scene rendering"},
1453 {OB_BODY_TYPE_SENSOR, "SENSOR", 0, "Sensor",
1454 "Collision Sensor, detects static and dynamic objects but not the other "
1455 "collision sensor objects"},
1456 {OB_BODY_TYPE_NAVMESH, "NAVMESH", 0, "Navigation Mesh", "Navigation mesh"},
1457 {OB_BODY_TYPE_CHARACTER, "CHARACTER", 0, "Character",
1458 "Simple kinematic physics appropriate for game characters"},
1459 {0, NULL, 0, NULL, NULL}
1462 srna = RNA_def_struct(brna, "GameObjectSettings", NULL);
1463 RNA_def_struct_sdna(srna, "Object");
1464 RNA_def_struct_nested(brna, srna, "Object");
1465 RNA_def_struct_ui_text(srna, "Game Object Settings", "Game engine related settings for the object");
1466 RNA_def_struct_ui_icon(srna, ICON_GAME);
1470 prop = RNA_def_property(srna, "sensors", PROP_COLLECTION, PROP_NONE);
1471 RNA_def_property_struct_type(prop, "Sensor");
1472 RNA_def_property_ui_text(prop, "Sensors", "Game engine sensor to detect events");
1474 prop = RNA_def_property(srna, "controllers", PROP_COLLECTION, PROP_NONE);
1475 RNA_def_property_struct_type(prop, "Controller");
1476 RNA_def_property_ui_text(prop, "Controllers",
1477 "Game engine controllers to process events, connecting sensors to actuators");
1479 prop = RNA_def_property(srna, "actuators", PROP_COLLECTION, PROP_NONE);
1480 RNA_def_property_struct_type(prop, "Actuator");
1481 RNA_def_property_ui_text(prop, "Actuators", "Game engine actuators to act on events");
1483 prop = RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE);
1484 RNA_def_property_collection_sdna(prop, NULL, "prop", NULL);
1485 RNA_def_property_struct_type(prop, "GameProperty"); /* rna_property.c */
1486 RNA_def_property_ui_text(prop, "Properties", "Game engine properties");
1488 prop = RNA_def_property(srna, "show_sensors", PROP_BOOLEAN, PROP_NONE);
1489 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSENS);
1490 RNA_def_property_ui_text(prop, "Show Sensors", "Shows sensors for this object in the user interface");
1492 prop = RNA_def_property(srna, "show_controllers", PROP_BOOLEAN, PROP_NONE);
1493 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWCONT);
1494 RNA_def_property_ui_text(prop, "Show Controllers", "Shows controllers for this object in the user interface");
1496 prop = RNA_def_property(srna, "show_actuators", PROP_BOOLEAN, PROP_NONE);
1497 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWACT);
1498 RNA_def_property_ui_text(prop, "Show Actuators", "Shows actuators for this object in the user interface");
1502 prop = RNA_def_property(srna, "physics_type", PROP_ENUM, PROP_NONE);
1503 RNA_def_property_enum_sdna(prop, NULL, "body_type");
1504 RNA_def_property_enum_items(prop, body_type_items);
1505 RNA_def_property_enum_funcs(prop, "rna_GameObjectSettings_physics_type_get",
1506 "rna_GameObjectSettings_physics_type_set", NULL);
1507 RNA_def_property_ui_text(prop, "Physics Type", "Select the type of physical representation");
1508 RNA_def_property_update(prop, NC_LOGIC, NULL);
1510 prop = RNA_def_property(srna, "use_actor", PROP_BOOLEAN, PROP_NONE);
1511 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ACTOR);
1512 RNA_def_property_ui_text(prop, "Actor", "Object is detected by the Near and Radar sensor");
1514 prop = RNA_def_property(srna, "use_ghost", PROP_BOOLEAN, PROP_NONE);
1515 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_GHOST);
1516 RNA_def_property_ui_text(prop, "Ghost", "Object does not react to collisions, like a ghost");
1518 prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE);
1519 RNA_def_property_range(prop, 0.01, 10000.0);
1520 RNA_def_property_ui_text(prop, "Mass", "Mass of the object");
1522 prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
1523 RNA_def_property_float_sdna(prop, NULL, "inertia");
1524 RNA_def_property_range(prop, 0.01f, FLT_MAX);
1525 RNA_def_property_ui_range(prop, 0.01f, 10.0f, 1, 3);
1526 RNA_def_property_ui_text(prop, "Radius", "Radius of bounding sphere and material physics");
1527 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
1529 prop = RNA_def_property(srna, "use_sleep", PROP_BOOLEAN, PROP_NONE);
1530 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_COLLISION_RESPONSE);
1531 RNA_def_property_ui_text(prop, "No Sleeping", "Disable auto (de)activation in physics simulation");
1533 prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE);
1534 RNA_def_property_float_sdna(prop, NULL, "damping");
1535 RNA_def_property_range(prop, 0.0, 1.0);
1536 RNA_def_property_ui_text(prop, "Damping", "General movement damping");
1538 prop = RNA_def_property(srna, "rotation_damping", PROP_FLOAT, PROP_NONE);
1539 RNA_def_property_float_sdna(prop, NULL, "rdamping");
1540 RNA_def_property_range(prop, 0.0, 1.0);
1541 RNA_def_property_ui_text(prop, "Rotation Damping", "General rotation damping");
1543 prop = RNA_def_property(srna, "velocity_min", PROP_FLOAT, PROP_NONE);
1544 RNA_def_property_float_sdna(prop, NULL, "min_vel");
1545 RNA_def_property_range(prop, 0.0, 1000.0);
1546 RNA_def_property_ui_text(prop, "Velocity Min", "Clamp velocity to this minimum speed (except when totally still)");
1548 prop = RNA_def_property(srna, "velocity_max", PROP_FLOAT, PROP_NONE);
1549 RNA_def_property_float_sdna(prop, NULL, "max_vel");
1550 RNA_def_property_range(prop, 0.0, 1000.0);
1551 RNA_def_property_ui_text(prop, "Velocity Max", "Clamp velocity to this maximum speed");
1553 prop = RNA_def_property(srna, "step_height", PROP_FLOAT, PROP_NONE);
1554 RNA_def_property_float_sdna(prop, NULL, "step_height");
1555 RNA_def_property_range(prop, 0.0, 1.0);
1556 RNA_def_property_ui_text(prop, "Step Height", "Maximum height of steps the character can run over");
1558 prop = RNA_def_property(srna, "jump_speed", PROP_FLOAT, PROP_NONE);
1559 RNA_def_property_float_sdna(prop, NULL, "jump_speed");
1560 RNA_def_property_range(prop, 0.0, 1000.0);
1561 RNA_def_property_ui_text(prop, "Jump Force", "Upward velocity applied to the character when jumping (with the Motion actuator)");
1563 prop = RNA_def_property(srna, "fall_speed", PROP_FLOAT, PROP_NONE);
1564 RNA_def_property_float_sdna(prop, NULL, "fall_speed");
1565 RNA_def_property_range(prop, 0.0, 1000.0);
1566 RNA_def_property_ui_text(prop, "Fall Speed Max", "Maximum speed at which the character will fall");
1570 prop = RNA_def_property(srna, "lock_location_x", PROP_BOOLEAN, PROP_NONE);
1571 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_AXIS);
1572 RNA_def_property_ui_text(prop, "Lock X Axis", "Disable simulation of linear motion along the X axis");
1574 prop = RNA_def_property(srna, "lock_location_y", PROP_BOOLEAN, PROP_NONE);
1575 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_AXIS);
1576 RNA_def_property_ui_text(prop, "Lock Y Axis", "Disable simulation of linear motion along the Y axis");
1578 prop = RNA_def_property(srna, "lock_location_z", PROP_BOOLEAN, PROP_NONE);
1579 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_AXIS);
1580 RNA_def_property_ui_text(prop, "Lock Z Axis", "Disable simulation of linear motion along the Z axis");
1584 prop = RNA_def_property(srna, "lock_rotation_x", PROP_BOOLEAN, PROP_NONE);
1585 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_ROT_AXIS);
1586 RNA_def_property_ui_text(prop, "Lock X Rotation Axis", "Disable simulation of angular motion along the X axis");
1588 prop = RNA_def_property(srna, "lock_rotation_y", PROP_BOOLEAN, PROP_NONE);
1589 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_ROT_AXIS);
1590 RNA_def_property_ui_text(prop, "Lock Y Rotation Axis", "Disable simulation of angular motion along the Y axis");
1592 prop = RNA_def_property(srna, "lock_rotation_z", PROP_BOOLEAN, PROP_NONE);
1593 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_ROT_AXIS);
1594 RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis");
1596 /* is this used anywhere ? */
1597 prop = RNA_def_property(srna, "use_activity_culling", PROP_BOOLEAN, PROP_NONE);
1598 RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflag2", OB_NEVER_DO_ACTIVITY_CULLING);
1599 RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis");
1602 prop = RNA_def_property(srna, "use_material_physics_fh", PROP_BOOLEAN, PROP_NONE);
1603 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_DO_FH);
1604 RNA_def_property_ui_text(prop, "Use Material Force Field", "React to force field physics settings in materials");
1606 prop = RNA_def_property(srna, "use_rotate_from_normal", PROP_BOOLEAN, PROP_NONE);
1607 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ROT_FH);
1608 RNA_def_property_ui_text(prop, "Rotate From Normal",
1609 "Use face normal to rotate object, so that it points away from the surface");
1611 prop = RNA_def_property(srna, "form_factor", PROP_FLOAT, PROP_NONE);
1612 RNA_def_property_float_sdna(prop, NULL, "formfactor");
1613 RNA_def_property_range(prop, 0.0, 1.0);
1614 RNA_def_property_ui_text(prop, "Form Factor", "Form factor scales the inertia tensor");
1616 prop = RNA_def_property(srna, "use_anisotropic_friction", PROP_BOOLEAN, PROP_NONE);
1617 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ANISOTROPIC_FRICTION);
1618 RNA_def_property_ui_text(prop, "Anisotropic Friction", "Enable anisotropic friction");
1620 prop = RNA_def_property(srna, "friction_coefficients", PROP_FLOAT, PROP_NONE);
1621 RNA_def_property_float_sdna(prop, NULL, "anisotropicFriction");
1622 RNA_def_property_range(prop, 0.0, 1.0);
1623 RNA_def_property_ui_text(prop, "Friction Coefficients",
1624 "Relative friction coefficients in the in the X, Y and Z directions, "
1625 "when anisotropic friction is enabled");
1627 prop = RNA_def_property(srna, "use_collision_bounds", PROP_BOOLEAN, PROP_NONE);
1628 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_BOUNDS);
1629 RNA_def_property_ui_text(prop, "Use Collision Bounds", "Specify a collision bounds type other than the default");
1630 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
1632 prop = RNA_def_property(srna, "collision_bounds_type", PROP_ENUM, PROP_NONE);
1633 RNA_def_property_enum_sdna(prop, NULL, "collision_boundtype");
1634 RNA_def_property_enum_items(prop, collision_bounds_items);
1635 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_collision_bounds_itemf");
1636 RNA_def_property_ui_text(prop, "Collision Bounds", "Select the collision type");
1637 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
1639 prop = RNA_def_property(srna, "use_collision_compound", PROP_BOOLEAN, PROP_NONE);
1640 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_CHILD);
1641 RNA_def_property_ui_text(prop, "Collision Compound", "Add children to form a compound collision object");
1643 prop = RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
1644 RNA_def_property_float_sdna(prop, NULL, "margin");
1645 RNA_def_property_range(prop, 0.0, 1.0);
1646 RNA_def_property_ui_text(prop, "Collision Margin",
1647 "Extra margin around object for collision detection, small amount required "
1650 prop = RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE);
1651 RNA_def_property_pointer_sdna(prop, NULL, "bsoft");
1652 RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for Bullet soft body simulation");
1654 prop = RNA_def_property(srna, "use_obstacle_create", PROP_BOOLEAN, PROP_NONE);
1655 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_HASOBSTACLE);
1656 RNA_def_property_ui_text(prop, "Create obstacle", "Create representation for obstacle simulation");
1658 prop = RNA_def_property(srna, "obstacle_radius", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
1659 RNA_def_property_float_sdna(prop, NULL, "obstacleRad");
1660 RNA_def_property_range(prop, 0.0, 1000.0);
1661 RNA_def_property_ui_text(prop, "Obstacle Radius", "Radius of object representation in obstacle simulation");
1665 prop = RNA_def_property(srna, "states_visible", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1666 RNA_def_property_boolean_sdna(prop, NULL, "state", 1);
1667 RNA_def_property_array(prop, OB_MAX_STATES);
1668 RNA_def_property_ui_text(prop, "State", "State determining which controllers are displayed");
1669 RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_state_get", "rna_GameObjectSettings_state_set");
1671 prop = RNA_def_property(srna, "used_states", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1672 RNA_def_property_array(prop, OB_MAX_STATES);
1673 RNA_def_property_ui_text(prop, "Used State", "States which are being used by controllers");
1674 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1675 RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_used_state_get", NULL);
1677 prop = RNA_def_property(srna, "states_initial", PROP_BOOLEAN, PROP_NONE);
1678 RNA_def_property_boolean_sdna(prop, NULL, "init_state", 1);
1679 RNA_def_property_array(prop, OB_MAX_STATES);
1680 RNA_def_property_ui_text(prop, "Initial State", "Initial state when the game starts");
1682 prop = RNA_def_property(srna, "show_debug_state", PROP_BOOLEAN, PROP_NONE);
1683 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_DEBUGSTATE);
1684 RNA_def_property_ui_text(prop, "Debug State", "Print state debug info in the game engine");
1685 RNA_def_property_ui_icon(prop, ICON_INFO, 0);
1687 prop = RNA_def_property(srna, "use_all_states", PROP_BOOLEAN, PROP_NONE);
1688 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_ALLSTATE);
1689 RNA_def_property_ui_text(prop, "All", "Set all state bits");
1691 prop = RNA_def_property(srna, "show_state_panel", PROP_BOOLEAN, PROP_NONE);
1692 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSTATE);
1693 RNA_def_property_ui_text(prop, "States", "Show state panel");
1694 RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
1697 static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
1705 RNA_def_property_srna(cprop, "ObjectConstraints");
1706 srna = RNA_def_struct(brna, "ObjectConstraints", NULL);
1707 RNA_def_struct_sdna(srna, "Object");
1708 RNA_def_struct_ui_text(srna, "Object Constraints", "Collection of object constraints");
1711 /* Collection active property */
1712 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1713 RNA_def_property_struct_type(prop, "Constraint");
1714 RNA_def_property_pointer_funcs(prop, "rna_Object_active_constraint_get",
1715 "rna_Object_active_constraint_set", NULL, NULL);
1716 RNA_def_property_flag(prop, PROP_EDITABLE);
1717 RNA_def_property_ui_text(prop, "Active Constraint", "Active Object constraint");
1720 /* Constraint collection */
1721 func = RNA_def_function(srna, "new", "rna_Object_constraints_new");
1722 RNA_def_function_ui_description(func, "Add a new constraint to this object");
1724 parm = RNA_def_enum(func, "type", constraint_type_items, 1, "", "Constraint type to add");
1725 RNA_def_property_flag(parm, PROP_REQUIRED);
1727 parm = RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint");
1728 RNA_def_function_return(func, parm);
1730 func = RNA_def_function(srna, "remove", "rna_Object_constraints_remove");
1731 RNA_def_function_ui_description(func, "Remove a constraint from this object");
1732 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1733 /* constraint to remove */
1734 parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
1735 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
1737 func = RNA_def_function(srna, "clear", "rna_Object_constraints_clear");
1738 RNA_def_function_ui_description(func, "Remove all constraint from this object");
1741 /* object.modifiers */
1742 static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
1749 RNA_def_property_srna(cprop, "ObjectModifiers");
1750 srna = RNA_def_struct(brna, "ObjectModifiers", NULL);
1751 RNA_def_struct_sdna(srna, "Object");
1752 RNA_def_struct_ui_text(srna, "Object Modifiers", "Collection of object modifiers");
1755 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1756 RNA_def_property_struct_type(prop, "EditBone");
1757 RNA_def_property_pointer_sdna(prop, NULL, "act_edbone");
1758 RNA_def_property_flag(prop, PROP_EDITABLE);
1759 RNA_def_property_ui_text(prop, "Active EditBone", "Armatures active edit bone");
1760 /*RNA_def_property_update(prop, 0, "rna_Armature_act_editbone_update"); */
1761 RNA_def_property_pointer_funcs(prop, NULL, "rna_Armature_act_edit_bone_set", NULL, NULL);
1764 /* RNA_def_property_collection_active(prop, prop_act); */
1768 func = RNA_def_function(srna, "new", "rna_Object_modifier_new");
1769 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1770 RNA_def_function_ui_description(func, "Add a new modifier");
1771 parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the bone");
1772 RNA_def_property_flag(parm, PROP_REQUIRED);
1773 /* modifier to add */
1774 parm = RNA_def_enum(func, "type", modifier_type_items, 1, "", "Modifier type to add");
1775 RNA_def_property_flag(parm, PROP_REQUIRED);
1777 parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Newly created modifier");
1778 RNA_def_function_return(func, parm);
1780 /* remove modifier */
1781 func = RNA_def_function(srna, "remove", "rna_Object_modifier_remove");
1782 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1783 RNA_def_function_ui_description(func, "Remove an existing modifier from the object");
1784 /* modifier to remove */
1785 parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove");
1786 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
1788 /* clear all modifiers */
1789 func = RNA_def_function(srna, "clear", "rna_Object_modifier_clear");
1790 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
1791 RNA_def_function_ui_description(func, "Remove all modifiers from the object");
1794 /* object.particle_systems */
1795 static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop)
1801 /* FunctionRNA *func; */
1802 /* PropertyRNA *parm; */
1804 RNA_def_property_srna(cprop, "ParticleSystems");
1805 srna = RNA_def_struct(brna, "ParticleSystems", NULL);
1806 RNA_def_struct_sdna(srna, "Object");
1807 RNA_def_struct_ui_text(srna, "Particle Systems", "Collection of particle systems");
1809 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1810 RNA_def_property_struct_type(prop, "ParticleSystem");
1811 RNA_def_property_pointer_funcs(prop, "rna_Object_active_particle_system_get", NULL, NULL, NULL);
1812 RNA_def_property_ui_text(prop, "Active Particle System", "Active particle system being displayed");
1813 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
1815 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
1816 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1817 RNA_def_property_int_funcs(prop, "rna_Object_active_particle_system_index_get",
1818 "rna_Object_active_particle_system_index_set",
1819 "rna_Object_active_particle_system_index_range");
1820 RNA_def_property_ui_text(prop, "Active Particle System Index", "Index of active particle system slot");
1821 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_particle_update");
1825 /* object.vertex_groups */
1826 static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
1835 RNA_def_property_srna(cprop, "VertexGroups");
1836 srna = RNA_def_struct(brna, "VertexGroups", NULL);
1837 RNA_def_struct_sdna(srna, "Object");
1838 RNA_def_struct_ui_text(srna, "Vertex Groups", "Collection of vertex groups");
1840 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1841 RNA_def_property_struct_type(prop, "VertexGroup");
1842 RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get",
1843 "rna_Object_active_vertex_group_set", NULL, NULL);
1844 RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object");
1845 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
1847 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE);
1848 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1849 RNA_def_property_int_sdna(prop, NULL, "actdef");
1850 RNA_def_property_int_funcs(prop, "rna_Object_active_vertex_group_index_get",
1851 "rna_Object_active_vertex_group_index_set",
1852 "rna_Object_active_vertex_group_index_range");
1853 RNA_def_property_ui_text(prop, "Active Vertex Group Index", "Active index in vertex group array");
1854 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
1856 /* vertex groups */ /* add_vertex_group */
1857 func = RNA_def_function(srna, "new", "rna_Object_vgroup_new");
1858 RNA_def_function_ui_description(func, "Add vertex group to object");
1859 RNA_def_string(func, "name", "Group", 0, "", "Vertex group name"); /* optional */
1860 parm = RNA_def_pointer(func, "group", "VertexGroup", "", "New vertex group");
1861 RNA_def_function_return(func, parm);
1863 func = RNA_def_function(srna, "remove", "rna_Object_vgroup_remove");
1864 RNA_def_function_ui_description(func, "Delete vertex group from object");
1865 parm = RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove");
1866 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
1868 func = RNA_def_function(srna, "clear", "rna_Object_vgroup_clear");
1869 RNA_def_function_ui_description(func, "Delete all vertex groups from object");
1873 static void rna_def_object(BlenderRNA *brna)
1878 static EnumPropertyItem empty_drawtype_items[] = {
1879 {OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""},
1880 {OB_ARROWS, "ARROWS", 0, "Arrows", ""},
1881 {OB_SINGLE_ARROW, "SINGLE_ARROW", 0, "Single Arrow", ""},
1882 {OB_CIRCLE, "CIRCLE", 0, "Circle", ""},
1883 {OB_CUBE, "CUBE", 0, "Cube", ""},
1884 {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""},
1885 {OB_EMPTY_CONE, "CONE", 0, "Cone", ""},
1886 {OB_EMPTY_IMAGE, "IMAGE", 0, "Image", ""},
1887 {0, NULL, 0, NULL, NULL}
1890 static EnumPropertyItem track_items[] = {
1891 {OB_POSX, "POS_X", 0, "+X", ""},
1892 {OB_POSY, "POS_Y", 0, "+Y", ""},
1893 {OB_POSZ, "POS_Z", 0, "+Z", ""},
1894 {OB_NEGX, "NEG_X", 0, "-X", ""},
1895 {OB_NEGY, "NEG_Y", 0, "-Y", ""},
1896 {OB_NEGZ, "NEG_Z", 0, "-Z", ""},
1897 {0, NULL, 0, NULL, NULL}
1900 static EnumPropertyItem up_items[] = {
1901 {OB_POSX, "X", 0, "X", ""},
1902 {OB_POSY, "Y", 0, "Y", ""},
1903 {OB_POSZ, "Z", 0, "Z", ""},
1904 {0, NULL, 0, NULL, NULL}
1907 static EnumPropertyItem drawtype_items[] = {
1908 {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", "Draw the bounds of the object"},
1909 {OB_WIRE, "WIRE", 0, "Wire", "Draw the object as a wireframe"},
1910 {OB_SOLID, "SOLID", 0, "Solid", "Draw the object as a solid (if solid drawing is enabled in the viewport)"},
1911 {OB_TEXTURE, "TEXTURED", 0, "Textured",
1912 "Draw the object with textures (if textures are enabled in the viewport)"},
1913 {0, NULL, 0, NULL, NULL}
1916 static EnumPropertyItem boundtype_items[] = {
1917 {OB_BOUND_BOX, "BOX", 0, "Box", "Draw bounds as box"},
1918 {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", "Draw bounds as sphere"},
1919 {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", "Draw bounds as cylinder"},
1920 {OB_BOUND_CONE, "CONE", 0, "Cone", "Draw bounds as cone"},
1921 {0, NULL, 0, NULL, NULL}
1924 static EnumPropertyItem dupli_items[] = {
1925 {0, "NONE", 0, "None", ""},
1926 {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"},
1927 {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"},
1928 {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"},
1929 {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"},
1930 {0, NULL, 0, NULL, NULL}
1933 /* XXX: this RNA enum define is currently duplicated for objects,
1934 * since there is some text here which is not applicable */
1935 static EnumPropertyItem prop_rotmode_items[] = {
1936 {ROT_MODE_QUAT, "QUATERNION", 0, "Quaternion (WXYZ)", "No Gimbal Lock"},
1937 {ROT_MODE_XYZ, "XYZ", 0, "XYZ Euler", "XYZ Rotation Order - prone to Gimbal Lock (default)"},
1938 {ROT_MODE_XZY, "XZY", 0, "XZY Euler", "XZY Rotation Order - prone to Gimbal Lock"},
1939 {ROT_MODE_YXZ, "YXZ", 0, "YXZ Euler", "YXZ Rotation Order - prone to Gimbal Lock"},
1940 {ROT_MODE_YZX, "YZX", 0, "YZX Euler", "YZX Rotation Order - prone to Gimbal Lock"},
1941 {ROT_MODE_ZXY, "ZXY", 0, "ZXY Euler", "ZXY Rotation Order - prone to Gimbal Lock"},
1942 {ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order - prone to Gimbal Lock"},
1943 {ROT_MODE_AXISANGLE, "AXIS_ANGLE", 0, "Axis Angle",
1944 "Axis Angle (W+XYZ), defines a rotation around some axis defined by 3D-Vector"},
1945 {0, NULL, 0, NULL, NULL}
1948 static float default_quat[4] = {1, 0, 0, 0}; /* default quaternion values */
1949 static float default_axisAngle[4] = {0, 0, 1, 0}; /* default axis-angle rotation values */
1950 static float default_scale[3] = {1, 1, 1}; /* default scale values */
1951 static int boundbox_dimsize[] = {8, 3};
1953 srna = RNA_def_struct(brna, "Object", "ID");
1954 RNA_def_struct_ui_text(srna, "Object", "Object datablock defining an object in a scene");
1955 RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
1956 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
1958 prop = RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
1959 RNA_def_property_struct_type(prop, "ID");
1960 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_set", "rna_Object_data_typef", NULL);
1961 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
1962 RNA_def_property_ui_text(prop, "Data", "Object data");
1963 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
1965 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1966 RNA_def_property_enum_sdna(prop, NULL, "type");
1967 RNA_def_property_enum_items(prop, object_type_items);
1968 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1969 RNA_def_property_ui_text(prop, "Type", "Type of Object");
1971 prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
1972 RNA_def_property_enum_sdna(prop, NULL, "mode");
1973 RNA_def_property_enum_items(prop, object_mode_items);
1974 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1975 RNA_def_property_ui_text(prop, "Mode", "Object interaction mode");
1977 prop = RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1978 RNA_def_property_boolean_sdna(prop, NULL, "lay", 1);
1979 RNA_def_property_array(prop, 20);
1980 RNA_def_property_ui_text(prop, "Layers", "Layers the object is on");
1981 RNA_def_property_boolean_funcs(prop, NULL, "rna_Object_layer_set");
1982 RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
1983 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_layer_update");
1985 prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1986 RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000);
1987 RNA_def_property_array(prop, 8);
1988 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1989 RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object is on");
1991 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1992 RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
1993 RNA_def_property_ui_text(prop, "Select", "Object selection state");
1994 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_select_update");
1996 /* for data access */
1997 prop = RNA_def_property(srna, "bound_box", PROP_FLOAT, PROP_NONE);
1998 RNA_def_property_multi_array(prop, 2, boundbox_dimsize);
1999 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2000 RNA_def_property_float_funcs(prop, "rna_Object_boundbox_get", NULL, NULL);
2001 RNA_def_property_ui_text(prop, "Bounding Box",
2002 "Object's bounding box in object-space coordinates, all values are -1.0 when "
2006 prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
2007 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_parent_set", NULL, NULL);
2008 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2009 RNA_def_property_ui_text(prop, "Parent", "Parent Object");
2010 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2012 prop = RNA_def_property(srna, "parent_type", PROP_ENUM, PROP_NONE);
2013 RNA_def_property_enum_bitflag_sdna(prop, NULL, "partype");
2014 RNA_def_property_enum_items(prop, parent_type_items);
2015 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_parent_type_set", "rna_Object_parent_type_itemf");
2016 RNA_def_property_ui_text(prop, "Parent Type", "Type of parent relation");
2017 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2019 prop = RNA_def_property(srna, "parent_vertices", PROP_INT, PROP_UNSIGNED);
2020 RNA_def_property_int_sdna(prop, NULL, "par1");
2021 RNA_def_property_array(prop, 3);
2022 RNA_def_property_ui_text(prop, "Parent Vertices", "Indices of vertices in case of a vertex parenting relation");
2023 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2025 prop = RNA_def_property(srna, "parent_bone", PROP_STRING, PROP_NONE);
2026 RNA_def_property_string_sdna(prop, NULL, "parsubstr");
2027 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Object_parent_bone_set");
2028 RNA_def_property_ui_text(prop, "Parent Bone", "Name of parent bone in case of a bone parenting relation");
2029 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2031 /* Track and Up flags */
2032 /* XXX: these have been saved here for a bit longer (after old track was removed),
2033 * since some other tools still refer to this */
2034 prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
2035 RNA_def_property_enum_sdna(prop, NULL, "trackflag");
2036 RNA_def_property_enum_items(prop, track_items);
2037 RNA_def_property_ui_text(prop, "Track Axis",
2038 "Axis that points in 'forward' direction (applies to DupliFrame when "
2039 "parent 'Follow' is enabled)");
2040 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2042 prop = RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE);
2043 RNA_def_property_enum_sdna(prop, NULL, "upflag");
2044 RNA_def_property_enum_items(prop, up_items);
2045 RNA_def_property_ui_text(prop, "Up Axis",
2046 "Axis that points in the upward direction (applies to DupliFrame when "
2047 "parent 'Follow' is enabled)");
2048 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2051 prop = RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE);
2052 RNA_def_property_ui_text(prop, "Proxy", "Library object this proxy object controls");
2054 prop = RNA_def_property(srna, "proxy_group", PROP_POINTER, PROP_NONE);
2055 RNA_def_property_ui_text(prop, "Proxy Group", "Library group duplicator object this proxy object controls");
2058 prop = RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE);
2059 RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
2060 RNA_def_property_struct_type(prop, "MaterialSlot");
2061 /* don't dereference pointer! */
2062 RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", NULL, NULL, NULL, NULL);
2063 RNA_def_property_ui_text(prop, "Material Slots", "Material slots in the object");
2065 prop = RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE);
2066 RNA_def_property_struct_type(prop, "Material");
2067 RNA_def_property_pointer_funcs(prop, "rna_Object_active_material_get",
2068 "rna_Object_active_material_set", NULL, NULL);
2069 RNA_def_property_flag(prop, PROP_EDITABLE);
2070 RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed");
2071 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
2073 prop = RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
2074 RNA_def_property_int_sdna(prop, NULL, "actcol");
2075 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2076 RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set",
2077 "rna_Object_active_material_index_range");
2078 RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot");
2079 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
2082 prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
2083 RNA_def_property_float_sdna(prop, NULL, "loc");
2084 RNA_def_property_editable_array_func(prop, "rna_Object_location_editable");
2085 RNA_def_property_ui_text(prop, "Location", "Location of the object");
2086 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2087 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2089 prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
2090 RNA_def_property_float_sdna(prop, NULL, "quat");
2091 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
2092 RNA_def_property_float_array_default(prop, default_quat);
2093 RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions");
2094 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2096 /* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but
2097 * having a single one is better for Keyframing and other property-management situations...
2099 prop = RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
2100 RNA_def_property_array(prop, 4);
2101 RNA_def_property_float_funcs(prop, "rna_Object_rotation_axis_angle_get",
2102 "rna_Object_rotation_axis_angle_set", NULL);
2103 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
2104 RNA_def_property_float_array_default(prop, default_axisAngle);
2105 RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
2106 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2108 prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
2109 RNA_def_property_float_sdna(prop, NULL, "rot");
2110 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_euler_editable");
2111 RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers");
2112 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2114 prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
2115 RNA_def_property_enum_sdna(prop, NULL, "rotmode");
2116 RNA_def_property_enum_items(prop, prop_rotmode_items); /* XXX move to using a single define of this someday */
2117 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_rotation_mode_set", NULL);
2118 RNA_def_property_ui_text(prop, "Rotation Mode", "");
2119 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2121 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
2122 RNA_def_property_float_sdna(prop, NULL, "size");
2123 RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable");
2124 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
2125 RNA_def_property_float_array_default(prop, default_scale);
2126 RNA_def_property_ui_text(prop, "Scale", "Scaling of the object");
2127 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2129 prop = RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ_LENGTH);
2130 RNA_def_property_array(prop, 3);
2131 RNA_def_property_float_funcs(prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", NULL);
2132 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
2133 RNA_def_property_ui_text(prop, "Dimensions", "Absolute bounding box dimensions of the object");
2134 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2137 /* delta transforms */
2138 prop = RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_TRANSLATION);
2139 RNA_def_property_float_sdna(prop, NULL, "dloc");
2140 RNA_def_property_ui_text(prop, "Delta Location", "Extra translation added to the location of the object");
2141 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2142 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2144 prop = RNA_def_property(srna, "delta_rotation_euler", PROP_FLOAT, PROP_EULER);
2145 RNA_def_property_float_sdna(prop, NULL, "drot");
2146 RNA_def_property_ui_text(prop, "Delta Rotation (Euler)",
2147 "Extra rotation added to the rotation of the object (when using Euler rotations)");
2148 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2150 prop = RNA_def_property(srna, "delta_rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
2151 RNA_def_property_float_sdna(prop, NULL, "dquat");
2152 RNA_def_property_float_array_default(prop, default_quat);
2153 RNA_def_property_ui_text(prop, "Delta Rotation (Quaternion)",
2154 "Extra rotation added to the rotation of the object (when using Quaternion rotations)");
2155 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2157 #if 0 /* XXX not supported well yet... */
2158 prop = RNA_def_property(srna, "delta_rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
2159 /* FIXME: this is not a single field any more! (drotAxis and drotAngle) */
2160 RNA_def_property_float_sdna(prop, NULL, "dquat");
2161 RNA_def_property_float_array_default(prop, default_axisAngle);
2162 RNA_def_property_ui_text(prop, "Delta Rotation (Axis Angle)",
2163 "Extra rotation added to the rotation of the object (when using Axis-Angle rotations)");
2164 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2167 prop = RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_XYZ);
2168 RNA_def_property_float_sdna(prop, NULL, "dscale");
2169 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
2170 RNA_def_property_float_array_default(prop, default_scale);
2171 RNA_def_property_ui_text(prop, "Delta Scale", "Extra scaling added to the scale of the object");
2172 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2174 /* transform locks */
2175 prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE);
2176 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX);
2177 RNA_def_property_array(prop, 3);
2178 RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface");
2179 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2180 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2182 prop = RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE);
2183 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX);
2184 RNA_def_property_array(prop, 3);
2185 RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface");
2186 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2187 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2189 /* XXX this is sub-optimal - it really should be included above,
2190 * but due to technical reasons we can't do this! */
2191 prop = RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE);
2192 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTW);
2193 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2194 RNA_def_property_ui_text(prop, "Lock Rotation (4D Angle)",
2195 "Lock editing of 'angle' component of four-component rotations in the interface");
2196 /* XXX this needs a better name */
2197 prop = RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE);
2198 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROT4D);
2199 RNA_def_property_ui_text(prop, "Lock Rotations (4D)",
2200 "Lock editing of four component rotations by components (instead of as Eulers)");
2202 prop = RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_NONE);
2203 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX);
2204 RNA_def_property_array(prop, 3);
2205 RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface");
2206 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2207 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2210 prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
2211 RNA_def_property_float_sdna(prop, NULL, "obmat");
2212 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2213 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2214 RNA_def_property_ui_text(prop, "Matrix World", "Worldspace transformation matrix");
2215 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_matrix_world_update");
2217 prop = RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX);
2218 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2219 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2220 RNA_def_property_ui_text(prop, "Local Matrix", "Parent relative transformation matrix");
2221 RNA_def_property_float_funcs(prop, "rna_Object_matrix_local_get", "rna_Object_matrix_local_set", NULL);
2222 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, NULL);
2224 prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
2225 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2226 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2227 RNA_def_property_ui_text(prop, "Input Matrix",
2228 "Matrix access to location, rotation and scale (including deltas), "
2229 "before constraints and parenting are applied");
2230 RNA_def_property_float_funcs(prop, "rna_Object_matrix_basis_get", "rna_Object_matrix_basis_set", NULL);
2231 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2234 prop = RNA_def_property(srna, "matrix_parent_inverse", PROP_FLOAT, PROP_MATRIX);
2235 RNA_def_property_float_sdna(prop, NULL, "parentinv");
2236 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2237 RNA_def_property_ui_text(prop, "Matrix", "Inverse of object's parent matrix at time of parenting");
2238 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2241 prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
2242 RNA_def_property_struct_type(prop, "Modifier");
2243 RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the geometric data of the object");
2244 rna_def_object_modifiers(brna, prop);
2247 prop = RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE);
2248 RNA_def_property_struct_type(prop, "Constraint");
2249 RNA_def_property_ui_text(prop, "Constraints", "Constraints affecting the transformation of the object");
2250 /* RNA_def_property_collection_funcs(prop, 0, 0, 0, 0, 0, 0, 0, "constraints__add", "constraints__remove"); */
2251 rna_def_object_constraints(brna, prop);
2254 prop = RNA_def_property(srna, "game", PROP_POINTER, PROP_NONE);
2255 RNA_def_property_flag(prop, PROP_NEVER_NULL);
2256 RNA_def_property_struct_type(prop, "GameObjectSettings");
2257 RNA_def_property_pointer_funcs(prop, "rna_Object_game_settings_get", NULL, NULL, NULL);
2258 RNA_def_property_ui_text(prop, "Game Settings", "Game engine related settings for the object");
2261 prop = RNA_def_property(srna, "vertex_groups", PROP_COLLECTION, PROP_NONE);
2262 RNA_def_property_collection_sdna(prop, NULL, "defbase", NULL);
2263 RNA_def_property_struct_type(prop, "VertexGroup");
2264 RNA_def_property_ui_text(prop, "Vertex Groups", "Vertex groups of the object");
2265 rna_def_object_vertex_groups(brna, prop);
2268 prop = RNA_def_property(srna, "empty_draw_type", PROP_ENUM, PROP_NONE);
2269 RNA_def_property_enum_sdna(prop, NULL, "empty_drawtype");
2270 RNA_def_property_enum_items(prop, empty_drawtype_items);
2271 RNA_def_property_ui_text(prop, "Empty Display Type", "Viewport display style for empties");
2272 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2274 prop = RNA_def_property(srna, "empty_draw_size", PROP_FLOAT, PROP_DISTANCE);
2275 RNA_def_property_float_sdna(prop, NULL, "empty_drawsize");
2276 RNA_def_property_range(prop, 0.0001f, 1000.0f);
2277 RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);
2278 RNA_def_property_ui_text(prop, "Empty Display Size", "Size of display for empties in the viewport");
2279 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2281 prop = RNA_def_property(srna, "empty_image_offset", PROP_FLOAT, PROP_DISTANCE);
2282 RNA_def_property_float_sdna(prop, NULL, "ima_ofs");
2283 RNA_def_property_ui_text(prop, "Origin Offset", "Origin offset distance");
2284 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1f, 2);
2285 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2288 prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
2289 RNA_def_property_int_sdna(prop, NULL, "index");
2290 RNA_def_property_ui_text(prop, "Pass Index", "Index number for the IndexOB render pass");
2291 RNA_def_property_update(prop, NC_OBJECT, NULL);
2293 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
2294 RNA_def_property_float_sdna(prop, NULL, "col");
2295 RNA_def_property_ui_text(prop, "Color", "Object color and alpha, used when faces have the ObColor mode enabled");
2296 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2299 prop = RNA_def_property(srna, "field", PROP_POINTER, PROP_NONE);
2300 RNA_def_property_pointer_sdna(prop, NULL, "pd");
2301 RNA_def_property_struct_type(prop, "FieldSettings");
2302 RNA_def_property_pointer_funcs(prop, "rna_Object_field_get", NULL, NULL, NULL);
2303 RNA_def_property_ui_text(prop, "Field Settings", "Settings for using the object as a field in physics simulation");
2305 prop = RNA_def_property(srna, "collision", PROP_POINTER, PROP_NONE);
2306 RNA_def_property_pointer_sdna(prop, NULL, "pd");
2307 RNA_def_property_struct_type(prop, "CollisionSettings");
2308 RNA_def_property_pointer_funcs(prop, "rna_Object_collision_get", NULL, NULL, NULL);
2309 RNA_def_property_ui_text(prop, "Collision Settings",
2310 "Settings for using the object as a collider in physics simulation");
2312 prop = RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE);
2313 RNA_def_property_pointer_sdna(prop, NULL, "soft");
2314 RNA_def_property_struct_type(prop, "SoftBodySettings");
2315 RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for soft body simulation");
2317 prop = RNA_def_property(srna, "particle_systems", PROP_COLLECTION, PROP_NONE);
2318 RNA_def_property_collection_sdna(prop, NULL, "particlesystem", NULL);
2319 RNA_def_property_struct_type(prop, "ParticleSystem");
2320 RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object");
2321 rna_def_object_particle_systems(brna, prop);
2324 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
2325 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW);
2326 RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport");
2327 RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1);
2328 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
2330 prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
2331 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT);
2332 RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection in the viewport");
2333 RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1);
2334 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2336 prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE);
2337 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER);
2338 RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability");
2339 RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
2340 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
2343 rna_def_animdata_common(srna);
2345 rna_def_animviz_common(srna);
2346 rna_def_motionpath_common(srna);
2348 /* slow parenting */
2349 /* XXX: evil old crap */
2350 prop = RNA_def_property(srna, "use_slow_parent", PROP_BOOLEAN, PROP_NONE);
2351 RNA_def_property_boolean_sdna(prop, NULL, "partype", PARSLOW);
2352 RNA_def_property_ui_text(prop, "Slow Parent",
2353 "Create a delay in the parent relationship (beware: this isn't renderfarm "
2354 "safe and may be invalid after jumping around the timeline)");
2355 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2357 prop = RNA_def_property(srna, "slow_parent_offset", PROP_FLOAT, PROP_NONE | PROP_UNIT_TIME);
2358 RNA_def_property_float_sdna(prop, NULL, "sf");
2359 RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
2360 RNA_def_property_ui_text(prop, "Slow Parent Offset", "Delay in the parent relationship");
2361 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2364 prop = RNA_def_property(srna, "dupli_type", PROP_ENUM, PROP_NONE);
2365 RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag");
2366 RNA_def_property_enum_items(prop, dupli_items);
2367 RNA_def_property_ui_text(prop, "Dupli Type", "If not None, object duplication method to use");
2368 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2370 prop = RNA_def_property(srna, "use_dupli_frames_speed", PROP_BOOLEAN, PROP_NONE);
2371 RNA_def_property_boolean_negative_sdna(prop, NULL, "transflag", OB_DUPLINOSPEED);
2372 RNA_def_property_ui_text(prop, "Dupli Frames Speed",
2373 "Set dupliframes to use the current frame instead of parent curve's evaluation time");
2374 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2376 prop = RNA_def_property(srna, "use_dupli_vertices_rotation", PROP_BOOLEAN, PROP_NONE);
2377 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIROT);
2378 RNA_def_property_ui_text(prop, "Dupli Verts Rotation", "Rotate dupli according to vertex normal");
2379 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2381 prop = RNA_def_property(srna, "use_dupli_faces_scale", PROP_BOOLEAN, PROP_NONE);
2382 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIFACES_SCALE);
2383 RNA_def_property_ui_text(prop, "Dupli Faces Inherit Scale", "Scale dupli based on face size");
2384 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2386 prop = RNA_def_property(srna, "dupli_faces_scale", PROP_FLOAT, PROP_NONE);
2387 RNA_def_property_float_sdna(prop, NULL, "dupfacesca");
2388 RNA_def_property_range(prop, 0.001f, 10000.0f);
2389 RNA_def_property_ui_text(prop, "Dupli Faces Scale", "Scale the DupliFace objects");
2390 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2392 prop = RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE);
2393 RNA_def_property_pointer_sdna(prop, NULL, "dup_group");
2394 RNA_def_property_flag(prop, PROP_EDITABLE);
2395 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_dup_group_set", NULL, NULL);
2396 RNA_def_property_ui_text(prop, "Dupli Group", "Instance an existing group");
2397 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2399 prop = RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
2400 RNA_def_property_int_sdna(prop, NULL, "dupsta");
2401 RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
2402 RNA_def_property_ui_text(prop, "Dupli Frames Start", "Start frame for DupliFrames");
2403 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2405 prop = RNA_def_property(srna, "dupli_frames_end", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
2406 RNA_def_property_int_sdna(prop, NULL, "dupend");
2407 RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
2408 RNA_def_property_ui_text(prop, "Dupli Frames End", "End frame for DupliFrames");
2409 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2411 prop = RNA_def_property(srna, "dupli_frames_on", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
2412 RNA_def_property_int_sdna(prop, NULL, "dupon");
2413 RNA_def_property_range(prop, MINFRAME, MAXFRAME);
2414 RNA_def_property_ui_range(prop, 1, 1500, 1, 0);
2415 RNA_def_property_ui_text(prop, "Dupli Frames On", "Number of frames to use between DupOff frames");
2416 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2418 prop = RNA_def_property(srna, "dupli_frames_off", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
2419 RNA_def_property_int_sdna(prop, NULL, "dupoff");
2420 RNA_def_property_range(prop, 0, MAXFRAME);
2421 RNA_def_property_ui_range(prop, 0, 1500, 1, 0);
2422 RNA_def_property_ui_text(prop, "Dupli Frames Off", "Recurring frames to exclude from the Dupliframes");
2423 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2425 prop = RNA_def_property(srna, "dupli_list", PROP_COLLECTION, PROP_NONE);
2426 RNA_def_property_collection_sdna(prop, NULL, "duplilist", NULL);
2427 RNA_def_property_struct_type(prop, "DupliObject");
2428 RNA_def_property_ui_text(prop, "Dupli list", "Object duplis");
2430 prop = RNA_def_property(srna, "is_duplicator", PROP_BOOLEAN, PROP_NONE);
2431 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLI);
2432 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2435 prop = RNA_def_property(srna, "draw_type", PROP_ENUM, PROP_NONE);
2436 RNA_def_property_enum_sdna(prop, NULL, "dt");
2437 RNA_def_property_enum_items(prop, drawtype_items);
2438 RNA_def_property_ui_text(prop, "Maximum Draw Type", "Maximum draw type to display object with in viewport");
2439 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2441 prop = RNA_def_property(srna, "show_bounds", PROP_BOOLEAN, PROP_NONE);
2442 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_BOUNDBOX);
2443 RNA_def_property_ui_text(prop, "Draw Bounds", "Display the object's bounds");
2444 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2446 prop = RNA_def_property(srna, "draw_bounds_type", PROP_ENUM, PROP_NONE);
2447 RNA_def_property_enum_sdna(prop, NULL, "boundtype");
2448 RNA_def_property_enum_items(prop, boundtype_items);
2449 RNA_def_property_ui_text(prop, "Draw Bounds Type", "Object boundary display type");
2450 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2452 prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE);
2453 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWNAME);
2454 RNA_def_property_ui_text(prop, "Draw Name", "Display the object's name");
2455 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2457 prop = RNA_def_property(srna, "show_axis", PROP_BOOLEAN, PROP_NONE);
2458 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_AXIS);
2459 RNA_def_property_ui_text(prop, "Draw Axes", "Display the object's origin and axes");
2460 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2462 prop = RNA_def_property(srna, "show_texture_space", PROP_BOOLEAN, PROP_NONE);
2463 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_TEXSPACE);
2464 RNA_def_property_ui_text(prop, "Draw Texture Space", "Display the object's texture space");
2465 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2467 prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE);
2468 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWWIRE);
2469 RNA_def_property_ui_text(prop, "Draw Wire", "Add the object's wireframe over solid drawing");
2470 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2472 prop = RNA_def_property(srna, "show_transparent", PROP_BOOLEAN, PROP_NONE);
2473 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWTRANSP);
2474 RNA_def_property_ui_text(prop, "Draw Transparent",
2475 "Display material transparency in the object (unsupported for duplicator drawing)");
2476 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2478 prop = RNA_def_property(srna, "show_x_ray", PROP_BOOLEAN, PROP_NONE);
2479 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWXRAY);
2480 RNA_def_property_ui_text(prop, "X-Ray",
2481 "Make the object draw in front of others (unsupported for duplicator drawing)");
2482 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2485 prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
2486 RNA_def_property_pointer_sdna(prop, NULL, "gpd");
2487 RNA_def_property_flag(prop, PROP_EDITABLE);
2488 RNA_def_property_struct_type(prop, "GreasePencil");
2489 RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock");
2490 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2493 prop = RNA_def_property(srna, "pose_library", PROP_POINTER, PROP_NONE);
2494 RNA_def_property_pointer_sdna(prop, NULL, "poselib");
2495 RNA_def_property_flag(prop, PROP_EDITABLE);
2496 RNA_def_property_struct_type(prop, "Action");
2497 RNA_def_property_ui_text(prop, "Pose Library", "Action used as a pose library for armatures");
2499 prop = RNA_def_property(srna, "pose", PROP_POINTER, PROP_NONE);
2500 RNA_def_property_pointer_sdna(prop, NULL, "pose");
2501 RNA_def_property_struct_type(prop, "Pose");
2502 RNA_def_property_ui_text(prop, "Pose", "Current pose for armatures");
2505 prop = RNA_def_property(srna, "show_only_shape_key", PROP_BOOLEAN, PROP_NONE);
2506 RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_LOCK);
2507 RNA_def_property_ui_text(prop, "Shape Key Lock", "Always show the current Shape for this Object");
2508 RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
2509 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
2511 prop = RNA_def_property(srna, "use_shape_key_edit_mode", PROP_BOOLEAN, PROP_NONE);
2512 RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_EDIT_MODE);
2513 RNA_def_property_ui_text(prop, "Shape Key Edit Mode", "Apply shape keys in edit mode (for Meshes only)");
2514 RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0);
2515 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
2517 prop = RNA_def_property(srna, "active_shape_key", PROP_POINTER, PROP_NONE);
2518 RNA_def_property_struct_type(prop, "ShapeKey");
2519 RNA_def_property_pointer_funcs(prop, "rna_Object_active_shape_key_get", NULL, NULL, NULL);
2520 RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key");
2522 prop = RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE);
2523 RNA_def_property_int_sdna(prop, NULL, "shapenr");
2524 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* XXX this is really unpredictable... */
2525 RNA_def_property_int_funcs(prop, "rna_Object_active_shape_key_index_get", "rna_Object_active_shape_key_index_set",
2526 "rna_Object_active_shape_key_index_range");
2527 RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index");
2528 RNA_def_property_update(prop, 0, "rna_Object_active_shape_update");
2530 RNA_api_object(srna);
2533 static void rna_def_dupli_object(BlenderRNA *brna)
2538 srna = RNA_def_struct(brna, "DupliObject", NULL);
2539 RNA_def_struct_sdna(srna, "DupliObject");
2540 RNA_def_struct_ui_text(srna, "Object Duplicate", "An object duplicate");
2541 /* RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); */
2543 prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2544 RNA_def_property_pointer_sdna(prop, NULL, "ob");
2545 /* RNA_def_property_pointer_funcs(prop, "rna_DupliObject_object_get", NULL, NULL, NULL); */
2546 RNA_def_property_ui_text(prop, "Object", "Object being duplicated");
2548 prop = RNA_def_property(srna, "matrix_original", PROP_FLOAT, PROP_MATRIX);
2549 RNA_def_property_float_sdna(prop, NULL, "omat");
2550 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2551 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2552 RNA_def_property_ui_text(prop, "Object Matrix", "The original matrix of this object before it was duplicated");
2554 prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
2555 RNA_def_property_float_sdna(prop, NULL, "mat");
2556 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2557 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2558 RNA_def_property_ui_text(prop, "Object Duplicate Matrix", "Object duplicate transformation matrix");
2560 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
2561 RNA_def_property_boolean_sdna(prop, NULL, "no_draw", 0);
2562 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2563 RNA_def_property_ui_text(prop, "Hide", "Don't show dupli object in viewport or render");
2565 prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
2566 RNA_def_property_int_sdna(prop, NULL, "index");
2567 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2568 RNA_def_property_ui_text(prop, "Index", "Index in the lowest-level dupli list");
2570 prop = RNA_def_property(srna, "particle_index", PROP_INT, PROP_NONE);
2571 RNA_def_property_int_sdna(prop, NULL, "particle_index");
2572 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2573 RNA_def_property_ui_text(prop, "Particle Index", "Index in the lowest-level particle dupli list");
2575 /* TODO: DupliObject has more properties that can be wrapped */
2578 static void rna_def_object_base(BlenderRNA *brna)
2583 srna = RNA_def_struct(brna, "ObjectBase", NULL);
2584 RNA_def_struct_sdna(srna, "Base");
2585 RNA_def_struct_ui_text(srna, "Object Base", "An object instance in a scene");
2586 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
2588 prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2589 RNA_def_property_pointer_sdna(prop, NULL, "object");
2590 RNA_def_property_ui_text(prop, "Object", "Object this base links to");
2592 /* same as object layer */
2593 prop = RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER);
2594 RNA_def_property_boolean_sdna(prop, NULL, "lay", 1);
2595 RNA_def_property_array(prop, 20);
2596 RNA_def_property_ui_text(prop, "Layers", "Layers the object base is on");
2597 RNA_def_property_boolean_funcs(prop, NULL, "rna_Base_layer_set");
2598 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Base_layer_update");
2600 prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER);
2601 RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000);
2602 RNA_def_property_array(prop, 8);
2603 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2604 RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object base is on");
2606 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2607 RNA_def_property_boolean_sdna(prop, NULL, "flag", BA_SELECT);
2608 RNA_def_property_ui_text(prop, "Select", "Object base selection state");
2609 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Base_select_update");
2611 RNA_api_object_base(srna);
2614 void RNA_def_object(BlenderRNA *brna)
2616 rna_def_object(brna);
2617 rna_def_object_game_settings(brna);
2618 rna_def_object_base(brna);
2619 rna_def_vertex_group(brna);
2620 rna_def_material_slot(brna);
2621 rna_def_dupli_object(brna);