2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 /** \file \ingroup RNA
23 #include "DNA_action_types.h"
24 #include "DNA_brush_types.h"
25 #include "DNA_collection_types.h"
26 #include "DNA_customdata_types.h"
27 #include "DNA_material_types.h"
28 #include "DNA_mesh_types.h"
29 #include "DNA_object_force_types.h"
30 #include "DNA_object_types.h"
31 #include "DNA_scene_types.h"
32 #include "DNA_meta_types.h"
33 #include "DNA_workspace_types.h"
34 #include "DNA_gpencil_modifier_types.h"
35 #include "DNA_shader_fx_types.h"
37 #include "BLI_utildefines.h"
39 #include "BKE_camera.h"
40 #include "BKE_collection.h"
41 #include "BKE_paint.h"
42 #include "BKE_editlattice.h"
43 #include "BKE_editmesh.h"
44 #include "BKE_layer.h"
45 #include "BKE_object_deform.h"
46 #include "BKE_object_facemap.h"
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 const EnumPropertyItem rna_enum_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_POSE, "POSE", ICON_POSE_HLT, "Pose Mode", ""},
64 {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""},
65 {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
66 {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
67 {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
68 {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""},
69 {OB_MODE_EDIT_GPENCIL, "EDIT_GPENCIL", ICON_EDITMODE_HLT, "Edit Mode", "Edit Grease Pencil Strokes"},
70 {OB_MODE_SCULPT_GPENCIL, "SCULPT_GPENCIL", ICON_SCULPTMODE_HLT, "Sculpt Mode", "Sculpt Grease Pencil Strokes"},
71 {OB_MODE_PAINT_GPENCIL, "PAINT_GPENCIL", ICON_GREASEPENCIL, "Draw", "Paint Grease Pencil Strokes"},
72 {OB_MODE_WEIGHT_GPENCIL, "WEIGHT_GPENCIL", ICON_WPAINT_HLT, "Weight Paint", "Grease Pencil Weight Paint Strokes" },
73 {0, NULL, 0, NULL, NULL},
76 /* Same as above, but with names that distinguish grease pencil. */
77 const EnumPropertyItem rna_enum_workspace_object_mode_items[] = {
78 {OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object Mode", ""},
79 {OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit Mode", ""},
80 {OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose Mode", ""},
81 {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""},
82 {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
83 {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
84 {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
85 {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""},
86 {OB_MODE_EDIT_GPENCIL, "EDIT_GPENCIL", ICON_EDITMODE_HLT, "Grease Pencil Edit Mode", "Edit Grease Pencil Strokes"},
87 {OB_MODE_SCULPT_GPENCIL, "SCULPT_GPENCIL", ICON_SCULPTMODE_HLT, "Grease Pencil Sculpt Mode", "Sculpt Grease Pencil Strokes"},
88 {OB_MODE_PAINT_GPENCIL, "PAINT_GPENCIL", ICON_GREASEPENCIL, "Grease Pencil Draw", "Paint Grease Pencil Strokes"},
89 {OB_MODE_WEIGHT_GPENCIL, "WEIGHT_GPENCIL", ICON_WPAINT_HLT, "Grease Pencil Weight Paint", "Grease Pencil Weight Paint Strokes" },
90 {0, NULL, 0, NULL, NULL},
93 const EnumPropertyItem rna_enum_object_empty_drawtype_items[] = {
94 {OB_PLAINAXES, "PLAIN_AXES", ICON_EMPTY_AXIS, "Plain Axes", ""},
95 {OB_ARROWS, "ARROWS", ICON_EMPTY_ARROWS, "Arrows", ""},
96 {OB_SINGLE_ARROW, "SINGLE_ARROW", ICON_EMPTY_SINGLE_ARROW, "Single Arrow", ""},
97 {OB_CIRCLE, "CIRCLE", ICON_MESH_CIRCLE, "Circle", ""},
98 {OB_CUBE, "CUBE", ICON_CUBE, "Cube", ""},
99 {OB_EMPTY_SPHERE, "SPHERE", ICON_SPHERE, "Sphere", ""},
100 {OB_EMPTY_CONE, "CONE", ICON_CONE, "Cone", ""},
101 {OB_EMPTY_IMAGE, "IMAGE", ICON_FILE_IMAGE, "Image", ""},
102 {0, NULL, 0, NULL, NULL},
105 static const EnumPropertyItem rna_enum_object_empty_image_depth_items[] = {
106 {OB_EMPTY_IMAGE_DEPTH_DEFAULT, "DEFAULT", 0, "Default", ""},
107 {OB_EMPTY_IMAGE_DEPTH_FRONT, "FRONT", 0, "Front", ""},
108 {OB_EMPTY_IMAGE_DEPTH_BACK, "BACK", 0, "Back", ""},
109 {0, NULL, 0, NULL, NULL},
112 const EnumPropertyItem rna_enum_object_gpencil_type_items[] = {
113 {GP_EMPTY, "EMPTY", ICON_EMPTY_AXIS, "Blank", "Create an empty grease pencil object"},
114 {GP_STROKE, "STROKE", ICON_STROKE, "Stroke", "Create a simple stroke with basic colors"},
115 {GP_MONKEY, "MONKEY", ICON_MONKEY, "Monkey", "Construct a Suzanne grease pencil object"},
116 {0, NULL, 0, NULL, NULL }
119 static const EnumPropertyItem parent_type_items[] = {
120 {PAROBJECT, "OBJECT", 0, "Object", "The object is parented to an object"},
121 {PARSKEL, "ARMATURE", 0, "Armature", ""},
122 {PARSKEL, "LATTICE", 0, "Lattice", "The object is parented to a lattice"}, /* PARSKEL reuse will give issues */
123 {PARVERT1, "VERTEX", 0, "Vertex", "The object is parented to a vertex"},
124 {PARVERT3, "VERTEX_3", 0, "3 Vertices", ""},
125 {PARBONE, "BONE", 0, "Bone", "The object is parented to a bone"},
126 {0, NULL, 0, NULL, NULL},
129 #define INSTANCE_ITEMS_SHARED \
130 {0, "NONE", 0, "None", ""}, \
131 {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Instantiate child objects on all vertices"}, \
132 {OB_DUPLIFACES, "FACES", 0, "Faces", "Instantiate child objects on all faces"}
134 #define INSTANCE_ITEM_COLLECTION \
135 {OB_DUPLICOLLECTION, "COLLECTION", 0, "Collection", "Enable collection instancing"}
136 static const EnumPropertyItem instance_items[] = {
137 INSTANCE_ITEMS_SHARED,
138 INSTANCE_ITEM_COLLECTION,
139 {0, NULL, 0, NULL, NULL},
142 static EnumPropertyItem instance_items_nogroup[] = {
143 INSTANCE_ITEMS_SHARED,
144 {0, NULL, 0, NULL, NULL},
147 #undef INSTANCE_ITEMS_SHARED
148 #undef INSTANCE_ITEM_COLLECTION
150 const EnumPropertyItem rna_enum_metaelem_type_items[] = {
151 {MB_BALL, "BALL", ICON_META_BALL, "Ball", ""},
152 {MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""},
153 {MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""},
154 {MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""}, /* NOTE: typo at original definition! */
155 {MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""},
156 {0, NULL, 0, NULL, NULL},
159 /* used for 2 enums */
160 #define OBTYPE_CU_CURVE {OB_CURVE, "CURVE", 0, "Curve", ""}
161 #define OBTYPE_CU_SURF {OB_SURF, "SURFACE", 0, "Surface", ""}
162 #define OBTYPE_CU_FONT {OB_FONT, "FONT", 0, "Font", ""}
164 const EnumPropertyItem rna_enum_object_type_items[] = {
165 {OB_MESH, "MESH", 0, "Mesh", ""},
168 {OB_MBALL, "META", 0, "Meta", ""},
170 {0, "", 0, NULL, NULL},
171 {OB_ARMATURE, "ARMATURE", 0, "Armature", ""},
172 {OB_LATTICE, "LATTICE", 0, "Lattice", ""},
173 {OB_EMPTY, "EMPTY", 0, "Empty", ""},
174 {OB_GPENCIL, "GPENCIL", 0, "GPencil", ""},
175 {0, "", 0, NULL, NULL},
176 {OB_CAMERA, "CAMERA", 0, "Camera", ""},
177 {OB_LAMP, "LIGHT", 0, "Light", ""},
178 {OB_SPEAKER, "SPEAKER", 0, "Speaker", ""},
179 {OB_LIGHTPROBE, "LIGHT_PROBE", 0, "Probe", ""},
180 {0, NULL, 0, NULL, NULL},
183 const EnumPropertyItem rna_enum_object_type_curve_items[] = {
187 {0, NULL, 0, NULL, NULL},
190 const EnumPropertyItem rna_enum_object_rotation_mode_items[] = {
191 {ROT_MODE_QUAT, "QUATERNION", 0, "Quaternion (WXYZ)", "No Gimbal Lock"},
192 {ROT_MODE_XYZ, "XYZ", 0, "XYZ Euler", "XYZ Rotation Order - prone to Gimbal Lock (default)"},
193 {ROT_MODE_XZY, "XZY", 0, "XZY Euler", "XZY Rotation Order - prone to Gimbal Lock"},
194 {ROT_MODE_YXZ, "YXZ", 0, "YXZ Euler", "YXZ Rotation Order - prone to Gimbal Lock"},
195 {ROT_MODE_YZX, "YZX", 0, "YZX Euler", "YZX Rotation Order - prone to Gimbal Lock"},
196 {ROT_MODE_ZXY, "ZXY", 0, "ZXY Euler", "ZXY Rotation Order - prone to Gimbal Lock"},
197 {ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order - prone to Gimbal Lock"},
198 {ROT_MODE_AXISANGLE, "AXIS_ANGLE", 0, "Axis Angle",
199 "Axis Angle (W+XYZ), defines a rotation around some axis defined by 3D-Vector"},
200 {0, NULL, 0, NULL, NULL},
203 const EnumPropertyItem rna_enum_object_axis_items[] = {
204 {OB_POSX, "POS_X", 0, "+X", ""},
205 {OB_POSY, "POS_Y", 0, "+Y", ""},
206 {OB_POSZ, "POS_Z", 0, "+Z", ""},
207 {OB_NEGX, "NEG_X", 0, "-X", ""},
208 {OB_NEGY, "NEG_Y", 0, "-Y", ""},
209 {OB_NEGZ, "NEG_Z", 0, "-Z", ""},
210 {0, NULL, 0, NULL, NULL},
215 #include "BLI_math.h"
217 #include "DNA_key_types.h"
218 #include "DNA_constraint_types.h"
219 #include "DNA_gpencil_types.h"
221 #include "DNA_lattice_types.h"
222 #include "DNA_node_types.h"
224 #include "BKE_armature.h"
225 #include "BKE_brush.h"
226 #include "BKE_constraint.h"
227 #include "BKE_context.h"
228 #include "BKE_curve.h"
229 #include "BKE_effect.h"
230 #include "BKE_global.h"
232 #include "BKE_object.h"
233 #include "BKE_material.h"
234 #include "BKE_mesh.h"
235 #include "BKE_modifier.h"
236 #include "BKE_particle.h"
237 #include "BKE_scene.h"
238 #include "BKE_deform.h"
240 #include "DEG_depsgraph.h"
241 #include "DEG_depsgraph_build.h"
243 #include "ED_object.h"
244 #include "ED_particle.h"
245 #include "ED_curve.h"
246 #include "ED_lattice.h"
248 static void rna_Object_internal_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
250 DEG_id_tag_update(ptr->id.data, ID_RECALC_TRANSFORM);
253 static void rna_Object_internal_update_draw(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
255 DEG_id_tag_update(ptr->id.data, ID_RECALC_TRANSFORM);
256 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
259 static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr)
261 /* don't use compat so we get predictable rotation */
262 BKE_object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat, false, true);
263 rna_Object_internal_update(bmain, scene, ptr);
266 static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
268 Object *ob = ptr->id.data;
269 BKE_main_collection_sync_remap(bmain);
270 DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
271 DEG_relations_tag_update(bmain);
272 WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id);
275 static void rna_MaterialIndex_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
277 /* update the material of all brushes not pinned */
278 Object *ob = (Object *)ptr->id.data;
279 if (ob && ob->type == OB_GPENCIL) {
280 Material *ma = give_current_material(ob, ob->actcol);
282 BKE_brush_update_material(bmain, ma, NULL);
283 WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL);
289 static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
291 Object *ob = ptr->id.data;
292 BKE_object_matrix_local_get(ob, (float(*)[4])values);
295 static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])
297 Object *ob = ptr->id.data;
298 float local_mat[4][4];
300 /* localspace matrix is truly relative to the parent, but parameters stored in object are
301 * relative to parentinv matrix. Undo the parent inverse part before applying it as local matrix. */
304 invert_m4_m4(invmat, ob->parentinv);
305 mul_m4_m4m4(local_mat, invmat, (float(*)[4])values);
308 copy_m4_m4(local_mat, (float(*)[4])values);
311 /* don't use compat so we get predictable rotation, and do not use parenting either, because it's a local matrix! */
312 BKE_object_apply_mat4(ob, local_mat, false, false);
315 static void rna_Object_matrix_basis_get(PointerRNA *ptr, float values[16])
317 Object *ob = ptr->id.data;
318 BKE_object_to_mat4(ob, (float(*)[4])values);
321 static void rna_Object_matrix_basis_set(PointerRNA *ptr, const float values[16])
323 Object *ob = ptr->id.data;
324 BKE_object_apply_mat4(ob, (float(*)[4])values, false, false);
327 void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
329 DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
330 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
333 static void rna_Object_active_shape_update(bContext *C, PointerRNA *ptr)
335 Object *ob = ptr->id.data;
336 Main *bmain = CTX_data_main(C);
337 Scene *scene = CTX_data_scene(C);
339 if (CTX_data_edit_object(C) == ob) {
340 /* exit/enter editmode to get new shape */
343 EDBM_mesh_load(bmain, ob);
344 EDBM_mesh_make(ob, scene->toolsettings->selectmode, true);
346 DEG_id_tag_update(ob->data, 0);
348 EDBM_mesh_normals_update(((Mesh *)ob->data)->edit_btmesh);
349 BKE_editmesh_tessface_calc(((Mesh *)ob->data)->edit_btmesh);
353 ED_curve_editnurb_load(bmain, ob);
354 ED_curve_editnurb_make(ob);
357 BKE_editlattice_load(ob);
358 BKE_editlattice_make(ob);
363 rna_Object_internal_update_data(bmain, scene, ptr);
366 static void rna_Object_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
368 DEG_id_tag_update(ptr->id.data, ID_RECALC_TRANSFORM);
369 DEG_relations_tag_update(bmain);
370 WM_main_add_notifier(NC_OBJECT | ND_PARENT, ptr->id.data);
373 static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
375 Object *ob = (Object *)ptr->data;
378 if (ob->mode & OB_MODE_EDIT) {
382 /* assigning NULL only for empties */
383 if ((id == NULL) && (ob->type != OB_EMPTY)) {
387 BLI_assert(BKE_id_is_in_global_main(&ob->id));
388 BLI_assert(BKE_id_is_in_global_main(id));
390 if (ob->type == OB_EMPTY) {
392 id_us_min((ID *)ob->data);
396 if (!id || GS(id->name) == ID_IM) {
401 else if (ob->type == OB_MESH) {
402 BKE_mesh_assign_object(G_MAIN, ob, (Mesh *)id);
406 id_us_min((ID *)ob->data);
409 /* no need to type-check here ID. this is done in the _typef() function */
410 BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name)));
414 test_object_materials(G_MAIN, ob, id);
416 if (GS(id->name) == ID_CU) {
417 BKE_curve_type_test(ob);
419 else if (ob->type == OB_ARMATURE) {
420 BKE_pose_rebuild(G_MAIN, ob, ob->data, true);
425 static StructRNA *rna_Object_data_typef(PointerRNA *ptr)
427 Object *ob = (Object *)ptr->data;
429 /* keep in sync with OB_DATA_SUPPORT_ID() macro */
431 case OB_EMPTY: return &RNA_Image;
432 case OB_MESH: return &RNA_Mesh;
433 case OB_CURVE: return &RNA_Curve;
434 case OB_SURF: return &RNA_Curve;
435 case OB_FONT: return &RNA_Curve;
436 case OB_MBALL: return &RNA_MetaBall;
437 case OB_LAMP: return &RNA_Light;
438 case OB_CAMERA: return &RNA_Camera;
439 case OB_LATTICE: return &RNA_Lattice;
440 case OB_ARMATURE: return &RNA_Armature;
441 case OB_SPEAKER: return &RNA_Speaker;
442 case OB_LIGHTPROBE: return &RNA_LightProbe;
443 case OB_GPENCIL: return &RNA_GreasePencil;
444 default: return &RNA_ID;
448 static bool rna_Object_data_poll(PointerRNA *ptr, const PointerRNA value)
450 Object *ob = (Object *)ptr->data;
452 if (ob->type == OB_GPENCIL) {
453 /* GP Object - Don't allow using "Annotation" GP datablocks here */
454 bGPdata *gpd = value.data;
455 return (gpd->flag & GP_DATA_ANNOTATIONS) == 0;
461 static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value)
463 Object *ob = (Object *)ptr->data;
464 Object *par = (Object *)value.data;
467 ED_object_parent(ob, par, ob->partype, ob->parsubstr);
471 static void rna_Object_parent_type_set(PointerRNA *ptr, int value)
473 Object *ob = (Object *)ptr->data;
475 ED_object_parent(ob, ob->parent, value, ob->parsubstr);
478 static const EnumPropertyItem *rna_Object_parent_type_itemf(
479 bContext *UNUSED(C), PointerRNA *ptr,
480 PropertyRNA *UNUSED(prop), bool *r_free)
482 Object *ob = (Object *)ptr->data;
483 EnumPropertyItem *item = NULL;
486 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PAROBJECT);
489 Object *par = ob->parent;
491 if (par->type == OB_LATTICE) {
492 /* special hack: prevents this overriding others */
493 RNA_enum_items_add_value(&item, &totitem, &parent_type_items[2], PARSKEL);
495 else if (par->type == OB_ARMATURE) {
496 /* special hack: prevents this being overridden */
497 RNA_enum_items_add_value(&item, &totitem, &parent_type_items[1], PARSKEL);
498 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARBONE);
501 if (OB_TYPE_SUPPORT_PARVERT(par->type)) {
502 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT1);
503 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT3);
507 RNA_enum_item_end(&item, &totitem);
513 static void rna_Object_empty_display_type_set(PointerRNA *ptr, int value)
515 Object *ob = (Object *)ptr->data;
517 BKE_object_empty_draw_type_set(ob, value);
520 static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value)
522 Object *ob = (Object *)ptr->data;
524 ED_object_parent(ob, ob->parent, ob->partype, value);
527 static const EnumPropertyItem *rna_Object_instance_type_itemf(
528 bContext *UNUSED(C), PointerRNA *ptr,
529 PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
531 Object *ob = (Object *)ptr->data;
532 const EnumPropertyItem *item;
534 if (ob->type == OB_EMPTY) {
535 item = instance_items;
538 item = instance_items_nogroup;
544 static void rna_Object_dup_collection_set(PointerRNA *ptr, PointerRNA value)
546 Object *ob = (Object *)ptr->data;
547 Collection *grp = (Collection *)value.data;
549 /* must not let this be set if the object belongs in this group already,
550 * thus causing a cycle/infinite-recursion leading to crashes on load [#25298]
552 if (BKE_collection_has_object_recursive(grp, ob) == 0) {
553 if (ob->type == OB_EMPTY) {
554 id_us_min(&ob->dup_group->id);
556 id_us_plus(&ob->dup_group->id);
559 BKE_report(NULL, RPT_ERROR,
560 "Only empty objects support group instances");
564 BKE_report(NULL, RPT_ERROR,
565 "Cannot set instance-collection as object belongs in group being instanced, thus causing a cycle");
569 static void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
571 Object *ob = (Object *)ptr->id.data;
572 bDeformGroup *dg = (bDeformGroup *)ptr->data;
573 BLI_strncpy_utf8(dg->name, value, sizeof(dg->name));
574 defgroup_unique_name(dg, ob);
577 static int rna_VertexGroup_index_get(PointerRNA *ptr)
579 Object *ob = (Object *)ptr->id.data;
581 return BLI_findindex(&ob->defbase, ptr->data);
584 static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr)
586 Object *ob = (Object *)ptr->id.data;
587 return rna_pointer_inherit_refine(ptr, &RNA_VertexGroup, BLI_findlink(&ob->defbase, ob->actdef - 1));
590 static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr)
592 Object *ob = (Object *)ptr->id.data;
593 return ob->actdef - 1;
596 static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value)
598 Object *ob = (Object *)ptr->id.data;
599 ob->actdef = value + 1;
602 static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min, int *max,
603 int *UNUSED(softmin), int *UNUSED(softmax))
605 Object *ob = (Object *)ptr->id.data;
608 *max = max_ii(0, BLI_listbase_count(&ob->defbase) - 1);
611 void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
613 Object *ob = (Object *)ptr->id.data;
616 dg = BLI_findlink(&ob->defbase, index - 1);
618 if (dg) BLI_strncpy(value, dg->name, sizeof(dg->name));
619 else value[0] = '\0';
622 int rna_object_vgroup_name_index_length(PointerRNA *ptr, int index)
624 Object *ob = (Object *)ptr->id.data;
627 dg = BLI_findlink(&ob->defbase, index - 1);
628 return (dg) ? strlen(dg->name) : 0;
631 void rna_object_vgroup_name_index_set(PointerRNA *ptr, const char *value, short *index)
633 Object *ob = (Object *)ptr->id.data;
634 *index = defgroup_name_index(ob, value) + 1;
637 void rna_object_vgroup_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
639 Object *ob = (Object *)ptr->id.data;
640 bDeformGroup *dg = defgroup_find_name(ob, value);
642 BLI_strncpy(result, value, maxlen); /* no need for BLI_strncpy_utf8, since this matches an existing group */
649 static void rna_FaceMap_name_set(PointerRNA *ptr, const char *value)
651 Object *ob = (Object *)ptr->id.data;
652 bFaceMap *fmap = (bFaceMap *)ptr->data;
653 BLI_strncpy_utf8(fmap->name, value, sizeof(fmap->name));
654 BKE_object_facemap_unique_name(ob, fmap);
657 static int rna_FaceMap_index_get(PointerRNA *ptr)
659 Object *ob = (Object *)ptr->id.data;
661 return BLI_findindex(&ob->fmaps, ptr->data);
664 static PointerRNA rna_Object_active_face_map_get(PointerRNA *ptr)
666 Object *ob = (Object *)ptr->id.data;
667 return rna_pointer_inherit_refine(ptr, &RNA_FaceMap, BLI_findlink(&ob->fmaps, ob->actfmap - 1));
670 static int rna_Object_active_face_map_index_get(PointerRNA *ptr)
672 Object *ob = (Object *)ptr->id.data;
673 return ob->actfmap - 1;
676 static void rna_Object_active_face_map_index_set(PointerRNA *ptr, int value)
678 Object *ob = (Object *)ptr->id.data;
679 ob->actfmap = value + 1;
682 static void rna_Object_active_face_map_index_range(PointerRNA *ptr, int *min, int *max,
683 int *UNUSED(softmin), int *UNUSED(softmax))
685 Object *ob = (Object *)ptr->id.data;
688 *max = max_ii(0, BLI_listbase_count(&ob->fmaps) - 1);
691 void rna_object_BKE_object_facemap_name_index_get(PointerRNA *ptr, char *value, int index)
693 Object *ob = (Object *)ptr->id.data;
696 fmap = BLI_findlink(&ob->fmaps, index - 1);
698 if (fmap) BLI_strncpy(value, fmap->name, sizeof(fmap->name));
699 else value[0] = '\0';
702 int rna_object_BKE_object_facemap_name_index_length(PointerRNA *ptr, int index)
704 Object *ob = (Object *)ptr->id.data;
707 fmap = BLI_findlink(&ob->fmaps, index - 1);
708 return (fmap) ? strlen(fmap->name) : 0;
711 void rna_object_BKE_object_facemap_name_index_set(PointerRNA *ptr, const char *value, short *index)
713 Object *ob = (Object *)ptr->id.data;
714 *index = BKE_object_facemap_name_index(ob, value) + 1;
717 void rna_object_fmap_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
719 Object *ob = (Object *)ptr->id.data;
720 bFaceMap *fmap = BKE_object_facemap_find_name(ob, value);
722 BLI_strncpy(result, value, maxlen); /* no need for BLI_strncpy_utf8, since this matches an existing group */
730 void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
732 Object *ob = (Object *)ptr->id.data;
734 CustomDataLayer *layer;
737 if (ob->type == OB_MESH && ob->data) {
738 me = (Mesh *)ob->data;
740 for (a = 0; a < me->ldata.totlayer; a++) {
741 layer = &me->ldata.layers[a];
743 if (layer->type == CD_MLOOPUV && STREQ(layer->name, value)) {
744 BLI_strncpy(result, value, maxlen);
753 void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
755 Object *ob = (Object *)ptr->id.data;
757 CustomDataLayer *layer;
760 if (ob->type == OB_MESH && ob->data) {
761 me = (Mesh *)ob->data;
763 for (a = 0; a < me->fdata.totlayer; a++) {
764 layer = &me->fdata.layers[a];
766 if (layer->type == CD_MCOL && STREQ(layer->name, value)) {
767 BLI_strncpy(result, value, maxlen);
776 static int rna_Object_active_material_index_get(PointerRNA *ptr)
778 Object *ob = (Object *)ptr->id.data;
779 return MAX2(ob->actcol - 1, 0);
782 static void rna_Object_active_material_index_set(PointerRNA *ptr, int value)
784 Object *ob = (Object *)ptr->id.data;
785 ob->actcol = value + 1;
787 if (ob->type == OB_MESH) {
791 me->edit_btmesh->mat_nr = value;
795 static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, int *max,
796 int *UNUSED(softmin), int *UNUSED(softmax))
798 Object *ob = (Object *)ptr->id.data;
800 *max = max_ii(ob->totcol - 1, 0);
803 /* returns active base material */
804 static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
806 Object *ob = (Object *)ptr->id.data;
809 ma = (ob->totcol) ? give_current_material(ob, ob->actcol) : NULL;
810 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
813 static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value)
815 Object *ob = (Object *)ptr->id.data;
817 DEG_id_tag_update(value.data, 0);
818 BLI_assert(BKE_id_is_in_global_main(&ob->id));
819 BLI_assert(BKE_id_is_in_global_main(value.data));
820 assign_material(G_MAIN, ob, value.data, ob->actcol, BKE_MAT_ASSIGN_EXISTING);
823 static int rna_Object_active_material_editable(PointerRNA *ptr, const char **UNUSED(r_info))
825 Object *ob = (Object *)ptr->id.data;
828 if ((ob->matbits == NULL) || (ob->actcol == 0) || ob->matbits[ob->actcol - 1]) {
829 is_editable = !ID_IS_LINKED(ob);
832 is_editable = ob->data ? !ID_IS_LINKED(ob->data) : false;
835 return is_editable ? PROP_EDITABLE : 0;
839 static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int *min, int *max,
840 int *UNUSED(softmin), int *UNUSED(softmax))
842 Object *ob = (Object *)ptr->id.data;
844 *max = max_ii(0, BLI_listbase_count(&ob->particlesystem) - 1);
847 static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
849 Object *ob = (Object *)ptr->id.data;
850 return psys_get_current_num(ob);
853 static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int value)
855 Object *ob = (Object *)ptr->id.data;
856 psys_set_current_num(ob, value);
859 static void rna_Object_particle_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
861 /* TODO: Disabled for now, because bContext is not available. */
863 Object *ob = (Object *)ptr->id.data;
864 PE_current_changed(NULL, scene, ob);
871 /* rotation - axis-angle */
872 static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value)
874 Object *ob = ptr->data;
876 /* for now, assume that rotation mode is axis-angle */
877 value[0] = ob->rotAngle;
878 copy_v3_v3(&value[1], ob->rotAxis);
881 /* rotation - axis-angle */
882 static void rna_Object_rotation_axis_angle_set(PointerRNA *ptr, const float *value)
884 Object *ob = ptr->data;
886 /* for now, assume that rotation mode is axis-angle */
887 ob->rotAngle = value[0];
888 copy_v3_v3(ob->rotAxis, &value[1]);
890 /* TODO: validate axis? */
893 static void rna_Object_rotation_mode_set(PointerRNA *ptr, int value)
895 Object *ob = ptr->data;
897 /* use API Method for conversions... */
898 BKE_rotMode_change_values(ob->quat, ob->rot, ob->rotAxis, &ob->rotAngle, ob->rotmode, (short)value);
900 /* finally, set the new rotation type */
904 static void rna_Object_dimensions_get(PointerRNA *ptr, float *value)
906 Object *ob = ptr->data;
907 BKE_object_dimensions_get(ob, value);
910 static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value)
912 Object *ob = ptr->data;
913 BKE_object_dimensions_set(ob, value, 0);
916 static int rna_Object_location_editable(PointerRNA *ptr, int index)
918 Object *ob = (Object *)ptr->data;
920 /* only if the axis in question is locked, not editable... */
921 if ((index == 0) && (ob->protectflag & OB_LOCK_LOCX))
923 else if ((index == 1) && (ob->protectflag & OB_LOCK_LOCY))
925 else if ((index == 2) && (ob->protectflag & OB_LOCK_LOCZ))
928 return PROP_EDITABLE;
931 static int rna_Object_scale_editable(PointerRNA *ptr, int index)
933 Object *ob = (Object *)ptr->data;
935 /* only if the axis in question is locked, not editable... */
936 if ((index == 0) && (ob->protectflag & OB_LOCK_SCALEX))
938 else if ((index == 1) && (ob->protectflag & OB_LOCK_SCALEY))
940 else if ((index == 2) && (ob->protectflag & OB_LOCK_SCALEZ))
943 return PROP_EDITABLE;
946 static int rna_Object_rotation_euler_editable(PointerRNA *ptr, int index)
948 Object *ob = (Object *)ptr->data;
950 /* only if the axis in question is locked, not editable... */
951 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTX))
953 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTY))
955 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTZ))
958 return PROP_EDITABLE;
961 static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index)
963 Object *ob = (Object *)ptr->data;
965 /* only consider locks if locking components individually... */
966 if (ob->protectflag & OB_LOCK_ROT4D) {
967 /* only if the axis in question is locked, not editable... */
968 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTW))
970 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTX))
972 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTY))
974 else if ((index == 3) && (ob->protectflag & OB_LOCK_ROTZ))
978 return PROP_EDITABLE;
981 static int rna_MaterialSlot_material_editable(PointerRNA *ptr, const char **UNUSED(r_info))
983 Object *ob = (Object *)ptr->id.data;
984 const int index = (Material **)ptr->data - ob->mat;
987 if ((ob->matbits == NULL) || ob->matbits[index]) {
988 is_editable = !ID_IS_LINKED(ob);
991 is_editable = ob->data ? !ID_IS_LINKED(ob->data) : false;
994 return is_editable ? PROP_EDITABLE : 0;
997 static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr)
999 Object *ob = (Object *)ptr->id.data;
1001 const int index = (Material **)ptr->data - ob->mat;
1003 ma = give_current_material(ob, index + 1);
1004 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
1007 static void rna_MaterialSlot_material_set(PointerRNA *ptr, PointerRNA value)
1009 Object *ob = (Object *)ptr->id.data;
1010 int index = (Material **)ptr->data - ob->mat;
1012 BLI_assert(BKE_id_is_in_global_main(&ob->id));
1013 BLI_assert(BKE_id_is_in_global_main(value.data));
1014 assign_material(G_MAIN, ob, value.data, index + 1, BKE_MAT_ASSIGN_EXISTING);
1017 static bool rna_MaterialSlot_material_poll(PointerRNA *ptr, PointerRNA value)
1019 Object *ob = (Object *)ptr->id.data;
1020 Material *ma = (Material *)value.data;
1022 if (ob->type == OB_GPENCIL) {
1023 /* GP Materials only */
1024 return (ma->gp_style != NULL);
1027 /* Everything except GP materials */
1028 return (ma->gp_style == NULL);
1032 static int rna_MaterialSlot_link_get(PointerRNA *ptr)
1034 Object *ob = (Object *)ptr->id.data;
1035 int index = (Material **)ptr->data - ob->mat;
1037 return ob->matbits[index] != 0;
1040 static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value)
1042 Object *ob = (Object *)ptr->id.data;
1043 int index = (Material **)ptr->data - ob->mat;
1046 ob->matbits[index] = 1;
1047 /* ob->colbits |= (1 << index); */ /* DEPRECATED */
1050 ob->matbits[index] = 0;
1051 /* ob->colbits &= ~(1 << index); */ /* DEPRECATED */
1055 static int rna_MaterialSlot_name_length(PointerRNA *ptr)
1057 Object *ob = (Object *)ptr->id.data;
1059 int index = (Material **)ptr->data - ob->mat;
1061 ma = give_current_material(ob, index + 1);
1064 return strlen(ma->id.name + 2);
1069 static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str)
1071 Object *ob = (Object *)ptr->id.data;
1073 int index = (Material **)ptr->data - ob->mat;
1075 ma = give_current_material(ob, index + 1);
1078 strcpy(str, ma->id.name + 2);
1083 static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr)
1085 rna_Object_internal_update(bmain, scene, ptr);
1087 WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, ptr->id.data);
1088 WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, NULL);
1089 DEG_relations_tag_update(bmain);
1092 static char *rna_MaterialSlot_path(PointerRNA *ptr)
1094 Object *ob = (Object *)ptr->id.data;
1095 int index = (Material **)ptr->data - ob->mat;
1097 return BLI_sprintfN("material_slots[%d]", index);
1100 /* why does this have to be so complicated?, can't all this crap be
1101 * moved to in BGE conversion function? - Campbell *
1103 * logic from check_body_type()
1106 static char *rna_ObjectDisplay_path(PointerRNA *UNUSED(ptr))
1108 return BLI_strdup("display");
1111 static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr)
1113 Object *ob = (Object *)ptr->id.data;
1114 ParticleSystem *psys = psys_get_current(ob);
1115 return rna_pointer_inherit_refine(ptr, &RNA_ParticleSystem, psys);
1118 static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max,
1119 int *UNUSED(softmin), int *UNUSED(softmax))
1121 Object *ob = (Object *)ptr->id.data;
1122 Key *key = BKE_key_from_object(ob);
1126 *max = BLI_listbase_count(&key->block) - 1;
1127 if (*max < 0) *max = 0;
1134 static int rna_Object_active_shape_key_index_get(PointerRNA *ptr)
1136 Object *ob = (Object *)ptr->id.data;
1138 return MAX2(ob->shapenr - 1, 0);
1141 static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value)
1143 Object *ob = (Object *)ptr->id.data;
1145 ob->shapenr = value + 1;
1148 static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr)
1150 Object *ob = (Object *)ptr->id.data;
1151 Key *key = BKE_key_from_object(ob);
1156 return PointerRNA_NULL;
1158 kb = BLI_findlink(&key->block, ob->shapenr - 1);
1159 RNA_pointer_create((ID *)key, &RNA_ShapeKey, kb, &keyptr);
1163 static PointerRNA rna_Object_field_get(PointerRNA *ptr)
1165 Object *ob = (Object *)ptr->id.data;
1169 ob->pd = BKE_partdeflect_new(0);
1171 return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, ob->pd);
1174 static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
1176 Object *ob = (Object *)ptr->id.data;
1178 if (ob->type != OB_MESH)
1179 return PointerRNA_NULL;
1183 ob->pd = BKE_partdeflect_new(0);
1185 return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd);
1188 static PointerRNA rna_Object_active_constraint_get(PointerRNA *ptr)
1190 Object *ob = (Object *)ptr->id.data;
1191 bConstraint *con = BKE_constraints_active_get(&ob->constraints);
1192 return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con);
1195 static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value)
1197 Object *ob = (Object *)ptr->id.data;
1198 BKE_constraints_active_set(&ob->constraints, (bConstraint *)value.data);
1201 static bConstraint *rna_Object_constraints_new(Object *object, Main *bmain, int type)
1203 bConstraint *new_con = BKE_constraint_add_for_object(object, NULL, type);
1205 ED_object_constraint_tag_update(bmain, object, new_con);
1206 WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, object);
1211 static void rna_Object_constraints_remove(Object *object, Main *bmain, ReportList *reports, PointerRNA *con_ptr)
1213 bConstraint *con = con_ptr->data;
1214 if (BLI_findindex(&object->constraints, con) == -1) {
1215 BKE_reportf(reports, RPT_ERROR, "Constraint '%s' not found in object '%s'", con->name, object->id.name + 2);
1219 BKE_constraint_remove(&object->constraints, con);
1220 RNA_POINTER_INVALIDATE(con_ptr);
1222 ED_object_constraint_update(bmain, object);
1223 ED_object_constraint_set_active(object, NULL);
1224 WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
1227 static void rna_Object_constraints_clear(Object *object, Main *bmain)
1229 BKE_constraints_free(&object->constraints);
1231 ED_object_constraint_update(bmain, object);
1232 ED_object_constraint_set_active(object, NULL);
1234 WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
1237 bool rna_Object_constraints_override_apply(
1238 Main *UNUSED(bmain),
1239 PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *UNUSED(ptr_storage),
1240 PropertyRNA *UNUSED(prop_dst), PropertyRNA *UNUSED(prop_src), PropertyRNA *UNUSED(prop_storage),
1241 const int UNUSED(len_dst), const int UNUSED(len_src), const int UNUSED(len_storage),
1242 PointerRNA *UNUSED(ptr_item_dst), PointerRNA *UNUSED(ptr_item_src), PointerRNA *UNUSED(ptr_item_storage),
1243 IDOverrideStaticPropertyOperation *opop)
1245 BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_INSERT_AFTER &&
1246 "Unsupported RNA override operation on constraints collection");
1248 Object *ob_dst = (Object *)ptr_dst->id.data;
1249 Object *ob_src = (Object *)ptr_src->id.data;
1251 /* Remember that insertion operations are defined and stored in correct order, which means that
1252 * even if we insert several items in a row, we alays insert first one, then second one, etc.
1253 * So we should always find 'anchor' constraint in both _src *and* _dst> */
1254 bConstraint *con_anchor = NULL;
1255 if (opop->subitem_local_name && opop->subitem_local_name[0]) {
1256 con_anchor = BLI_findstring(&ob_dst->constraints, opop->subitem_local_name, offsetof(bConstraint, name));
1258 if (con_anchor == NULL && opop->subitem_local_index >= 0) {
1259 con_anchor = BLI_findlink(&ob_dst->constraints, opop->subitem_local_index);
1261 /* Otherwise we just insert in first position. */
1263 bConstraint *con_src = NULL;
1264 if (opop->subitem_local_name && opop->subitem_local_name[0]) {
1265 con_src = BLI_findstring(&ob_src->constraints, opop->subitem_local_name, offsetof(bConstraint, name));
1267 if (con_src == NULL && opop->subitem_local_index >= 0) {
1268 con_src = BLI_findlink(&ob_src->constraints, opop->subitem_local_index);
1270 con_src = con_src ? con_src->next : ob_src->constraints.first;
1272 BLI_assert(con_src != NULL);
1274 bConstraint *con_dst = BKE_constraint_duplicate_ex(con_src, 0, true);
1276 /* This handles NULL anchor as expected by adding at head of list. */
1277 BLI_insertlinkafter(&ob_dst->constraints, con_anchor, con_dst);
1279 /* This should actually *not* be needed in typical cases. However, if overridden source was edited,
1280 * we *may* have some new conflicting names. */
1281 BKE_constraint_unique_name(con_dst, &ob_dst->constraints);
1283 // printf("%s: We inserted a constraint...\n", __func__);
1287 static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports,
1288 const char *name, int type)
1290 return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
1293 static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, PointerRNA *md_ptr)
1295 ModifierData *md = md_ptr->data;
1296 if (ED_object_modifier_remove(reports, CTX_data_main(C), object, md) == false) {
1297 /* error is already set */
1301 RNA_POINTER_INVALIDATE(md_ptr);
1303 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1306 static void rna_Object_modifier_clear(Object *object, bContext *C)
1308 ED_object_modifier_clear(CTX_data_main(C), object);
1310 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1313 bool rna_Object_modifiers_override_apply(
1314 Main *UNUSED(bmain),
1315 PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *UNUSED(ptr_storage),
1316 PropertyRNA *UNUSED(prop_dst), PropertyRNA *UNUSED(prop_src), PropertyRNA *UNUSED(prop_storage),
1317 const int UNUSED(len_dst), const int UNUSED(len_src), const int UNUSED(len_storage),
1318 PointerRNA *UNUSED(ptr_item_dst), PointerRNA *UNUSED(ptr_item_src), PointerRNA *UNUSED(ptr_item_storage),
1319 IDOverrideStaticPropertyOperation *opop)
1321 BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_INSERT_AFTER &&
1322 "Unsupported RNA override operation on modifiers collection");
1324 Object *ob_dst = (Object *)ptr_dst->id.data;
1325 Object *ob_src = (Object *)ptr_src->id.data;
1327 /* Remember that insertion operations are defined and stored in correct order, which means that
1328 * even if we insert several items in a row, we alays insert first one, then second one, etc.
1329 * So we should always find 'anchor' constraint in both _src *and* _dst> */
1330 ModifierData *mod_anchor = NULL;
1331 if (opop->subitem_local_name && opop->subitem_local_name[0]) {
1332 mod_anchor = BLI_findstring(&ob_dst->modifiers, opop->subitem_local_name, offsetof(ModifierData, name));
1334 if (mod_anchor == NULL && opop->subitem_local_index >= 0) {
1335 mod_anchor = BLI_findlink(&ob_dst->modifiers, opop->subitem_local_index);
1337 /* Otherwise we just insert in first position. */
1339 ModifierData *mod_src = NULL;
1340 if (opop->subitem_local_name && opop->subitem_local_name[0]) {
1341 mod_src = BLI_findstring(&ob_src->modifiers, opop->subitem_local_name, offsetof(ModifierData, name));
1343 if (mod_src == NULL && opop->subitem_local_index >= 0) {
1344 mod_src = BLI_findlink(&ob_src->modifiers, opop->subitem_local_index);
1346 mod_src = mod_src ? mod_src->next : ob_src->modifiers.first;
1348 BLI_assert(mod_src != NULL);
1350 ModifierData *mod_dst = modifier_new(mod_src->type);
1351 modifier_copyData(mod_src, mod_dst);
1353 /* This handles NULL anchor as expected by adding at head of list. */
1354 BLI_insertlinkafter(&ob_dst->modifiers, mod_anchor, mod_dst);
1356 /* This should actually *not* be needed in typical cases. However, if overridden source was edited,
1357 * we *may* have some new conflicting names. */
1358 modifier_unique_name(&ob_dst->modifiers, mod_dst);
1360 // printf("%s: We inserted a modifier...\n", __func__);
1364 static GpencilModifierData *rna_Object_greasepencil_modifier_new(
1365 Object *object, bContext *C, ReportList *reports,
1366 const char *name, int type)
1368 return ED_object_gpencil_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
1371 static void rna_Object_greasepencil_modifier_remove(
1372 Object *object, bContext *C, ReportList *reports, PointerRNA *gmd_ptr)
1374 GpencilModifierData *gmd = gmd_ptr->data;
1375 if (ED_object_gpencil_modifier_remove(reports, CTX_data_main(C), object, gmd) == false) {
1376 /* error is already set */
1380 RNA_POINTER_INVALIDATE(gmd_ptr);
1382 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1385 static void rna_Object_greasepencil_modifier_clear(Object *object, bContext *C)
1387 ED_object_gpencil_modifier_clear(CTX_data_main(C), object);
1388 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1392 static ShaderFxData *rna_Object_shaderfx_new(
1393 Object *object, bContext *C, ReportList *reports,
1394 const char *name, int type)
1396 return ED_object_shaderfx_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
1399 static void rna_Object_shaderfx_remove(
1400 Object *object, bContext *C, ReportList *reports, PointerRNA *gmd_ptr)
1402 ShaderFxData *gmd = gmd_ptr->data;
1403 if (ED_object_shaderfx_remove(reports, CTX_data_main(C), object, gmd) == false) {
1404 /* error is already set */
1408 RNA_POINTER_INVALIDATE(gmd_ptr);
1410 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1413 static void rna_Object_shaderfx_clear(Object *object, bContext *C)
1415 ED_object_shaderfx_clear(CTX_data_main(C), object);
1416 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1419 static void rna_Object_boundbox_get(PointerRNA *ptr, float *values)
1421 Object *ob = (Object *)ptr->id.data;
1422 BoundBox *bb = BKE_object_boundbox_get(ob);
1424 memcpy(values, bb->vec, sizeof(bb->vec));
1427 copy_vn_fl(values, sizeof(bb->vec) / sizeof(float), 0.0f);
1432 static bDeformGroup *rna_Object_vgroup_new(Object *ob, const char *name)
1434 bDeformGroup *defgroup = BKE_object_defgroup_add_name(ob, name);
1436 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1441 static void rna_Object_vgroup_remove(Object *ob, ReportList *reports, PointerRNA *defgroup_ptr)
1443 bDeformGroup *defgroup = defgroup_ptr->data;
1444 if (BLI_findindex(&ob->defbase, defgroup) == -1) {
1445 BKE_reportf(reports, RPT_ERROR, "DeformGroup '%s' not in object '%s'", defgroup->name, ob->id.name + 2);
1449 BKE_object_defgroup_remove(ob, defgroup);
1450 RNA_POINTER_INVALIDATE(defgroup_ptr);
1452 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1455 static void rna_Object_vgroup_clear(Object *ob)
1457 BKE_object_defgroup_remove_all(ob);
1459 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1462 static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *reports, int index_len,
1463 int *index, float weight, int assignmode)
1465 Object *ob = (Object *)id;
1467 if (BKE_object_is_in_editmode_vgroup(ob)) {
1468 BKE_report(reports, RPT_ERROR, "VertexGroup.add(): cannot be called while object is in edit mode");
1473 ED_vgroup_vert_add(ob, def, *index++, weight, assignmode); /* XXX, not efficient calling within loop*/
1475 WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
1478 static void rna_VertexGroup_vertex_remove(ID *id, bDeformGroup *dg, ReportList *reports, int index_len, int *index)
1480 Object *ob = (Object *)id;
1482 if (BKE_object_is_in_editmode_vgroup(ob)) {
1483 BKE_report(reports, RPT_ERROR, "VertexGroup.remove(): cannot be called while object is in edit mode");
1488 ED_vgroup_vert_remove(ob, dg, *index++);
1490 WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
1493 static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *reports, int index)
1495 float weight = ED_vgroup_vert_weight((Object *)id, dg, index);
1498 BKE_report(reports, RPT_ERROR, "Vertex not in group");
1503 static bFaceMap *rna_Object_fmap_new(Object *ob, const char *name)
1505 bFaceMap *fmap = BKE_object_facemap_add_name(ob, name);
1507 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1512 static void rna_Object_fmap_remove(Object *ob, ReportList *reports, PointerRNA *fmap_ptr)
1514 bFaceMap *fmap = fmap_ptr->data;
1515 if (BLI_findindex(&ob->fmaps, fmap) == -1) {
1516 BKE_reportf(reports, RPT_ERROR, "FaceMap '%s' not in object '%s'", fmap->name, ob->id.name + 2);
1520 BKE_object_facemap_remove(ob, fmap);
1521 RNA_POINTER_INVALIDATE(fmap_ptr);
1523 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1527 static void rna_Object_fmap_clear(Object *ob)
1529 BKE_object_facemap_clear(ob);
1531 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1535 static void rna_FaceMap_face_add(ID *id, bFaceMap *fmap, ReportList *reports, int index_len,
1538 Object *ob = (Object *)id;
1540 if (BKE_object_is_in_editmode(ob)) {
1541 BKE_report(reports, RPT_ERROR, "FaceMap.add(): cannot be called while object is in edit mode");
1546 ED_object_facemap_face_add(ob, fmap, *index++);
1548 WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
1551 static void rna_FaceMap_face_remove(ID *id, bFaceMap *fmap, ReportList *reports, int index_len, int *index)
1553 Object *ob = (Object *)id;
1555 if (BKE_object_is_in_editmode(ob)) {
1556 BKE_report(reports, RPT_ERROR, "FaceMap.add(): cannot be called while object is in edit mode");
1561 ED_object_facemap_face_remove(ob, fmap, *index++);
1563 WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
1566 /* generic poll functions */
1567 bool rna_Lattice_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1569 return ((Object *)value.id.data)->type == OB_LATTICE;
1572 bool rna_Curve_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1574 return ((Object *)value.id.data)->type == OB_CURVE;
1577 bool rna_Armature_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1579 return ((Object *)value.id.data)->type == OB_ARMATURE;
1582 bool rna_Mesh_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1584 return ((Object *)value.id.data)->type == OB_MESH;
1587 bool rna_Camera_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1589 return ((Object *)value.id.data)->type == OB_CAMERA;
1592 bool rna_Light_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1594 return ((Object *)value.id.data)->type == OB_LAMP;
1597 bool rna_GPencil_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
1599 return ((Object *)value.id.data)->type == OB_GPENCIL;
1602 int rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr)
1604 SculptSession *ss = ((Object *)ptr->id.data)->sculpt;
1605 return (ss && ss->bm);
1610 static void rna_def_vertex_group(BlenderRNA *brna)
1617 static const EnumPropertyItem assign_mode_items[] = {
1618 {WEIGHT_REPLACE, "REPLACE", 0, "Replace", "Replace"},
1619 {WEIGHT_ADD, "ADD", 0, "Add", "Add"},
1620 {WEIGHT_SUBTRACT, "SUBTRACT", 0, "Subtract", "Subtract"},
1621 {0, NULL, 0, NULL, NULL},
1624 srna = RNA_def_struct(brna, "VertexGroup", NULL);
1625 RNA_def_struct_sdna(srna, "bDeformGroup");
1626 RNA_def_struct_ui_text(srna, "Vertex Group", "Group of vertices, used for armature deform and other purposes");
1627 RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX);
1629 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1630 RNA_def_property_ui_text(prop, "Name", "Vertex group name");
1631 RNA_def_struct_name_property(srna, prop);
1632 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_VertexGroup_name_set");
1633 /* update data because modifiers may use [#24761] */
1634 RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
1636 prop = RNA_def_property(srna, "lock_weight", PROP_BOOLEAN, PROP_NONE);
1637 RNA_def_property_ui_text(prop, "", "Maintain the relative weights for the group");
1638 RNA_def_property_boolean_sdna(prop, NULL, "flag", 0);
1639 /* update data because modifiers may use [#24761] */
1640 RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
1642 prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
1643 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1644 RNA_def_property_int_funcs(prop, "rna_VertexGroup_index_get", NULL, NULL);
1645 RNA_def_property_ui_text(prop, "Index", "Index number of the vertex group");
1647 func = RNA_def_function(srna, "add", "rna_VertexGroup_vertex_add");
1648 RNA_def_function_ui_description(func, "Add vertices to the group");
1649 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
1650 /* TODO, see how array size of 0 works, this shouldnt be used */
1651 parm = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
1652 RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_REQUIRED);
1653 parm = RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight", 0.0f, 1.0f);
1654 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1655 parm = RNA_def_enum(func, "type", assign_mode_items, 0, "", "Vertex assign mode");
1656 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1658 func = RNA_def_function(srna, "remove", "rna_VertexGroup_vertex_remove");
1659 RNA_def_function_ui_description(func, "Remove a vertex from the group");
1660 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
1661 /* TODO, see how array size of 0 works, this shouldnt be used */
1662 parm = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
1663 RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_REQUIRED);
1665 func = RNA_def_function(srna, "weight", "rna_VertexGroup_weight");
1666 RNA_def_function_ui_description(func, "Get a vertex weight from the group");
1667 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
1668 parm = RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "The index of the vertex", 0, INT_MAX);
1669 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1670 parm = RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight", 0.0f, 1.0f);
1671 RNA_def_function_return(func, parm);
1674 static void rna_def_face_map(BlenderRNA *brna)
1680 srna = RNA_def_struct(brna, "FaceMap", NULL);
1681 RNA_def_struct_sdna(srna, "bFaceMap");
1682 RNA_def_struct_ui_text(srna, "Face Map", "Group of faces, each face can only be part of one map");
1683 RNA_def_struct_ui_icon(srna, ICON_MOD_TRIANGULATE);
1685 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1686 RNA_def_property_ui_text(prop, "Name", "Face map name");
1687 RNA_def_struct_name_property(srna, prop);
1688 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_FaceMap_name_set");
1689 /* update data because modifiers may use [#24761] */
1690 RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
1692 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1693 RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
1694 RNA_def_property_ui_text(prop, "Select", "Face-map selection state (for tools to use)");
1695 /* important not to use a notifier here, creates a feedback loop! */
1697 prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
1698 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1699 RNA_def_property_int_funcs(prop, "rna_FaceMap_index_get", NULL, NULL);
1700 RNA_def_property_ui_text(prop, "Index", "Index number of the face map");
1702 func = RNA_def_function(srna, "add", "rna_FaceMap_face_add");
1703 RNA_def_function_ui_description(func, "Add vertices to the group");
1704 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
1705 /* TODO, see how array size of 0 works, this shouldnt be used */
1706 prop = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
1707 RNA_def_parameter_flags(prop, PROP_DYNAMIC, PARM_REQUIRED);
1709 func = RNA_def_function(srna, "remove", "rna_FaceMap_face_remove");
1710 RNA_def_function_ui_description(func, "Remove a vertex from the group");
1711 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
1712 /* TODO, see how array size of 0 works, this shouldnt be used */
1713 prop = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
1714 RNA_def_parameter_flags(prop, PROP_DYNAMIC, PARM_REQUIRED);
1717 static void rna_def_material_slot(BlenderRNA *brna)
1722 static const EnumPropertyItem link_items[] = {
1723 {1, "OBJECT", 0, "Object", ""},
1724 {0, "DATA", 0, "Data", ""},
1725 {0, NULL, 0, NULL, NULL},
1728 /* NOTE: there is no MaterialSlot equivalent in DNA, so the internal
1729 * pointer data points to ob->mat + index, and we manually implement
1730 * get/set for the properties. */
1732 srna = RNA_def_struct(brna, "MaterialSlot", NULL);
1733 RNA_def_struct_ui_text(srna, "Material Slot", "Material slot in an object");
1734 RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
1736 /* WARNING! Order is crucial for override to work properly here... :/
1737 * 'link' must come before material pointer, since it defines where (in object or obdata) that one is set! */
1738 prop = RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE);
1739 RNA_def_property_enum_items(prop, link_items);
1740 RNA_def_property_enum_funcs(prop, "rna_MaterialSlot_link_get", "rna_MaterialSlot_link_set", NULL);
1741 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
1742 RNA_def_property_ui_text(prop, "Link", "Link material to object or the object's data");
1743 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
1745 prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
1746 RNA_def_property_struct_type(prop, "Material");
1747 RNA_def_property_flag(prop, PROP_EDITABLE);
1748 RNA_def_property_editable_func(prop, "rna_MaterialSlot_material_editable");
1749 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
1750 RNA_def_property_pointer_funcs(prop, "rna_MaterialSlot_material_get", "rna_MaterialSlot_material_set", NULL, "rna_MaterialSlot_material_poll");
1751 RNA_def_property_ui_text(prop, "Material", "Material data-block used by this material slot");
1752 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
1754 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1755 RNA_def_property_string_funcs(prop, "rna_MaterialSlot_name_get", "rna_MaterialSlot_name_length", NULL);
1756 RNA_def_property_ui_text(prop, "Name", "Material slot name");
1757 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1758 RNA_def_struct_name_property(srna, prop);
1760 RNA_def_struct_path_func(srna, "rna_MaterialSlot_path");
1763 static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
1771 RNA_def_property_srna(cprop, "ObjectConstraints");
1772 srna = RNA_def_struct(brna, "ObjectConstraints", NULL);
1773 RNA_def_struct_sdna(srna, "Object");
1774 RNA_def_struct_ui_text(srna, "Object Constraints", "Collection of object constraints");
1777 /* Collection active property */
1778 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1779 RNA_def_property_struct_type(prop, "Constraint");
1780 RNA_def_property_pointer_funcs(prop, "rna_Object_active_constraint_get",
1781 "rna_Object_active_constraint_set", NULL, NULL);
1782 RNA_def_property_flag(prop, PROP_EDITABLE);
1783 RNA_def_property_ui_text(prop, "Active Constraint", "Active Object constraint");
1786 /* Constraint collection */
1787 func = RNA_def_function(srna, "new", "rna_Object_constraints_new");
1788 RNA_def_function_ui_description(func, "Add a new constraint to this object");
1789 RNA_def_function_flag(func, FUNC_USE_MAIN);
1791 parm = RNA_def_enum(func, "type", rna_enum_constraint_type_items, 1, "", "Constraint type to add");
1792 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1794 parm = RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint");
1795 RNA_def_function_return(func, parm);
1797 func = RNA_def_function(srna, "remove", "rna_Object_constraints_remove");
1798 RNA_def_function_ui_description(func, "Remove a constraint from this object");
1799 RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
1800 /* constraint to remove */
1801 parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
1802 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1803 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1805 func = RNA_def_function(srna, "clear", "rna_Object_constraints_clear");
1806 RNA_def_function_flag(func, FUNC_USE_MAIN);
1807 RNA_def_function_ui_description(func, "Remove all constraint from this object");
1810 /* object.modifiers */
1811 static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
1818 RNA_def_property_srna(cprop, "ObjectModifiers");
1819 srna = RNA_def_struct(brna, "ObjectModifiers", NULL);
1820 RNA_def_struct_sdna(srna, "Object");
1821 RNA_def_struct_ui_text(srna, "Object Modifiers", "Collection of object modifiers");
1824 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1825 RNA_def_property_struct_type(prop, "EditBone");
1826 RNA_def_property_pointer_sdna(prop, NULL, "act_edbone");
1827 RNA_def_property_flag(prop, PROP_EDITABLE);
1828 RNA_def_property_ui_text(prop, "Active EditBone", "Armatures active edit bone");
1829 /*RNA_def_property_update(prop, 0, "rna_Armature_act_editbone_update"); */
1830 RNA_def_property_pointer_funcs(prop, NULL, "rna_Armature_act_edit_bone_set", NULL, NULL);
1833 /* RNA_def_property_collection_active(prop, prop_act); */
1837 func = RNA_def_function(srna, "new", "rna_Object_modifier_new");
1838 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1839 RNA_def_function_ui_description(func, "Add a new modifier");
1840 parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the modifier");
1841 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1842 /* modifier to add */
1843 parm = RNA_def_enum(func, "type", rna_enum_object_modifier_type_items, 1, "", "Modifier type to add");
1844 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1846 parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Newly created modifier");
1847 RNA_def_function_return(func, parm);
1849 /* remove modifier */
1850 func = RNA_def_function(srna, "remove", "rna_Object_modifier_remove");
1851 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1852 RNA_def_function_ui_description(func, "Remove an existing modifier from the object");
1853 /* modifier to remove */
1854 parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove");
1855 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1856 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1858 /* clear all modifiers */
1859 func = RNA_def_function(srna, "clear", "rna_Object_modifier_clear");
1860 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
1861 RNA_def_function_ui_description(func, "Remove all modifiers from the object");
1864 /* object.grease_pencil_modifiers */
1865 static void rna_def_object_grease_pencil_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
1872 RNA_def_property_srna(cprop, "ObjectGpencilModifiers");
1873 srna = RNA_def_struct(brna, "ObjectGpencilModifiers", NULL);
1874 RNA_def_struct_sdna(srna, "Object");
1875 RNA_def_struct_ui_text(srna, "Object Grease Pencil Modifiers", "Collection of object grease pencil modifiers");
1877 /* add greasepencil modifier */
1878 func = RNA_def_function(srna, "new", "rna_Object_greasepencil_modifier_new");
1879 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1880 RNA_def_function_ui_description(func, "Add a new greasepencil_modifier");
1881 parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the greasepencil_modifier");
1882 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1883 /* greasepencil_modifier to add */
1884 parm = RNA_def_enum(func, "type", rna_enum_object_greasepencil_modifier_type_items, 1, "", "Modifier type to add");
1885 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1887 parm = RNA_def_pointer(func, "greasepencil_modifier", "GpencilModifier", "", "Newly created modifier");
1888 RNA_def_function_return(func, parm);
1890 /* remove greasepencil_modifier */
1891 func = RNA_def_function(srna, "remove", "rna_Object_greasepencil_modifier_remove");
1892 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1893 RNA_def_function_ui_description(func, "Remove an existing greasepencil_modifier from the object");
1894 /* greasepencil_modifier to remove */
1895 parm = RNA_def_pointer(func, "greasepencil_modifier", "GpencilModifier", "", "Modifier to remove");
1896 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1897 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1899 /* clear all greasepencil modifiers */
1900 func = RNA_def_function(srna, "clear", "rna_Object_greasepencil_modifier_clear");
1901 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
1902 RNA_def_function_ui_description(func, "Remove all grease pencil modifiers from the object");
1905 /* object.shaderfxs */
1906 static void rna_def_object_shaderfxs(BlenderRNA *brna, PropertyRNA *cprop)
1913 RNA_def_property_srna(cprop, "ObjectShaderFx");
1914 srna = RNA_def_struct(brna, "ObjectShaderFx", NULL);
1915 RNA_def_struct_sdna(srna, "Object");
1916 RNA_def_struct_ui_text(srna, "Object Shader Effects", "Collection of object effects");
1919 func = RNA_def_function(srna, "new", "rna_Object_shaderfx_new");
1920 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1921 RNA_def_function_ui_description(func, "Add a new shader fx");
1922 parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the effect");
1923 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1925 parm = RNA_def_enum(func, "type", rna_enum_object_shaderfx_type_items, 1, "", "Effect type to add");
1926 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1928 parm = RNA_def_pointer(func, "shader_fx", "ShaderFx", "", "Newly created effect");
1929 RNA_def_function_return(func, parm);
1931 /* remove shader_fx */
1932 func = RNA_def_function(srna, "remove", "rna_Object_shaderfx_remove");
1933 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
1934 RNA_def_function_ui_description(func, "Remove an existing effect from the object");
1935 /* shader to remove */
1936 parm = RNA_def_pointer(func, "shader_fx", "ShaderFx", "", "Effect to remove");
1937 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1938 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1940 /* clear all shader fx */
1941 func = RNA_def_function(srna, "clear", "rna_Object_shaderfx_clear");
1942 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
1943 RNA_def_function_ui_description(func, "Remove all effects from the object");
1946 /* object.particle_systems */
1947 static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop)
1953 /* FunctionRNA *func; */
1954 /* PropertyRNA *parm; */
1956 RNA_def_property_srna(cprop, "ParticleSystems");
1957 srna = RNA_def_struct(brna, "ParticleSystems", NULL);
1958 RNA_def_struct_sdna(srna, "Object");
1959 RNA_def_struct_ui_text(srna, "Particle Systems", "Collection of particle systems");
1961 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1962 RNA_def_property_struct_type(prop, "ParticleSystem");
1963 RNA_def_property_pointer_funcs(prop, "rna_Object_active_particle_system_get", NULL, NULL, NULL);
1964 RNA_def_property_ui_text(prop, "Active Particle System", "Active particle system being displayed");
1965 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
1967 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
1968 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1969 RNA_def_property_int_funcs(prop, "rna_Object_active_particle_system_index_get",
1970 "rna_Object_active_particle_system_index_set",
1971 "rna_Object_active_particle_system_index_range");
1972 RNA_def_property_ui_text(prop, "Active Particle System Index", "Index of active particle system slot");
1973 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_particle_update");
1977 /* object.vertex_groups */
1978 static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
1987 RNA_def_property_srna(cprop, "VertexGroups");
1988 srna = RNA_def_struct(brna, "VertexGroups", NULL);
1989 RNA_def_struct_sdna(srna, "Object");
1990 RNA_def_struct_ui_text(srna, "Vertex Groups", "Collection of vertex groups");
1992 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1993 RNA_def_property_struct_type(prop, "VertexGroup");
1994 RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get",
1995 "rna_Object_active_vertex_group_set", NULL, NULL);
1996 RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object");
1997 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
1999 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
2000 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2001 RNA_def_property_int_sdna(prop, NULL, "actdef");
2002 RNA_def_property_int_funcs(prop, "rna_Object_active_vertex_group_index_get",
2003 "rna_Object_active_vertex_group_index_set",
2004 "rna_Object_active_vertex_group_index_range");
2005 RNA_def_property_ui_text(prop, "Active Vertex Group Index", "Active index in vertex group array");
2006 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
2008 /* vertex groups */ /* add_vertex_group */
2009 func = RNA_def_function(srna, "new", "rna_Object_vgroup_new");
2010 RNA_def_function_ui_description(func, "Add vertex group to object");
2011 RNA_def_string(func, "name", "Group", 0, "", "Vertex group name"); /* optional */
2012 parm = RNA_def_pointer(func, "group", "VertexGroup", "", "New vertex group");
2013 RNA_def_function_return(func, parm);
2015 func = RNA_def_function(srna, "remove", "rna_Object_vgroup_remove");
2016 RNA_def_function_flag(func, FUNC_USE_REPORTS);
2017 RNA_def_function_ui_description(func, "Delete vertex group from object");
2018 parm = RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove");
2019 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2020 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
2022 func = RNA_def_function(srna, "clear", "rna_Object_vgroup_clear");
2023 RNA_def_function_ui_description(func, "Delete all vertex groups from object");
2026 /* object.face_maps */
2027 static void rna_def_object_face_maps(BlenderRNA *brna, PropertyRNA *cprop)
2036 RNA_def_property_srna(cprop, "FaceMaps");
2037 srna = RNA_def_struct(brna, "FaceMaps", NULL);
2038 RNA_def_struct_sdna(srna, "Object");
2039 RNA_def_struct_ui_text(srna, "Face Maps", "Collection of face maps");
2041 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2042 RNA_def_property_struct_type(prop, "FaceMap");
2043 RNA_def_property_pointer_funcs(prop, "rna_Object_active_face_map_get",
2044 "rna_Object_active_face_map_set", NULL, NULL);
2045 RNA_def_property_ui_text(prop, "Active Face Map", "Face maps of the object");
2046 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
2048 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
2049 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2050 RNA_def_property_int_sdna(prop, NULL, "actfmap");
2051 RNA_def_property_int_funcs(prop, "rna_Object_active_face_map_index_get",
2052 "rna_Object_active_face_map_index_set",
2053 "rna_Object_active_face_map_index_range");
2054 RNA_def_property_ui_text(prop, "Active Face Map Index", "Active index in face map array");
2055 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
2057 /* face maps */ /* add_face_map */
2058 func = RNA_def_function(srna, "new", "rna_Object_fmap_new");
2059 RNA_def_function_ui_description(func, "Add face map to object");
2060 RNA_def_string(func, "name", "Map", 0, "", "face map name"); /* optional */
2061 parm = RNA_def_pointer(func, "fmap", "FaceMap", "", "New face map");
2062 RNA_def_function_return(func, parm);
2064 func = RNA_def_function(srna, "remove", "rna_Object_fmap_remove");
2065 RNA_def_function_flag(func, FUNC_USE_REPORTS);
2066 RNA_def_function_ui_description(func, "Delete vertex group from object");
2067 parm = RNA_def_pointer(func, "group", "FaceMap", "", "Face map to remove");
2068 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2069 RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
2071 func = RNA_def_function(srna, "clear", "rna_Object_fmap_clear");
2072 RNA_def_function_ui_description(func, "Delete all vertex groups from object");
2075 static void rna_def_object_display(BlenderRNA *brna)
2080 srna = RNA_def_struct(brna, "ObjectDisplay", NULL);
2081 RNA_def_struct_ui_text(srna, "Object Display", "Object display settings for 3d viewport");
2082 RNA_def_struct_sdna(srna, "ObjectDisplay");
2083 RNA_def_struct_path_func(srna, "rna_ObjectDisplay_path");
2085 prop = RNA_def_property(srna, "show_shadows", PROP_BOOLEAN, PROP_NONE);
2086 RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_SHOW_SHADOW);
2087 RNA_def_property_boolean_default(prop, true);
2088 RNA_def_property_ui_text(prop, "Shadow", "Object cast shadows in the 3d viewport");
2089 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2092 static void rna_def_object(BlenderRNA *brna)
2097 static const EnumPropertyItem up_items[] = {
2098 {OB_POSX, "X", 0, "X", ""},
2099 {OB_POSY, "Y", 0, "Y", ""},
2100 {OB_POSZ, "Z", 0, "Z", ""},
2101 {0, NULL, 0, NULL, NULL},
2104 static const EnumPropertyItem drawtype_items[] = {
2105 {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", "Display the bounds of the object"},
2106 {OB_WIRE, "WIRE", 0, "Wire", "Display the object as a wireframe"},
2107 {OB_SOLID, "SOLID", 0, "Solid", "Display the object as a solid (if solid drawing is enabled in the viewport)"},
2108 {OB_TEXTURE, "TEXTURED", 0, "Textured",
2109 "Display the object with textures (if textures are enabled in the viewport)"},
2110 {0, NULL, 0, NULL, NULL},
2113 static const EnumPropertyItem boundtype_items[] = {
2114 {OB_BOUND_BOX, "BOX", 0, "Box", "Display bounds as box"},
2115 {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", "Display bounds as sphere"},
2116 {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", "Display bounds as cylinder"},
2117 {OB_BOUND_CONE, "CONE", 0, "Cone", "Display bounds as cone"},
2118 {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", "Display bounds as capsule"},
2119 {0, NULL, 0, NULL, NULL},
2122 static float default_quat[4] = {1, 0, 0, 0}; /* default quaternion values */
2123 static float default_axisAngle[4] = {0, 0, 1, 0}; /* default axis-angle rotation values */
2124 static float default_scale[3] = {1, 1, 1}; /* default scale values */
2125 static int boundbox_dimsize[] = {8, 3};
2127 srna = RNA_def_struct(brna, "Object", "ID");
2128 RNA_def_struct_ui_text(srna, "Object", "Object data-block defining an object in a scene");
2129 RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
2130 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
2132 prop = RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
2133 RNA_def_property_struct_type(prop, "ID");
2134 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_set", "rna_Object_data_typef", "rna_Object_data_poll");
2135 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
2136 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
2137 RNA_def_property_ui_text(prop, "Data", "Object data");
2138 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
2140 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2141 RNA_def_property_enum_sdna(prop, NULL, "type");
2142 RNA_def_property_enum_items(prop, rna_enum_object_type_items);
2143 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2144 RNA_def_property_ui_text(prop, "Type", "Type of Object");
2146 prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
2147 RNA_def_property_enum_sdna(prop, NULL, "mode");
2148 RNA_def_property_enum_items(prop, rna_enum_object_mode_items);
2149 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2150 RNA_def_property_ui_text(prop, "Mode", "Object interaction mode");
2152 /* for data access */
2153 prop = RNA_def_property(srna, "bound_box", PROP_FLOAT, PROP_NONE);
2154 RNA_def_property_multi_array(prop, 2, boundbox_dimsize);
2155 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2156 RNA_def_property_float_funcs(prop, "rna_Object_boundbox_get", NULL, NULL);
2157 RNA_def_property_ui_text(prop, "Bounding Box",
2158 "Object's bounding box in object-space coordinates, all values are -1.0 when "
2162 prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
2163 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_parent_set", NULL, NULL);
2164 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2165 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
2166 RNA_def_property_ui_text(prop, "Parent", "Parent Object");
2167 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2169 prop = RNA_def_property(srna, "parent_type", PROP_ENUM, PROP_NONE);
2170 RNA_def_property_enum_bitflag_sdna(prop, NULL, "partype");
2171 RNA_def_property_enum_items(prop, parent_type_items);
2172 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_parent_type_set", "rna_Object_parent_type_itemf");
2173 RNA_def_property_ui_text(prop, "Parent Type", "Type of parent relation");
2174 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2176 prop = RNA_def_property(srna, "parent_vertices", PROP_INT, PROP_UNSIGNED);
2177 RNA_def_property_int_sdna(prop, NULL, "par1");
2178 RNA_def_property_array(prop, 3);
2179 RNA_def_property_ui_text(prop, "Parent Vertices", "Indices of vertices in case of a vertex parenting relation");
2180 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2182 prop = RNA_def_property(srna, "parent_bone", PROP_STRING, PROP_NONE);
2183 RNA_def_property_string_sdna(prop, NULL, "parsubstr");
2184 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Object_parent_bone_set");
2185 RNA_def_property_ui_text(prop, "Parent Bone", "Name of parent bone in case of a bone parenting relation");
2186 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2188 /* Track and Up flags */
2189 /* XXX: these have been saved here for a bit longer (after old track was removed),
2190 * since some other tools still refer to this */
2191 prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
2192 RNA_def_property_enum_sdna(prop, NULL, "trackflag");
2193 RNA_def_property_enum_items(prop, rna_enum_object_axis_items);
2194 RNA_def_property_ui_text(prop, "Track Axis",
2195 "Axis that points in 'forward' direction (applies to InstanceFrame when "
2196 "parent 'Follow' is enabled)");
2197 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2199 prop = RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE);
2200 RNA_def_property_enum_sdna(prop, NULL, "upflag");
2201 RNA_def_property_enum_items(prop, up_items);
2202 RNA_def_property_ui_text(prop, "Up Axis",
2203 "Axis that points in the upward direction (applies to InstanceFrame when "
2204 "parent 'Follow' is enabled)");
2205 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2208 prop = RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE);
2209 RNA_def_property_ui_text(prop, "Proxy", "Library object this proxy object controls");
2211 prop = RNA_def_property(srna, "proxy_collection", PROP_POINTER, PROP_NONE);
2212 RNA_def_property_pointer_sdna(prop, NULL, "proxy_group");
2213 RNA_def_property_ui_text(prop, "Proxy Collection", "Library collection duplicator object this proxy object controls");
2216 prop = RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE);
2217 RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
2218 RNA_def_property_struct_type(prop, "MaterialSlot");
2219 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_NO_PROP_NAME);
2220 /* don't dereference pointer! */
2221 RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", NULL, NULL, NULL, NULL);
2222 RNA_def_property_ui_text(prop, "Material Slots", "Material slots in the object");
2224 prop = RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE);
2225 RNA_def_property_struct_type(prop, "Material");
2226 RNA_def_property_pointer_funcs(prop, "rna_Object_active_material_get",
2227 "rna_Object_active_material_set", NULL,
2228 "rna_MaterialSlot_material_poll");
2229 RNA_def_property_flag(prop, PROP_EDITABLE);
2230 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
2231 RNA_def_property_editable_func(prop, "rna_Object_active_material_editable");
2232 RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed");
2233 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
2235 prop = RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
2236 RNA_def_property_int_sdna(prop, NULL, "actcol");
2237 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2238 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
2239 RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set",
2240 "rna_Object_active_material_index_range");
2241 RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot");
2242 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, "rna_MaterialIndex_update");
2245 prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
2246 RNA_def_property_float_sdna(prop, NULL, "loc");
2247 RNA_def_property_editable_array_func(prop, "rna_Object_location_editable");
2248 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
2249 RNA_def_property_ui_text(prop, "Location", "Location of the object");
2250 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2251 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2253 prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
2254 RNA_def_property_float_sdna(prop, NULL, "quat");
2255 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
2256 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
2257 RNA_def_property_float_array_default(prop, default_quat);
2258 RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions");
2259 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2261 /* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but
2262 * having a single one is better for Keyframing and other property-management situations...
2264 prop = RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
2265 RNA_def_property_array(prop, 4);
2266 RNA_def_property_float_funcs(prop, "rna_Object_rotation_axis_angle_get",
2267 "rna_Object_rotation_axis_angle_set", NULL);
2268 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
2269 RNA_def_property_float_array_default(prop, default_axisAngle);
2270 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
2271 RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
2272 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2274 prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
2275 RNA_def_property_float_sdna(prop, NULL, "rot");
2276 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_euler_editable");
2277 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
2278 RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers");
2279 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2281 prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
2282 RNA_def_property_enum_sdna(prop, NULL, "rotmode");
2283 RNA_def_property_enum_items(prop, rna_enum_object_rotation_mode_items);
2284 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_rotation_mode_set", NULL);
2285 RNA_def_property_ui_text(prop, "Rotation Mode", "");
2286 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2288 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
2289 RNA_def_property_float_sdna(prop, NULL, "size");
2290 RNA_def_property_flag(prop, PROP_PROPORTIONAL);
2291 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
2292 RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable");
2293 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
2294 RNA_def_property_float_array_default(prop, default_scale);
2295 RNA_def_property_ui_text(prop, "Scale", "Scaling of the object");
2296 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2298 prop = RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ_LENGTH);
2299 RNA_def_property_array(prop, 3);
2300 /* Only as convinient helper for py API, and conflicts with animating scale. */
2301 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2302 RNA_def_property_float_funcs(prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", NULL);
2303 RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2304 RNA_def_property_ui_text(prop, "Dimensions",
2305 "Absolute bounding box dimensions of the object (WARNING: assigning to it or "
2306 "its members mutiple consecutive times will not work correctly, "
2307 "as this needs up-to-date evaluated data)");
2308 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2311 /* delta transforms */
2312 prop = RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_TRANSLATION);
2313 RNA_def_property_float_sdna(prop, NULL, "dloc");
2314 RNA_def_property_ui_text(prop, "Delta Location", "Extra translation added to the location of the object");
2315 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2316 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2318 prop = RNA_def_property(srna, "delta_rotation_euler", PROP_FLOAT, PROP_EULER);
2319 RNA_def_property_float_sdna(prop, NULL, "drot");
2320 RNA_def_property_ui_text(prop, "Delta Rotation (Euler)",
2321 "Extra rotation added to the rotation of the object (when using Euler rotations)");
2322 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2324 prop = RNA_def_property(srna, "delta_rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
2325 RNA_def_property_float_sdna(prop, NULL, "dquat");
2326 RNA_def_property_float_array_default(prop, default_quat);
2327 RNA_def_property_ui_text(prop, "Delta Rotation (Quaternion)",
2328 "Extra rotation added to the rotation of the object (when using Quaternion rotations)");
2329 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2331 #if 0 /* XXX not supported well yet... */
2332 prop = RNA_def_property(srna, "delta_rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
2333 /* FIXME: this is not a single field any more! (drotAxis and drotAngle) */
2334 RNA_def_property_float_sdna(prop, NULL, "dquat");
2335 RNA_def_property_float_array_default(prop, default_axisAngle);
2336 RNA_def_property_ui_text(prop, "Delta Rotation (Axis Angle)",
2337 "Extra rotation added to the rotation of the object (when using Axis-Angle rotations)");
2338 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2341 prop = RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_XYZ);
2342 RNA_def_property_float_sdna(prop, NULL, "dscale");
2343 RNA_def_property_flag(prop, PROP_PROPORTIONAL);
2344 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
2345 RNA_def_property_float_array_default(prop, default_scale);
2346 RNA_def_property_ui_text(prop, "Delta Scale", "Extra scaling added to the scale of the object");
2347 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2349 /* transform locks */
2350 prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE);
2351 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX);
2352 RNA_def_property_array(prop, 3);
2353 RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface");
2354 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2355 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2357 prop = RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE);
2358 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX);
2359 RNA_def_property_array(prop, 3);
2360 RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface");
2361 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2362 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2364 /* XXX this is sub-optimal - it really should be included above,
2365 * but due to technical reasons we can't do this! */
2366 prop = RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE);
2367 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTW);
2368 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2369 RNA_def_property_ui_text(prop, "Lock Rotation (4D Angle)",
2370 "Lock editing of 'angle' component of four-component rotations in the interface");
2371 /* XXX this needs a better name */
2372 prop = RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE);
2373 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROT4D);
2374 RNA_def_property_ui_text(prop, "Lock Rotations (4D)",
2375 "Lock editing of four component rotations by components (instead of as Eulers)");
2377 prop = RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_NONE);
2378 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX);
2379 RNA_def_property_array(prop, 3);
2380 RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface");
2381 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2382 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2385 prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
2386 RNA_def_property_float_sdna(prop, NULL, "obmat");
2387 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2388 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2389 RNA_def_property_ui_text(prop, "Matrix World", "Worldspace transformation matrix");
2390 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_matrix_world_update");
2392 prop = RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX);
2393 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2394 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2395 RNA_def_property_ui_text(prop, "Local Matrix", "Parent relative transformation matrix - "
2396 "WARNING: Only takes into account 'Object' parenting, so e.g. in case of bone parenting "
2397 "you get a matrix relative to the Armature object, not to the actual parent bone");
2398 RNA_def_property_float_funcs(prop, "rna_Object_matrix_local_get", "rna_Object_matrix_local_set", NULL);
2399 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2401 prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
2402 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2403 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2404 RNA_def_property_ui_text(prop, "Input Matrix",
2405 "Matrix access to location, rotation and scale (including deltas), "
2406 "before constraints and parenting are applied");
2407 RNA_def_property_float_funcs(prop, "rna_Object_matrix_basis_get", "rna_Object_matrix_basis_set", NULL);
2408 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2411 prop = RNA_def_property(srna, "matrix_parent_inverse", PROP_FLOAT, PROP_MATRIX);
2412 RNA_def_property_float_sdna(prop, NULL, "parentinv");
2413 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2414 RNA_def_property_ui_text(prop, "Matrix", "Inverse of object's parent matrix at time of parenting");
2415 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2418 prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
2419 RNA_def_property_struct_type(prop, "Modifier");
2420 RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the geometric data of the object");
2421 RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Object_modifiers_override_apply");
2422 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_STATIC_INSERTION);
2423 rna_def_object_modifiers(brna, prop);
2425 /* Grease Pencil modifiers. */
2426 prop = RNA_def_property(srna, "grease_pencil_modifiers", PROP_COLLECTION, PROP_NONE);
2427 RNA_def_property_collection_sdna(prop, NULL, "greasepencil_modifiers", NULL);
2428 RNA_def_property_struct_type(prop, "GpencilModifier");
2429 RNA_def_property_ui_text(prop, "Grease Pencil Modifiers", "Modifiers affecting the data of the grease pencil object");
2430 rna_def_object_grease_pencil_modifiers(brna, prop);
2433 prop = RNA_def_property(srna, "shader_effects", PROP_COLLECTION, PROP_NONE);
2434 RNA_def_property_collection_sdna(prop, NULL, "shader_fx", NULL);
2435 RNA_def_property_struct_type(prop, "ShaderFx");
2436 RNA_def_property_ui_text(prop, "Shader Effects", "Effects affecting display of object");
2437 rna_def_object_shaderfxs(brna, prop);
2440 prop = RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE);
2441 RNA_def_property_struct_type(prop, "Constraint");
2442 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_STATIC_INSERTION);
2443 RNA_def_property_ui_text(prop, "Constraints", "Constraints affecting the transformation of the object");
2444 RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Object_constraints_override_apply");
2445 /* RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "constraints__add", "constraints__remove"); */
2446 rna_def_object_constraints(brna, prop);
2449 prop = RNA_def_property(srna, "vertex_groups", PROP_COLLECTION, PROP_NONE);
2450 RNA_def_property_collection_sdna(prop, NULL, "defbase", NULL);
2451 RNA_def_property_struct_type(prop, "VertexGroup");
2452 RNA_def_property_ui_text(prop, "Vertex Groups", "Vertex groups of the object");
2453 rna_def_object_vertex_groups(brna, prop);
2457 prop = RNA_def_property(srna, "face_maps", PROP_COLLECTION, PROP_NONE);
2458 RNA_def_property_collection_sdna(prop, NULL, "fmaps", NULL);
2459 RNA_def_property_struct_type(prop, "FaceMap");
2460 RNA_def_property_ui_text(prop, "Face Maps", "Maps of faces of the object");
2461 rna_def_object_face_maps(brna, prop);
2464 prop = RNA_def_property(srna, "empty_display_type", PROP_ENUM, PROP_NONE);
2465 RNA_def_property_enum_sdna(prop, NULL, "empty_drawtype");
2466 RNA_def_property_enum_items(prop, rna_enum_object_empty_drawtype_items);
2467 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_empty_display_type_set", NULL);
2468 RNA_def_property_ui_text(prop, "Empty Display Type", "Viewport display style for empties");
2469 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2471 prop = RNA_def_property(srna, "empty_display_size", PROP_FLOAT, PROP_DISTANCE);
2472 RNA_def_property_float_sdna(prop, NULL, "empty_drawsize");
2473 RNA_def_property_range(prop, 0.0001f, 1000.0f);
2474 RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);
2475 RNA_def_property_ui_text(prop, "Empty Display Size", "Size of display for empties in the viewport");
2476 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2478 prop = RNA_def_property(srna, "empty_image_offset", PROP_FLOAT, PROP_NONE);
2479 RNA_def_property_float_sdna(prop, NULL, "ima_ofs");
2480 RNA_def_property_ui_text(prop, "Origin Offset", "Origin offset distance");
2481 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1f, 2);
2482 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2484 prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE);
2485 RNA_def_property_flag(prop, PROP_NEVER_NULL);
2486 RNA_def_property_pointer_sdna(prop, NULL, "iuser");
2487 RNA_def_property_ui_text(prop, "Image User",
2488 "Parameters defining which layer, pass and frame of the image is displayed");
2489 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2491 prop = RNA_def_property(srna, "empty_image_depth", PROP_ENUM, PROP_NONE);
2492 RNA_def_property_enum_items(prop, rna_enum_object_empty_image_depth_items);
2493 RNA_def_property_ui_text(prop, "Empty Image Depth", "Determine which other objects will occlude the image");
2494 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2496 prop = RNA_def_property(srna, "show_empty_image_perspective", PROP_BOOLEAN, PROP_NONE);
2497 RNA_def_property_boolean_negative_sdna(prop, NULL, "empty_image_visibility_flag", OB_EMPTY_IMAGE_HIDE_PERSPECTIVE);
2498 RNA_def_property_ui_text(prop, "Display in Perspective Mode", "Display image in perspective mode");
2499 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2501 prop = RNA_def_property(srna, "show_empty_image_orthographic", PROP_BOOLEAN, PROP_NONE);
2502 RNA_def_property_boolean_negative_sdna(prop, NULL, "empty_image_visibility_flag", OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC);
2503 RNA_def_property_ui_text(prop, "Display in Orthographic Mode", "Display image in orthographic mode");
2504 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2506 static EnumPropertyItem prop_empty_image_side_items[] = {
2507 {0, "DOUBLE_SIDED", 0, "Both", ""},
2508 {OB_EMPTY_IMAGE_HIDE_BACK, "FRONT", 0, "Front", ""},
2509 {OB_EMPTY_IMAGE_HIDE_FRONT, "BACK", 0, "Back", ""},
2510 {0, NULL, 0, NULL, NULL},
2512 prop = RNA_def_property(srna, "empty_image_side", PROP_ENUM, PROP_NONE);
2513 RNA_def_property_enum_bitflag_sdna(prop, NULL, "empty_image_visibility_flag");
2514 RNA_def_property_enum_items(prop, prop_empty_image_side_items);
2515 RNA_def_property_ui_text(prop, "Empty Image Side", "Show front/back side");
2516 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2519 prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
2520 RNA_def_property_int_sdna(prop, NULL, "index");
2521 RNA_def_property_ui_text(prop, "Pass Index", "Index number for the \"Object Index\" render pass");
2522 RNA_def_property_update(prop, NC_OBJECT, "rna_Object_internal_update_draw");
2524 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
2525 RNA_def_property_float_sdna(prop, NULL, "col");
2526 RNA_def_property_ui_text(prop, "Color", "Object color and alpha, used when faces have the ObColor mode enabled");
2527 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2530 prop = RNA_def_property(srna, "field", PROP_POINTER, PROP_NONE);
2531 RNA_def_property_pointer_sdna(prop, NULL, "pd");
2532 RNA_def_property_struct_type(prop, "FieldSettings");
2533 RNA_def_property_pointer_funcs(prop, "rna_Object_field_get", NULL, NULL, NULL);
2534 RNA_def_property_ui_text(prop, "Field Settings", "Settings for using the object as a field in physics simulation");
2536 prop = RNA_def_property(srna, "collision", PROP_POINTER, PROP_NONE);
2537 RNA_def_property_pointer_sdna(prop, NULL, "pd");
2538 RNA_def_property_struct_type(prop, "CollisionSettings");
2539 RNA_def_property_pointer_funcs(prop, "rna_Object_collision_get", NULL, NULL, NULL);
2540 RNA_def_property_ui_text(prop, "Collision Settings",
2541 "Settings for using the object as a collider in physics simulation");
2543 prop = RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE);
2544 RNA_def_property_pointer_sdna(prop, NULL, "soft");
2545 RNA_def_property_struct_type(prop, "SoftBodySettings");
2546 RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for soft body simulation");
2548 prop = RNA_def_property(srna, "particle_systems", PROP_COLLECTION, PROP_NONE);
2549 RNA_def_property_collection_sdna(prop, NULL, "particlesystem", NULL);
2550 RNA_def_property_struct_type(prop, "ParticleSystem");
2551 RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object");
2552 rna_def_object_particle_systems(brna, prop);
2555 prop = RNA_def_property(srna, "rigid_body", PROP_POINTER, PROP_NONE);
2556 RNA_def_property_pointer_sdna(prop, NULL, "rigidbody_object");
2557 RNA_def_property_struct_type(prop, "RigidBodyObject");
2558 RNA_def_property_ui_text(prop, "Rigid Body Settings", "Settings for rigid body simulation");
2560 prop = RNA_def_property(srna, "rigid_body_constraint", PROP_POINTER, PROP_NONE);
2561 RNA_def_property_pointer_sdna(prop, NULL, "rigidbody_constraint");
2562 RNA_def_property_struct_type(prop, "RigidBodyConstraint");
2563 RNA_def_property_ui_text(prop, "Rigid Body Constraint", "Constraint constraining rigid bodies");
2566 prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE);
2567 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW);
2568 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
2569 RNA_def_property_ui_text(prop, "Disable View", "Disable object in the viewport");
2570 RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, -1);
2571 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
2573 prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
2574 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT);
2575 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
2576 RNA_def_property_ui_text(prop, "Disable Select", "Disable object selection in the viewport");
2577 RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, -1);
2578 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
2580 prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE);
2581 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER);
2582 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
2583 RNA_def_property_ui_text(prop, "Disable Render", "Disable object in renders");
2584 RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, -1);
2585 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
2587 prop = RNA_def_property(srna, "show_instancer_for_render", PROP_BOOLEAN, PROP_NONE);
2588 RNA_def_property_boolean_sdna(prop, NULL, "duplicator_visibility_flag", OB_DUPLI_FLAG_RENDER);
2589 RNA_def_property_ui_text(prop, "Render Instancer", "Make instancer visible when rendering");
2591 prop = RNA_def_property(srna, "show_instancer_for_viewport", PROP_BOOLEAN, PROP_NONE);
2592 RNA_def_property_boolean_sdna(prop, NULL, "duplicator_visibility_flag", OB_DUPLI_FLAG_VIEWPORT);
2593 RNA_def_property_ui_text(prop, "Display Instancer", "Make instancer visible in the viewport");
2596 rna_def_animdata_common(srna);
2598 rna_def_animviz_common(srna);
2599 rna_def_motionpath_common(srna);
2602 prop = RNA_def_property(srna, "instance_type", PROP_ENUM, PROP_NONE);
2603 RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag");
2604 RNA_def_property_enum_items(prop, instance_items);
2605 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_instance_type_itemf");
2606 RNA_def_property_ui_text(prop, "Instance Type", "If not None, object instancing method to use");
2607 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2609 prop = RNA_def_property(srna, "use_instance_vertices_rotation", PROP_BOOLEAN, PROP_NONE);
2610 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIROT);
2611 RNA_def_property_ui_text(prop, "Instance Verts Rotation", "Rotate instance according to vertex normal");
2612 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2614 prop = RNA_def_property(srna, "use_instance_faces_scale", PROP_BOOLEAN, PROP_NONE);
2615 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIFACES_SCALE);
2616 RNA_def_property_ui_text(prop, "Instance Faces Inherit Scale", "Scale instance based on face size");
2617 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2619 prop = RNA_def_property(srna, "instance_faces_scale", PROP_FLOAT, PROP_NONE);
2620 RNA_def_property_float_sdna(prop, NULL, "dupfacesca");
2621 RNA_def_property_range(prop, 0.001f, 10000.0f);
2622 RNA_def_property_ui_text(prop, "Instance Faces Scale", "Scale the face instance objects");
2623 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2625 prop = RNA_def_property(srna, "instance_collection", PROP_POINTER, PROP_NONE);
2626 RNA_def_property_struct_type(prop, "Collection");
2627 RNA_def_property_pointer_sdna(prop, NULL, "dup_group");
2628 RNA_def_property_flag(prop, PROP_EDITABLE);
2629 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_dup_collection_set", NULL, NULL);
2630 RNA_def_property_ui_text(prop, "Instance Collection", "Instance an existing collection");
2631 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2633 prop = RNA_def_property(srna, "is_instancer", PROP_BOOLEAN, PROP_NONE);
2634 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLI);
2635 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2638 prop = RNA_def_property(srna, "display_type", PROP_ENUM, PROP_NONE);
2639 RNA_def_property_enum_sdna(prop, NULL, "dt");
2640 RNA_def_property_enum_items(prop, drawtype_items);
2641 RNA_def_property_ui_text(prop, "Display As", "How to display object in viewport");
2642 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2644 prop = RNA_def_property(srna, "show_bounds", PROP_BOOLEAN, PROP_NONE);
2645 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWBOUNDOX);
2646 RNA_def_property_ui_text(prop, "Display Bounds", "Display the object's bounds");
2647 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2649 prop = RNA_def_property(srna, "display_bounds_type", PROP_ENUM, PROP_NONE);
2650 RNA_def_property_enum_sdna(prop, NULL, "boundtype");
2651 RNA_def_property_enum_items(prop, boundtype_items);
2652 RNA_def_property_ui_text(prop, "Display Bounds Type", "Object boundary display type");
2653 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2655 prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE);
2656 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWNAME);
2657 RNA_def_property_ui_text(prop, "Display Name", "Display the object's name");
2658 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2660 prop = RNA_def_property(srna, "show_axis", PROP_BOOLEAN, PROP_NONE);
2661 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_AXIS);
2662 RNA_def_property_ui_text(prop, "Display Axes", "Display the object's origin and axes");
2663 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2665 prop = RNA_def_property(srna, "show_texture_space", PROP_BOOLEAN, PROP_NONE);
2666 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_TEXSPACE);
2667 RNA_def_property_ui_text(prop, "Display Texture Space", "Display the object's texture space");
2668 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2670 prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE);
2671 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWWIRE);
2672 RNA_def_property_ui_text(prop, "Display Wire", "Add the object's wireframe over solid drawing");
2673 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2675 prop = RNA_def_property(srna, "show_all_edges", PROP_BOOLEAN, PROP_NONE);
2676 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAW_ALL_EDGES);
2677 RNA_def_property_ui_text(prop, "Display All Edges", "Display all edges for mesh objects");
2678 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2680 prop = RNA_def_property(srna, "show_transparent", PROP_BOOLEAN, PROP_NONE);
2681 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWTRANSP);
2682 RNA_def_property_ui_text(prop, "Display Transparent",
2683 "Display material transparency in the object");
2684 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2686 prop = RNA_def_property(srna, "show_in_front", PROP_BOOLEAN, PROP_NONE);
2687 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWXRAY);
2688 RNA_def_property_ui_text(prop, "In Front",
2689 "Make the object draw in front of others");
2690 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2693 #if 1 /* FIXME: Remove this code when all Open-Movie assets have been fixed */
2694 prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
2695 RNA_def_property_pointer_sdna(prop, NULL, "gpd");
2696 RNA_def_property_struct_type(prop, "GreasePencil");
2697 RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_GPencil_datablocks_obdata_poll"); /* XXX */
2698 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
2699 RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil data-block (deprecated)");
2700 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2704 prop = RNA_def_property(srna, "pose_library", PROP_POINTER, PROP_NONE);
2705 RNA_def_property_pointer_sdna(prop, NULL, "poselib");
2706 RNA_def_property_struct_type(prop, "Action");
2707 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
2708 RNA_def_property_ui_text(prop, "Pose Library", "Action used as a pose library for armatures");
2710 prop = RNA_def_property(srna, "pose", PROP_POINTER, PROP_NONE);
2711 RNA_def_property_pointer_sdna(prop, NULL, "pose");
2712 RNA_def_property_struct_type(prop, "Pose");
2713 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
2714 RNA_def_property_ui_text(prop, "Pose", "Current pose for armatures");
2717 prop = RNA_def_property(srna, "show_only_shape_key", PROP_BOOLEAN, PROP_NONE);
2718 RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_LOCK);
2719 RNA_def_property_ui_text(prop, "Shape Key Lock", "Always show the current Shape for this Object");
2720 RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
2721 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
2723 prop = RNA_def_property(srna, "use_shape_key_edit_mode", PROP_BOOLEAN, PROP_NONE);
2724 RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_EDIT_MODE);
2725 RNA_def_property_ui_text(prop, "Shape Key Edit Mode", "Apply shape keys in edit mode (for Meshes only)");
2726 RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0);
2727 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
2729 prop = RNA_def_property(srna, "active_shape_key", PROP_POINTER, PROP_NONE);
2730 RNA_def_property_struct_type(prop, "ShapeKey");
2731 RNA_def_property_pointer_funcs(prop, "rna_Object_active_shape_key_get", NULL, NULL, NULL);
2732 RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key");
2734 prop = RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE);
2735 RNA_def_property_int_sdna(prop, NULL, "shapenr");
2736 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
2737 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* XXX this is really unpredictable... */
2738 RNA_def_property_int_funcs(prop, "rna_Object_active_shape_key_index_get", "rna_Object_active_shape_key_index_set",
2739 "rna_Object_active_shape_key_index_range");
2740 RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index");
2741 RNA_def_property_update(prop, 0, "rna_Object_active_shape_update");
2744 prop = RNA_def_property(srna, "use_dynamic_topology_sculpting", PROP_BOOLEAN, PROP_NONE);
2745 RNA_def_property_boolean_funcs(prop, "rna_Object_use_dynamic_topology_sculpting_get", NULL);
2746 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2747 RNA_def_property_ui_text(prop, "Dynamic Topology Sculpting", NULL);
2750 prop = RNA_def_property(srna, "is_from_instancer", PROP_BOOLEAN, PROP_NONE);
2751 RNA_def_property_boolean_sdna(prop, NULL, "base_flag", BASE_FROM_DUPLI);
2752 RNA_def_property_ui_text(prop, "Base from Instancer", "Object comes from a instancer");
2753 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2755 prop = RNA_def_property(srna, "is_from_set", PROP_BOOLEAN, PROP_NONE);
2756 RNA_def_property_boolean_sdna(prop, NULL, "base_flag", BASE_FROM_SET);
2757 RNA_def_property_ui_text(prop, "Base from Set", "Object comes from a background set");
2758 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2760 /* Object Display */
2761 prop = RNA_def_property(srna, "display", PROP_POINTER, PROP_NONE);
2762 RNA_def_property_pointer_sdna(prop, NULL, "display");
2763 RNA_def_property_struct_type(prop, "ObjectDisplay");
2764 RNA_def_property_ui_text(prop, "Object Display", "Object display settings for 3d viewport");
2766 RNA_api_object(srna);
2769 void RNA_def_object(BlenderRNA *brna)
2771 rna_def_object(brna);
2773 RNA_define_animate_sdna(false);
2774 rna_def_vertex_group(brna);
2775 rna_def_face_map(brna);
2776 rna_def_material_slot(brna);
2777 rna_def_object_display(brna);
2778 RNA_define_animate_sdna(true);