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
30 #include "DNA_action_types.h"
31 #include "DNA_customdata_types.h"
32 #include "DNA_controller_types.h"
33 #include "DNA_group_types.h"
34 #include "DNA_material_types.h"
35 #include "DNA_mesh_types.h"
36 #include "DNA_object_force.h"
37 #include "DNA_object_types.h"
38 #include "DNA_property_types.h"
39 #include "DNA_scene_types.h"
40 #include "DNA_meta_types.h"
42 #include "BLI_utildefines.h"
44 #include "BKE_paint.h"
45 #include "BKE_editmesh.h"
46 #include "BKE_group.h" /* needed for BKE_group_object_exists() */
47 #include "BKE_object.h" /* Needed for BKE_object_matrix_local_get() */
48 #include "RNA_access.h"
49 #include "RNA_define.h"
50 #include "RNA_enum_types.h"
52 #include "rna_internal.h"
54 #include "BLI_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 Mode", ""},
62 {OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit Mode", ""},
63 {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""},
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 Mode", ""},
69 {0, NULL, 0, NULL, NULL}
72 EnumPropertyItem object_empty_drawtype_items[] = {
73 {OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""},
74 {OB_ARROWS, "ARROWS", 0, "Arrows", ""},
75 {OB_SINGLE_ARROW, "SINGLE_ARROW", 0, "Single Arrow", ""},
76 {OB_CIRCLE, "CIRCLE", 0, "Circle", ""},
77 {OB_CUBE, "CUBE", 0, "Cube", ""},
78 {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""},
79 {OB_EMPTY_CONE, "CONE", 0, "Cone", ""},
80 {OB_EMPTY_IMAGE, "IMAGE", 0, "Image", ""},
81 {0, NULL, 0, NULL, NULL}
85 static EnumPropertyItem parent_type_items[] = {
86 {PAROBJECT, "OBJECT", 0, "Object", "The object is parented to an object"},
87 {PARCURVE, "CURVE", 0, "Curve", "The object is parented to a curve"},
88 {PARKEY, "KEY", 0, "Key", ""},
89 {PARSKEL, "ARMATURE", 0, "Armature", ""},
90 {PARSKEL, "LATTICE", 0, "Lattice", "The object is parented to a lattice"}, /* PARSKEL reuse will give issues */
91 {PARVERT1, "VERTEX", 0, "Vertex", "The object is parented to a vertex"},
92 {PARVERT3, "VERTEX_3", 0, "3 Vertices", ""},
93 {PARBONE, "BONE", 0, "Bone", "The object is parented to a bone"},
94 {0, NULL, 0, NULL, NULL}
98 static EnumPropertyItem dupli_items[] = {
99 {0, "NONE", 0, "None", ""},
100 {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"},
101 {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"},
102 {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"},
103 {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"},
104 {0, NULL, 0, NULL, NULL}
108 static EnumPropertyItem collision_bounds_items[] = {
109 {OB_BOUND_BOX, "BOX", 0, "Box", ""},
110 {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""},
111 {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", ""},
112 {OB_BOUND_CONE, "CONE", 0, "Cone", ""},
113 {OB_BOUND_CONVEX_HULL, "CONVEX_HULL", 0, "Convex Hull", ""},
114 {OB_BOUND_TRIANGLE_MESH, "TRIANGLE_MESH", 0, "Triangle Mesh", ""},
115 {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", ""},
116 /*{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""}, */
117 {0, NULL, 0, NULL, NULL}
120 EnumPropertyItem metaelem_type_items[] = {
121 {MB_BALL, "BALL", ICON_META_BALL, "Ball", ""},
122 {MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""},
123 {MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""},
124 {MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""}, /* NOTE: typo at original definition! */
125 {MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""},
126 {0, NULL, 0, NULL, NULL}
129 /* used for 2 enums */
130 #define OBTYPE_CU_CURVE {OB_CURVE, "CURVE", 0, "Curve", ""}
131 #define OBTYPE_CU_SURF {OB_SURF, "SURFACE", 0, "Surface", ""}
132 #define OBTYPE_CU_FONT {OB_FONT, "FONT", 0, "Font", ""}
134 EnumPropertyItem object_type_items[] = {
135 {OB_MESH, "MESH", 0, "Mesh", ""},
138 {OB_MBALL, "META", 0, "Meta", ""},
140 {0, "", 0, NULL, NULL},
141 {OB_ARMATURE, "ARMATURE", 0, "Armature", ""},
142 {OB_LATTICE, "LATTICE", 0, "Lattice", ""},
143 {OB_EMPTY, "EMPTY", 0, "Empty", ""},
144 {0, "", 0, NULL, NULL},
145 {OB_CAMERA, "CAMERA", 0, "Camera", ""},
146 {OB_LAMP, "LAMP", 0, "Lamp", ""},
147 {OB_SPEAKER, "SPEAKER", 0, "Speaker", ""},
148 {0, NULL, 0, NULL, NULL}
151 EnumPropertyItem object_type_curve_items[] = {
155 {0, NULL, 0, NULL, NULL}
158 EnumPropertyItem object_axis_items[] = {
159 {OB_POSX, "POS_X", 0, "+X", ""},
160 {OB_POSY, "POS_Y", 0, "+Y", ""},
161 {OB_POSZ, "POS_Z", 0, "+Z", ""},
162 {OB_NEGX, "NEG_X", 0, "-X", ""},
163 {OB_NEGY, "NEG_Y", 0, "-Y", ""},
164 {OB_NEGZ, "NEG_Z", 0, "-Z", ""},
165 {0, NULL, 0, NULL, NULL}
170 #include "BLI_math.h"
172 #include "DNA_key_types.h"
173 #include "DNA_constraint_types.h"
174 #include "DNA_lattice_types.h"
175 #include "DNA_node_types.h"
177 #include "BKE_armature.h"
178 #include "BKE_bullet.h"
179 #include "BKE_constraint.h"
180 #include "BKE_context.h"
181 #include "BKE_curve.h"
182 #include "BKE_depsgraph.h"
183 #include "BKE_effect.h"
184 #include "BKE_global.h"
186 #include "BKE_object.h"
187 #include "BKE_material.h"
188 #include "BKE_mesh.h"
189 #include "BKE_particle.h"
190 #include "BKE_scene.h"
191 #include "BKE_deform.h"
194 #include "ED_object.h"
195 #include "ED_particle.h"
196 #include "ED_curve.h"
197 #include "ED_lattice.h"
199 static void rna_Object_internal_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
201 DAG_id_tag_update(ptr->id.data, OB_RECALC_OB);
204 static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr)
206 /* don't use compat so we get predictable rotation */
207 BKE_object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat, FALSE, TRUE);
208 rna_Object_internal_update(bmain, scene, ptr);
211 static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
213 DAG_id_type_tag(bmain, ID_OB);
216 static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
218 Object *ob = ptr->id.data;
219 BKE_object_matrix_local_get(ob, (float(*)[4])values);
222 static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])
224 Object *ob = ptr->id.data;
226 /* localspace matrix is truly relative to the parent, but parameters
227 * stored in object are relative to parentinv matrix. Undo the parent
228 * inverse part before updating obmat and calling apply_obmat() */
231 invert_m4_m4(invmat, ob->parentinv);
232 mul_m4_m4m4(ob->obmat, invmat, (float(*)[4])values);
235 copy_m4_m4(ob->obmat, (float(*)[4])values);
238 /* don't use compat so we get predictable rotation */
239 BKE_object_apply_mat4(ob, ob->obmat, FALSE, FALSE);
242 static void rna_Object_matrix_basis_get(PointerRNA *ptr, float values[16])
244 Object *ob = ptr->id.data;
245 BKE_object_to_mat4(ob, (float(*)[4])values);
248 static void rna_Object_matrix_basis_set(PointerRNA *ptr, const float values[16])
250 Object *ob = ptr->id.data;
251 BKE_object_apply_mat4(ob, (float(*)[4])values, FALSE, FALSE);
254 void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
256 DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
257 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
260 static void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
262 Object *ob = ptr->id.data;
264 if (scene->obedit == ob) {
265 /* exit/enter editmode to get new shape */
269 EDBM_mesh_make(scene->toolsettings, ob);
270 EDBM_mesh_normals_update(((Mesh *)ob->data)->edit_btmesh);
271 BKE_editmesh_tessface_calc(((Mesh *)ob->data)->edit_btmesh);
285 rna_Object_internal_update_data(bmain, scene, ptr);
288 static void rna_Object_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
290 DAG_id_tag_update(ptr->id.data, OB_RECALC_OB);
291 DAG_relations_tag_update(bmain);
292 WM_main_add_notifier(NC_OBJECT | ND_PARENT, ptr->id.data);
295 /* when changing the selection flag the scene needs updating */
296 static void rna_Object_select_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
299 Object *ob = (Object *)ptr->id.data;
300 short mode = ob->flag & SELECT ? BA_SELECT : BA_DESELECT;
301 ED_base_object_select(BKE_scene_base_find(scene, ob), mode);
305 static void rna_Base_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
307 Base *base = (Base *)ptr->data;
308 short mode = base->flag & BA_SELECT ? BA_SELECT : BA_DESELECT;
309 ED_base_object_select(base, mode);
312 static void rna_Object_layer_update__internal(Main *bmain, Scene *scene, Base *base, Object *ob)
314 /* try to avoid scene sort */
316 /* pass - unlikely but when running scripts on startup it happens */
318 else if ((ob->lay & scene->lay) && (base->lay & scene->lay)) {
321 else if ((ob->lay & scene->lay) == 0 && (base->lay & scene->lay) == 0) {
325 DAG_relations_tag_update(bmain);
328 DAG_id_type_tag(bmain, ID_OB);
331 static void rna_Object_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
333 Object *ob = (Object *)ptr->id.data;
336 base = scene ? BKE_scene_base_find(scene, ob) : NULL;
340 SWAP(unsigned int, base->lay, ob->lay);
342 rna_Object_layer_update__internal(bmain, scene, base, ob);
345 WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, scene);
348 static void rna_Base_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
350 Base *base = (Base *)ptr->data;
351 Object *ob = (Object *)base->object;
353 rna_Object_layer_update__internal(bmain, scene, base, ob);
356 WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, scene);
359 static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
361 Object *ob = (Object *)ptr->data;
364 if (id == NULL || ob->mode & OB_MODE_EDIT)
367 if (ob->type == OB_EMPTY) {
369 id_us_min((ID *)ob->data);
373 if (id && GS(id->name) == ID_IM) {
378 else if (ob->type == OB_MESH) {
379 BKE_mesh_assign_object(ob, (Mesh *)id);
383 id_us_min((ID *)ob->data);
386 /* no need to type-check here ID. this is done in the _typef() function */
387 BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name)));
392 test_object_materials(G.main, id);
394 if (GS(id->name) == ID_CU)
395 BKE_curve_type_test(ob);
396 else if (ob->type == OB_ARMATURE)
397 BKE_pose_rebuild(ob, ob->data);
401 static StructRNA *rna_Object_data_typef(PointerRNA *ptr)
403 Object *ob = (Object *)ptr->data;
405 /* keep in sync with OB_DATA_SUPPORT_ID() macro */
407 case OB_EMPTY: return &RNA_Image;
408 case OB_MESH: return &RNA_Mesh;
409 case OB_CURVE: return &RNA_Curve;
410 case OB_SURF: return &RNA_Curve;
411 case OB_FONT: return &RNA_Curve;
412 case OB_MBALL: return &RNA_MetaBall;
413 case OB_LAMP: return &RNA_Lamp;
414 case OB_CAMERA: return &RNA_Camera;
415 case OB_LATTICE: return &RNA_Lattice;
416 case OB_ARMATURE: return &RNA_Armature;
417 case OB_SPEAKER: return &RNA_Speaker;
418 default: return &RNA_ID;
422 static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value)
424 Object *ob = (Object *)ptr->data;
425 Object *par = (Object *)value.data;
428 /* NOTE: this dummy check here prevents this method causing weird runtime errors on mingw 4.6.2 */
432 ED_object_parent(ob, par, ob->partype, ob->parsubstr);
436 static void rna_Object_parent_type_set(PointerRNA *ptr, int value)
438 Object *ob = (Object *)ptr->data;
440 ED_object_parent(ob, ob->parent, value, ob->parsubstr);
443 static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *UNUSED(C), PointerRNA *ptr,
444 PropertyRNA *UNUSED(prop), int *free)
446 Object *ob = (Object *)ptr->data;
447 EnumPropertyItem *item = NULL;
450 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PAROBJECT);
453 Object *par = ob->parent;
455 if (par->type == OB_CURVE) {
456 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARCURVE);
458 else if (par->type == OB_LATTICE) {
459 /* special hack: prevents this overriding others */
460 RNA_enum_items_add_value(&item, &totitem, &parent_type_items[4], PARSKEL);
462 else if (par->type == OB_ARMATURE) {
463 /* special hack: prevents this being overrided */
464 RNA_enum_items_add_value(&item, &totitem, &parent_type_items[3], PARSKEL);
465 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARBONE);
468 if (ELEM4(par->type, OB_MESH, OB_CURVE, OB_SURF, OB_LATTICE)) {
469 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT1);
470 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT3);
474 RNA_enum_item_end(&item, &totitem);
480 static EnumPropertyItem *rna_Object_collision_bounds_itemf(bContext *UNUSED(C), PointerRNA *ptr,
481 PropertyRNA *UNUSED(prop), int *free)
483 Object *ob = (Object *)ptr->data;
484 EnumPropertyItem *item = NULL;
487 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_TRIANGLE_MESH);
488 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CONVEX_HULL);
490 if (ob->body_type != OB_BODY_TYPE_SOFT) {
491 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CONE);
492 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CYLINDER);
493 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_SPHERE);
494 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_BOX);
495 RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CAPSULE);
498 RNA_enum_item_end(&item, &totitem);
504 static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value)
506 Object *ob = (Object *)ptr->data;
508 ED_object_parent(ob, ob->parent, ob->partype, value);
511 static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value)
513 Object *ob = (Object *)ptr->data;
514 Group *grp = (Group *)value.data;
516 /* must not let this be set if the object belongs in this group already,
517 * thus causing a cycle/infinite-recursion leading to crashes on load [#25298]
519 if (BKE_group_object_exists(grp, ob) == 0)
522 BKE_report(NULL, RPT_ERROR,
523 "Cannot set dupli-group as object belongs in group being instanced, thus causing a cycle");
526 static void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
528 Object *ob = (Object *)ptr->id.data;
529 bDeformGroup *dg = (bDeformGroup *)ptr->data;
530 BLI_strncpy_utf8(dg->name, value, sizeof(dg->name));
531 defgroup_unique_name(dg, ob);
534 static int rna_VertexGroup_index_get(PointerRNA *ptr)
536 Object *ob = (Object *)ptr->id.data;
538 return BLI_findindex(&ob->defbase, ptr->data);
541 static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr)
543 Object *ob = (Object *)ptr->id.data;
544 return rna_pointer_inherit_refine(ptr, &RNA_VertexGroup, BLI_findlink(&ob->defbase, ob->actdef - 1));
547 static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr)
549 Object *ob = (Object *)ptr->id.data;
550 return ob->actdef - 1;
553 static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value)
555 Object *ob = (Object *)ptr->id.data;
556 ob->actdef = value + 1;
559 static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
561 Object *ob = (Object *)ptr->id.data;
564 *max = max_ii(0, BLI_countlist(&ob->defbase) - 1);
567 void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
569 Object *ob = (Object *)ptr->id.data;
572 dg = BLI_findlink(&ob->defbase, index - 1);
574 if (dg) BLI_strncpy(value, dg->name, sizeof(dg->name));
575 else value[0] = '\0';
578 int rna_object_vgroup_name_index_length(PointerRNA *ptr, int index)
580 Object *ob = (Object *)ptr->id.data;
583 dg = BLI_findlink(&ob->defbase, index - 1);
584 return (dg) ? strlen(dg->name) : 0;
587 void rna_object_vgroup_name_index_set(PointerRNA *ptr, const char *value, short *index)
589 Object *ob = (Object *)ptr->id.data;
590 *index = defgroup_name_index(ob, value) + 1;
593 void rna_object_vgroup_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
595 Object *ob = (Object *)ptr->id.data;
596 bDeformGroup *dg = defgroup_find_name(ob, value);
598 BLI_strncpy(result, value, maxlen); /* no need for BLI_strncpy_utf8, since this matches an existing group */
605 void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
607 Object *ob = (Object *)ptr->id.data;
609 CustomDataLayer *layer;
612 if (ob->type == OB_MESH && ob->data) {
613 me = (Mesh *)ob->data;
615 for (a = 0; a < me->pdata.totlayer; a++) {
616 layer = &me->pdata.layers[a];
618 if (layer->type == CD_MTEXPOLY && strcmp(layer->name, value) == 0) {
619 BLI_strncpy(result, value, maxlen);
628 void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
630 Object *ob = (Object *)ptr->id.data;
632 CustomDataLayer *layer;
635 if (ob->type == OB_MESH && ob->data) {
636 me = (Mesh *)ob->data;
638 for (a = 0; a < me->fdata.totlayer; a++) {
639 layer = &me->fdata.layers[a];
641 if (layer->type == CD_MCOL && strcmp(layer->name, value) == 0) {
642 BLI_strncpy(result, value, maxlen);
651 static int rna_Object_active_material_index_get(PointerRNA *ptr)
653 Object *ob = (Object *)ptr->id.data;
654 return MAX2(ob->actcol - 1, 0);
657 static void rna_Object_active_material_index_set(PointerRNA *ptr, int value)
659 Object *ob = (Object *)ptr->id.data;
660 ob->actcol = value + 1;
662 if (ob->type == OB_MESH) {
666 me->edit_btmesh->mat_nr = value;
670 static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
672 Object *ob = (Object *)ptr->id.data;
674 *max = max_ii(ob->totcol - 1, 0);
677 /* returns active base material */
678 static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
680 Object *ob = (Object *)ptr->id.data;
683 ma = (ob->totcol) ? give_current_material(ob, ob->actcol) : NULL;
684 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
687 static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value)
689 Object *ob = (Object *)ptr->id.data;
691 DAG_id_tag_update(value.data, 0);
692 assign_material(ob, value.data, ob->actcol, BKE_MAT_ASSIGN_USERPREF);
695 static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int *min, int *max,
696 int *softmin, int *softmax)
698 Object *ob = (Object *)ptr->id.data;
700 *max = max_ii(0, BLI_countlist(&ob->particlesystem) - 1);
703 static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
705 Object *ob = (Object *)ptr->id.data;
706 return psys_get_current_num(ob);
709 static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int value)
711 Object *ob = (Object *)ptr->id.data;
712 psys_set_current_num(ob, value);
715 static void rna_Object_particle_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
717 Object *ob = (Object *)ptr->id.data;
719 PE_current_changed(scene, ob);
722 /* rotation - axis-angle */
723 static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value)
725 Object *ob = ptr->data;
727 /* for now, assume that rotation mode is axis-angle */
728 value[0] = ob->rotAngle;
729 copy_v3_v3(&value[1], ob->rotAxis);
732 /* rotation - axis-angle */
733 static void rna_Object_rotation_axis_angle_set(PointerRNA *ptr, const float *value)
735 Object *ob = ptr->data;
737 /* for now, assume that rotation mode is axis-angle */
738 ob->rotAngle = value[0];
739 copy_v3_v3(ob->rotAxis, (float *)&value[1]);
741 /* TODO: validate axis? */
744 static void rna_Object_rotation_mode_set(PointerRNA *ptr, int value)
746 Object *ob = ptr->data;
748 /* use API Method for conversions... */
749 BKE_rotMode_change_values(ob->quat, ob->rot, ob->rotAxis, &ob->rotAngle, ob->rotmode, (short)value);
751 /* finally, set the new rotation type */
755 static void rna_Object_dimensions_get(PointerRNA *ptr, float *value)
757 Object *ob = ptr->data;
758 BKE_object_dimensions_get(ob, value);
761 static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value)
763 Object *ob = ptr->data;
764 BKE_object_dimensions_set(ob, value);
767 static int rna_Object_location_editable(PointerRNA *ptr, int index)
769 Object *ob = (Object *)ptr->data;
771 /* only if the axis in question is locked, not editable... */
772 if ((index == 0) && (ob->protectflag & OB_LOCK_LOCX))
774 else if ((index == 1) && (ob->protectflag & OB_LOCK_LOCY))
776 else if ((index == 2) && (ob->protectflag & OB_LOCK_LOCZ))
779 return PROP_EDITABLE;
782 static int rna_Object_scale_editable(PointerRNA *ptr, int index)
784 Object *ob = (Object *)ptr->data;
786 /* only if the axis in question is locked, not editable... */
787 if ((index == 0) && (ob->protectflag & OB_LOCK_SCALEX))
789 else if ((index == 1) && (ob->protectflag & OB_LOCK_SCALEY))
791 else if ((index == 2) && (ob->protectflag & OB_LOCK_SCALEZ))
794 return PROP_EDITABLE;
797 static int rna_Object_rotation_euler_editable(PointerRNA *ptr, int index)
799 Object *ob = (Object *)ptr->data;
801 /* only if the axis in question is locked, not editable... */
802 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTX))
804 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTY))
806 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTZ))
809 return PROP_EDITABLE;
812 static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index)
814 Object *ob = (Object *)ptr->data;
816 /* only consider locks if locking components individually... */
817 if (ob->protectflag & OB_LOCK_ROT4D) {
818 /* only if the axis in question is locked, not editable... */
819 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTW))
821 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTX))
823 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTY))
825 else if ((index == 3) && (ob->protectflag & OB_LOCK_ROTZ))
829 return PROP_EDITABLE;
833 static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr)
835 Object *ob = (Object *)ptr->id.data;
837 int index = (Material **)ptr->data - ob->mat;
839 ma = give_current_material(ob, index + 1);
840 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
843 static void rna_MaterialSlot_material_set(PointerRNA *ptr, PointerRNA value)
845 Object *ob = (Object *)ptr->id.data;
846 int index = (Material **)ptr->data - ob->mat;
848 assign_material(ob, value.data, index + 1, BKE_MAT_ASSIGN_USERPREF);
851 static int rna_MaterialSlot_link_get(PointerRNA *ptr)
853 Object *ob = (Object *)ptr->id.data;
854 int index = (Material **)ptr->data - ob->mat;
856 return ob->matbits[index] != 0;
859 static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value)
861 Object *ob = (Object *)ptr->id.data;
862 int index = (Material **)ptr->data - ob->mat;
865 ob->matbits[index] = 1;
866 /* ob->colbits |= (1 << index); */ /* DEPRECATED */
869 ob->matbits[index] = 0;
870 /* ob->colbits &= ~(1 << index); */ /* DEPRECATED */
874 static int rna_MaterialSlot_name_length(PointerRNA *ptr)
876 Object *ob = (Object *)ptr->id.data;
878 int index = (Material **)ptr->data - ob->mat;
880 ma = give_current_material(ob, index + 1);
883 return strlen(ma->id.name + 2);
888 static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str)
890 Object *ob = (Object *)ptr->id.data;
892 int index = (Material **)ptr->data - ob->mat;
894 ma = give_current_material(ob, index + 1);
897 strcpy(str, ma->id.name + 2);
902 static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr)
904 rna_Object_internal_update(bmain, scene, ptr);
905 WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, ptr->id.data);
906 WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, NULL);
909 /* why does this have to be so complicated?, can't all this crap be
910 * moved to in BGE conversion function? - Campbell *
912 * logic from check_body_type()
914 static int rna_GameObjectSettings_physics_type_get(PointerRNA *ptr)
916 Object *ob = (Object *)ptr->id.data;
918 /* determine the body_type setting based on flags */
919 if (!(ob->gameflag & OB_COLLISION)) {
920 if (ob->gameflag & OB_OCCLUDER) {
921 ob->body_type = OB_BODY_TYPE_OCCLUDER;
923 else if (ob->gameflag & OB_NAVMESH) {
924 ob->body_type = OB_BODY_TYPE_NAVMESH;
927 ob->body_type = OB_BODY_TYPE_NO_COLLISION;
930 else if (ob->gameflag & OB_CHARACTER) {
931 ob->body_type = OB_BODY_TYPE_CHARACTER;
933 else if (ob->gameflag & OB_SENSOR) {
934 ob->body_type = OB_BODY_TYPE_SENSOR;
936 else if (!(ob->gameflag & OB_DYNAMIC)) {
937 ob->body_type = OB_BODY_TYPE_STATIC;
939 else if (!(ob->gameflag & (OB_RIGID_BODY | OB_SOFT_BODY))) {
940 ob->body_type = OB_BODY_TYPE_DYNAMIC;
942 else if (ob->gameflag & OB_RIGID_BODY) {
943 ob->body_type = OB_BODY_TYPE_RIGID;
946 ob->body_type = OB_BODY_TYPE_SOFT;
947 /* create the structure here because we display soft body buttons in the main panel */
949 ob->bsoft = bsbNew();
952 return ob->body_type;
955 static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value)
957 Object *ob = (Object *)ptr->id.data;
958 const int was_navmesh = (ob->gameflag & OB_NAVMESH);
959 ob->body_type = value;
961 switch (ob->body_type) {
962 case OB_BODY_TYPE_SENSOR:
963 ob->gameflag |= OB_SENSOR | OB_COLLISION | OB_GHOST;
964 ob->gameflag &= ~(OB_OCCLUDER | OB_CHARACTER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR |
965 OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH);
967 case OB_BODY_TYPE_OCCLUDER:
968 ob->gameflag |= OB_OCCLUDER;
969 ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_DYNAMIC | OB_NAVMESH);
971 case OB_BODY_TYPE_NAVMESH:
972 ob->gameflag |= OB_NAVMESH;
973 ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_DYNAMIC | OB_OCCLUDER);
975 if (ob->type == OB_MESH) {
976 /* could be moved into mesh UI but for now ensure mesh data layer */
977 BKE_mesh_ensure_navmesh(ob->data);
981 case OB_BODY_TYPE_NO_COLLISION:
982 ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH);
984 case OB_BODY_TYPE_CHARACTER:
985 ob->gameflag |= OB_COLLISION | OB_GHOST | OB_CHARACTER;
986 ob->gameflag &= ~(OB_SENSOR | OB_OCCLUDER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR |
987 OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH);
989 case OB_BODY_TYPE_STATIC:
990 ob->gameflag |= OB_COLLISION;
991 ob->gameflag &= ~(OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
993 case OB_BODY_TYPE_DYNAMIC:
994 ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_ACTOR;
995 ob->gameflag &= ~(OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
997 case OB_BODY_TYPE_RIGID:
998 ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_RIGID_BODY | OB_ACTOR;
999 ob->gameflag &= ~(OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
1002 case OB_BODY_TYPE_SOFT:
1003 ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_SOFT_BODY | OB_ACTOR;
1004 ob->gameflag &= ~(OB_RIGID_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH);
1006 /* assume triangle mesh, if no bounds chosen for soft body */
1007 if ((ob->gameflag & OB_BOUNDS) && (ob->boundtype < OB_BOUND_TRIANGLE_MESH)) {
1008 ob->boundtype = OB_BOUND_TRIANGLE_MESH;
1010 /* create a BulletSoftBody structure if not already existing */
1012 ob->bsoft = bsbNew();
1016 if (was_navmesh != (ob->gameflag & OB_NAVMESH)) {
1017 if (ob->type == OB_MESH) {
1018 /* this is needed to refresh the derived meshes draw func */
1019 DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
1023 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
1026 static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr)
1028 Object *ob = (Object *)ptr->id.data;
1029 ParticleSystem *psys = psys_get_current(ob);
1030 return rna_pointer_inherit_refine(ptr, &RNA_ParticleSystem, psys);
1033 static PointerRNA rna_Object_game_settings_get(PointerRNA *ptr)
1035 return rna_pointer_inherit_refine(ptr, &RNA_GameObjectSettings, ptr->id.data);
1039 static unsigned int rna_Object_layer_validate__internal(const int *values, unsigned int lay)
1043 /* ensure we always have some layer selected */
1044 for (i = 0; i < 20; i++)
1051 for (i = 0; i < 20; i++) {
1052 if (values[i]) lay |= (1 << i);
1053 else lay &= ~(1 << i);
1059 static void rna_Object_layer_set(PointerRNA *ptr, const int *values)
1061 Object *ob = (Object *)ptr->data;
1064 lay = rna_Object_layer_validate__internal(values, ob->lay);
1069 static void rna_Base_layer_set(PointerRNA *ptr, const int *values)
1071 Base *base = (Base *)ptr->data;
1074 lay = rna_Object_layer_validate__internal(values, base->lay);
1078 /* rna_Base_layer_update updates the objects layer */
1081 static void rna_GameObjectSettings_state_get(PointerRNA *ptr, int *values)
1083 Object *ob = (Object *)ptr->data;
1085 int all_states = (ob->scaflag & OB_ALLSTATE ? 1 : 0);
1087 memset(values, 0, sizeof(int) * OB_MAX_STATES);
1088 for (i = 0; i < OB_MAX_STATES; i++) {
1089 values[i] = (ob->state & (1 << i)) | all_states;
1093 static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values)
1095 Object *ob = (Object *)ptr->data;
1098 /* ensure we always have some state selected */
1099 for (i = 0; i < OB_MAX_STATES; i++)
1106 for (i = 0; i < OB_MAX_STATES; i++) {
1107 if (values[i]) ob->state |= (1 << i);
1108 else ob->state &= ~(1 << i);
1112 static void rna_GameObjectSettings_used_state_get(PointerRNA *ptr, int *values)
1114 Object *ob = (Object *)ptr->data;
1117 memset(values, 0, sizeof(int) * OB_MAX_STATES);
1118 for (cont = ob->controllers.first; cont; cont = cont->next) {
1121 for (i = 0; i < OB_MAX_STATES; i++) {
1122 if (cont->state_mask & (1 << i))
1128 static void rna_GameObjectSettings_col_group_get(PointerRNA *ptr, int *values)
1130 Object *ob = (Object *)ptr->data;
1133 for (i = 0; i < OB_MAX_COL_MASKS; i++) {
1134 values[i] = (ob->col_group & (1 << i));
1138 static void rna_GameObjectSettings_col_group_set(PointerRNA *ptr, const int *values)
1140 Object *ob = (Object *)ptr->data;
1143 /* ensure we always have some group selected */
1144 for (i = 0; i < OB_MAX_COL_MASKS; i++)
1151 for (i = 0; i < OB_MAX_COL_MASKS; i++) {
1152 if (values[i]) ob->col_group |= (1 << i);
1153 else ob->col_group &= ~(1 << i);
1157 static void rna_GameObjectSettings_col_mask_get(PointerRNA *ptr, int *values)
1159 Object *ob = (Object *)ptr->data;
1162 for (i = 0; i < OB_MAX_COL_MASKS; i++) {
1163 values[i] = (ob->col_mask & (1 << i));
1167 static void rna_GameObjectSettings_col_mask_set(PointerRNA *ptr, const int *values)
1169 Object *ob = (Object *)ptr->data;
1172 /* ensure we always have some mask selected */
1173 for (i = 0; i < OB_MAX_COL_MASKS; i++)
1180 for (i = 0; i < OB_MAX_COL_MASKS; i++) {
1181 if (values[i]) ob->col_mask |= (1 << i);
1182 else ob->col_mask &= ~(1 << i);
1187 static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
1189 Object *ob = (Object *)ptr->id.data;
1190 Key *key = BKE_key_from_object(ob);
1194 *max = BLI_countlist(&key->block) - 1;
1195 if (*max < 0) *max = 0;
1202 static int rna_Object_active_shape_key_index_get(PointerRNA *ptr)
1204 Object *ob = (Object *)ptr->id.data;
1206 return MAX2(ob->shapenr - 1, 0);
1209 static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value)
1211 Object *ob = (Object *)ptr->id.data;
1213 ob->shapenr = value + 1;
1216 static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr)
1218 Object *ob = (Object *)ptr->id.data;
1219 Key *key = BKE_key_from_object(ob);
1224 return PointerRNA_NULL;
1226 kb = BLI_findlink(&key->block, ob->shapenr - 1);
1227 RNA_pointer_create((ID *)key, &RNA_ShapeKey, kb, &keyptr);
1231 static PointerRNA rna_Object_field_get(PointerRNA *ptr)
1233 Object *ob = (Object *)ptr->id.data;
1237 ob->pd = object_add_collision_fields(0);
1239 return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, ob->pd);
1242 static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
1244 Object *ob = (Object *)ptr->id.data;
1246 if (ob->type != OB_MESH)
1247 return PointerRNA_NULL;
1251 ob->pd = object_add_collision_fields(0);
1253 return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd);
1256 static PointerRNA rna_Object_active_constraint_get(PointerRNA *ptr)
1258 Object *ob = (Object *)ptr->id.data;
1259 bConstraint *con = BKE_constraints_get_active(&ob->constraints);
1260 return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con);
1263 static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value)
1265 Object *ob = (Object *)ptr->id.data;
1266 BKE_constraints_set_active(&ob->constraints, (bConstraint *)value.data);
1269 static bConstraint *rna_Object_constraints_new(Object *object, int type)
1271 WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, object);
1272 return BKE_add_ob_constraint(object, NULL, type);
1275 static void rna_Object_constraints_remove(Object *object, ReportList *reports, PointerRNA *con_ptr)
1277 bConstraint *con = con_ptr->data;
1278 if (BLI_findindex(&object->constraints, con) == -1) {
1279 BKE_reportf(reports, RPT_ERROR, "Constraint '%s' not found in object '%s'", con->name, object->id.name + 2);
1283 BKE_remove_constraint(&object->constraints, con);
1284 RNA_POINTER_INVALIDATE(con_ptr);
1286 ED_object_constraint_update(object);
1287 ED_object_constraint_set_active(object, NULL);
1288 WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
1291 static void rna_Object_constraints_clear(Object *object)
1293 BKE_free_constraints(&object->constraints);
1295 ED_object_constraint_update(object);
1296 ED_object_constraint_set_active(object, NULL);
1298 WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
1301 static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports,
1302 const char *name, int type)
1304 return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
1307 static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, PointerRNA *md_ptr)
1309 ModifierData *md = md_ptr->data;
1310 if (ED_object_modifier_remove(reports, CTX_data_main(C), object, md) == FALSE) {
1311 /* error is already set */
1315 RNA_POINTER_INVALIDATE(md_ptr);
1317 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1320 static void rna_Object_modifier_clear(Object *object, bContext *C)
1322 ED_object_modifier_clear(CTX_data_main(C), object);
1324 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1327 static void rna_Object_boundbox_get(PointerRNA *ptr, float *values)
1329 Object *ob = (Object *)ptr->id.data;
1330 BoundBox *bb = BKE_object_boundbox_get(ob);
1332 memcpy(values, bb->vec, sizeof(bb->vec));
1335 fill_vn_fl(values, sizeof(bb->vec) / sizeof(float), 0.0f);
1340 static bDeformGroup *rna_Object_vgroup_new(Object *ob, const char *name)
1342 bDeformGroup *defgroup = ED_vgroup_add_name(ob, name);
1344 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1349 static void rna_Object_vgroup_remove(Object *ob, ReportList *reports, PointerRNA *defgroup_ptr)
1351 bDeformGroup *defgroup = defgroup_ptr->data;
1352 if (BLI_findindex(&ob->defbase, defgroup) == -1) {
1353 BKE_reportf(reports, RPT_ERROR, "DeformGroup '%s' not in object '%s'", defgroup->name, ob->id.name + 2);
1357 ED_vgroup_delete(ob, defgroup);
1358 RNA_POINTER_INVALIDATE(defgroup_ptr);
1360 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1363 static void rna_Object_vgroup_clear(Object *ob)
1365 ED_vgroup_clear(ob);
1367 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1370 static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *reports, int index_len,
1371 int *index, float weight, int assignmode)
1373 Object *ob = (Object *)id;
1375 if (ED_vgroup_object_is_edit_mode(ob)) {
1376 BKE_report(reports, RPT_ERROR, "VertexGroup.add(): cannot be called while object is in edit mode");
1381 ED_vgroup_vert_add(ob, def, *index++, weight, assignmode); /* XXX, not efficient calling within loop*/
1383 WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
1386 static void rna_VertexGroup_vertex_remove(ID *id, bDeformGroup *dg, ReportList *reports, int index_len, int *index)
1388 Object *ob = (Object *)id;
1390 if (ED_vgroup_object_is_edit_mode(ob)) {
1391 BKE_report(reports, RPT_ERROR, "VertexGroup.remove(): cannot be called while object is in edit mode");
1396 ED_vgroup_vert_remove(ob, dg, *index++);
1398 WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
1401 static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *reports, int index)
1403 float weight = ED_vgroup_vert_weight((Object *)id, dg, index);
1406 BKE_report(reports, RPT_ERROR, "Vertex not in group");
1411 /* generic poll functions */
1412 int rna_Lattice_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1414 return ((Object *)value.id.data)->type == OB_LATTICE;
1417 int rna_Curve_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1419 return ((Object *)value.id.data)->type == OB_CURVE;
1422 int rna_Armature_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1424 return ((Object *)value.id.data)->type == OB_ARMATURE;
1427 int rna_Mesh_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1429 return ((Object *)value.id.data)->type == OB_MESH;
1432 int rna_Camera_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1434 return ((Object *)value.id.data)->type == OB_CAMERA;
1437 int rna_DupliObject_index_get(PointerRNA *ptr)
1439 DupliObject *dob = (DupliObject *)ptr->data;
1440 return dob->persistent_id[0];
1443 int rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr)
1445 SculptSession *ss = ((Object *)ptr->id.data)->sculpt;
1446 return (ss && ss->bm);
1451 static int rna_matrix_dimsize_4x4[] = {4, 4};
1453 static void rna_def_vertex_group(BlenderRNA *brna)
1459 static EnumPropertyItem assign_mode_items[] = {
1460 {WEIGHT_REPLACE, "REPLACE", 0, "Replace", "Replace"},
1461 {WEIGHT_ADD, "ADD", 0, "Add", "Add"},
1462 {WEIGHT_SUBTRACT, "SUBTRACT", 0, "Subtract", "Subtract"},
1463 {0, NULL, 0, NULL, NULL}
1466 srna = RNA_def_struct(brna, "VertexGroup", NULL);
1467 RNA_def_struct_sdna(srna, "bDeformGroup");
1468 RNA_def_struct_ui_text(srna, "Vertex Group", "Group of vertices, used for armature deform and other purposes");
1469 RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX);
1471 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1472 RNA_def_property_ui_text(prop, "Name", "Vertex group name");
1473 RNA_def_struct_name_property(srna, prop);
1474 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_VertexGroup_name_set");
1475 /* update data because modifiers may use [#24761] */
1476 RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
1478 prop = RNA_def_property(srna, "lock_weight", PROP_BOOLEAN, PROP_NONE);
1479 RNA_def_property_ui_text(prop, "", "Maintain the relative weights for the group");
1480 RNA_def_property_boolean_sdna(prop, NULL, "flag", 0);
1481 /* update data because modifiers may use [#24761] */
1482 RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
1484 prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
1485 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1486 RNA_def_property_int_funcs(prop, "rna_VertexGroup_index_get", NULL, NULL);
1487 RNA_def_property_ui_text(prop, "Index", "Index number of the vertex group");
1489 func = RNA_def_function(srna, "add", "rna_VertexGroup_vertex_add");
1490 RNA_def_function_ui_description(func, "Add vertices to the group");
1491 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
1492 /* TODO, see how array size of 0 works, this shouldnt be used */
1493 prop = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
1494 RNA_def_property_flag(prop, PROP_DYNAMIC | PROP_REQUIRED);
1495 prop = RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight", 0.0f, 1.0f);
1496 RNA_def_property_flag(prop, PROP_REQUIRED);
1497 prop = RNA_def_enum(func, "type", assign_mode_items, 0, "", "Vertex assign mode");
1498 RNA_def_property_flag(prop, PROP_REQUIRED);
1500 func = RNA_def_function(srna, "remove", "rna_VertexGroup_vertex_remove");
1501 RNA_def_function_ui_description(func, "Remove a vertex from the group");
1502 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
1503 /* TODO, see how array size of 0 works, this shouldnt be used */
1504 prop = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
1505 RNA_def_property_flag(prop, PROP_DYNAMIC | PROP_REQUIRED);
1507 func = RNA_def_function(srna, "weight", "rna_VertexGroup_weight");
1508 RNA_def_function_ui_description(func, "Get a vertex weight from the group");
1509 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
1510 prop = RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "The index of the vertex", 0, INT_MAX);
1511 RNA_def_property_flag(prop, PROP_REQUIRED);
1512 prop = RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight", 0.0f, 1.0f);
1513 RNA_def_function_return(func, prop);
1516 static void rna_def_material_slot(BlenderRNA *brna)
1521 static EnumPropertyItem link_items[] = {
1522 {1, "OBJECT", 0, "Object", ""},
1523 {0, "DATA", 0, "Data", ""},
1524 {0, NULL, 0, NULL, NULL}
1527 /* NOTE: there is no MaterialSlot equivalent in DNA, so the internal
1528 * pointer data points to ob->mat + index, and we manually implement
1529 * get/set for the properties. */
1531 srna = RNA_def_struct(brna, "MaterialSlot", NULL);
1532 RNA_def_struct_ui_text(srna, "Material Slot", "Material slot in an object");
1533 RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
1535 prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
1536 RNA_def_property_struct_type(prop, "Material");
1537 RNA_def_property_flag(prop, PROP_EDITABLE);
1538 RNA_def_property_pointer_funcs(prop, "rna_MaterialSlot_material_get", "rna_MaterialSlot_material_set", NULL, NULL);
1539 RNA_def_property_ui_text(prop, "Material", "Material datablock used by this material slot");
1540 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
1542 prop = RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE);
1543 RNA_def_property_enum_items(prop, link_items);
1544 RNA_def_property_enum_funcs(prop, "rna_MaterialSlot_link_get", "rna_MaterialSlot_link_set", NULL);
1545 RNA_def_property_ui_text(prop, "Link", "Link material to object or the object's data");
1546 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
1548 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1549 RNA_def_property_string_funcs(prop, "rna_MaterialSlot_name_get", "rna_MaterialSlot_name_length", NULL);
1550 RNA_def_property_ui_text(prop, "Name", "Material slot name");
1551 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1552 RNA_def_struct_name_property(srna, prop);
1555 static void rna_def_object_game_settings(BlenderRNA *brna)
1560 static EnumPropertyItem body_type_items[] = {
1561 {OB_BODY_TYPE_NO_COLLISION, "NO_COLLISION", 0, "No Collision", "Disable collision for this object"},
1562 {OB_BODY_TYPE_STATIC, "STATIC", 0, "Static", "Stationary object"},
1563 {OB_BODY_TYPE_DYNAMIC, "DYNAMIC", 0, "Dynamic", "Linear physics"},
1564 {OB_BODY_TYPE_RIGID, "RIGID_BODY", 0, "Rigid Body", "Linear and angular physics"},
1565 {OB_BODY_TYPE_SOFT, "SOFT_BODY", 0, "Soft Body", "Soft body"},
1566 {OB_BODY_TYPE_OCCLUDER, "OCCLUDE", 0, "Occlude", "Occluder for optimizing scene rendering"},
1567 {OB_BODY_TYPE_SENSOR, "SENSOR", 0, "Sensor",
1568 "Collision Sensor, detects static and dynamic objects but not the other "
1569 "collision sensor objects"},
1570 {OB_BODY_TYPE_NAVMESH, "NAVMESH", 0, "Navigation Mesh", "Navigation mesh"},
1571 {OB_BODY_TYPE_CHARACTER, "CHARACTER", 0, "Character",
1572 "Simple kinematic physics appropriate for game characters"},
1573 {0, NULL, 0, NULL, NULL}
1576 srna = RNA_def_struct(brna, "GameObjectSettings", NULL);
1577 RNA_def_struct_sdna(srna, "Object");
1578 RNA_def_struct_nested(brna, srna, "Object");
1579 RNA_def_struct_ui_text(srna, "Game Object Settings", "Game engine related settings for the object");
1580 RNA_def_struct_ui_icon(srna, ICON_GAME);
1584 prop = RNA_def_property(srna, "sensors", PROP_COLLECTION, PROP_NONE);
1585 RNA_def_property_struct_type(prop, "Sensor");
1586 RNA_def_property_ui_text(prop, "Sensors", "Game engine sensor to detect events");
1588 prop = RNA_def_property(srna, "controllers", PROP_COLLECTION, PROP_NONE);
1589 RNA_def_property_struct_type(prop, "Controller");
1590 RNA_def_property_ui_text(prop, "Controllers",
1591 "Game engine controllers to process events, connecting sensors to actuators");
1593 prop = RNA_def_property(srna, "actuators", PROP_COLLECTION, PROP_NONE);
1594 RNA_def_property_struct_type(prop, "Actuator");
1595 RNA_def_property_ui_text(prop, "Actuators", "Game engine actuators to act on events");
1597 prop = RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE);
1598 RNA_def_property_collection_sdna(prop, NULL, "prop", NULL);
1599 RNA_def_property_struct_type(prop, "GameProperty"); /* rna_property.c */
1600 RNA_def_property_ui_text(prop, "Properties", "Game engine properties");
1602 prop = RNA_def_property(srna, "show_sensors", PROP_BOOLEAN, PROP_NONE);
1603 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSENS);
1604 RNA_def_property_ui_text(prop, "Show Sensors", "Shows sensors for this object in the user interface");
1606 prop = RNA_def_property(srna, "show_controllers", PROP_BOOLEAN, PROP_NONE);
1607 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWCONT);
1608 RNA_def_property_ui_text(prop, "Show Controllers", "Shows controllers for this object in the user interface");
1610 prop = RNA_def_property(srna, "show_actuators", PROP_BOOLEAN, PROP_NONE);
1611 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWACT);
1612 RNA_def_property_ui_text(prop, "Show Actuators", "Shows actuators for this object in the user interface");
1616 prop = RNA_def_property(srna, "physics_type", PROP_ENUM, PROP_NONE);
1617 RNA_def_property_enum_sdna(prop, NULL, "body_type");
1618 RNA_def_property_enum_items(prop, body_type_items);
1619 RNA_def_property_enum_funcs(prop, "rna_GameObjectSettings_physics_type_get",
1620 "rna_GameObjectSettings_physics_type_set", NULL);
1621 RNA_def_property_ui_text(prop, "Physics Type", "Select the type of physical representation");
1622 RNA_def_property_update(prop, NC_LOGIC, NULL);
1624 prop = RNA_def_property(srna, "use_actor", PROP_BOOLEAN, PROP_NONE);
1625 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ACTOR);
1626 RNA_def_property_ui_text(prop, "Actor", "Object is detected by the Near and Radar sensor");
1628 prop = RNA_def_property(srna, "use_ghost", PROP_BOOLEAN, PROP_NONE);
1629 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_GHOST);
1630 RNA_def_property_ui_text(prop, "Ghost", "Object does not react to collisions, like a ghost");
1632 prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE);
1633 RNA_def_property_range(prop, 0.01, 10000.0);
1634 RNA_def_property_ui_text(prop, "Mass", "Mass of the object");
1636 prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
1637 RNA_def_property_float_sdna(prop, NULL, "inertia");
1638 RNA_def_property_range(prop, 0.01f, FLT_MAX);
1639 RNA_def_property_ui_range(prop, 0.01f, 10.0f, 1, 3);
1640 RNA_def_property_ui_text(prop, "Radius", "Radius of bounding sphere and material physics");
1641 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
1643 prop = RNA_def_property(srna, "use_sleep", PROP_BOOLEAN, PROP_NONE);
1644 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_COLLISION_RESPONSE);
1645 RNA_def_property_ui_text(prop, "No Sleeping", "Disable auto (de)activation in physics simulation");
1647 prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE);
1648 RNA_def_property_float_sdna(prop, NULL, "damping");
1649 RNA_def_property_range(prop, 0.0, 1.0);
1650 RNA_def_property_ui_text(prop, "Damping", "General movement damping");
1652 prop = RNA_def_property(srna, "rotation_damping", PROP_FLOAT, PROP_NONE);
1653 RNA_def_property_float_sdna(prop, NULL, "rdamping");
1654 RNA_def_property_range(prop, 0.0, 1.0);
1655 RNA_def_property_ui_text(prop, "Rotation Damping", "General rotation damping");
1657 prop = RNA_def_property(srna, "velocity_min", PROP_FLOAT, PROP_NONE);
1658 RNA_def_property_float_sdna(prop, NULL, "min_vel");
1659 RNA_def_property_range(prop, 0.0, 1000.0);
1660 RNA_def_property_ui_text(prop, "Velocity Min", "Clamp velocity to this minimum speed (except when totally still)");
1662 prop = RNA_def_property(srna, "velocity_max", PROP_FLOAT, PROP_NONE);
1663 RNA_def_property_float_sdna(prop, NULL, "max_vel");
1664 RNA_def_property_range(prop, 0.0, 1000.0);
1665 RNA_def_property_ui_text(prop, "Velocity Max", "Clamp velocity to this maximum speed");
1667 /* Character physics */
1668 prop = RNA_def_property(srna, "step_height", PROP_FLOAT, PROP_NONE);
1669 RNA_def_property_float_sdna(prop, NULL, "step_height");
1670 RNA_def_property_range(prop, 0.01, 1.0);
1671 RNA_def_property_ui_text(prop, "Step Height", "Maximum height of steps the character can run over");
1673 prop = RNA_def_property(srna, "jump_speed", PROP_FLOAT, PROP_NONE);
1674 RNA_def_property_float_sdna(prop, NULL, "jump_speed");
1675 RNA_def_property_range(prop, 0.0, 1000.0);
1676 RNA_def_property_ui_text(prop, "Jump Force", "Upward velocity applied to the character when jumping");
1678 prop = RNA_def_property(srna, "fall_speed", PROP_FLOAT, PROP_NONE);
1679 RNA_def_property_float_sdna(prop, NULL, "fall_speed");
1680 RNA_def_property_range(prop, 0.0, 1000.0);
1681 RNA_def_property_ui_text(prop, "Fall Speed Max", "Maximum speed at which the character will fall");
1683 /* Collision Masks */
1684 prop = RNA_def_property(srna, "collision_group", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1685 RNA_def_property_boolean_sdna(prop, NULL, "col_group", 1);
1686 RNA_def_property_array(prop, OB_MAX_COL_MASKS);
1687 RNA_def_property_ui_text(prop, "Collision Group", "The collision group of the object");
1688 RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_group_get", "rna_GameObjectSettings_col_group_set");
1690 prop = RNA_def_property(srna, "collision_mask", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1691 RNA_def_property_boolean_sdna(prop, NULL, "col_mask", 1);
1692 RNA_def_property_array(prop, OB_MAX_COL_MASKS);
1693 RNA_def_property_ui_text(prop, "Collision Mask", "The groups this object can collide with");
1694 RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_mask_get", "rna_GameObjectSettings_col_mask_set");
1697 prop = RNA_def_property(srna, "lock_location_x", PROP_BOOLEAN, PROP_NONE);
1698 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_AXIS);
1699 RNA_def_property_ui_text(prop, "Lock X Axis", "Disable simulation of linear motion along the X axis");
1701 prop = RNA_def_property(srna, "lock_location_y", PROP_BOOLEAN, PROP_NONE);
1702 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_AXIS);
1703 RNA_def_property_ui_text(prop, "Lock Y Axis", "Disable simulation of linear motion along the Y axis");
1705 prop = RNA_def_property(srna, "lock_location_z", PROP_BOOLEAN, PROP_NONE);
1706 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_AXIS);
1707 RNA_def_property_ui_text(prop, "Lock Z Axis", "Disable simulation of linear motion along the Z axis");
1711 prop = RNA_def_property(srna, "lock_rotation_x", PROP_BOOLEAN, PROP_NONE);
1712 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_ROT_AXIS);
1713 RNA_def_property_ui_text(prop, "Lock X Rotation Axis", "Disable simulation of angular motion along the X axis");
1715 prop = RNA_def_property(srna, "lock_rotation_y", PROP_BOOLEAN, PROP_NONE);
1716 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_ROT_AXIS);
1717 RNA_def_property_ui_text(prop, "Lock Y Rotation Axis", "Disable simulation of angular motion along the Y axis");
1719 prop = RNA_def_property(srna, "lock_rotation_z", PROP_BOOLEAN, PROP_NONE);
1720 RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_ROT_AXIS);
1721 RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis");
1723 /* is this used anywhere ? */
1724 prop = RNA_def_property(srna, "use_activity_culling", PROP_BOOLEAN, PROP_NONE);
1725 RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflag2", OB_NEVER_DO_ACTIVITY_CULLING);
1726 RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis");
1729 prop = RNA_def_property(srna, "use_material_physics_fh", PROP_BOOLEAN, PROP_NONE);
1730 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_DO_FH);
1731 RNA_def_property_ui_text(prop, "Use Material Force Field", "React to force field physics settings in materials");
1733 prop = RNA_def_property(srna, "use_rotate_from_normal", PROP_BOOLEAN, PROP_NONE);
1734 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ROT_FH);
1735 RNA_def_property_ui_text(prop, "Rotate From Normal",
1736 "Use face normal to rotate object, so that it points away from the surface");
1738 prop = RNA_def_property(srna, "form_factor", PROP_FLOAT, PROP_NONE);
1739 RNA_def_property_float_sdna(prop, NULL, "formfactor");
1740 RNA_def_property_range(prop, 0.0, 1.0);
1741 RNA_def_property_ui_text(prop, "Form Factor", "Form factor scales the inertia tensor");
1743 prop = RNA_def_property(srna, "use_anisotropic_friction", PROP_BOOLEAN, PROP_NONE);
1744 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ANISOTROPIC_FRICTION);
1745 RNA_def_property_ui_text(prop, "Anisotropic Friction", "Enable anisotropic friction");
1747 prop = RNA_def_property(srna, "friction_coefficients", PROP_FLOAT, PROP_NONE);
1748 RNA_def_property_float_sdna(prop, NULL, "anisotropicFriction");
1749 RNA_def_property_range(prop, 0.0, 1.0);
1750 RNA_def_property_ui_text(prop, "Friction Coefficients",
1751 "Relative friction coefficients in the in the X, Y and Z directions, "
1752 "when anisotropic friction is enabled");
1754 prop = RNA_def_property(srna, "use_collision_bounds", PROP_BOOLEAN, PROP_NONE);
1755 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_BOUNDS);
1756 RNA_def_property_ui_text(prop, "Use Collision Bounds", "Specify a collision bounds type other than the default");
1757 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
1759 prop = RNA_def_property(srna, "collision_bounds_type", PROP_ENUM, PROP_NONE);
1760 RNA_def_property_enum_sdna(prop, NULL, "collision_boundtype");
1761 RNA_def_property_enum_items(prop, collision_bounds_items);
1762 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_collision_bounds_itemf");
1763 RNA_def_property_ui_text(prop, "Collision Bounds", "Select the collision type");
1764 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
1766 prop = RNA_def_property(srna, "use_collision_compound", PROP_BOOLEAN, PROP_NONE);
1767 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_CHILD);
1768 RNA_def_property_ui_text(prop, "Collision Compound", "Add children to form a compound collision object");
1770 prop = RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
1771 RNA_def_property_float_sdna(prop, NULL, "margin");
1772 RNA_def_property_range(prop, 0.0, 1.0);
1773 RNA_def_property_ui_text(prop, "Collision Margin",
1774 "Extra margin around object for collision detection, small amount required "
1777 prop = RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE);
1778 RNA_def_property_pointer_sdna(prop, NULL, "bsoft");
1779 RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for Bullet soft body simulation");
1781 prop = RNA_def_property(srna, "use_obstacle_create", PROP_BOOLEAN, PROP_NONE);
1782 RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_HASOBSTACLE);
1783 RNA_def_property_ui_text(prop, "Create obstacle", "Create representation for obstacle simulation");
1785 prop = RNA_def_property(srna, "obstacle_radius", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
1786 RNA_def_property_float_sdna(prop, NULL, "obstacleRad");
1787 RNA_def_property_range(prop, 0.0, 1000.0);
1788 RNA_def_property_ui_text(prop, "Obstacle Radius", "Radius of object representation in obstacle simulation");
1792 prop = RNA_def_property(srna, "states_visible", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1793 RNA_def_property_boolean_sdna(prop, NULL, "state", 1);
1794 RNA_def_property_array(prop, OB_MAX_STATES);
1795 RNA_def_property_ui_text(prop, "State", "State determining which controllers are displayed");
1796 RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_state_get", "rna_GameObjectSettings_state_set");
1798 prop = RNA_def_property(srna, "used_states", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1799 RNA_def_property_array(prop, OB_MAX_STATES);
1800 RNA_def_property_ui_text(prop, "Used State", "States which are being used by controllers");
1801 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1802 RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_used_state_get", NULL);
1804 prop = RNA_def_property(srna, "states_initial", PROP_BOOLEAN, PROP_NONE);
1805 RNA_def_property_boolean_sdna(prop, NULL, "init_state", 1);
1806 RNA_def_property_array(prop, OB_MAX_STATES);
1807 RNA_def_property_ui_text(prop, "Initial State", "Initial state when the game starts");
1809 prop = RNA_def_property(srna, "show_debug_state", PROP_BOOLEAN, PROP_NONE);
1810 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_DEBUGSTATE);
1811 RNA_def_property_ui_text(prop, "Debug State", "Print state debug info in the game engine");
1812 RNA_def_property_ui_icon(prop, ICON_INFO, 0);
1814 prop = RNA_def_property(srna, "use_all_states", PROP_BOOLEAN, PROP_NONE);
1815 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_ALLSTATE);
1816 RNA_def_property_ui_text(prop, "All", "Set all state bits");
1818 prop = RNA_def_property(srna, "show_state_panel", PROP_BOOLEAN, PROP_NONE);
1819 RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSTATE);
1820 RNA_def_property_ui_text(prop, "States", "Show state panel");
1821 RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
1824 static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
1832 RNA_def_property_srna(cprop, "ObjectConstraints");
1833 srna = RNA_def_struct(brna, "ObjectConstraints", NULL);
1834 RNA_def_struct_sdna(srna, "Object");
1835 RNA_def_struct_ui_text(srna, "Object Constraints", "Collection of object constraints");
1838 /* Collection active property */
1839 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1840 RNA_def_property_struct_type(prop, "Constraint");
1841 RNA_def_property_pointer_funcs(prop, "rna_Object_active_constraint_get",
1842 "rna_Object_active_constraint_set", NULL, NULL);
1843 RNA_def_property_flag(prop, PROP_EDITABLE);
1844 RNA_def_property_ui_text(prop, "Active Constraint", "Active Object constraint");
1847 /* Constraint collection */
1848 func = RNA_def_function(srna, "new", "rna_Object_constraints_new");
1849 RNA_def_function_ui_description(func, "Add a new constraint to this object");
1851 parm = RNA_def_enum(func, "type", constraint_type_items, 1, "", "Constraint type to add");
1852 RNA_def_property_flag(parm, PROP_REQUIRED);
1854 parm = RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint");
1855 RNA_def_function_return(func, parm);
1857 func = RNA_def_function(srna, "remove", "rna_Object_constraints_remove");
1858 RNA_def_function_ui_description(func, "Remove a constraint from this object");
1859 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1860 /* constraint to remove */
1861 parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
1862 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
1863 RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
1865 func = RNA_def_function(srna, "clear", "rna_Object_constraints_clear");
1866 RNA_def_function_ui_description(func, "Remove all constraint from this object");
1869 /* object.modifiers */
1870 static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
1877 RNA_def_property_srna(cprop, "ObjectModifiers");
1878 srna = RNA_def_struct(brna, "ObjectModifiers", NULL);
1879 RNA_def_struct_sdna(srna, "Object");
1880 RNA_def_struct_ui_text(srna, "Object Modifiers", "Collection of object modifiers");
1883 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1884 RNA_def_property_struct_type(prop, "EditBone");
1885 RNA_def_property_pointer_sdna(prop, NULL, "act_edbone");
1886 RNA_def_property_flag(prop, PROP_EDITABLE);
1887 RNA_def_property_ui_text(prop, "Active EditBone", "Armatures active edit bone");
1888 /*RNA_def_property_update(prop, 0, "rna_Armature_act_editbone_update"); */
1889 RNA_def_property_pointer_funcs(prop, NULL, "rna_Armature_act_edit_bone_set", NULL, NULL);
1892 /* RNA_def_property_collection_active(prop, prop_act); */
1896 func = RNA_def_function(srna, "new", "rna_Object_modifier_new");
1897 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1898 RNA_def_function_ui_description(func, "Add a new modifier");
1899 parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the modifier");
1900 RNA_def_property_flag(parm, PROP_REQUIRED);
1901 /* modifier to add */
1902 parm = RNA_def_enum(func, "type", modifier_type_items, 1, "", "Modifier type to add");
1903 RNA_def_property_flag(parm, PROP_REQUIRED);
1905 parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Newly created modifier");
1906 RNA_def_function_return(func, parm);
1908 /* remove modifier */
1909 func = RNA_def_function(srna, "remove", "rna_Object_modifier_remove");
1910 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1911 RNA_def_function_ui_description(func, "Remove an existing modifier from the object");
1912 /* modifier to remove */
1913 parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove");
1914 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
1915 RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
1917 /* clear all modifiers */
1918 func = RNA_def_function(srna, "clear", "rna_Object_modifier_clear");
1919 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
1920 RNA_def_function_ui_description(func, "Remove all modifiers from the object");
1923 /* object.particle_systems */
1924 static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop)
1930 /* FunctionRNA *func; */
1931 /* PropertyRNA *parm; */
1933 RNA_def_property_srna(cprop, "ParticleSystems");
1934 srna = RNA_def_struct(brna, "ParticleSystems", NULL);
1935 RNA_def_struct_sdna(srna, "Object");
1936 RNA_def_struct_ui_text(srna, "Particle Systems", "Collection of particle systems");
1938 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1939 RNA_def_property_struct_type(prop, "ParticleSystem");
1940 RNA_def_property_pointer_funcs(prop, "rna_Object_active_particle_system_get", NULL, NULL, NULL);
1941 RNA_def_property_ui_text(prop, "Active Particle System", "Active particle system being displayed");
1942 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
1944 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
1945 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1946 RNA_def_property_int_funcs(prop, "rna_Object_active_particle_system_index_get",
1947 "rna_Object_active_particle_system_index_set",
1948 "rna_Object_active_particle_system_index_range");
1949 RNA_def_property_ui_text(prop, "Active Particle System Index", "Index of active particle system slot");
1950 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_particle_update");
1954 /* object.vertex_groups */
1955 static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
1964 RNA_def_property_srna(cprop, "VertexGroups");
1965 srna = RNA_def_struct(brna, "VertexGroups", NULL);
1966 RNA_def_struct_sdna(srna, "Object");
1967 RNA_def_struct_ui_text(srna, "Vertex Groups", "Collection of vertex groups");
1969 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1970 RNA_def_property_struct_type(prop, "VertexGroup");
1971 RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get",
1972 "rna_Object_active_vertex_group_set", NULL, NULL);
1973 RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object");
1974 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
1976 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
1977 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1978 RNA_def_property_int_sdna(prop, NULL, "actdef");
1979 RNA_def_property_int_funcs(prop, "rna_Object_active_vertex_group_index_get",
1980 "rna_Object_active_vertex_group_index_set",
1981 "rna_Object_active_vertex_group_index_range");
1982 RNA_def_property_ui_text(prop, "Active Vertex Group Index", "Active index in vertex group array");
1983 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
1985 /* vertex groups */ /* add_vertex_group */
1986 func = RNA_def_function(srna, "new", "rna_Object_vgroup_new");
1987 RNA_def_function_ui_description(func, "Add vertex group to object");
1988 RNA_def_string(func, "name", "Group", 0, "", "Vertex group name"); /* optional */
1989 parm = RNA_def_pointer(func, "group", "VertexGroup", "", "New vertex group");
1990 RNA_def_function_return(func, parm);
1992 func = RNA_def_function(srna, "remove", "rna_Object_vgroup_remove");
1993 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1994 RNA_def_function_ui_description(func, "Delete vertex group from object");
1995 parm = RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove");
1996 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
1997 RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
1999 func = RNA_def_function(srna, "clear", "rna_Object_vgroup_clear");
2000 RNA_def_function_ui_description(func, "Delete all vertex groups from object");
2004 static void rna_def_object(BlenderRNA *brna)
2009 static EnumPropertyItem up_items[] = {
2010 {OB_POSX, "X", 0, "X", ""},
2011 {OB_POSY, "Y", 0, "Y", ""},
2012 {OB_POSZ, "Z", 0, "Z", ""},
2013 {0, NULL, 0, NULL, NULL}
2016 static EnumPropertyItem drawtype_items[] = {
2017 {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", "Draw the bounds of the object"},
2018 {OB_WIRE, "WIRE", 0, "Wire", "Draw the object as a wireframe"},
2019 {OB_SOLID, "SOLID", 0, "Solid", "Draw the object as a solid (if solid drawing is enabled in the viewport)"},
2020 {OB_TEXTURE, "TEXTURED", 0, "Textured",
2021 "Draw the object with textures (if textures are enabled in the viewport)"},
2022 {0, NULL, 0, NULL, NULL}
2025 static EnumPropertyItem boundtype_items[] = {
2026 {OB_BOUND_BOX, "BOX", 0, "Box", "Draw bounds as box"},
2027 {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", "Draw bounds as sphere"},
2028 {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", "Draw bounds as cylinder"},
2029 {OB_BOUND_CONE, "CONE", 0, "Cone", "Draw bounds as cone"},
2030 {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", "Draw bounds as capsule"},
2031 {0, NULL, 0, NULL, NULL}
2035 /* XXX: this RNA enum define is currently duplicated for objects,
2036 * since there is some text here which is not applicable */
2037 static EnumPropertyItem prop_rotmode_items[] = {
2038 {ROT_MODE_QUAT, "QUATERNION", 0, "Quaternion (WXYZ)", "No Gimbal Lock"},
2039 {ROT_MODE_XYZ, "XYZ", 0, "XYZ Euler", "XYZ Rotation Order - prone to Gimbal Lock (default)"},
2040 {ROT_MODE_XZY, "XZY", 0, "XZY Euler", "XZY Rotation Order - prone to Gimbal Lock"},
2041 {ROT_MODE_YXZ, "YXZ", 0, "YXZ Euler", "YXZ Rotation Order - prone to Gimbal Lock"},
2042 {ROT_MODE_YZX, "YZX", 0, "YZX Euler", "YZX Rotation Order - prone to Gimbal Lock"},
2043 {ROT_MODE_ZXY, "ZXY", 0, "ZXY Euler", "ZXY Rotation Order - prone to Gimbal Lock"},
2044 {ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order - prone to Gimbal Lock"},
2045 {ROT_MODE_AXISANGLE, "AXIS_ANGLE", 0, "Axis Angle",
2046 "Axis Angle (W+XYZ), defines a rotation around some axis defined by 3D-Vector"},
2047 {0, NULL, 0, NULL, NULL}
2050 static float default_quat[4] = {1, 0, 0, 0}; /* default quaternion values */
2051 static float default_axisAngle[4] = {0, 0, 1, 0}; /* default axis-angle rotation values */
2052 static float default_scale[3] = {1, 1, 1}; /* default scale values */
2053 static int boundbox_dimsize[] = {8, 3};
2055 srna = RNA_def_struct(brna, "Object", "ID");
2056 RNA_def_struct_ui_text(srna, "Object", "Object datablock defining an object in a scene");
2057 RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
2058 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
2060 prop = RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
2061 RNA_def_property_struct_type(prop, "ID");
2062 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_set", "rna_Object_data_typef", NULL);
2063 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
2064 RNA_def_property_ui_text(prop, "Data", "Object data");
2065 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
2067 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2068 RNA_def_property_enum_sdna(prop, NULL, "type");
2069 RNA_def_property_enum_items(prop, object_type_items);
2070 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2071 RNA_def_property_ui_text(prop, "Type", "Type of Object");
2073 prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
2074 RNA_def_property_enum_sdna(prop, NULL, "mode");
2075 RNA_def_property_enum_items(prop, object_mode_items);
2076 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2077 RNA_def_property_ui_text(prop, "Mode", "Object interaction mode");
2079 prop = RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER);
2080 RNA_def_property_boolean_sdna(prop, NULL, "lay", 1);
2081 RNA_def_property_array(prop, 20);
2082 RNA_def_property_ui_text(prop, "Layers", "Layers the object is on");
2083 RNA_def_property_boolean_funcs(prop, NULL, "rna_Object_layer_set");
2084 RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
2085 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_layer_update");
2086 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2088 prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER);
2089 RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000);
2090 RNA_def_property_array(prop, 8);
2091 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2092 RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object is on");
2094 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2095 RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
2096 RNA_def_property_ui_text(prop, "Select", "Object selection state");
2097 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_select_update");
2099 /* for data access */
2100 prop = RNA_def_property(srna, "bound_box", PROP_FLOAT, PROP_NONE);
2101 RNA_def_property_multi_array(prop, 2, boundbox_dimsize);
2102 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2103 RNA_def_property_float_funcs(prop, "rna_Object_boundbox_get", NULL, NULL);
2104 RNA_def_property_ui_text(prop, "Bounding Box",
2105 "Object's bounding box in object-space coordinates, all values are -1.0 when "
2109 prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
2110 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_parent_set", NULL, NULL);
2111 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2112 RNA_def_property_ui_text(prop, "Parent", "Parent Object");
2113 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2115 prop = RNA_def_property(srna, "parent_type", PROP_ENUM, PROP_NONE);
2116 RNA_def_property_enum_bitflag_sdna(prop, NULL, "partype");
2117 RNA_def_property_enum_items(prop, parent_type_items);
2118 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_parent_type_set", "rna_Object_parent_type_itemf");
2119 RNA_def_property_ui_text(prop, "Parent Type", "Type of parent relation");
2120 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2122 prop = RNA_def_property(srna, "parent_vertices", PROP_INT, PROP_UNSIGNED);
2123 RNA_def_property_int_sdna(prop, NULL, "par1");
2124 RNA_def_property_array(prop, 3);
2125 RNA_def_property_ui_text(prop, "Parent Vertices", "Indices of vertices in case of a vertex parenting relation");
2126 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2128 prop = RNA_def_property(srna, "parent_bone", PROP_STRING, PROP_NONE);
2129 RNA_def_property_string_sdna(prop, NULL, "parsubstr");
2130 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Object_parent_bone_set");
2131 RNA_def_property_ui_text(prop, "Parent Bone", "Name of parent bone in case of a bone parenting relation");
2132 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2134 /* Track and Up flags */
2135 /* XXX: these have been saved here for a bit longer (after old track was removed),
2136 * since some other tools still refer to this */
2137 prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
2138 RNA_def_property_enum_sdna(prop, NULL, "trackflag");
2139 RNA_def_property_enum_items(prop, object_axis_items);
2140 RNA_def_property_ui_text(prop, "Track Axis",
2141 "Axis that points in 'forward' direction (applies to DupliFrame when "
2142 "parent 'Follow' is enabled)");
2143 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2145 prop = RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE);
2146 RNA_def_property_enum_sdna(prop, NULL, "upflag");
2147 RNA_def_property_enum_items(prop, up_items);
2148 RNA_def_property_ui_text(prop, "Up Axis",
2149 "Axis that points in the upward direction (applies to DupliFrame when "
2150 "parent 'Follow' is enabled)");
2151 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2154 prop = RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE);
2155 RNA_def_property_ui_text(prop, "Proxy", "Library object this proxy object controls");
2157 prop = RNA_def_property(srna, "proxy_group", PROP_POINTER, PROP_NONE);
2158 RNA_def_property_ui_text(prop, "Proxy Group", "Library group duplicator object this proxy object controls");
2161 prop = RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE);
2162 RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
2163 RNA_def_property_struct_type(prop, "MaterialSlot");
2164 /* don't dereference pointer! */
2165 RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", NULL, NULL, NULL, NULL);
2166 RNA_def_property_ui_text(prop, "Material Slots", "Material slots in the object");
2168 prop = RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE);
2169 RNA_def_property_struct_type(prop, "Material");
2170 RNA_def_property_pointer_funcs(prop, "rna_Object_active_material_get",
2171 "rna_Object_active_material_set", NULL, NULL);
2172 RNA_def_property_flag(prop, PROP_EDITABLE);
2173 RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed");
2174 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
2176 prop = RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
2177 RNA_def_property_int_sdna(prop, NULL, "actcol");
2178 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2179 RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set",
2180 "rna_Object_active_material_index_range");
2181 RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot");
2182 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, NULL);
2185 prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
2186 RNA_def_property_float_sdna(prop, NULL, "loc");
2187 RNA_def_property_editable_array_func(prop, "rna_Object_location_editable");
2188 RNA_def_property_ui_text(prop, "Location", "Location of the object");
2189 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2190 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2192 prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
2193 RNA_def_property_float_sdna(prop, NULL, "quat");
2194 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
2195 RNA_def_property_float_array_default(prop, default_quat);
2196 RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions");
2197 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2199 /* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but
2200 * having a single one is better for Keyframing and other property-management situations...
2202 prop = RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
2203 RNA_def_property_array(prop, 4);
2204 RNA_def_property_float_funcs(prop, "rna_Object_rotation_axis_angle_get",
2205 "rna_Object_rotation_axis_angle_set", NULL);
2206 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
2207 RNA_def_property_float_array_default(prop, default_axisAngle);
2208 RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
2209 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2211 prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
2212 RNA_def_property_float_sdna(prop, NULL, "rot");
2213 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_euler_editable");
2214 RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers");
2215 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2217 prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
2218 RNA_def_property_enum_sdna(prop, NULL, "rotmode");
2219 RNA_def_property_enum_items(prop, prop_rotmode_items); /* XXX move to using a single define of this someday */
2220 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_rotation_mode_set", NULL);
2221 RNA_def_property_ui_text(prop, "Rotation Mode", "");
2222 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2224 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
2225 RNA_def_property_float_sdna(prop, NULL, "size");
2226 RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable");
2227 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
2228 RNA_def_property_float_array_default(prop, default_scale);
2229 RNA_def_property_ui_text(prop, "Scale", "Scaling of the object");
2230 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2232 prop = RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ_LENGTH);
2233 RNA_def_property_array(prop, 3);
2234 RNA_def_property_float_funcs(prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", NULL);
2235 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
2236 RNA_def_property_ui_text(prop, "Dimensions", "Absolute bounding box dimensions of the object");
2237 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2240 /* delta transforms */
2241 prop = RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_TRANSLATION);
2242 RNA_def_property_float_sdna(prop, NULL, "dloc");
2243 RNA_def_property_ui_text(prop, "Delta Location", "Extra translation added to the location of the object");
2244 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2245 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2247 prop = RNA_def_property(srna, "delta_rotation_euler", PROP_FLOAT, PROP_EULER);
2248 RNA_def_property_float_sdna(prop, NULL, "drot");
2249 RNA_def_property_ui_text(prop, "Delta Rotation (Euler)",
2250 "Extra rotation added to the rotation of the object (when using Euler rotations)");
2251 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2253 prop = RNA_def_property(srna, "delta_rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
2254 RNA_def_property_float_sdna(prop, NULL, "dquat");
2255 RNA_def_property_float_array_default(prop, default_quat);
2256 RNA_def_property_ui_text(prop, "Delta Rotation (Quaternion)",
2257 "Extra rotation added to the rotation of the object (when using Quaternion rotations)");
2258 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2260 #if 0 /* XXX not supported well yet... */
2261 prop = RNA_def_property(srna, "delta_rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
2262 /* FIXME: this is not a single field any more! (drotAxis and drotAngle) */
2263 RNA_def_property_float_sdna(prop, NULL, "dquat");
2264 RNA_def_property_float_array_default(prop, default_axisAngle);
2265 RNA_def_property_ui_text(prop, "Delta Rotation (Axis Angle)",
2266 "Extra rotation added to the rotation of the object (when using Axis-Angle rotations)");
2267 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2270 prop = RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_XYZ);
2271 RNA_def_property_float_sdna(prop, NULL, "dscale");
2272 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
2273 RNA_def_property_float_array_default(prop, default_scale);
2274 RNA_def_property_ui_text(prop, "Delta Scale", "Extra scaling added to the scale of the object");
2275 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2277 /* transform locks */
2278 prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE);
2279 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX);
2280 RNA_def_property_array(prop, 3);
2281 RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface");
2282 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2283 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2285 prop = RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE);
2286 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX);
2287 RNA_def_property_array(prop, 3);
2288 RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface");
2289 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2290 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2292 /* XXX this is sub-optimal - it really should be included above,
2293 * but due to technical reasons we can't do this! */
2294 prop = RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE);
2295 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTW);
2296 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2297 RNA_def_property_ui_text(prop, "Lock Rotation (4D Angle)",
2298 "Lock editing of 'angle' component of four-component rotations in the interface");
2299 /* XXX this needs a better name */
2300 prop = RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE);
2301 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROT4D);
2302 RNA_def_property_ui_text(prop, "Lock Rotations (4D)",
2303 "Lock editing of four component rotations by components (instead of as Eulers)");
2305 prop = RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_NONE);
2306 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX);
2307 RNA_def_property_array(prop, 3);
2308 RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface");
2309 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2310 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2313 prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
2314 RNA_def_property_float_sdna(prop, NULL, "obmat");
2315 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2316 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2317 RNA_def_property_ui_text(prop, "Matrix World", "Worldspace transformation matrix");
2318 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_matrix_world_update");
2320 prop = RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX);
2321 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2322 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2323 RNA_def_property_ui_text(prop, "Local Matrix", "Parent relative transformation matrix");
2324 RNA_def_property_float_funcs(prop, "rna_Object_matrix_local_get", "rna_Object_matrix_local_set", NULL);
2325 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, NULL);
2327 prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
2328 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2329 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2330 RNA_def_property_ui_text(prop, "Input Matrix",
2331 "Matrix access to location, rotation and scale (including deltas), "
2332 "before constraints and parenting are applied");
2333 RNA_def_property_float_funcs(prop, "rna_Object_matrix_basis_get", "rna_Object_matrix_basis_set", NULL);
2334 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2337 prop = RNA_def_property(srna, "matrix_parent_inverse", PROP_FLOAT, PROP_MATRIX);
2338 RNA_def_property_float_sdna(prop, NULL, "parentinv");
2339 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2340 RNA_def_property_ui_text(prop, "Matrix", "Inverse of object's parent matrix at time of parenting");
2341 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2344 prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
2345 RNA_def_property_struct_type(prop, "Modifier");
2346 RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the geometric data of the object");
2347 rna_def_object_modifiers(brna, prop);
2350 prop = RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE);
2351 RNA_def_property_struct_type(prop, "Constraint");
2352 RNA_def_property_ui_text(prop, "Constraints", "Constraints affecting the transformation of the object");
2353 /* RNA_def_property_collection_funcs(prop, 0, 0, 0, 0, 0, 0, 0, "constraints__add", "constraints__remove"); */
2354 rna_def_object_constraints(brna, prop);
2357 prop = RNA_def_property(srna, "game", PROP_POINTER, PROP_NONE);
2358 RNA_def_property_flag(prop, PROP_NEVER_NULL);
2359 RNA_def_property_struct_type(prop, "GameObjectSettings");
2360 RNA_def_property_pointer_funcs(prop, "rna_Object_game_settings_get", NULL, NULL, NULL);
2361 RNA_def_property_ui_text(prop, "Game Settings", "Game engine related settings for the object");
2364 prop = RNA_def_property(srna, "vertex_groups", PROP_COLLECTION, PROP_NONE);
2365 RNA_def_property_collection_sdna(prop, NULL, "defbase", NULL);
2366 RNA_def_property_struct_type(prop, "VertexGroup");
2367 RNA_def_property_ui_text(prop, "Vertex Groups", "Vertex groups of the object");
2368 rna_def_object_vertex_groups(brna, prop);
2371 prop = RNA_def_property(srna, "empty_draw_type", PROP_ENUM, PROP_NONE);
2372 RNA_def_property_enum_sdna(prop, NULL, "empty_drawtype");
2373 RNA_def_property_enum_items(prop, object_empty_drawtype_items);
2374 RNA_def_property_ui_text(prop, "Empty Display Type", "Viewport display style for empties");
2375 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2377 prop = RNA_def_property(srna, "empty_draw_size", PROP_FLOAT, PROP_DISTANCE);
2378 RNA_def_property_float_sdna(prop, NULL, "empty_drawsize");
2379 RNA_def_property_range(prop, 0.0001f, 1000.0f);
2380 RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);
2381 RNA_def_property_ui_text(prop, "Empty Display Size", "Size of display for empties in the viewport");
2382 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2384 prop = RNA_def_property(srna, "empty_image_offset", PROP_FLOAT, PROP_NONE);
2385 RNA_def_property_float_sdna(prop, NULL, "ima_ofs");
2386 RNA_def_property_ui_text(prop, "Origin Offset", "Origin offset distance");
2387 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1f, 2);
2388 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2391 prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
2392 RNA_def_property_int_sdna(prop, NULL, "index");
2393 RNA_def_property_ui_text(prop, "Pass Index", "Index number for the IndexOB render pass");
2394 RNA_def_property_update(prop, NC_OBJECT, "rna_Object_internal_update");
2396 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
2397 RNA_def_property_float_sdna(prop, NULL, "col");
2398 RNA_def_property_ui_text(prop, "Color", "Object color and alpha, used when faces have the ObColor mode enabled");
2399 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2402 prop = RNA_def_property(srna, "field", PROP_POINTER, PROP_NONE);
2403 RNA_def_property_pointer_sdna(prop, NULL, "pd");
2404 RNA_def_property_struct_type(prop, "FieldSettings");
2405 RNA_def_property_pointer_funcs(prop, "rna_Object_field_get", NULL, NULL, NULL);
2406 RNA_def_property_ui_text(prop, "Field Settings", "Settings for using the object as a field in physics simulation");
2408 prop = RNA_def_property(srna, "collision", PROP_POINTER, PROP_NONE);
2409 RNA_def_property_pointer_sdna(prop, NULL, "pd");
2410 RNA_def_property_struct_type(prop, "CollisionSettings");
2411 RNA_def_property_pointer_funcs(prop, "rna_Object_collision_get", NULL, NULL, NULL);
2412 RNA_def_property_ui_text(prop, "Collision Settings",
2413 "Settings for using the object as a collider in physics simulation");
2415 prop = RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE);
2416 RNA_def_property_pointer_sdna(prop, NULL, "soft");
2417 RNA_def_property_struct_type(prop, "SoftBodySettings");
2418 RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for soft body simulation");
2420 prop = RNA_def_property(srna, "particle_systems", PROP_COLLECTION, PROP_NONE);
2421 RNA_def_property_collection_sdna(prop, NULL, "particlesystem", NULL);
2422 RNA_def_property_struct_type(prop, "ParticleSystem");
2423 RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object");
2424 rna_def_object_particle_systems(brna, prop);
2427 prop = RNA_def_property(srna, "rigid_body", PROP_POINTER, PROP_NONE);
2428 RNA_def_property_pointer_sdna(prop, NULL, "rigidbody_object");
2429 RNA_def_property_struct_type(prop, "RigidBodyObject");
2430 RNA_def_property_ui_text(prop, "Rigid Body Settings", "Settings for rigid body simulation");
2432 prop = RNA_def_property(srna, "rigid_body_constraint", PROP_POINTER, PROP_NONE);
2433 RNA_def_property_pointer_sdna(prop, NULL, "rigidbody_constraint");
2434 RNA_def_property_struct_type(prop, "RigidBodyConstraint");
2435 RNA_def_property_ui_text(prop, "Rigid Body Constraint", "Constraint constraining rigid bodies");
2438 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
2439 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW);
2440 RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport");
2441 RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1);
2442 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
2444 prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
2445 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT);
2446 RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection in the viewport");
2447 RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1);
2448 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2450 prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE);
2451 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER);
2452 RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability");
2453 RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
2454 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
2457 rna_def_animdata_common(srna);
2459 rna_def_animviz_common(srna);
2460 rna_def_motionpath_common(srna);
2462 /* slow parenting */
2463 /* XXX: evil old crap */
2464 prop = RNA_def_property(srna, "use_slow_parent", PROP_BOOLEAN, PROP_NONE);
2465 RNA_def_property_boolean_sdna(prop, NULL, "partype", PARSLOW);
2466 RNA_def_property_ui_text(prop, "Slow Parent",
2467 "Create a delay in the parent relationship (beware: this isn't renderfarm "
2468 "safe and may be invalid after jumping around the timeline)");
2469 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2471 prop = RNA_def_property(srna, "slow_parent_offset", PROP_FLOAT, PROP_NONE | PROP_UNIT_TIME);
2472 RNA_def_property_float_sdna(prop, NULL, "sf");
2473 RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
2474 RNA_def_property_ui_text(prop, "Slow Parent Offset", "Delay in the parent relationship");
2475 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2477 /* depsgraph hack */
2478 prop = RNA_def_property(srna, "use_extra_recalc_object", PROP_BOOLEAN, PROP_NONE);
2479 RNA_def_property_boolean_sdna(prop, NULL, "depsflag", OB_DEPS_EXTRA_OB_RECALC);
2480 RNA_def_property_ui_text(prop, "Extra Object Update", "Refresh this object again on frame changes, dependency graph hack");
2482 prop = RNA_def_property(srna, "use_extra_recalc_data", PROP_BOOLEAN, PROP_NONE);
2483 RNA_def_property_boolean_sdna(prop, NULL, "depsflag", OB_DEPS_EXTRA_DATA_RECALC);
2484 RNA_def_property_ui_text(prop, "Extra Data Update", "Refresh this object's data again on frame changes, dependency graph hack");
2487 prop = RNA_def_property(srna, "dupli_type", PROP_ENUM, PROP_NONE);
2488 RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag");
2489 RNA_def_property_enum_items(prop, dupli_items);
2490 RNA_def_property_ui_text(prop, "Dupli Type", "If not None, object duplication method to use");
2491 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2493 prop = RNA_def_property(srna, "use_dupli_frames_speed", PROP_BOOLEAN, PROP_NONE);
2494 RNA_def_property_boolean_negative_sdna(prop, NULL, "transflag", OB_DUPLINOSPEED);
2495 RNA_def_property_ui_text(prop, "Dupli Frames Speed",
2496 "Set dupliframes to use the current frame instead of parent curve's evaluation time");
2497 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2499 prop = RNA_def_property(srna, "use_dupli_vertices_rotation", PROP_BOOLEAN, PROP_NONE);
2500 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIROT);
2501 RNA_def_property_ui_text(prop, "Dupli Verts Rotation", "Rotate dupli according to vertex normal");
2502 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2504 prop = RNA_def_property(srna, "use_dupli_faces_scale", PROP_BOOLEAN, PROP_NONE);
2505 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIFACES_SCALE);
2506 RNA_def_property_ui_text(prop, "Dupli Faces Inherit Scale", "Scale dupli based on face size");
2507 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2509 prop = RNA_def_property(srna, "dupli_faces_scale", PROP_FLOAT, PROP_NONE);
2510 RNA_def_property_float_sdna(prop, NULL, "dupfacesca");
2511 RNA_def_property_range(prop, 0.001f, 10000.0f);
2512 RNA_def_property_ui_text(prop, "Dupli Faces Scale", "Scale the DupliFace objects");
2513 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2515 prop = RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE);
2516 RNA_def_property_pointer_sdna(prop, NULL, "dup_group");
2517 RNA_def_property_flag(prop, PROP_EDITABLE);
2518 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_dup_group_set", NULL, NULL);
2519 RNA_def_property_ui_text(prop, "Dupli Group", "Instance an existing group");
2520 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2522 prop = RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
2523 RNA_def_property_int_sdna(prop, NULL, "dupsta");
2524 RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
2525 RNA_def_property_ui_text(prop, "Dupli Frames Start", "Start frame for DupliFrames");
2526 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2528 prop = RNA_def_property(srna, "dupli_frames_end", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
2529 RNA_def_property_int_sdna(prop, NULL, "dupend");
2530 RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
2531 RNA_def_property_ui_text(prop, "Dupli Frames End", "End frame for DupliFrames");
2532 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2534 prop = RNA_def_property(srna, "dupli_frames_on", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
2535 RNA_def_property_int_sdna(prop, NULL, "dupon");
2536 RNA_def_property_range(prop, MINFRAME, MAXFRAME);
2537 RNA_def_property_ui_range(prop, 1, 1500, 1, -1);
2538 RNA_def_property_ui_text(prop, "Dupli Frames On", "Number of frames to use between DupOff frames");
2539 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2541 prop = RNA_def_property(srna, "dupli_frames_off", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
2542 RNA_def_property_int_sdna(prop, NULL, "dupoff");
2543 RNA_def_property_range(prop, 0, MAXFRAME);
2544 RNA_def_property_ui_range(prop, 0, 1500, 1, -1);
2545 RNA_def_property_ui_text(prop, "Dupli Frames Off", "Recurring frames to exclude from the Dupliframes");
2546 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2548 prop = RNA_def_property(srna, "dupli_list", PROP_COLLECTION, PROP_NONE);
2549 RNA_def_property_collection_sdna(prop, NULL, "duplilist", NULL);
2550 RNA_def_property_struct_type(prop, "DupliObject");
2551 RNA_def_property_ui_text(prop, "Dupli list", "Object duplis");
2553 prop = RNA_def_property(srna, "is_duplicator", PROP_BOOLEAN, PROP_NONE);
2554 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLI);
2555 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2558 prop = RNA_def_property(srna, "draw_type", PROP_ENUM, PROP_NONE);
2559 RNA_def_property_enum_sdna(prop, NULL, "dt");
2560 RNA_def_property_enum_items(prop, drawtype_items);
2561 RNA_def_property_ui_text(prop, "Maximum Draw Type", "Maximum draw type to display object with in viewport");
2562 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2564 prop = RNA_def_property(srna, "show_bounds", PROP_BOOLEAN, PROP_NONE);
2565 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWBOUNDOX);
2566 RNA_def_property_ui_text(prop, "Draw Bounds", "Display the object's bounds");
2567 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2569 prop = RNA_def_property(srna, "draw_bounds_type", PROP_ENUM, PROP_NONE);
2570 RNA_def_property_enum_sdna(prop, NULL, "boundtype");
2571 RNA_def_property_enum_items(prop, boundtype_items);
2572 RNA_def_property_ui_text(prop, "Draw Bounds Type", "Object boundary display type");
2573 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2575 prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE);
2576 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWNAME);
2577 RNA_def_property_ui_text(prop, "Draw Name", "Display the object's name");
2578 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2580 prop = RNA_def_property(srna, "show_axis", PROP_BOOLEAN, PROP_NONE);
2581 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_AXIS);
2582 RNA_def_property_ui_text(prop, "Draw Axes", "Display the object's origin and axes");
2583 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2585 prop = RNA_def_property(srna, "show_texture_space", PROP_BOOLEAN, PROP_NONE);
2586 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_TEXSPACE);
2587 RNA_def_property_ui_text(prop, "Draw Texture Space", "Display the object's texture space");
2588 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2590 prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE);
2591 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWWIRE);
2592 RNA_def_property_ui_text(prop, "Draw Wire", "Add the object's wireframe over solid drawing");
2593 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2595 prop = RNA_def_property(srna, "show_all_edges", PROP_BOOLEAN, PROP_NONE);
2596 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAW_ALL_EDGES);
2597 RNA_def_property_ui_text(prop, "Draw All Edges", "Display all edges for mesh objects");
2598 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2600 prop = RNA_def_property(srna, "show_transparent", PROP_BOOLEAN, PROP_NONE);
2601 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWTRANSP);
2602 RNA_def_property_ui_text(prop, "Draw Transparent",
2603 "Display material transparency in the object (unsupported for duplicator drawing)");
2604 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2606 prop = RNA_def_property(srna, "show_x_ray", PROP_BOOLEAN, PROP_NONE);
2607 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWXRAY);
2608 RNA_def_property_ui_text(prop, "X-Ray",
2609 "Make the object draw in front of others (unsupported for duplicator drawing)");
2610 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2613 prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
2614 RNA_def_property_pointer_sdna(prop, NULL, "gpd");
2615 RNA_def_property_flag(prop, PROP_EDITABLE);
2616 RNA_def_property_struct_type(prop, "GreasePencil");
2617 RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock");
2618 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2621 prop = RNA_def_property(srna, "pose_library", PROP_POINTER, PROP_NONE);
2622 RNA_def_property_pointer_sdna(prop, NULL, "poselib");
2623 RNA_def_property_flag(prop, PROP_EDITABLE);
2624 RNA_def_property_struct_type(prop, "Action");
2625 RNA_def_property_ui_text(prop, "Pose Library", "Action used as a pose library for armatures");
2627 prop = RNA_def_property(srna, "pose", PROP_POINTER, PROP_NONE);
2628 RNA_def_property_pointer_sdna(prop, NULL, "pose");
2629 RNA_def_property_struct_type(prop, "Pose");
2630 RNA_def_property_ui_text(prop, "Pose", "Current pose for armatures");
2633 prop = RNA_def_property(srna, "show_only_shape_key", PROP_BOOLEAN, PROP_NONE);
2634 RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_LOCK);
2635 RNA_def_property_ui_text(prop, "Shape Key Lock", "Always show the current Shape for this Object");
2636 RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
2637 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
2639 prop = RNA_def_property(srna, "use_shape_key_edit_mode", PROP_BOOLEAN, PROP_NONE);
2640 RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_EDIT_MODE);
2641 RNA_def_property_ui_text(prop, "Shape Key Edit Mode", "Apply shape keys in edit mode (for Meshes only)");
2642 RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0);
2643 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
2645 prop = RNA_def_property(srna, "active_shape_key", PROP_POINTER, PROP_NONE);
2646 RNA_def_property_struct_type(prop, "ShapeKey");
2647 RNA_def_property_pointer_funcs(prop, "rna_Object_active_shape_key_get", NULL, NULL, NULL);
2648 RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key");
2650 prop = RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE);
2651 RNA_def_property_int_sdna(prop, NULL, "shapenr");
2652 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* XXX this is really unpredictable... */
2653 RNA_def_property_int_funcs(prop, "rna_Object_active_shape_key_index_get", "rna_Object_active_shape_key_index_set",
2654 "rna_Object_active_shape_key_index_range");
2655 RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index");
2656 RNA_def_property_update(prop, 0, "rna_Object_active_shape_update");
2659 prop = RNA_def_property(srna, "use_dynamic_topology_sculpting", PROP_BOOLEAN, PROP_NONE);
2660 RNA_def_property_boolean_funcs(prop, "rna_Object_use_dynamic_topology_sculpting_get", NULL);
2661 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2662 RNA_def_property_ui_text(prop, "Dynamic Topology Sculpting", NULL);
2664 RNA_api_object(srna);
2667 static void rna_def_dupli_object(BlenderRNA *brna)
2672 srna = RNA_def_struct(brna, "DupliObject", NULL);
2673 RNA_def_struct_sdna(srna, "DupliObject");
2674 RNA_def_struct_ui_text(srna, "Object Duplicate", "An object duplicate");
2675 /* RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); */
2677 prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2678 RNA_def_property_pointer_sdna(prop, NULL, "ob");
2679 /* RNA_def_property_pointer_funcs(prop, "rna_DupliObject_object_get", NULL, NULL, NULL); */
2680 RNA_def_property_ui_text(prop, "Object", "Object being duplicated");
2682 prop = RNA_def_property(srna, "matrix_original", PROP_FLOAT, PROP_MATRIX);
2683 RNA_def_property_float_sdna(prop, NULL, "omat");
2684 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2685 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2686 RNA_def_property_ui_text(prop, "Object Matrix", "The original matrix of this object before it was duplicated");
2688 prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
2689 RNA_def_property_float_sdna(prop, NULL, "mat");
2690 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2691 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2692 RNA_def_property_ui_text(prop, "Object Duplicate Matrix", "Object duplicate transformation matrix");
2694 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
2695 RNA_def_property_boolean_sdna(prop, NULL, "no_draw", 0);
2696 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2697 RNA_def_property_ui_text(prop, "Hide", "Don't show dupli object in viewport or render");
2699 prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
2700 RNA_def_property_int_funcs(prop, "rna_DupliObject_index_get", NULL, NULL);
2701 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2702 RNA_def_property_ui_text(prop, "Index", "Index in the lowest-level dupli list");
2704 prop = RNA_def_property(srna, "persistent_id", PROP_INT, PROP_NONE);
2705 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2706 RNA_def_property_ui_text(prop, "Persistent ID", "Persistent identifier for inter-frame matching of objects with motion blur");
2708 prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
2709 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2710 RNA_def_property_ui_text(prop, "Particle System", "Particle system that this dupli object was instanced from");
2712 prop = RNA_def_property(srna, "orco", PROP_FLOAT, PROP_TRANSLATION);
2713 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2714 RNA_def_property_ui_text(prop, "Generated Coordinates", "Generated coordinates in parent object space");
2716 prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE);
2717 RNA_def_property_array(prop, 2);
2718 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2719 RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space");
2721 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2722 RNA_def_property_enum_items(prop, dupli_items);
2723 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
2724 RNA_def_property_ui_text(prop, "Dupli Type", "Duplicator type that generated this dupli object");
2727 static void rna_def_object_base(BlenderRNA *brna)
2732 srna = RNA_def_struct(brna, "ObjectBase", NULL);
2733 RNA_def_struct_sdna(srna, "Base");
2734 RNA_def_struct_ui_text(srna, "Object Base", "An object instance in a scene");
2735 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
2737 prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2738 RNA_def_property_pointer_sdna(prop, NULL, "object");
2739 RNA_def_property_ui_text(prop, "Object", "Object this base links to");
2741 /* same as object layer */
2742 prop = RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER);
2743 RNA_def_property_boolean_sdna(prop, NULL, "lay", 1);
2744 RNA_def_property_array(prop, 20);
2745 RNA_def_property_ui_text(prop, "Layers", "Layers the object base is on");
2746 RNA_def_property_boolean_funcs(prop, NULL, "rna_Base_layer_set");
2747 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Base_layer_update");
2749 prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER);
2750 RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000);
2751 RNA_def_property_array(prop, 8);
2752 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2753 RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object base is on");
2755 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2756 RNA_def_property_boolean_sdna(prop, NULL, "flag", BA_SELECT);
2757 RNA_def_property_ui_text(prop, "Select", "Object base selection state");
2758 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Base_select_update");
2760 RNA_api_object_base(srna);
2763 void RNA_def_object(BlenderRNA *brna)
2765 rna_def_object(brna);
2766 rna_def_object_game_settings(brna);
2767 rna_def_object_base(brna);
2768 rna_def_vertex_group(brna);
2769 rna_def_material_slot(brna);
2770 rna_def_dupli_object(brna);