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.
24 #include "DNA_action_types.h"
25 #include "DNA_brush_types.h"
26 #include "DNA_collection_types.h"
27 #include "DNA_customdata_types.h"
28 #include "DNA_gpencil_modifier_types.h"
29 #include "DNA_lightprobe_types.h"
30 #include "DNA_material_types.h"
31 #include "DNA_mesh_types.h"
32 #include "DNA_meta_types.h"
33 #include "DNA_object_force_types.h"
34 #include "DNA_object_types.h"
35 #include "DNA_scene_types.h"
36 #include "DNA_shader_fx_types.h"
37 #include "DNA_workspace_types.h"
39 #include "BLI_utildefines.h"
41 #include "BLT_translation.h"
43 #include "BKE_camera.h"
44 #include "BKE_collection.h"
45 #include "BKE_editlattice.h"
46 #include "BKE_editmesh.h"
47 #include "BKE_layer.h"
48 #include "BKE_object_deform.h"
49 #include "BKE_object_facemap.h"
50 #include "BKE_paint.h"
52 #include "RNA_access.h"
53 #include "RNA_define.h"
54 #include "RNA_enum_types.h"
56 #include "rna_internal.h"
58 #include "BLI_sys_types.h" /* needed for intptr_t used in ED_mesh.h */
64 const EnumPropertyItem rna_enum_object_mode_items[] = {
65 {OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object Mode", ""},
66 {OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit Mode", ""},
67 {OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose Mode", ""},
68 {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""},
69 {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
70 {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
71 {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
72 {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""},
73 {OB_MODE_EDIT_GPENCIL,
77 "Edit Grease Pencil Strokes"},
78 {OB_MODE_SCULPT_GPENCIL,
82 "Sculpt Grease Pencil Strokes"},
83 {OB_MODE_PAINT_GPENCIL,
87 "Paint Grease Pencil Strokes"},
88 {OB_MODE_VERTEX_GPENCIL,
92 "Grease Pencil Vertex Paint Strokes"},
93 {OB_MODE_WEIGHT_GPENCIL,
97 "Grease Pencil Weight Paint Strokes"},
98 {0, NULL, 0, NULL, NULL},
101 /* Same as above, but with names that distinguish grease pencil. */
102 const EnumPropertyItem rna_enum_workspace_object_mode_items[] = {
103 {OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object Mode", ""},
104 {OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit Mode", ""},
105 {OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose Mode", ""},
106 {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""},
107 {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
108 {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
109 {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
110 {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""},
111 {OB_MODE_EDIT_GPENCIL,
114 "Grease Pencil Edit Mode",
115 "Edit Grease Pencil Strokes"},
116 {OB_MODE_SCULPT_GPENCIL,
119 "Grease Pencil Sculpt Mode",
120 "Sculpt Grease Pencil Strokes"},
121 {OB_MODE_PAINT_GPENCIL,
124 "Grease Pencil Draw",
125 "Paint Grease Pencil Strokes"},
126 {OB_MODE_VERTEX_GPENCIL,
129 "Grease Pencil Vertex Paint",
130 "Grease Pencil Vertex Paint Strokes"},
131 {OB_MODE_WEIGHT_GPENCIL,
134 "Grease Pencil Weight Paint",
135 "Grease Pencil Weight Paint Strokes"},
136 {0, NULL, 0, NULL, NULL},
139 const EnumPropertyItem rna_enum_object_empty_drawtype_items[] = {
140 {OB_PLAINAXES, "PLAIN_AXES", ICON_EMPTY_AXIS, "Plain Axes", ""},
141 {OB_ARROWS, "ARROWS", ICON_EMPTY_ARROWS, "Arrows", ""},
142 {OB_SINGLE_ARROW, "SINGLE_ARROW", ICON_EMPTY_SINGLE_ARROW, "Single Arrow", ""},
143 {OB_CIRCLE, "CIRCLE", ICON_MESH_CIRCLE, "Circle", ""},
144 {OB_CUBE, "CUBE", ICON_CUBE, "Cube", ""},
145 {OB_EMPTY_SPHERE, "SPHERE", ICON_SPHERE, "Sphere", ""},
146 {OB_EMPTY_CONE, "CONE", ICON_CONE, "Cone", ""},
147 {OB_EMPTY_IMAGE, "IMAGE", ICON_FILE_IMAGE, "Image", ""},
148 {0, NULL, 0, NULL, NULL},
151 static const EnumPropertyItem rna_enum_object_empty_image_depth_items[] = {
152 {OB_EMPTY_IMAGE_DEPTH_DEFAULT, "DEFAULT", 0, "Default", ""},
153 {OB_EMPTY_IMAGE_DEPTH_FRONT, "FRONT", 0, "Front", ""},
154 {OB_EMPTY_IMAGE_DEPTH_BACK, "BACK", 0, "Back", ""},
155 {0, NULL, 0, NULL, NULL},
158 const EnumPropertyItem rna_enum_object_gpencil_type_items[] = {
159 {GP_EMPTY, "EMPTY", ICON_EMPTY_AXIS, "Blank", "Create an empty grease pencil object"},
160 {GP_STROKE, "STROKE", ICON_STROKE, "Stroke", "Create a simple stroke with basic colors"},
161 {GP_MONKEY, "MONKEY", ICON_MONKEY, "Monkey", "Construct a Suzanne grease pencil object"},
162 {0, NULL, 0, NULL, NULL}};
164 static const EnumPropertyItem parent_type_items[] = {
165 {PAROBJECT, "OBJECT", 0, "Object", "The object is parented to an object"},
166 {PARSKEL, "ARMATURE", 0, "Armature", ""},
167 /* PARSKEL reuse will give issues. */
168 {PARSKEL, "LATTICE", 0, "Lattice", "The object is parented to a lattice"},
169 {PARVERT1, "VERTEX", 0, "Vertex", "The object is parented to a vertex"},
170 {PARVERT3, "VERTEX_3", 0, "3 Vertices", ""},
171 {PARBONE, "BONE", 0, "Bone", "The object is parented to a bone"},
172 {0, NULL, 0, NULL, NULL},
175 #define INSTANCE_ITEMS_SHARED \
176 {0, "NONE", 0, "None", ""}, \
177 {OB_DUPLIVERTS, "VERTS", 0, "Vertices", "Instantiate child objects on all vertices"}, \
179 OB_DUPLIFACES, "FACES", 0, "Faces", "Instantiate child objects on all faces" \
182 #define INSTANCE_ITEM_COLLECTION \
184 OB_DUPLICOLLECTION, "COLLECTION", 0, "Collection", "Enable collection instancing" \
186 static const EnumPropertyItem instance_items[] = {
187 INSTANCE_ITEMS_SHARED,
188 INSTANCE_ITEM_COLLECTION,
189 {0, NULL, 0, NULL, NULL},
192 static EnumPropertyItem instance_items_nogroup[] = {
193 INSTANCE_ITEMS_SHARED,
194 {0, NULL, 0, NULL, NULL},
197 static EnumPropertyItem instance_items_pointcloud[] = {
198 {0, "NONE", 0, "None", ""},
199 {OB_DUPLIVERTS, "POINTS", 0, "Points", "Instantiate child objects on all points"},
200 {0, NULL, 0, NULL, NULL},
203 #undef INSTANCE_ITEMS_SHARED
204 #undef INSTANCE_ITEM_COLLECTION
206 const EnumPropertyItem rna_enum_metaelem_type_items[] = {
207 {MB_BALL, "BALL", ICON_META_BALL, "Ball", ""},
208 {MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""},
209 {MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""},
210 /* NOTE: typo at original definition! */
211 {MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""},
212 {MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""},
213 {0, NULL, 0, NULL, NULL},
216 const EnumPropertyItem rna_enum_lightprobes_type_items[] = {
217 {LIGHTPROBE_TYPE_CUBE, "CUBE", ICON_LIGHTPROBE_CUBEMAP, "Cube", ""},
218 {LIGHTPROBE_TYPE_PLANAR, "PLANAR", ICON_LIGHTPROBE_PLANAR, "Planar", ""},
219 {LIGHTPROBE_TYPE_GRID, "GRID", ICON_LIGHTPROBE_GRID, "Grid", ""},
220 {0, NULL, 0, NULL, NULL},
223 /* used for 2 enums */
224 #define OBTYPE_CU_CURVE \
226 OB_CURVE, "CURVE", ICON_OUTLINER_OB_CURVE, "Curve", "" \
228 #define OBTYPE_CU_SURF \
230 OB_SURF, "SURFACE", ICON_OUTLINER_OB_SURFACE, "Surface", "" \
232 #define OBTYPE_CU_FONT \
234 OB_FONT, "FONT", ICON_OUTLINER_OB_FONT, "Text", "" \
237 const EnumPropertyItem rna_enum_object_type_items[] = {
238 {OB_MESH, "MESH", ICON_OUTLINER_OB_MESH, "Mesh", ""},
241 {OB_MBALL, "META", ICON_OUTLINER_OB_META, "Metaball", ""},
243 {OB_HAIR, "HAIR", ICON_OUTLINER_OB_HAIR, "Hair", ""},
244 {OB_POINTCLOUD, "POINTCLOUD", ICON_OUTLINER_OB_POINTCLOUD, "Point Cloud", ""},
245 {OB_VOLUME, "VOLUME", ICON_OUTLINER_OB_VOLUME, "Volume", ""},
246 {OB_GPENCIL, "GPENCIL", ICON_OUTLINER_OB_GREASEPENCIL, "Grease Pencil", ""},
247 {0, "", 0, NULL, NULL},
248 {OB_ARMATURE, "ARMATURE", ICON_OUTLINER_OB_ARMATURE, "Armature", ""},
249 {OB_LATTICE, "LATTICE", ICON_OUTLINER_OB_LATTICE, "Lattice", ""},
250 {0, "", 0, NULL, NULL},
251 {OB_EMPTY, "EMPTY", ICON_OUTLINER_OB_EMPTY, "Empty", ""},
252 {0, "", 0, NULL, NULL},
253 {OB_LAMP, "LIGHT", ICON_OUTLINER_OB_LIGHT, "Light", ""},
254 {OB_LIGHTPROBE, "LIGHT_PROBE", ICON_OUTLINER_OB_LIGHTPROBE, "Light Probe", ""},
255 {0, "", 0, NULL, NULL},
256 {OB_CAMERA, "CAMERA", ICON_OUTLINER_OB_CAMERA, "Camera", ""},
257 {0, "", 0, NULL, NULL},
258 {OB_SPEAKER, "SPEAKER", ICON_OUTLINER_OB_SPEAKER, "Speaker", ""},
259 {0, NULL, 0, NULL, NULL},
262 const EnumPropertyItem rna_enum_object_type_curve_items[] = {
266 {0, NULL, 0, NULL, NULL},
269 const EnumPropertyItem rna_enum_object_rotation_mode_items[] = {
270 {ROT_MODE_QUAT, "QUATERNION", 0, "Quaternion (WXYZ)", "No Gimbal Lock"},
271 {ROT_MODE_XYZ, "XYZ", 0, "XYZ Euler", "XYZ Rotation Order - prone to Gimbal Lock (default)"},
272 {ROT_MODE_XZY, "XZY", 0, "XZY Euler", "XZY Rotation Order - prone to Gimbal Lock"},
273 {ROT_MODE_YXZ, "YXZ", 0, "YXZ Euler", "YXZ Rotation Order - prone to Gimbal Lock"},
274 {ROT_MODE_YZX, "YZX", 0, "YZX Euler", "YZX Rotation Order - prone to Gimbal Lock"},
275 {ROT_MODE_ZXY, "ZXY", 0, "ZXY Euler", "ZXY Rotation Order - prone to Gimbal Lock"},
276 {ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order - prone to Gimbal Lock"},
281 "Axis Angle (W+XYZ), defines a rotation around some axis defined by 3D-Vector"},
282 {0, NULL, 0, NULL, NULL},
285 const EnumPropertyItem rna_enum_object_axis_items[] = {
286 {OB_POSX, "POS_X", 0, "+X", ""},
287 {OB_POSY, "POS_Y", 0, "+Y", ""},
288 {OB_POSZ, "POS_Z", 0, "+Z", ""},
289 {OB_NEGX, "NEG_X", 0, "-X", ""},
290 {OB_NEGY, "NEG_Y", 0, "-Y", ""},
291 {OB_NEGZ, "NEG_Z", 0, "-Z", ""},
292 {0, NULL, 0, NULL, NULL},
297 # include "BLI_math.h"
300 # include "DNA_constraint_types.h"
301 # include "DNA_gpencil_types.h"
302 # include "DNA_key_types.h"
303 # include "DNA_lattice_types.h"
304 # include "DNA_node_types.h"
306 # include "BKE_armature.h"
307 # include "BKE_brush.h"
308 # include "BKE_constraint.h"
309 # include "BKE_context.h"
310 # include "BKE_curve.h"
311 # include "BKE_deform.h"
312 # include "BKE_effect.h"
313 # include "BKE_global.h"
314 # include "BKE_key.h"
315 # include "BKE_material.h"
316 # include "BKE_mesh.h"
317 # include "BKE_modifier.h"
318 # include "BKE_object.h"
319 # include "BKE_particle.h"
320 # include "BKE_scene.h"
322 # include "DEG_depsgraph.h"
323 # include "DEG_depsgraph_build.h"
325 # include "ED_curve.h"
326 # include "ED_lattice.h"
327 # include "ED_object.h"
328 # include "ED_particle.h"
330 static void rna_Object_internal_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
332 DEG_id_tag_update(ptr->owner_id, ID_RECALC_TRANSFORM);
335 static void rna_Object_internal_update_draw(Main *UNUSED(bmain),
336 Scene *UNUSED(scene),
339 DEG_id_tag_update(ptr->owner_id, ID_RECALC_SHADING);
340 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->owner_id);
343 static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr)
345 /* don't use compat so we get predictable rotation */
346 BKE_object_apply_mat4((Object *)ptr->owner_id, ((Object *)ptr->owner_id)->obmat, false, true);
347 rna_Object_internal_update(bmain, scene, ptr);
350 static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
352 Object *ob = (Object *)ptr->owner_id;
353 BKE_main_collection_sync_remap(bmain);
354 DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
355 DEG_relations_tag_update(bmain);
356 WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id);
359 static void rna_Object_duplicator_visibility_flag_update(Main *UNUSED(bmain),
360 Scene *UNUSED(scene),
363 Object *ob = (Object *)ptr->owner_id;
364 DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
367 static void rna_MaterialIndex_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
369 Object *ob = (Object *)ptr->owner_id;
370 if (ob && ob->type == OB_GPENCIL) {
371 /* notifying material property in topbar */
372 WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL);
376 static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
378 Object *ob = (Object *)ptr->owner_id;
379 if (ob && ob->type == OB_GPENCIL) {
380 bGPdata *gpd = (bGPdata *)ob->data;
381 DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
382 WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
386 static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
388 Object *ob = (Object *)ptr->owner_id;
389 BKE_object_matrix_local_get(ob, (float(*)[4])values);
392 static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])
394 Object *ob = (Object *)ptr->owner_id;
395 float local_mat[4][4];
397 /* Localspace matrix is truly relative to the parent,
398 * but parameters stored in object are relative to parentinv matrix.
399 * Undo the parent inverse part before applying it as local matrix. */
402 invert_m4_m4(invmat, ob->parentinv);
403 mul_m4_m4m4(local_mat, invmat, (float(*)[4])values);
406 copy_m4_m4(local_mat, (float(*)[4])values);
409 /* Don't use compatible so we get predictable rotation, and do not use parenting either,
410 * because it's a local matrix! */
411 BKE_object_apply_mat4(ob, local_mat, false, false);
414 static void rna_Object_matrix_basis_get(PointerRNA *ptr, float values[16])
416 Object *ob = (Object *)ptr->owner_id;
417 BKE_object_to_mat4(ob, (float(*)[4])values);
420 static void rna_Object_matrix_basis_set(PointerRNA *ptr, const float values[16])
422 Object *ob = (Object *)ptr->owner_id;
423 BKE_object_apply_mat4(ob, (float(*)[4])values, false, false);
426 void rna_Object_internal_update_data_impl(PointerRNA *ptr)
428 DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY);
429 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->owner_id);
432 void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
434 rna_Object_internal_update_data_impl(ptr);
437 void rna_Object_internal_update_data_dependency(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
439 DEG_relations_tag_update(bmain);
440 rna_Object_internal_update_data_impl(ptr);
443 static void rna_Object_active_shape_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
445 Object *ob = (Object *)ptr->owner_id;
447 if (BKE_object_is_in_editmode(ob)) {
448 /* exit/enter editmode to get new shape */
452 BMEditMesh *em = me->edit_mesh;
453 int select_mode = em->selectmode;
454 EDBM_mesh_load(bmain, ob);
455 EDBM_mesh_make(ob, select_mode, true);
458 DEG_id_tag_update(&me->id, 0);
460 EDBM_mesh_normals_update(em);
461 BKE_editmesh_looptri_calc(em);
466 ED_curve_editnurb_load(bmain, ob);
467 ED_curve_editnurb_make(ob);
470 BKE_editlattice_load(ob);
471 BKE_editlattice_make(ob);
476 rna_Object_internal_update_data_impl(ptr);
479 static void rna_Object_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
481 DEG_id_tag_update(ptr->owner_id, ID_RECALC_TRANSFORM);
482 DEG_relations_tag_update(bmain);
483 WM_main_add_notifier(NC_OBJECT | ND_PARENT, ptr->owner_id);
486 void rna_Object_data_update(Main *bmain, Scene *scene, PointerRNA *ptr)
488 Object *object = (Object *)ptr->data;
490 if (object->mode == OB_MODE_SCULPT) {
491 BKE_sculpt_ensure_orig_mesh_data(scene, object);
494 rna_Object_internal_update_data_dependency(bmain, scene, ptr);
497 static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value, struct ReportList *reports)
499 Object *ob = (Object *)ptr->data;
502 if (ob->mode & OB_MODE_EDIT) {
506 /* assigning NULL only for empties */
507 if ((id == NULL) && (ob->type != OB_EMPTY)) {
511 if (id && ((id->tag & LIB_TAG_NO_MAIN) != (ob->id.tag & LIB_TAG_NO_MAIN))) {
514 "Can only assign evaluated data to evaluated object, or original data to "
519 if (ob->type == OB_EMPTY) {
521 id_us_min((ID *)ob->data);
525 if (!id || GS(id->name) == ID_IM) {
530 else if (ob->type == OB_MESH) {
531 BKE_mesh_assign_object(G_MAIN, ob, (Mesh *)id);
535 id_us_min((ID *)ob->data);
538 /* no need to type-check here ID. this is done in the _typef() function */
539 BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name)));
543 BKE_object_materials_test(G_MAIN, ob, id);
545 if (GS(id->name) == ID_CU) {
546 BKE_curve_type_test(ob);
548 else if (ob->type == OB_ARMATURE) {
549 BKE_pose_rebuild(G_MAIN, ob, ob->data, true);
554 static StructRNA *rna_Object_data_typef(PointerRNA *ptr)
556 Object *ob = (Object *)ptr->data;
558 /* keep in sync with OB_DATA_SUPPORT_ID() macro */
571 return &RNA_MetaBall;
579 return &RNA_Armature;
583 return &RNA_LightProbe;
585 return &RNA_GreasePencil;
587 # ifdef WITH_HAIR_NODES
593 # ifdef WITH_POINT_CLOUD
594 return &RNA_PointCloud;
605 static bool rna_Object_data_poll(PointerRNA *ptr, const PointerRNA value)
607 Object *ob = (Object *)ptr->data;
609 if (ob->type == OB_GPENCIL) {
610 /* GP Object - Don't allow using "Annotation" GP datablocks here */
611 bGPdata *gpd = value.data;
612 return (gpd->flag & GP_DATA_ANNOTATIONS) == 0;
618 static void rna_Object_parent_set(PointerRNA *ptr,
620 struct ReportList *UNUSED(reports))
622 Object *ob = (Object *)ptr->data;
623 Object *par = (Object *)value.data;
626 ED_object_parent(ob, par, ob->partype, ob->parsubstr);
630 static bool rna_Object_parent_override_apply(Main *UNUSED(bmain),
633 PointerRNA *ptr_storage,
634 PropertyRNA *prop_dst,
635 PropertyRNA *prop_src,
636 PropertyRNA *UNUSED(prop_storage),
639 const int len_storage,
640 PointerRNA *UNUSED(ptr_item_dst),
641 PointerRNA *UNUSED(ptr_item_src),
642 PointerRNA *UNUSED(ptr_item_storage),
643 IDOverrideLibraryPropertyOperation *opop)
645 BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0);
646 BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_REPLACE &&
647 "Unsupported RNA override operation on object parent pointer");
648 UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop);
650 /* We need a special handling here because setting parent resets invert parent matrix,
651 * which is evil in our case. */
652 Object *ob = (Object *)ptr_dst->data;
653 Object *parent_dst = RNA_property_pointer_get(ptr_dst, prop_dst).data;
654 Object *parent_src = RNA_property_pointer_get(ptr_src, prop_src).data;
656 if (parent_src == parent_dst) {
660 if (parent_src == NULL) {
661 /* The only case where we do want default behavior (with matrix reset). */
662 ED_object_parent(ob, parent_src, ob->partype, ob->parsubstr);
665 ob->parent = parent_src;
670 static void rna_Object_parent_type_set(PointerRNA *ptr, int value)
672 Object *ob = (Object *)ptr->data;
674 ED_object_parent(ob, ob->parent, value, ob->parsubstr);
677 static const EnumPropertyItem *rna_Object_parent_type_itemf(bContext *UNUSED(C),
679 PropertyRNA *UNUSED(prop),
682 Object *ob = (Object *)ptr->data;
683 EnumPropertyItem *item = NULL;
686 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PAROBJECT);
689 Object *par = ob->parent;
691 if (par->type == OB_LATTICE) {
692 /* special hack: prevents this overriding others */
693 RNA_enum_items_add_value(&item, &totitem, &parent_type_items[2], PARSKEL);
695 else if (par->type == OB_ARMATURE) {
696 /* special hack: prevents this being overridden */
697 RNA_enum_items_add_value(&item, &totitem, &parent_type_items[1], PARSKEL);
698 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARBONE);
701 if (OB_TYPE_SUPPORT_PARVERT(par->type)) {
702 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT1);
703 RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT3);
707 RNA_enum_item_end(&item, &totitem);
713 static void rna_Object_empty_display_type_set(PointerRNA *ptr, int value)
715 Object *ob = (Object *)ptr->data;
717 BKE_object_empty_draw_type_set(ob, value);
720 static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value)
722 Object *ob = (Object *)ptr->data;
724 ED_object_parent(ob, ob->parent, ob->partype, value);
727 static const EnumPropertyItem *rna_Object_instance_type_itemf(bContext *UNUSED(C),
729 PropertyRNA *UNUSED(prop),
730 bool *UNUSED(r_free))
732 Object *ob = (Object *)ptr->data;
733 const EnumPropertyItem *item;
735 if (ob->type == OB_EMPTY) {
736 item = instance_items;
738 else if (ob->type == OB_POINTCLOUD) {
739 item = instance_items_pointcloud;
742 item = instance_items_nogroup;
748 static void rna_Object_dup_collection_set(PointerRNA *ptr,
750 struct ReportList *UNUSED(reports))
752 Object *ob = (Object *)ptr->data;
753 Collection *grp = (Collection *)value.data;
755 /* Must not let this be set if the object belongs in this group already,
756 * thus causing a cycle/infinite-recursion leading to crashes on load T25298. */
757 if (BKE_collection_has_object_recursive(grp, ob) == 0) {
758 if (ob->type == OB_EMPTY) {
759 id_us_min(&ob->instance_collection->id);
760 ob->instance_collection = grp;
761 id_us_plus(&ob->instance_collection->id);
764 BKE_report(NULL, RPT_ERROR, "Only empty objects support collection instances");
770 "Cannot set instance-collection as object belongs in group being instanced, thus "
775 static void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
777 Object *ob = (Object *)ptr->owner_id;
778 bDeformGroup *dg = (bDeformGroup *)ptr->data;
779 BLI_strncpy_utf8(dg->name, value, sizeof(dg->name));
780 BKE_object_defgroup_unique_name(dg, ob);
783 static int rna_VertexGroup_index_get(PointerRNA *ptr)
785 Object *ob = (Object *)ptr->owner_id;
787 return BLI_findindex(&ob->defbase, ptr->data);
790 static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr)
792 Object *ob = (Object *)ptr->owner_id;
793 return rna_pointer_inherit_refine(
794 ptr, &RNA_VertexGroup, BLI_findlink(&ob->defbase, ob->actdef - 1));
797 static void rna_Object_active_vertex_group_set(PointerRNA *ptr,
799 struct ReportList *reports)
801 Object *ob = (Object *)ptr->owner_id;
802 int index = BLI_findindex(&ob->defbase, value.data);
806 "VertexGroup '%s' not found in object '%s'",
807 ((bDeformGroup *)value.data)->name,
812 ob->actdef = index + 1;
815 static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr)
817 Object *ob = (Object *)ptr->owner_id;
818 return ob->actdef - 1;
821 static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value)
823 Object *ob = (Object *)ptr->owner_id;
824 ob->actdef = value + 1;
827 static void rna_Object_active_vertex_group_index_range(
828 PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
830 Object *ob = (Object *)ptr->owner_id;
833 *max = max_ii(0, BLI_listbase_count(&ob->defbase) - 1);
836 void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
838 Object *ob = (Object *)ptr->owner_id;
841 dg = BLI_findlink(&ob->defbase, index - 1);
844 BLI_strncpy(value, dg->name, sizeof(dg->name));
851 int rna_object_vgroup_name_index_length(PointerRNA *ptr, int index)
853 Object *ob = (Object *)ptr->owner_id;
856 dg = BLI_findlink(&ob->defbase, index - 1);
857 return (dg) ? strlen(dg->name) : 0;
860 void rna_object_vgroup_name_index_set(PointerRNA *ptr, const char *value, short *index)
862 Object *ob = (Object *)ptr->owner_id;
863 *index = BKE_object_defgroup_name_index(ob, value) + 1;
866 void rna_object_vgroup_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
868 Object *ob = (Object *)ptr->owner_id;
869 bDeformGroup *dg = BKE_object_defgroup_find_name(ob, value);
871 /* No need for BLI_strncpy_utf8, since this matches an existing group. */
872 BLI_strncpy(result, value, maxlen);
879 static void rna_FaceMap_name_set(PointerRNA *ptr, const char *value)
881 Object *ob = (Object *)ptr->owner_id;
882 bFaceMap *fmap = (bFaceMap *)ptr->data;
883 BLI_strncpy_utf8(fmap->name, value, sizeof(fmap->name));
884 BKE_object_facemap_unique_name(ob, fmap);
887 static int rna_FaceMap_index_get(PointerRNA *ptr)
889 Object *ob = (Object *)ptr->owner_id;
891 return BLI_findindex(&ob->fmaps, ptr->data);
894 static PointerRNA rna_Object_active_face_map_get(PointerRNA *ptr)
896 Object *ob = (Object *)ptr->owner_id;
897 return rna_pointer_inherit_refine(ptr, &RNA_FaceMap, BLI_findlink(&ob->fmaps, ob->actfmap - 1));
900 static int rna_Object_active_face_map_index_get(PointerRNA *ptr)
902 Object *ob = (Object *)ptr->owner_id;
903 return ob->actfmap - 1;
906 static void rna_Object_active_face_map_index_set(PointerRNA *ptr, int value)
908 Object *ob = (Object *)ptr->owner_id;
909 ob->actfmap = value + 1;
912 static void rna_Object_active_face_map_index_range(
913 PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
915 Object *ob = (Object *)ptr->owner_id;
918 *max = max_ii(0, BLI_listbase_count(&ob->fmaps) - 1);
921 void rna_object_BKE_object_facemap_name_index_get(PointerRNA *ptr, char *value, int index)
923 Object *ob = (Object *)ptr->owner_id;
926 fmap = BLI_findlink(&ob->fmaps, index - 1);
929 BLI_strncpy(value, fmap->name, sizeof(fmap->name));
936 int rna_object_BKE_object_facemap_name_index_length(PointerRNA *ptr, int index)
938 Object *ob = (Object *)ptr->owner_id;
941 fmap = BLI_findlink(&ob->fmaps, index - 1);
942 return (fmap) ? strlen(fmap->name) : 0;
945 void rna_object_BKE_object_facemap_name_index_set(PointerRNA *ptr, const char *value, short *index)
947 Object *ob = (Object *)ptr->owner_id;
948 *index = BKE_object_facemap_name_index(ob, value) + 1;
951 void rna_object_fmap_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
953 Object *ob = (Object *)ptr->owner_id;
954 bFaceMap *fmap = BKE_object_facemap_find_name(ob, value);
956 /* No need for BLI_strncpy_utf8, since this matches an existing group. */
957 BLI_strncpy(result, value, maxlen);
964 void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
966 Object *ob = (Object *)ptr->owner_id;
968 CustomDataLayer *layer;
971 if (ob->type == OB_MESH && ob->data) {
972 me = (Mesh *)ob->data;
974 for (a = 0; a < me->ldata.totlayer; a++) {
975 layer = &me->ldata.layers[a];
977 if (layer->type == CD_MLOOPUV && STREQ(layer->name, value)) {
978 BLI_strncpy(result, value, maxlen);
987 void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
989 Object *ob = (Object *)ptr->owner_id;
991 CustomDataLayer *layer;
994 if (ob->type == OB_MESH && ob->data) {
995 me = (Mesh *)ob->data;
997 for (a = 0; a < me->fdata.totlayer; a++) {
998 layer = &me->fdata.layers[a];
1000 if (layer->type == CD_MCOL && STREQ(layer->name, value)) {
1001 BLI_strncpy(result, value, maxlen);
1010 static int rna_Object_active_material_index_get(PointerRNA *ptr)
1012 Object *ob = (Object *)ptr->owner_id;
1013 return MAX2(ob->actcol - 1, 0);
1016 static void rna_Object_active_material_index_set(PointerRNA *ptr, int value)
1018 Object *ob = (Object *)ptr->owner_id;
1019 ob->actcol = value + 1;
1021 if (ob->type == OB_MESH) {
1022 Mesh *me = ob->data;
1024 if (me->edit_mesh) {
1025 me->edit_mesh->mat_nr = value;
1030 static void rna_Object_active_material_index_range(
1031 PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
1033 Object *ob = (Object *)ptr->owner_id;
1035 *max = max_ii(ob->totcol - 1, 0);
1038 /* returns active base material */
1039 static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
1041 Object *ob = (Object *)ptr->owner_id;
1044 ma = (ob->totcol) ? BKE_object_material_get(ob, ob->actcol) : NULL;
1045 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
1048 static void rna_Object_active_material_set(PointerRNA *ptr,
1050 struct ReportList *UNUSED(reports))
1052 Object *ob = (Object *)ptr->owner_id;
1054 DEG_id_tag_update(value.data, 0);
1055 BLI_assert(BKE_id_is_in_global_main(&ob->id));
1056 BLI_assert(BKE_id_is_in_global_main(value.data));
1057 BKE_object_material_assign(G_MAIN, ob, value.data, ob->actcol, BKE_MAT_ASSIGN_EXISTING);
1059 if (ob->type == OB_GPENCIL) {
1060 /* notifying material property in topbar */
1061 WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL);
1065 static int rna_Object_active_material_editable(PointerRNA *ptr, const char **UNUSED(r_info))
1067 Object *ob = (Object *)ptr->owner_id;
1070 if ((ob->matbits == NULL) || (ob->actcol == 0) || ob->matbits[ob->actcol - 1]) {
1071 is_editable = !ID_IS_LINKED(ob);
1074 is_editable = ob->data ? !ID_IS_LINKED(ob->data) : false;
1077 return is_editable ? PROP_EDITABLE : 0;
1080 static void rna_Object_active_particle_system_index_range(
1081 PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
1083 Object *ob = (Object *)ptr->owner_id;
1085 *max = max_ii(0, BLI_listbase_count(&ob->particlesystem) - 1);
1088 static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
1090 Object *ob = (Object *)ptr->owner_id;
1091 return psys_get_current_num(ob);
1094 static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int value)
1096 Object *ob = (Object *)ptr->owner_id;
1097 psys_set_current_num(ob, value);
1100 static void rna_Object_particle_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
1102 /* TODO: Disabled for now, because bContext is not available. */
1104 Object *ob = (Object *)ptr->owner_id;
1105 PE_current_changed(NULL, scene, ob);
1112 /* rotation - axis-angle */
1113 static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value)
1115 Object *ob = ptr->data;
1117 /* for now, assume that rotation mode is axis-angle */
1118 value[0] = ob->rotAngle;
1119 copy_v3_v3(&value[1], ob->rotAxis);
1122 /* rotation - axis-angle */
1123 static void rna_Object_rotation_axis_angle_set(PointerRNA *ptr, const float *value)
1125 Object *ob = ptr->data;
1127 /* for now, assume that rotation mode is axis-angle */
1128 ob->rotAngle = value[0];
1129 copy_v3_v3(ob->rotAxis, &value[1]);
1131 /* TODO: validate axis? */
1134 static void rna_Object_rotation_mode_set(PointerRNA *ptr, int value)
1136 Object *ob = ptr->data;
1138 /* use API Method for conversions... */
1139 BKE_rotMode_change_values(
1140 ob->quat, ob->rot, ob->rotAxis, &ob->rotAngle, ob->rotmode, (short)value);
1142 /* finally, set the new rotation type */
1143 ob->rotmode = value;
1146 static void rna_Object_dimensions_get(PointerRNA *ptr, float *value)
1148 Object *ob = ptr->data;
1149 BKE_object_dimensions_get(ob, value);
1152 static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value)
1154 Object *ob = ptr->data;
1155 BKE_object_dimensions_set(ob, value, 0);
1158 static int rna_Object_location_editable(PointerRNA *ptr, int index)
1160 Object *ob = (Object *)ptr->data;
1162 /* only if the axis in question is locked, not editable... */
1163 if ((index == 0) && (ob->protectflag & OB_LOCK_LOCX)) {
1166 else if ((index == 1) && (ob->protectflag & OB_LOCK_LOCY)) {
1169 else if ((index == 2) && (ob->protectflag & OB_LOCK_LOCZ)) {
1173 return PROP_EDITABLE;
1177 static int rna_Object_scale_editable(PointerRNA *ptr, int index)
1179 Object *ob = (Object *)ptr->data;
1181 /* only if the axis in question is locked, not editable... */
1182 if ((index == 0) && (ob->protectflag & OB_LOCK_SCALEX)) {
1185 else if ((index == 1) && (ob->protectflag & OB_LOCK_SCALEY)) {
1188 else if ((index == 2) && (ob->protectflag & OB_LOCK_SCALEZ)) {
1192 return PROP_EDITABLE;
1196 static int rna_Object_rotation_euler_editable(PointerRNA *ptr, int index)
1198 Object *ob = (Object *)ptr->data;
1200 /* only if the axis in question is locked, not editable... */
1201 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTX)) {
1204 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTY)) {
1207 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTZ)) {
1211 return PROP_EDITABLE;
1215 static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index)
1217 Object *ob = (Object *)ptr->data;
1219 /* only consider locks if locking components individually... */
1220 if (ob->protectflag & OB_LOCK_ROT4D) {
1221 /* only if the axis in question is locked, not editable... */
1222 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTW)) {
1225 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTX)) {
1228 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTY)) {
1231 else if ((index == 3) && (ob->protectflag & OB_LOCK_ROTZ)) {
1236 return PROP_EDITABLE;
1239 static int rna_MaterialSlot_material_editable(PointerRNA *ptr, const char **UNUSED(r_info))
1241 Object *ob = (Object *)ptr->owner_id;
1242 const int index = (Material **)ptr->data - ob->mat;
1245 if ((ob->matbits == NULL) || ob->matbits[index]) {
1246 is_editable = !ID_IS_LINKED(ob);
1249 is_editable = ob->data ? !ID_IS_LINKED(ob->data) : false;
1252 return is_editable ? PROP_EDITABLE : 0;
1255 static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr)
1257 Object *ob = (Object *)ptr->owner_id;
1259 const int index = (Material **)ptr->data - ob->mat;
1261 ma = BKE_object_material_get(ob, index + 1);
1262 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
1265 static void rna_MaterialSlot_material_set(PointerRNA *ptr,
1267 struct ReportList *UNUSED(reports))
1269 Object *ob = (Object *)ptr->owner_id;
1270 int index = (Material **)ptr->data - ob->mat;
1272 BLI_assert(BKE_id_is_in_global_main(&ob->id));
1273 BLI_assert(BKE_id_is_in_global_main(value.data));
1274 BKE_object_material_assign(G_MAIN, ob, value.data, index + 1, BKE_MAT_ASSIGN_EXISTING);
1277 static bool rna_MaterialSlot_material_poll(PointerRNA *ptr, PointerRNA value)
1279 Object *ob = (Object *)ptr->owner_id;
1280 Material *ma = (Material *)value.data;
1282 if (ob->type == OB_GPENCIL) {
1283 /* GP Materials only */
1284 return (ma->gp_style != NULL);
1287 /* Everything except GP materials */
1288 return (ma->gp_style == NULL);
1292 static int rna_MaterialSlot_link_get(PointerRNA *ptr)
1294 Object *ob = (Object *)ptr->owner_id;
1295 int index = (Material **)ptr->data - ob->mat;
1297 return ob->matbits[index] != 0;
1300 static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value)
1302 Object *ob = (Object *)ptr->owner_id;
1303 int index = (Material **)ptr->data - ob->mat;
1306 ob->matbits[index] = 1;
1307 /* ob->colbits |= (1 << index); */ /* DEPRECATED */
1310 ob->matbits[index] = 0;
1311 /* ob->colbits &= ~(1 << index); */ /* DEPRECATED */
1315 static int rna_MaterialSlot_name_length(PointerRNA *ptr)
1317 Object *ob = (Object *)ptr->owner_id;
1319 int index = (Material **)ptr->data - ob->mat;
1321 ma = BKE_object_material_get(ob, index + 1);
1324 return strlen(ma->id.name + 2);
1330 static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str)
1332 Object *ob = (Object *)ptr->owner_id;
1334 int index = (Material **)ptr->data - ob->mat;
1336 ma = BKE_object_material_get(ob, index + 1);
1339 strcpy(str, ma->id.name + 2);
1346 static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr)
1348 rna_Object_internal_update(bmain, scene, ptr);
1350 WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, ptr->owner_id);
1351 WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, NULL);
1352 DEG_relations_tag_update(bmain);
1355 static char *rna_MaterialSlot_path(PointerRNA *ptr)
1357 Object *ob = (Object *)ptr->owner_id;
1358 int index = (Material **)ptr->data - ob->mat;
1360 return BLI_sprintfN("material_slots[%d]", index);
1363 static PointerRNA rna_Object_display_get(PointerRNA *ptr)
1365 return rna_pointer_inherit_refine(ptr, &RNA_ObjectDisplay, ptr->data);
1368 static char *rna_ObjectDisplay_path(PointerRNA *UNUSED(ptr))
1370 return BLI_strdup("display");
1373 static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr)
1375 Object *ob = (Object *)ptr->owner_id;
1376 ParticleSystem *psys = psys_get_current(ob);
1377 return rna_pointer_inherit_refine(ptr, &RNA_ParticleSystem, psys);
1380 static void rna_Object_active_shape_key_index_range(
1381 PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
1383 Object *ob = (Object *)ptr->owner_id;
1384 Key *key = BKE_key_from_object(ob);
1388 *max = BLI_listbase_count(&key->block) - 1;
1398 static int rna_Object_active_shape_key_index_get(PointerRNA *ptr)
1400 Object *ob = (Object *)ptr->owner_id;
1402 return MAX2(ob->shapenr - 1, 0);
1405 static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value)
1407 Object *ob = (Object *)ptr->owner_id;
1409 ob->shapenr = value + 1;
1412 static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr)
1414 Object *ob = (Object *)ptr->owner_id;
1415 Key *key = BKE_key_from_object(ob);
1420 return PointerRNA_NULL;
1423 kb = BLI_findlink(&key->block, ob->shapenr - 1);
1424 RNA_pointer_create((ID *)key, &RNA_ShapeKey, kb, &keyptr);
1428 static PointerRNA rna_Object_field_get(PointerRNA *ptr)
1430 Object *ob = (Object *)ptr->owner_id;
1434 ob->pd = BKE_partdeflect_new(0);
1437 return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, ob->pd);
1440 static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
1442 Object *ob = (Object *)ptr->owner_id;
1444 if (ob->type != OB_MESH) {
1445 return PointerRNA_NULL;
1450 ob->pd = BKE_partdeflect_new(0);
1453 return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd);
1456 static PointerRNA rna_Object_active_constraint_get(PointerRNA *ptr)
1458 Object *ob = (Object *)ptr->owner_id;
1459 bConstraint *con = BKE_constraints_active_get(&ob->constraints);
1460 return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con);
1463 static void rna_Object_active_constraint_set(PointerRNA *ptr,
1465 struct ReportList *UNUSED(reports))
1467 Object *ob = (Object *)ptr->owner_id;
1468 BKE_constraints_active_set(&ob->constraints, (bConstraint *)value.data);
1471 static bConstraint *rna_Object_constraints_new(Object *object, Main *bmain, int type)
1473 bConstraint *new_con = BKE_constraint_add_for_object(object, NULL, type);
1475 ED_object_constraint_tag_update(bmain, object, new_con);
1476 WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, object);
1481 static void rna_Object_constraints_remove(Object *object,
1483 ReportList *reports,
1484 PointerRNA *con_ptr)
1486 bConstraint *con = con_ptr->data;
1487 if (BLI_findindex(&object->constraints, con) == -1) {
1488 BKE_reportf(reports,
1490 "Constraint '%s' not found in object '%s'",
1492 object->id.name + 2);
1496 BKE_constraint_remove(&object->constraints, con);
1497 RNA_POINTER_INVALIDATE(con_ptr);
1499 ED_object_constraint_update(bmain, object);
1500 ED_object_constraint_active_set(object, NULL);
1501 WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
1504 static void rna_Object_constraints_clear(Object *object, Main *bmain)
1506 BKE_constraints_free(&object->constraints);
1508 ED_object_constraint_update(bmain, object);
1509 ED_object_constraint_active_set(object, NULL);
1511 WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
1514 static void rna_Object_constraints_move(
1515 Object *object, Main *bmain, ReportList *reports, int from, int to)
1521 if (!BLI_listbase_move_index(&object->constraints, from, to)) {
1522 BKE_reportf(reports, RPT_ERROR, "Could not move constraint from index '%d' to '%d'", from, to);
1526 ED_object_constraint_tag_update(bmain, object, NULL);
1527 WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT, object);
1530 static bConstraint *rna_Object_constraints_copy(Object *object, Main *bmain, PointerRNA *con_ptr)
1532 bConstraint *con = con_ptr->data;
1533 bConstraint *new_con = BKE_constraint_copy_for_object(object, con);
1535 ED_object_constraint_tag_update(bmain, object, new_con);
1536 WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, object);
1541 bool rna_Object_constraints_override_apply(Main *UNUSED(bmain),
1542 PointerRNA *ptr_dst,
1543 PointerRNA *ptr_src,
1544 PointerRNA *UNUSED(ptr_storage),
1545 PropertyRNA *UNUSED(prop_dst),
1546 PropertyRNA *UNUSED(prop_src),
1547 PropertyRNA *UNUSED(prop_storage),
1548 const int UNUSED(len_dst),
1549 const int UNUSED(len_src),
1550 const int UNUSED(len_storage),
1551 PointerRNA *UNUSED(ptr_item_dst),
1552 PointerRNA *UNUSED(ptr_item_src),
1553 PointerRNA *UNUSED(ptr_item_storage),
1554 IDOverrideLibraryPropertyOperation *opop)
1556 BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_INSERT_AFTER &&
1557 "Unsupported RNA override operation on constraints collection");
1559 Object *ob_dst = (Object *)ptr_dst->owner_id;
1560 Object *ob_src = (Object *)ptr_src->owner_id;
1562 /* Remember that insertion operations are defined and stored in correct order, which means that
1563 * even if we insert several items in a row, we always insert first one, then second one, etc.
1564 * So we should always find 'anchor' constraint in both _src *and* _dst. */
1565 bConstraint *con_anchor = NULL;
1566 if (opop->subitem_local_name && opop->subitem_local_name[0]) {
1567 con_anchor = BLI_findstring(
1568 &ob_dst->constraints, opop->subitem_local_name, offsetof(bConstraint, name));
1570 if (con_anchor == NULL && opop->subitem_local_index >= 0) {
1571 con_anchor = BLI_findlink(&ob_dst->constraints, opop->subitem_local_index);
1573 /* Otherwise we just insert in first position. */
1575 bConstraint *con_src = NULL;
1576 if (opop->subitem_local_name && opop->subitem_local_name[0]) {
1577 con_src = BLI_findstring(
1578 &ob_src->constraints, opop->subitem_local_name, offsetof(bConstraint, name));
1580 if (con_src == NULL && opop->subitem_local_index >= 0) {
1581 con_src = BLI_findlink(&ob_src->constraints, opop->subitem_local_index);
1583 con_src = con_src ? con_src->next : ob_src->constraints.first;
1585 BLI_assert(con_src != NULL);
1587 bConstraint *con_dst = BKE_constraint_duplicate_ex(con_src, 0, true);
1589 /* This handles NULL anchor as expected by adding at head of list. */
1590 BLI_insertlinkafter(&ob_dst->constraints, con_anchor, con_dst);
1592 /* This should actually *not* be needed in typical cases.
1593 * However, if overridden source was edited, we *may* have some new conflicting names. */
1594 BKE_constraint_unique_name(con_dst, &ob_dst->constraints);
1596 // printf("%s: We inserted a constraint...\n", __func__);
1600 static ModifierData *rna_Object_modifier_new(
1601 Object *object, bContext *C, ReportList *reports, const char *name, int type)
1603 return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
1606 static void rna_Object_modifier_remove(Object *object,
1608 ReportList *reports,
1611 ModifierData *md = md_ptr->data;
1612 if (ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md) ==
1614 /* error is already set */
1618 RNA_POINTER_INVALIDATE(md_ptr);
1620 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1623 static void rna_Object_modifier_clear(Object *object, bContext *C)
1625 ED_object_modifier_clear(CTX_data_main(C), CTX_data_scene(C), object);
1627 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1630 static PointerRNA rna_Object_active_modifier_get(PointerRNA *ptr)
1632 Object *ob = (Object *)ptr->owner_id;
1633 ModifierData *md = BKE_object_active_modifier(ob);
1634 return rna_pointer_inherit_refine(ptr, &RNA_Modifier, md);
1637 static void rna_Object_active_modifier_set(PointerRNA *ptr, PointerRNA value, ReportList *reports)
1639 Object *ob = (Object *)ptr->owner_id;
1640 ModifierData *md = value.data;
1642 if (RNA_pointer_is_null(&value)) {
1643 BKE_object_modifier_set_active(ob, NULL);
1647 if (BLI_findindex(&ob->modifiers, md) == -1) {
1649 reports, RPT_ERROR, "Modifier \"%s\" is not in the object's modifier list", md->name);
1653 BKE_object_modifier_set_active(ob, md);
1656 bool rna_Object_modifiers_override_apply(Main *bmain,
1657 PointerRNA *ptr_dst,
1658 PointerRNA *ptr_src,
1659 PointerRNA *UNUSED(ptr_storage),
1660 PropertyRNA *UNUSED(prop_dst),
1661 PropertyRNA *UNUSED(prop_src),
1662 PropertyRNA *UNUSED(prop_storage),
1663 const int UNUSED(len_dst),
1664 const int UNUSED(len_src),
1665 const int UNUSED(len_storage),
1666 PointerRNA *UNUSED(ptr_item_dst),
1667 PointerRNA *UNUSED(ptr_item_src),
1668 PointerRNA *UNUSED(ptr_item_storage),
1669 IDOverrideLibraryPropertyOperation *opop)
1671 BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_INSERT_AFTER &&
1672 "Unsupported RNA override operation on modifiers collection");
1674 Object *ob_dst = (Object *)ptr_dst->owner_id;
1675 Object *ob_src = (Object *)ptr_src->owner_id;
1677 /* Remember that insertion operations are defined and stored in correct order, which means that
1678 * even if we insert several items in a row, we always insert first one, then second one, etc.
1679 * So we should always find 'anchor' modifier in both _src *and* _dst. */
1680 ModifierData *mod_anchor = NULL;
1681 if (opop->subitem_local_name && opop->subitem_local_name[0]) {
1682 mod_anchor = BLI_findstring(
1683 &ob_dst->modifiers, opop->subitem_local_name, offsetof(ModifierData, name));
1685 if (mod_anchor == NULL && opop->subitem_local_index >= 0) {
1686 mod_anchor = BLI_findlink(&ob_dst->modifiers, opop->subitem_local_index);
1688 /* Otherwise we just insert in first position. */
1690 ModifierData *mod_src = NULL;
1691 if (opop->subitem_local_name && opop->subitem_local_name[0]) {
1692 mod_src = BLI_findstring(
1693 &ob_src->modifiers, opop->subitem_local_name, offsetof(ModifierData, name));
1695 if (mod_src == NULL && opop->subitem_local_index >= 0) {
1696 mod_src = BLI_findlink(&ob_src->modifiers, opop->subitem_local_index);
1698 mod_src = mod_src ? mod_src->next : ob_src->modifiers.first;
1700 if (mod_src == NULL) {
1701 BLI_assert(mod_src != NULL);
1705 /* While it would be nicer to use lower-level BKE_modifier_new() here, this one is lacking
1706 * special-cases handling (particles and other physics modifiers mostly), so using the ED version
1707 * instead, to avoid duplicating code. */
1708 ModifierData *mod_dst = ED_object_modifier_add(
1709 NULL, bmain, NULL, ob_dst, mod_src->name, mod_src->type);
1711 /* XXX Current handling of 'copy' from particle-system modifier is *very* bad (it keeps same psys
1712 * pointer as source, then calling code copies psys of object separately and do some magic
1713 * remapping of pointers...), unfortunately several pieces of code in Object editing area rely on
1714 * this behavior. So for now, hacking around it to get it doing what we want it to do, as getting
1715 * a proper behavior would be everything but trivial, and this whole particle thingy is
1717 ParticleSystem *psys_dst = (mod_dst->type == eModifierType_ParticleSystem) ?
1718 ((ParticleSystemModifierData *)mod_dst)->psys :
1720 BKE_modifier_copydata(mod_src, mod_dst);
1721 if (mod_dst->type == eModifierType_ParticleSystem) {
1722 psys_dst->flag &= ~PSYS_DELETE;
1723 ((ParticleSystemModifierData *)mod_dst)->psys = psys_dst;
1726 BLI_remlink(&ob_dst->modifiers, mod_dst);
1727 /* This handles NULL anchor as expected by adding at head of list. */
1728 BLI_insertlinkafter(&ob_dst->modifiers, mod_anchor, mod_dst);
1730 // printf("%s: We inserted a modifier '%s'...\n", __func__, mod_dst->name);
1734 static GpencilModifierData *rna_Object_greasepencil_modifier_new(
1735 Object *object, bContext *C, ReportList *reports, const char *name, int type)
1737 return ED_object_gpencil_modifier_add(
1738 reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
1741 static void rna_Object_greasepencil_modifier_remove(Object *object,
1743 ReportList *reports,
1744 PointerRNA *gmd_ptr)
1746 GpencilModifierData *gmd = gmd_ptr->data;
1747 if (ED_object_gpencil_modifier_remove(reports, CTX_data_main(C), object, gmd) == false) {
1748 /* error is already set */
1752 RNA_POINTER_INVALIDATE(gmd_ptr);
1754 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1757 static void rna_Object_greasepencil_modifier_clear(Object *object, bContext *C)
1759 ED_object_gpencil_modifier_clear(CTX_data_main(C), object);
1760 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1763 bool rna_Object_greasepencil_modifiers_override_apply(Main *bmain,
1764 PointerRNA *ptr_dst,
1765 PointerRNA *ptr_src,
1766 PointerRNA *UNUSED(ptr_storage),
1767 PropertyRNA *UNUSED(prop_dst),
1768 PropertyRNA *UNUSED(prop_src),
1769 PropertyRNA *UNUSED(prop_storage),
1770 const int UNUSED(len_dst),
1771 const int UNUSED(len_src),
1772 const int UNUSED(len_storage),
1773 PointerRNA *UNUSED(ptr_item_dst),
1774 PointerRNA *UNUSED(ptr_item_src),
1775 PointerRNA *UNUSED(ptr_item_storage),
1776 IDOverrideLibraryPropertyOperation *opop)
1778 BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_INSERT_AFTER &&
1779 "Unsupported RNA override operation on modifiers collection");
1781 Object *ob_dst = (Object *)ptr_dst->owner_id;
1782 Object *ob_src = (Object *)ptr_src->owner_id;
1784 /* Remember that insertion operations are defined and stored in correct order, which means that
1785 * even if we insert several items in a row, we always insert first one, then second one, etc.
1786 * So we should always find 'anchor' modifier in both _src *and* _dst. */
1787 GpencilModifierData *mod_anchor = NULL;
1788 if (opop->subitem_local_name && opop->subitem_local_name[0]) {
1789 mod_anchor = BLI_findstring(
1790 &ob_dst->greasepencil_modifiers, opop->subitem_local_name, offsetof(ModifierData, name));
1792 if (mod_anchor == NULL && opop->subitem_local_index >= 0) {
1793 mod_anchor = BLI_findlink(&ob_dst->greasepencil_modifiers, opop->subitem_local_index);
1795 /* Otherwise we just insert in first position. */
1797 GpencilModifierData *mod_src = NULL;
1798 if (opop->subitem_local_name && opop->subitem_local_name[0]) {
1799 mod_src = BLI_findstring(
1800 &ob_src->greasepencil_modifiers, opop->subitem_local_name, offsetof(ModifierData, name));
1802 if (mod_src == NULL && opop->subitem_local_index >= 0) {
1803 mod_src = BLI_findlink(&ob_src->greasepencil_modifiers, opop->subitem_local_index);
1805 mod_src = mod_src ? mod_src->next : ob_src->greasepencil_modifiers.first;
1807 if (mod_src == NULL) {
1808 BLI_assert(mod_src != NULL);
1812 /* While it would be nicer to use lower-level BKE_modifier_new() here, this one is lacking
1813 * special-cases handling (particles and other physics modifiers mostly), so using the ED version
1814 * instead, to avoid duplicating code. */
1815 GpencilModifierData *mod_dst = ED_object_gpencil_modifier_add(
1816 NULL, bmain, NULL, ob_dst, mod_src->name, mod_src->type);
1818 BLI_remlink(&ob_dst->modifiers, mod_dst);
1819 /* This handles NULL anchor as expected by adding at head of list. */
1820 BLI_insertlinkafter(&ob_dst->greasepencil_modifiers, mod_anchor, mod_dst);
1822 // printf("%s: We inserted a gpencil modifier '%s'...\n", __func__, mod_dst->name);
1827 static ShaderFxData *rna_Object_shaderfx_new(
1828 Object *object, bContext *C, ReportList *reports, const char *name, int type)
1830 return ED_object_shaderfx_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
1833 static void rna_Object_shaderfx_remove(Object *object,
1835 ReportList *reports,
1836 PointerRNA *gmd_ptr)
1838 ShaderFxData *gmd = gmd_ptr->data;
1839 if (ED_object_shaderfx_remove(reports, CTX_data_main(C), object, gmd) == false) {
1840 /* error is already set */
1844 RNA_POINTER_INVALIDATE(gmd_ptr);
1846 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1849 static void rna_Object_shaderfx_clear(Object *object, bContext *C)
1851 ED_object_shaderfx_clear(CTX_data_main(C), object);
1852 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
1855 static void rna_Object_boundbox_get(PointerRNA *ptr, float *values)
1857 Object *ob = (Object *)ptr->owner_id;
1858 BoundBox *bb = BKE_object_boundbox_get(ob);
1860 memcpy(values, bb->vec, sizeof(bb->vec));
1863 copy_vn_fl(values, sizeof(bb->vec) / sizeof(float), 0.0f);
1867 static bDeformGroup *rna_Object_vgroup_new(Object *ob,
1869 ReportList *reports,
1872 if (!OB_TYPE_SUPPORT_VGROUP(ob->type)) {
1873 const char *ob_type_name = "Unknown";
1874 RNA_enum_name_from_value(rna_enum_object_type_items, ob->type, &ob_type_name);
1876 reports, RPT_ERROR, "VertexGroups.new(): is not supported for '%s' objects", ob_type_name);
1880 bDeformGroup *defgroup = BKE_object_defgroup_add_name(ob, name);
1882 DEG_relations_tag_update(bmain);
1883 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1888 static void rna_Object_vgroup_remove(Object *ob,
1890 ReportList *reports,
1891 PointerRNA *defgroup_ptr)
1893 bDeformGroup *defgroup = defgroup_ptr->data;
1894 if (BLI_findindex(&ob->defbase, defgroup) == -1) {
1895 BKE_reportf(reports,
1897 "DeformGroup '%s' not in object '%s'",
1903 BKE_object_defgroup_remove(ob, defgroup);
1904 RNA_POINTER_INVALIDATE(defgroup_ptr);
1906 DEG_relations_tag_update(bmain);
1907 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1910 static void rna_Object_vgroup_clear(Object *ob, Main *bmain)
1912 BKE_object_defgroup_remove_all(ob);
1914 DEG_relations_tag_update(bmain);
1915 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1918 static void rna_VertexGroup_vertex_add(ID *id,
1920 ReportList *reports,
1926 Object *ob = (Object *)id;
1928 if (BKE_object_is_in_editmode_vgroup(ob)) {
1930 reports, RPT_ERROR, "VertexGroup.add(): cannot be called while object is in edit mode");
1934 while (index_len--) {
1936 ob, def, *index++, weight, assignmode); /* XXX, not efficient calling within loop*/
1939 DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
1940 WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
1943 static void rna_VertexGroup_vertex_remove(
1944 ID *id, bDeformGroup *dg, ReportList *reports, int index_len, int *index)
1946 Object *ob = (Object *)id;
1948 if (BKE_object_is_in_editmode_vgroup(ob)) {
1950 reports, RPT_ERROR, "VertexGroup.remove(): cannot be called while object is in edit mode");
1954 while (index_len--) {
1955 ED_vgroup_vert_remove(ob, dg, *index++);
1958 DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
1959 WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
1962 static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *reports, int index)
1964 float weight = ED_vgroup_vert_weight((Object *)id, dg, index);
1967 BKE_report(reports, RPT_ERROR, "Vertex not in group");
1972 static bFaceMap *rna_Object_fmap_new(Object *ob, const char *name)
1974 bFaceMap *fmap = BKE_object_facemap_add_name(ob, name);
1976 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1981 static void rna_Object_fmap_remove(Object *ob, ReportList *reports, PointerRNA *fmap_ptr)
1983 bFaceMap *fmap = fmap_ptr->data;
1984 if (BLI_findindex(&ob->fmaps, fmap) == -1) {
1986 reports, RPT_ERROR, "Face map '%s' not in object '%s'", fmap->name, ob->id.name + 2);
1990 BKE_object_facemap_remove(ob, fmap);
1991 RNA_POINTER_INVALIDATE(fmap_ptr);
1993 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
1996 static void rna_Object_fmap_clear(Object *ob)
1998 BKE_object_facemap_clear(ob);
2000 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
2003 static void rna_FaceMap_face_add(
2004 ID *id, bFaceMap *fmap, ReportList *reports, int index_len, int *index)
2006 Object *ob = (Object *)id;
2008 if (BKE_object_is_in_editmode(ob)) {
2009 BKE_report(reports, RPT_ERROR, "FaceMap.add(): cannot be called while object is in edit mode");
2013 while (index_len--) {
2014 ED_object_facemap_face_add(ob, fmap, *index++);
2017 WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
2020 static void rna_FaceMap_face_remove(
2021 ID *id, bFaceMap *fmap, ReportList *reports, int index_len, int *index)
2023 Object *ob = (Object *)id;
2025 if (BKE_object_is_in_editmode(ob)) {
2026 BKE_report(reports, RPT_ERROR, "FaceMap.add(): cannot be called while object is in edit mode");
2030 while (index_len--) {
2031 ED_object_facemap_face_remove(ob, fmap, *index++);
2034 WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
2037 /* generic poll functions */
2038 bool rna_Lattice_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
2040 return ((Object *)value.owner_id)->type == OB_LATTICE;
2043 bool rna_Curve_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
2045 return ((Object *)value.owner_id)->type == OB_CURVE;
2048 bool rna_Armature_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
2050 return ((Object *)value.owner_id)->type == OB_ARMATURE;
2053 bool rna_Mesh_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
2055 return ((Object *)value.owner_id)->type == OB_MESH;
2058 bool rna_Camera_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
2060 return ((Object *)value.owner_id)->type == OB_CAMERA;
2063 bool rna_Light_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
2065 return ((Object *)value.owner_id)->type == OB_LAMP;
2068 bool rna_GPencil_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
2070 return ((Object *)value.owner_id)->type == OB_GPENCIL;
2073 int rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr)
2075 SculptSession *ss = ((Object *)ptr->owner_id)->sculpt;
2076 return (ss && ss->bm);
2081 static void rna_def_vertex_group(BlenderRNA *brna)
2088 static const EnumPropertyItem assign_mode_items[] = {
2089 {WEIGHT_REPLACE, "REPLACE", 0, "Replace", "Replace"},
2090 {WEIGHT_ADD, "ADD", 0, "Add", "Add"},
2091 {WEIGHT_SUBTRACT, "SUBTRACT", 0, "Subtract", "Subtract"},
2092 {0, NULL, 0, NULL, NULL},
2095 srna = RNA_def_struct(brna, "VertexGroup", NULL);
2096 RNA_def_struct_sdna(srna, "bDeformGroup");
2097 RNA_def_struct_ui_text(
2098 srna, "Vertex Group", "Group of vertices, used for armature deform and other purposes");
2099 RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX);
2101 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2102 RNA_def_property_ui_text(prop, "Name", "Vertex group name");
2103 RNA_def_struct_name_property(srna, prop);
2104 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_VertexGroup_name_set");
2105 /* update data because modifiers may use T24761. */
2106 RNA_def_property_update(
2107 prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data_dependency");
2109 prop = RNA_def_property(srna, "lock_weight", PROP_BOOLEAN, PROP_NONE);
2110 RNA_def_property_ui_text(prop, "", "Maintain the relative weights for the group");
2111 RNA_def_property_boolean_sdna(prop, NULL, "flag", 0);
2112 /* update data because modifiers may use T24761. */
2113 RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
2115 prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
2116 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2117 RNA_def_property_int_funcs(prop, "rna_VertexGroup_index_get", NULL, NULL);
2118 RNA_def_property_ui_text(prop, "Index", "Index number of the vertex group");
2120 func = RNA_def_function(srna, "add", "rna_VertexGroup_vertex_add");
2121 RNA_def_function_ui_description(func, "Add vertices to the group");
2122 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
2123 /* TODO, see how array size of 0 works, this shouldnt be used */
2124 parm = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
2125 RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_REQUIRED);
2126 parm = RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight", 0.0f, 1.0f);
2127 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2128 parm = RNA_def_enum(func, "type", assign_mode_items, 0, "", "Vertex assign mode");
2129 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2131 func = RNA_def_function(srna, "remove", "rna_VertexGroup_vertex_remove");
2132 RNA_def_function_ui_description(func, "Remove a vertex from the group");
2133 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
2134 /* TODO, see how array size of 0 works, this shouldnt be used */
2135 parm = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
2136 RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_REQUIRED);
2138 func = RNA_def_function(srna, "weight", "rna_VertexGroup_weight");
2139 RNA_def_function_ui_description(func, "Get a vertex weight from the group");
2140 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
2141 parm = RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "The index of the vertex", 0, INT_MAX);
2142 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2143 parm = RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight", 0.0f, 1.0f);
2144 RNA_def_function_return(func, parm);
2147 static void rna_def_face_map(BlenderRNA *brna)
2155 srna = RNA_def_struct(brna, "FaceMap", NULL);
2156 RNA_def_struct_sdna(srna, "bFaceMap");
2157 RNA_def_struct_ui_text(
2158 srna, "Face Map", "Group of faces, each face can only be part of one map");
2159 RNA_def_struct_ui_icon(srna, ICON_MOD_TRIANGULATE);
2161 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2162 RNA_def_property_ui_text(prop, "Name", "Face map name");
2163 RNA_def_struct_name_property(srna, prop);
2164 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_FaceMap_name_set");
2165 /* update data because modifiers may use T24761. */
2166 RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
2168 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2169 RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
2170 RNA_def_property_ui_text(prop, "Select", "Face map selection state (for tools to use)");
2171 /* important not to use a notifier here, creates a feedback loop! */
2173 prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
2174 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2175 RNA_def_property_int_funcs(prop, "rna_FaceMap_index_get", NULL, NULL);
2176 RNA_def_property_ui_text(prop, "Index", "Index number of the face map");
2178 func = RNA_def_function(srna, "add", "rna_FaceMap_face_add");
2179 RNA_def_function_ui_description(func, "Add vertices to the group");
2180 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
2181 /* TODO, see how array size of 0 works, this shouldnt be used */
2182 parm = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
2183 RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_REQUIRED);
2185 func = RNA_def_function(srna, "remove", "rna_FaceMap_face_remove");
2186 RNA_def_function_ui_description(func, "Remove a vertex from the group");
2187 RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
2188 /* TODO, see how array size of 0 works, this shouldnt be used */
2189 parm = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
2190 RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_REQUIRED);
2193 static void rna_def_material_slot(BlenderRNA *brna)
2198 static const EnumPropertyItem link_items[] = {
2199 {1, "OBJECT", 0, "Object", ""},
2200 {0, "DATA", 0, "Data", ""},
2201 {0, NULL, 0, NULL, NULL},
2204 /* NOTE: there is no MaterialSlot equivalent in DNA, so the internal
2205 * pointer data points to ob->mat + index, and we manually implement
2206 * get/set for the properties. */
2208 srna = RNA_def_struct(brna, "MaterialSlot", NULL);
2209 RNA_def_struct_ui_text(srna, "Material Slot", "Material slot in an object");
2210 RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
2212 RNA_define_lib_overridable(true);
2214 /* WARNING! Order is crucial for override to work properly here... :/
2215 * 'link' must come before material pointer,
2216 * since it defines where (in object or obdata) that one is set! */
2217 prop = RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE);
2218 RNA_def_property_enum_items(prop, link_items);
2219 RNA_def_property_enum_funcs(
2220 prop, "rna_MaterialSlot_link_get", "rna_MaterialSlot_link_set", NULL);
2221 RNA_def_property_ui_text(prop, "Link", "Link material to object or the object's data");
2222 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
2224 prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
2225 RNA_def_property_struct_type(prop, "Material");
2226 RNA_def_property_flag(prop, PROP_EDITABLE);
2227 RNA_def_property_editable_func(prop, "rna_MaterialSlot_material_editable");
2228 RNA_def_property_pointer_funcs(prop,
2229 "rna_MaterialSlot_material_get",
2230 "rna_MaterialSlot_material_set",
2232 "rna_MaterialSlot_material_poll");
2233 RNA_def_property_ui_text(prop, "Material", "Material data-block used by this material slot");
2234 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
2236 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2237 RNA_def_property_string_funcs(
2238 prop, "rna_MaterialSlot_name_get", "rna_MaterialSlot_name_length", NULL);
2239 RNA_def_property_ui_text(prop, "Name", "Material slot name");
2240 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2241 RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE);
2242 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
2243 RNA_def_struct_name_property(srna, prop);
2245 RNA_define_lib_overridable(false);
2247 RNA_def_struct_path_func(srna, "rna_MaterialSlot_path");
2250 static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
2258 RNA_def_property_srna(cprop, "ObjectConstraints");
2259 srna = RNA_def_struct(brna, "ObjectConstraints", NULL);
2260 RNA_def_struct_sdna(srna, "Object");
2261 RNA_def_struct_ui_text(srna, "Object Constraints", "Collection of object constraints");
2263 /* Collection active property */
2264 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2265 RNA_def_property_struct_type(prop, "Constraint");
2266 RNA_def_property_pointer_funcs(
2267 prop, "rna_Object_active_constraint_get", "rna_Object_active_constraint_set", NULL, NULL);
2268 RNA_def_property_flag(prop, PROP_EDITABLE);
2269 RNA_def_property_ui_text(prop, "Active Constraint", "Active Object constraint");
2271 /* Constraint collection */
2272 func = RNA_def_function(srna, "new", "rna_Object_constraints_new");
2273 RNA_def_function_ui_description(func, "Add a new constraint to this object");
2274 RNA_def_function_flag(func, FUNC_USE_MAIN);
2276 parm = RNA_def_enum(
2277 func, "type", rna_enum_constraint_type_items, 1, "", "Constraint type to add");
2278 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2280 parm = RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint");
2281 RNA_def_function_return(func, parm);
2283 func = RNA_def_function(srna, "remove", "rna_Object_constraints_remove");
2284 RNA_def_function_ui_description(func, "Remove a constraint from this object");
2285 RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
2286 /* constraint to remove */
2287 parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
2288 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2289 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
2291 func = RNA_def_function(srna, "clear", "rna_Object_constraints_clear");
2292 RNA_def_function_flag(func, FUNC_USE_MAIN);
2293 RNA_def_function_ui_description(func, "Remove all constraint from this object");
2295 func = RNA_def_function(srna, "move", "rna_Object_constraints_move");
2296 RNA_def_function_ui_description(func, "Move a constraint to a different position");
2297 RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
2299 func, "from_index", -1, INT_MIN, INT_MAX, "From Index", "Index to move", 0, 10000);
2300 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2301 parm = RNA_def_int(func, "to_index", -1, INT_MIN, INT_MAX, "To Index", "Target index", 0, 10000);
2302 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2304 func = RNA_def_function(srna, "copy", "rna_Object_constraints_copy");
2305 RNA_def_function_ui_description(func, "Add a new constraint that is a copy of the given one");
2306 RNA_def_function_flag(func, FUNC_USE_MAIN);
2307 /* constraint to copy */
2308 parm = RNA_def_pointer(func,
2312 "Constraint to copy - may belong to a different object");
2313 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2314 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
2316 parm = RNA_def_pointer(func, "new_constraint", "Constraint", "", "New constraint");
2317 RNA_def_function_return(func, parm);
2320 /* object.modifiers */
2321 static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
2329 RNA_def_property_srna(cprop, "ObjectModifiers");
2330 srna = RNA_def_struct(brna, "ObjectModifiers", NULL);
2331 RNA_def_struct_sdna(srna, "Object");
2332 RNA_def_struct_ui_text(srna, "Object Modifiers", "Collection of object modifiers");
2335 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2336 RNA_def_property_struct_type(prop, "EditBone");
2337 RNA_def_property_pointer_sdna(prop, NULL, "act_edbone");
2338 RNA_def_property_flag(prop, PROP_EDITABLE);
2339 RNA_def_property_ui_text(prop, "Active EditBone", "Armatures active edit bone");
2340 /*RNA_def_property_update(prop, 0, "rna_Armature_act_editbone_update"); */
2341 RNA_def_property_pointer_funcs(prop, NULL, "rna_Armature_act_edit_bone_set", NULL, NULL);
2344 /* RNA_def_property_collection_active(prop, prop_act); */
2348 func = RNA_def_function(srna, "new", "rna_Object_modifier_new");
2349 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
2350 RNA_def_function_ui_description(func, "Add a new modifier");
2351 parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the modifier");
2352 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2353 /* modifier to add */
2354 parm = RNA_def_enum(
2355 func, "type", rna_enum_object_modifier_type_items, 1, "", "Modifier type to add");
2356 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2358 parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Newly created modifier");
2359 RNA_def_function_return(func, parm);
2361 /* remove modifier */
2362 func = RNA_def_function(srna, "remove", "rna_Object_modifier_remove");
2363 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
2364 RNA_def_function_ui_description(func, "Remove an existing modifier from the object");
2365 /* modifier to remove */
2366 parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove");
2367 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2368 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
2370 /* clear all modifiers */
2371 func = RNA_def_function(srna, "clear", "rna_Object_modifier_clear");
2372 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
2373 RNA_def_function_ui_description(func, "Remove all modifiers from the object");
2375 /* Active modifier. */
2376 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2377 RNA_def_property_struct_type(prop, "Modifier");
2378 RNA_def_property_pointer_funcs(
2379 prop, "rna_Object_active_modifier_get", "rna_Object_active_modifier_set", NULL, NULL);
2380 RNA_def_property_flag(prop, PROP_EDITABLE);
2381 RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
2382 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
2383 RNA_def_property_ui_text(prop, "Active Modifier", "The active modifier in the list");
2384 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2387 /* object.grease_pencil_modifiers */
2388 static void rna_def_object_grease_pencil_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
2395 RNA_def_property_srna(cprop, "ObjectGpencilModifiers");
2396 srna = RNA_def_struct(brna, "ObjectGpencilModifiers", NULL);
2397 RNA_def_struct_sdna(srna, "Object");
2398 RNA_def_struct_ui_text(
2399 srna, "Object Grease Pencil Modifiers", "Collection of object grease pencil modifiers");
2401 /* add greasepencil modifier */
2402 func = RNA_def_function(srna, "new", "rna_Object_greasepencil_modifier_new");
2403 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
2404 RNA_def_function_ui_description(func, "Add a new greasepencil_modifier");
2405 parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the greasepencil_modifier");
2406 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2407 /* greasepencil_modifier to add */
2408 parm = RNA_def_enum(func,
2410 rna_enum_object_greasepencil_modifier_type_items,
2413 "Modifier type to add");
2414 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2416 parm = RNA_def_pointer(
2417 func, "greasepencil_modifier", "GpencilModifier", "", "Newly created modifier");
2418 RNA_def_function_return(func, parm);
2420 /* remove greasepencil_modifier */
2421 func = RNA_def_function(srna, "remove", "rna_Object_greasepencil_modifier_remove");
2422 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
2423 RNA_def_function_ui_description(func,
2424 "Remove an existing greasepencil_modifier from the object");
2425 /* greasepencil_modifier to remove */
2426 parm = RNA_def_pointer(
2427 func, "greasepencil_modifier", "GpencilModifier", "", "Modifier to remove");
2428 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2429 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
2431 /* clear all greasepencil modifiers */
2432 func = RNA_def_function(srna, "clear", "rna_Object_greasepencil_modifier_clear");
2433 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
2434 RNA_def_function_ui_description(func, "Remove all grease pencil modifiers from the object");
2437 /* object.shaderfxs */
2438 static void rna_def_object_shaderfxs(BlenderRNA *brna, PropertyRNA *cprop)
2445 RNA_def_property_srna(cprop, "ObjectShaderFx");
2446 srna = RNA_def_struct(brna, "ObjectShaderFx", NULL);
2447 RNA_def_struct_sdna(srna, "Object");
2448 RNA_def_struct_ui_text(srna, "Object Shader Effects", "Collection of object effects");
2451 func = RNA_def_function(srna, "new", "rna_Object_shaderfx_new");
2452 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
2453 RNA_def_function_ui_description(func, "Add a new shader fx");
2454 parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the effect");
2455 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2457 parm = RNA_def_enum(
2458 func, "type", rna_enum_object_shaderfx_type_items, 1, "", "Effect type to add");
2459 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
2461 parm = RNA_def_pointer(func, "shader_fx", "ShaderFx", "", "Newly created effect");
2462 RNA_def_function_return(func, parm);
2464 /* remove shader_fx */
2465 func = RNA_def_function(srna, "remove", "rna_Object_shaderfx_remove");
2466 RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
2467 RNA_def_function_ui_description(func, "Remove an existing effect from the object");
2468 /* shader to remove */
2469 parm = RNA_def_pointer(func, "shader_fx", "ShaderFx", "", "Effect to remove");
2470 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2471 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
2473 /* clear all shader fx */
2474 func = RNA_def_function(srna, "clear", "rna_Object_shaderfx_clear");
2475 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
2476 RNA_def_function_ui_description(func, "Remove all effects from the object");
2479 /* object.particle_systems */
2480 static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop)
2486 /* FunctionRNA *func; */
2487 /* PropertyRNA *parm; */
2489 RNA_def_property_srna(cprop, "ParticleSystems");
2490 srna = RNA_def_struct(brna, "ParticleSystems", NULL);
2491 RNA_def_struct_sdna(srna, "Object");
2492 RNA_def_struct_ui_text(srna, "Particle Systems", "Collection of particle systems");
2494 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2495 RNA_def_property_struct_type(prop, "ParticleSystem");
2496 RNA_def_property_pointer_funcs(prop, "rna_Object_active_particle_system_get", NULL, NULL, NULL);
2497 RNA_def_property_ui_text(
2498 prop, "Active Particle System", "Active particle system being displayed");
2499 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2501 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
2502 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2503 RNA_def_property_int_funcs(prop,
2504 "rna_Object_active_particle_system_index_get",
2505 "rna_Object_active_particle_system_index_set",
2506 "rna_Object_active_particle_system_index_range");
2507 RNA_def_property_ui_text(
2508 prop, "Active Particle System Index", "Index of active particle system slot");
2509 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_particle_update");
2512 /* object.vertex_groups */
2513 static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
2522 RNA_def_property_srna(cprop, "VertexGroups");
2523 srna = RNA_def_struct(brna, "VertexGroups", NULL);
2524 RNA_def_struct_sdna(srna, "Object");
2525 RNA_def_struct_ui_text(srna, "Vertex Groups", "Collection of vertex groups");
2527 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2528 RNA_def_property_struct_type(prop, "VertexGroup");
2529 RNA_def_property_pointer_funcs(prop,
2530 "rna_Object_active_vertex_group_get",
2531 "rna_Object_active_vertex_group_set",
2534 RNA_def_property_flag(prop, PROP_EDITABLE);
2535 RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object");
2536 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
2538 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
2539 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2540 RNA_def_property_int_sdna(prop, NULL, "actdef");
2541 RNA_def_property_int_funcs(prop,
2542 "rna_Object_active_vertex_group_index_get",
2543 "rna_Object_active_vertex_group_index_set",
2544 "rna_Object_active_vertex_group_index_range");
2545 RNA_def_property_ui_text(
2546 prop, "Active Vertex Group Index", "Active index in vertex group array");
2547 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
2549 /* vertex groups */ /* add_vertex_group */
2550 func = RNA_def_function(srna, "new", "rna_Object_vgroup_new");
2551 RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
2552 RNA_def_function_ui_description(func, "Add vertex group to object");
2553 RNA_def_string(func, "name", "Group", 0, "", "Vertex group name"); /* optional */
2554 parm = RNA_def_pointer(func, "group", "VertexGroup", "", "New vertex group");
2555 RNA_def_function_return(func, parm);
2557 func = RNA_def_function(srna, "remove", "rna_Object_vgroup_remove");
2558 RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
2559 RNA_def_function_ui_description(func, "Delete vertex group from object");
2560 parm = RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove");
2561 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2562 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
2564 func = RNA_def_function(srna, "clear", "rna_Object_vgroup_clear");
2565 RNA_def_function_flag(func, FUNC_USE_MAIN);
2566 RNA_def_function_ui_description(func, "Delete all vertex groups from object");
2569 /* object.face_maps */
2570 static void rna_def_object_face_maps(BlenderRNA *brna, PropertyRNA *cprop)
2579 RNA_def_property_srna(cprop, "FaceMaps");
2580 srna = RNA_def_struct(brna, "FaceMaps", NULL);
2581 RNA_def_struct_sdna(srna, "Object");
2582 RNA_def_struct_ui_text(srna, "Face Maps", "Collection of face maps");
2584 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2585 RNA_def_property_struct_type(prop, "FaceMap");
2586 RNA_def_property_pointer_funcs(
2587 prop, "rna_Object_active_face_map_get", "rna_Object_active_face_map_set", NULL, NULL);
2588 RNA_def_property_ui_text(prop, "Active Face Map", "Face maps of the object");
2589 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
2591 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
2592 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2593 RNA_def_property_int_sdna(prop, NULL, "actfmap");
2594 RNA_def_property_int_funcs(prop,
2595 "rna_Object_active_face_map_index_get",
2596 "rna_Object_active_face_map_index_set",
2597 "rna_Object_active_face_map_index_range");
2598 RNA_def_property_ui_text(prop, "Active Face Map Index", "Active index in face map array");
2599 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data");
2601 /* face maps */ /* add_face_map */
2602 func = RNA_def_function(srna, "new", "rna_Object_fmap_new");
2603 RNA_def_function_ui_description(func, "Add face map to object");
2604 RNA_def_string(func, "name", "Map", 0, "", "face map name"); /* optional */
2605 parm = RNA_def_pointer(func, "fmap", "FaceMap", "", "New face map");
2606 RNA_def_function_return(func, parm);
2608 func = RNA_def_function(srna, "remove", "rna_Object_fmap_remove");
2609 RNA_def_function_flag(func, FUNC_USE_REPORTS);
2610 RNA_def_function_ui_description(func, "Delete vertex group from object");
2611 parm = RNA_def_pointer(func, "group", "FaceMap", "", "Face map to remove");
2612 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
2613 RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
2615 func = RNA_def_function(srna, "clear", "rna_Object_fmap_clear");
2616 RNA_def_function_ui_description(func, "Delete all vertex groups from object");
2619 static void rna_def_object_display(BlenderRNA *brna)
2624 srna = RNA_def_struct(brna, "ObjectDisplay", NULL);
2625 RNA_def_struct_ui_text(srna, "Object Display", "Object display settings for 3D viewport");
2626 RNA_def_struct_sdna(srna, "Object");
2627 RNA_def_struct_nested(brna, srna, "Object");
2628 RNA_def_struct_path_func(srna, "rna_ObjectDisplay_path");
2630 RNA_define_lib_overridable(true);
2632 prop = RNA_def_property(srna, "show_shadows", PROP_BOOLEAN, PROP_NONE);
2633 RNA_def_property_boolean_negative_sdna(prop, NULL, "dtx", OB_DRAW_NO_SHADOW_CAST);
2634 RNA_def_property_boolean_default(prop, true);
2635 RNA_def_property_ui_text(prop, "Shadow", "Object cast shadows in the 3D viewport");
2636 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2638 RNA_define_lib_overridable(false);
2641 static void rna_def_object(BlenderRNA *brna)
2646 static const EnumPropertyItem up_items[] = {
2647 {OB_POSX, "X", 0, "X", ""},
2648 {OB_POSY, "Y", 0, "Y", ""},
2649 {OB_POSZ, "Z", 0, "Z", ""},
2650 {0, NULL, 0, NULL, NULL},
2653 static const EnumPropertyItem drawtype_items[] = {
2654 {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", "Display the bounds of the object"},
2655 {OB_WIRE, "WIRE", 0, "Wire", "Display the object as a wireframe"},
2660 "Display the object as a solid (if solid drawing is enabled in the viewport)"},
2665 "Display the object with textures (if textures are enabled in the viewport)"},
2666 {0, NULL, 0, NULL, NULL},
2669 static const EnumPropertyItem boundtype_items[] = {
2670 {OB_BOUND_BOX, "BOX", 0, "Box", "Display bounds as box"},
2671 {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", "Display bounds as sphere"},
2672 {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", "Display bounds as cylinder"},
2673 {OB_BOUND_CONE, "CONE", 0, "Cone", "Display bounds as cone"},
2674 {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", "Display bounds as capsule"},
2675 {0, NULL, 0, NULL, NULL},
2678 static int boundbox_dimsize[] = {8, 3};
2680 srna = RNA_def_struct(brna, "Object", "ID");
2681 RNA_def_struct_ui_text(srna, "Object", "Object data-block defining an object in a scene");
2682 RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
2683 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
2685 RNA_define_lib_overridable(true);
2687 prop = RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
2688 RNA_def_property_struct_type(prop, "ID");
2689 RNA_def_property_pointer_funcs(
2690 prop, NULL, "rna_Object_data_set", "rna_Object_data_typef", "rna_Object_data_poll");
2691 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
2692 RNA_def_property_ui_text(prop, "Data", "Object data");
2693 RNA_def_property_update(prop, 0, "rna_Object_data_update");
2695 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2696 RNA_def_property_enum_sdna(prop, NULL, "type");
2697 RNA_def_property_enum_items(prop, rna_enum_object_type_items);
2698 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2699 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
2700 RNA_def_property_ui_text(prop, "Type", "Type of object");
2701 RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID);
2703 prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
2704 RNA_def_property_enum_sdna(prop, NULL, "mode");
2705 RNA_def_property_enum_items(prop, rna_enum_object_mode_items);
2706 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2707 RNA_def_property_ui_text(prop, "Mode", "Object interaction mode");
2709 /* for data access */
2710 prop = RNA_def_property(srna, "bound_box", PROP_FLOAT, PROP_NONE);
2711 RNA_def_property_multi_array(prop, 2, boundbox_dimsize);
2712 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2713 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
2714 RNA_def_property_float_funcs(prop, "rna_Object_boundbox_get", NULL, NULL);
2715 RNA_def_property_ui_text(
2718 "Object's bounding box in object-space coordinates, all values are -1.0 when "
2722 prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
2723 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_parent_set", NULL, NULL);
2724 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2725 RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Object_parent_override_apply");
2726 RNA_def_property_ui_text(prop, "Parent", "Parent object");
2727 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2729 prop = RNA_def_property(srna, "parent_type", PROP_ENUM, PROP_NONE);
2730 RNA_def_property_enum_bitflag_sdna(prop, NULL, "partype");
2731 RNA_def_property_enum_items(prop, parent_type_items);
2732 RNA_def_property_enum_funcs(
2733 prop, NULL, "rna_Object_parent_type_set", "rna_Object_parent_type_itemf");
2734 RNA_def_property_ui_text(prop, "Parent Type", "Type of parent relation");
2735 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2737 prop = RNA_def_property(srna, "parent_vertices", PROP_INT, PROP_UNSIGNED);
2738 RNA_def_property_int_sdna(prop, NULL, "par1");
2739 RNA_def_property_array(prop, 3);
2740 RNA_def_property_ui_text(
2741 prop, "Parent Vertices", "Indices of vertices in case of a vertex parenting relation");
2742 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2744 prop = RNA_def_property(srna, "parent_bone", PROP_STRING, PROP_NONE);
2745 RNA_def_property_string_sdna(prop, NULL, "parsubstr");
2746 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Object_parent_bone_set");
2747 RNA_def_property_ui_text(
2748 prop, "Parent Bone", "Name of parent bone in case of a bone parenting relation");
2749 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2751 prop = RNA_def_property(srna, "use_camera_lock_parent", PROP_BOOLEAN, PROP_NONE);
2752 RNA_def_property_boolean_sdna(
2753 prop, NULL, "transflag", OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK);
2754 RNA_def_property_ui_text(prop,
2755 "Camera Parent Lock",
2756 "View Lock 3D viewport camera transformation affects the object's "
2758 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2760 /* Track and Up flags */
2761 /* XXX: these have been saved here for a bit longer (after old track was removed),
2762 * since some other tools still refer to this */
2763 prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
2764 RNA_def_property_enum_sdna(prop, NULL, "trackflag");
2765 RNA_def_property_enum_items(prop, rna_enum_object_axis_items);
2766 RNA_def_property_ui_text(
2769 "Axis that points in the 'forward' direction (applies to Instance Vertices when "
2770 "Align to Vertex Normal is enabled)");
2771 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2773 prop = RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE);
2774 RNA_def_property_enum_sdna(prop, NULL, "upflag");
2775 RNA_def_property_enum_items(prop, up_items);
2776 RNA_def_property_ui_text(
2779 "Axis that points in the upward direction (applies to Instance Vertices when "
2780 "Align to Vertex Normal is enabled)");
2781 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2784 prop = RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE);
2785 RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
2786 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
2787 RNA_def_property_ui_text(prop, "Proxy", "Library object this proxy object controls");
2789 prop = RNA_def_property(srna, "proxy_collection", PROP_POINTER, PROP_NONE);
2790 RNA_def_property_pointer_sdna(prop, NULL, "proxy_group");
2791 RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
2792 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
2793 RNA_def_property_ui_text(
2794 prop, "Proxy Collection", "Library collection duplicator object this proxy object controls");
2797 prop = RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE);
2798 RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
2799 RNA_def_property_struct_type(prop, "MaterialSlot");
2800 RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_PROP_NAME);
2801 /* don't dereference pointer! */
2802 RNA_def_property_collection_funcs(
2803 prop, NULL, NULL, NULL, "rna_iterator_array_get", NULL, NULL, NULL, NULL);
2804 RNA_def_property_ui_text(prop, "Material Slots", "Material slots in the object");
2806 prop = RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE);
2807 RNA_def_property_struct_type(prop, "Material");
2808 RNA_def_property_pointer_funcs(prop,
2809 "rna_Object_active_material_get",
2810 "rna_Object_active_material_set",
2812 "rna_MaterialSlot_material_poll");
2813 RNA_def_property_flag(prop, PROP_EDITABLE);
2814 RNA_def_property_editable_func(prop, "rna_Object_active_material_editable");
2815 RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed");
2816 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
2818 prop = RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
2819 RNA_def_property_int_sdna(prop, NULL, "actcol");
2820 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2821 RNA_def_property_int_funcs(prop,
2822 "rna_Object_active_material_index_get",
2823 "rna_Object_active_material_index_set",
2824 "rna_Object_active_material_index_range");
2825 RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot");
2826 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, "rna_MaterialIndex_update");
2829 prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
2830 RNA_def_property_float_sdna(prop, NULL, "loc");
2831 RNA_def_property_editable_array_func(prop, "rna_Object_location_editable");
2832 RNA_def_property_ui_text(prop, "Location", "Location of the object");
2833 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2834 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2836 prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
2837 RNA_def_property_float_sdna(prop, NULL, "quat");
2838 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
2839 RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions");
2840 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2842 /* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but
2843 * having a single one is better for Keyframing and other property-management situations...
2845 prop = RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
2846 RNA_def_property_array(prop, 4);
2847 RNA_def_property_float_funcs(
2848 prop, "rna_Object_rotation_axis_angle_get", "rna_Object_rotation_axis_angle_set", NULL);
2849 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
2850 RNA_def_property_float_array_default(prop, rna_default_axis_angle);
2851 RNA_def_property_ui_text(
2852 prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
2853 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2855 prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
2856 RNA_def_property_float_sdna(prop, NULL, "rot");
2857 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_euler_editable");
2858 RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers");
2859 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2861 prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
2862 RNA_def_property_enum_sdna(prop, NULL, "rotmode");
2863 RNA_def_property_enum_items(prop, rna_enum_object_rotation_mode_items);
2864 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_rotation_mode_set", NULL);
2865 RNA_def_property_ui_text(prop, "Rotation Mode", "");
2866 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2868 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
2869 RNA_def_property_flag(prop, PROP_PROPORTIONAL);
2870 RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable");
2871 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
2872 RNA_def_property_ui_text(prop, "Scale", "Scaling of the object");
2873 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2875 prop = RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ_LENGTH);
2876 RNA_def_property_array(prop, 3);
2877 /* Only as convenient helper for py API, and conflicts with animating scale. */
2878 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2879 RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
2880 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
2881 RNA_def_property_float_funcs(
2882 prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", NULL);
2883 RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2884 RNA_def_property_ui_text(
2887 "Absolute bounding box dimensions of the object (WARNING: assigning to it or "
2888 "its members multiple consecutive times will not work correctly, "
2889 "as this needs up-to-date evaluated data)");
2890 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2892 /* delta transforms */
2893 prop = RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_TRANSLATION);
2894 RNA_def_property_float_sdna(prop, NULL, "dloc");
2895 RNA_def_property_ui_text(
2896 prop, "Delta Location", "Extra translation added to the location of the object");
2897 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2898 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2900 prop = RNA_def_property(srna, "delta_rotation_euler", PROP_FLOAT, PROP_EULER);
2901 RNA_def_property_float_sdna(prop, NULL, "drot");
2902 RNA_def_property_ui_text(
2904 "Delta Rotation (Euler)",
2905 "Extra rotation added to the rotation of the object (when using Euler rotations)");
2906 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2908 prop = RNA_def_property(srna, "delta_rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
2909 RNA_def_property_float_sdna(prop, NULL, "dquat");
2910 RNA_def_property_ui_text(
2912 "Delta Rotation (Quaternion)",
2913 "Extra rotation added to the rotation of the object (when using Quaternion rotations)");
2914 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2916 # if 0 /* XXX not supported well yet... */
2917 prop = RNA_def_property(srna, "delta_rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
2918 /* FIXME: this is not a single field any more! (drotAxis and drotAngle) */
2919 RNA_def_property_float_sdna(prop, NULL, "dquat");
2920 RNA_def_property_float_array_default(prop, rna_default_axis_angle);
2921 RNA_def_property_ui_text(
2923 "Delta Rotation (Axis Angle)",
2924 "Extra rotation added to the rotation of the object (when using Axis-Angle rotations)");
2925 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2928 prop = RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_XYZ);
2929 RNA_def_property_float_sdna(prop, NULL, "dscale");
2930 RNA_def_property_flag(prop, PROP_PROPORTIONAL);
2931 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
2932 RNA_def_property_ui_text(prop, "Delta Scale", "Extra scaling added to the scale of the object");
2933 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2935 /* transform locks */
2936 prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE);
2937 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX);
2938 RNA_def_property_array(prop, 3);
2939 RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location when transforming");
2940 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2941 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2943 prop = RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE);
2944 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX);
2945 RNA_def_property_array(prop, 3);
2946 RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation when transforming");
2947 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2948 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2950 /* XXX this is sub-optimal - it really should be included above,
2951 * but due to technical reasons we can't do this! */
2952 prop = RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE);
2953 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTW);
2954 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2955 RNA_def_property_ui_text(
2957 "Lock Rotation (4D Angle)",
2958 "Lock editing of 'angle' component of four-component rotations when transforming");
2959 /* XXX this needs a better name */
2960 prop = RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE);
2961 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROT4D);
2962 RNA_def_property_ui_text(
2964 "Lock Rotations (4D)",
2965 "Lock editing of four component rotations by components (instead of as Eulers)");
2967 prop = RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_NONE);
2968 RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX);
2969 RNA_def_property_array(prop, 3);
2970 RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale when transforming");
2971 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
2972 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2975 prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
2976 RNA_def_property_float_sdna(prop, NULL, "obmat");
2977 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2978 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2979 RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
2980 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
2981 RNA_def_property_ui_text(prop, "Matrix World", "Worldspace transformation matrix");
2982 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_matrix_world_update");
2984 prop = RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX);
2985 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2986 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2987 RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
2988 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
2989 RNA_def_property_ui_text(
2992 "Parent relative transformation matrix - "
2993 "WARNING: Only takes into account 'Object' parenting, so e.g. in case of bone parenting "
2994 "you get a matrix relative to the Armature object, not to the actual parent bone");
2995 RNA_def_property_float_funcs(
2996 prop, "rna_Object_matrix_local_get", "rna_Object_matrix_local_set", NULL);
2997 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
2999 prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
3000 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
3001 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
3002 RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
3003 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
3004 RNA_def_property_ui_text(prop,
3006 "Matrix access to location, rotation and scale (including deltas), "
3007 "before constraints and parenting are applied");
3008 RNA_def_property_float_funcs(
3009 prop, "rna_Object_matrix_basis_get", "rna_Object_matrix_basis_set", NULL);
3010 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3013 prop = RNA_def_property(srna, "matrix_parent_inverse", PROP_FLOAT, PROP_MATRIX);
3014 RNA_def_property_float_sdna(prop, NULL, "parentinv");
3015 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
3016 RNA_def_property_ui_text(
3017 prop, "Parent Inverse Matrix", "Inverse of object's parent matrix at time of parenting");
3018 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3021 prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
3022 RNA_def_property_struct_type(prop, "Modifier");
3023 RNA_def_property_ui_text(
3024 prop, "Modifiers", "Modifiers affecting the geometric data of the object");
3025 RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Object_modifiers_override_apply");
3026 RNA_def_property_override_flag(prop, PROPOVERRIDE_LIBRARY_INSERTION);
3027 rna_def_object_modifiers(brna, prop);
3029 /* Grease Pencil modifiers. */
3030 prop = RNA_def_property(srna, "grease_pencil_modifiers", PROP_COLLECTION, PROP_NONE);
3031 RNA_def_property_collection_sdna(prop, NULL, "greasepencil_modifiers", NULL);
3032 RNA_def_property_struct_type(prop, "GpencilModifier");
3033 RNA_def_property_ui_text(
3034 prop, "Grease Pencil Modifiers", "Modifiers affecting the data of the grease pencil object");
3035 RNA_def_property_override_funcs(
3036 prop, NULL, NULL, "rna_Object_greasepencil_modifiers_override_apply");
3037 RNA_def_property_override_flag(prop, PROPOVERRIDE_LIBRARY_INSERTION);
3038 rna_def_object_grease_pencil_modifiers(brna, prop);
3041 prop = RNA_def_property(srna, "shader_effects", PROP_COLLECTION, PROP_NONE);
3042 RNA_def_property_collection_sdna(prop, NULL, "shader_fx", NULL);
3043 RNA_def_property_struct_type(prop, "ShaderFx");
3044 RNA_def_property_ui_text(prop, "Shader Effects", "Effects affecting display of object");
3045 RNA_define_lib_overridable(false);
3046 rna_def_object_shaderfxs(brna, prop);
3047 RNA_define_lib_overridable(true);
3050 prop = RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE);
3051 RNA_def_property_struct_type(prop, "Constraint");
3052 RNA_def_property_override_flag(prop, PROPOVERRIDE_LIBRARY_INSERTION);
3053 RNA_def_property_ui_text(
3054 prop, "Constraints", "Constraints affecting the transformation of the object");
3055 RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Object_constraints_override_apply");
3057 RNA_def_property_collection_funcs(
3058 prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "constraints__add", "constraints__remove");
3060 rna_def_object_constraints(brna, prop);
3063 prop = RNA_def_property(srna, "vertex_groups", PROP_COLLECTION, PROP_NONE);
3064 RNA_def_property_collection_sdna(prop, NULL, "defbase", NULL);
3065 RNA_def_property_struct_type(prop, "VertexGroup");
3066 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
3067 RNA_def_property_ui_text(prop, "Vertex Groups", "Vertex groups of the object");
3068 rna_def_object_vertex_groups(brna, prop);
3071 prop = RNA_def_property(srna, "face_maps", PROP_COLLECTION, PROP_NONE);
3072 RNA_def_property_collection_sdna(prop, NULL, "fmaps", NULL);
3073 RNA_def_property_struct_type(prop, "FaceMap");
3074 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
3075 RNA_def_property_ui_text(prop, "Face Maps", "Maps of faces of the object");
3076 rna_def_object_face_maps(brna, prop);
3079 prop = RNA_def_property(srna, "empty_display_type", PROP_ENUM, PROP_NONE);
3080 RNA_def_property_enum_sdna(prop, NULL, "empty_drawtype");
3081 RNA_def_property_enum_items(prop, rna_enum_object_empty_drawtype_items);
3082 RNA_def_property_enum_funcs(prop, NULL, "rna_Object_empty_display_type_set", NULL);
3083 RNA_def_property_ui_text(prop, "Empty Display Type", "Viewport display style for empties");
3084 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3086 prop = RNA_def_property(srna, "empty_display_size", PROP_FLOAT, PROP_DISTANCE);
3087 RNA_def_property_float_sdna(prop, NULL, "empty_drawsize");
3088 RNA_def_property_range(prop, 0.0001f, 1000.0f);
3089 RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);
3090 RNA_def_property_ui_text(
3091 prop, "Empty Display Size", "Size of display for empties in the viewport");
3092 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3094 prop = RNA_def_property(srna, "empty_image_offset", PROP_FLOAT, PROP_NONE);
3095 RNA_def_property_float_sdna(prop, NULL, "ima_ofs");
3096 RNA_def_property_ui_text(prop, "Origin Offset", "Origin offset distance");
3097 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1f, 2);
3098 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3100 prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE);
3101 RNA_def_property_flag(prop, PROP_NEVER_NULL);
3102 RNA_def_property_pointer_sdna(prop, NULL, "iuser");
3103 RNA_def_property_ui_text(
3106 "Parameters defining which layer, pass and frame of the image is displayed");
3107 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3109 prop = RNA_def_property(srna, "empty_image_depth", PROP_ENUM, PROP_NONE);
3110 RNA_def_property_enum_items(prop, rna_enum_object_empty_image_depth_items);
3111 RNA_def_property_ui_text(
3112 prop, "Empty Image Depth", "Determine which other objects will occlude the image");
3113 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3115 prop = RNA_def_property(srna, "show_empty_image_perspective", PROP_BOOLEAN, PROP_NONE);
3116 RNA_def_property_boolean_negative_sdna(
3117 prop, NULL, "empty_image_visibility_flag", OB_EMPTY_IMAGE_HIDE_PERSPECTIVE);
3118 RNA_def_property_ui_text(
3119 prop, "Display in Perspective Mode", "Display image in perspective mode");
3120 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3122 prop = RNA_def_property(srna, "show_empty_image_orthographic", PROP_BOOLEAN, PROP_NONE);
3123 RNA_def_property_boolean_negative_sdna(
3124 prop, NULL, "empty_image_visibility_flag", OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC);
3125 RNA_def_property_ui_text(
3126 prop, "Display in Orthographic Mode", "Display image in orthographic mode");
3127 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3129 prop = RNA_def_property(srna, "show_empty_image_only_axis_aligned", PROP_BOOLEAN, PROP_NONE);
3130 RNA_def_property_boolean_sdna(
3131 prop, NULL, "empty_image_visibility_flag", OB_EMPTY_IMAGE_HIDE_NON_AXIS_ALIGNED);
3132 RNA_def_property_ui_text(prop,
3133 "Display Only Axis Aligned",
3134 "Only display the image when it is aligned with the view axis");
3135 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3137 prop = RNA_def_property(srna, "use_empty_image_alpha", PROP_BOOLEAN, PROP_NONE);
3138 RNA_def_property_boolean_sdna(prop, NULL, "empty_image_flag", OB_EMPTY_IMAGE_USE_ALPHA_BLEND);
3139 RNA_def_property_ui_text(
3142 "Use alpha blending instead of alpha test (can produce sorting artifacts)");
3143 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3145 static EnumPropertyItem prop_empty_image_side_items[] = {
3146 {0, "DOUBLE_SIDED", 0, "Both", ""},
3147 {OB_EMPTY_IMAGE_HIDE_BACK, "FRONT", 0, "Front", ""},
3148 {OB_EMPTY_IMAGE_HIDE_FRONT, "BACK", 0, "Back", ""},
3149 {0, NULL, 0, NULL, NULL},
3151 prop = RNA_def_property(srna, "empty_image_side", PROP_ENUM, PROP_NONE);
3152 RNA_def_property_enum_bitflag_sdna(prop, NULL, "empty_image_visibility_flag");
3153 RNA_def_property_enum_items(prop, prop_empty_image_side_items);
3154 RNA_def_property_ui_text(prop, "Empty Image Side", "Show front/back side");
3155 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3158 prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
3159 RNA_def_property_int_sdna(prop, NULL, "index");
3160 RNA_def_property_ui_text(
3161 prop, "Pass Index", "Index number for the \"Object Index\" render pass");
3162 RNA_def_property_update(prop, NC_OBJECT, "rna_Object_internal_update_draw");
3164 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
3165 RNA_def_property_ui_text(
3166 prop, "Color", "Object color and alpha, used when faces have the ObColor mode enabled");
3167 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
3170 prop = RNA_def_property(srna, "field", PROP_POINTER, PROP_NONE);
3171 RNA_def_property_pointer_sdna(prop, NULL, "pd");
3172 RNA_def_property_struct_type(prop, "FieldSettings");
3173 RNA_def_property_pointer_funcs(prop, "rna_Object_field_get", NULL, NULL, NULL);
3174 RNA_def_property_ui_text(
3175 prop, "Field Settings", "Settings for using the object as a field in physics simulation");
3177 prop = RNA_def_property(srna, "collision", PROP_POINTER, PROP_NONE);
3178 RNA_def_property_pointer_sdna(prop, NULL, "pd");
3179 RNA_def_property_struct_type(prop, "CollisionSettings");
3180 RNA_def_property_pointer_funcs(prop, "rna_Object_collision_get", NULL, NULL, NULL);
3181 RNA_def_property_ui_text(prop,
3182 "Collision Settings",
3183 "Settings for using the object as a collider in physics simulation");
3185 prop = RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE);
3186 RNA_def_property_pointer_sdna(prop, NULL, "soft");
3187 RNA_def_property_struct_type(prop, "SoftBodySettings");
3188 RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for soft body simulation");
3190 prop = RNA_def_property(srna, "particle_systems", PROP_COLLECTION, PROP_NONE);
3191 RNA_def_property_collection_sdna(prop, NULL, "particlesystem", NULL);
3192 RNA_def_property_struct_type(prop, "ParticleSystem");
3193 RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object");
3194 rna_def_object_particle_systems(brna, prop);
3196 prop = RNA_def_property(srna, "rigid_body", PROP_POINTER, PROP_NONE);
3197 RNA_def_property_pointer_sdna(prop, NULL, "rigidbody_object");
3198 RNA_def_property_struct_type(prop, "RigidBodyObject");
3199 RNA_def_property_ui_text(prop, "Rigid Body Settings", "Settings for rigid body simulation");
3201 prop = RNA_def_property(srna, "rigid_body_constraint", PROP_POINTER, PROP_NONE);
3202 RNA_def_property_pointer_sdna(prop, NULL, "rigidbody_constraint");
3203 RNA_def_property_struct_type(prop, "RigidBodyConstraint");
3204 RNA_def_property_ui_text(prop, "Rigid Body Constraint", "Constraint constraining rigid bodies");
3207 prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE);
3208 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEWPORT);
3209 RNA_def_property_ui_text(prop, "Disable in Viewports", "Globally disable in viewports");
3210 RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, -1);
3211 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
3213 prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
3214 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT);
3215 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
3216 RNA_def_property_ui_text(prop, "Disable Selection", "Disable selection in viewport");
3217 RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, -1);
3218 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
3220 prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE);
3221 RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER);
3222 RNA_def_property_ui_text(prop, "Disable in Renders", "Globally disable in renders");
3223 RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, -1);
3224 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
3226 prop = RNA_def_property(srna, "show_instancer_for_render", PROP_BOOLEAN, PROP_NONE);
3227 RNA_def_property_boolean_sdna(prop, NULL, "duplicator_visibility_flag", OB_DUPLI_FLAG_RENDER);
3228 RNA_def_property_ui_text(prop, "Render Instancer", "Make instancer visible when rendering");
3229 RNA_def_property_update(
3230 prop, NC_OBJECT | ND_DRAW, "rna_Object_duplicator_visibility_flag_update");
3232 prop = RNA_def_property(srna, "show_instancer_for_viewport", PROP_BOOLEAN, PROP_NONE);
3233 RNA_def_property_boolean_sdna(prop, NULL, "duplicator_visibility_flag", OB_DUPLI_FLAG_VIEWPORT);
3234 RNA_def_property_ui_text(prop, "Display Instancer", "Make instancer visible in the viewport");
3235 RNA_def_property_update(
3236 prop, NC_OBJECT | ND_DRAW, "rna_Object_duplicator_visibility_flag_update");
3239 prop = RNA_def_property(srna, "instance_type", PROP_ENUM, PROP_NONE);
3240 RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag");
3241 RNA_def_property_enum_items(prop, instance_items);
3242 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_instance_type_itemf");
3243 RNA_def_property_ui_text(prop, "Instance Type", "If not None, object instancing method to use");
3244 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
3246 prop = RNA_def_property(srna, "use_instance_vertices_rotation", PROP_BOOLEAN, PROP_NONE);
3247 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIROT);
3248 RNA_def_property_ui_text(
3249 prop, "Orient with Normals", "Rotate instance according to vertex normal");
3250 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3252 prop = RNA_def_property(srna, "use_instance_faces_scale", PROP_BOOLEAN, PROP_NONE);
3253 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIFACES_SCALE);
3254 RNA_def_property_ui_text(prop, "Scale to Face Sizes", "Scale instance based on face size");
3255 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
3257 prop = RNA_def_property(srna, "instance_faces_scale", PROP_FLOAT, PROP_NONE);
3258 RNA_def_property_float_sdna(prop, NULL, "instance_faces_scale");
3259 RNA_def_property_range(prop, 0.001f, 10000.0f);
3260 RNA_def_property_ui_text(prop, "Instance Faces Scale", "Scale the face instance objects");
3261 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
3263 prop = RNA_def_property(srna, "instance_collection", PROP_POINTER, PROP_NONE);
3264 RNA_def_property_struct_type(prop, "Collection");
3265 RNA_def_property_pointer_sdna(prop, NULL, "instance_collection");
3266 RNA_def_property_flag(prop, PROP_EDITABLE);
3267 RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_dup_collection_set", NULL, NULL);
3268 RNA_def_property_ui_text(prop, "Instance Collection", "Instance an existing collection");
3269 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
3271 prop = RNA_def_property(srna, "is_instancer", PROP_BOOLEAN, PROP_NONE);
3272 RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLI);
3273 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3274 RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
3275 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
3278 prop = RNA_def_property(srna, "display_type", PROP_ENUM, PROP_NONE);
3279 RNA_def_property_enum_sdna(prop, NULL, "dt");
3280 RNA_def_property_enum_items(prop, drawtype_items);
3281 RNA_def_property_ui_text(prop, "Display As", "How to display object in viewport");
3282 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
3284 prop = RNA_def_property(srna, "show_bounds", PROP_BOOLEAN, PROP_NONE);
3285 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWBOUNDOX);
3286 RNA_def_property_ui_text(prop, "Display Bounds", "Display the object's bounds");
3287 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3289 prop = RNA_def_property(srna, "display_bounds_type", PROP_ENUM, PROP_NONE);
3290 RNA_def_property_enum_sdna(prop, NULL, "boundtype");
3291 RNA_def_property_enum_items(prop, boundtype_items);
3292 RNA_def_property_ui_text(prop, "Display Bounds Type", "Object boundary display type");
3293 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3295 prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE);
3296 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWNAME);
3297 RNA_def_property_ui_text(prop, "Display Name", "Display the object's name");
3298 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3300 prop = RNA_def_property(srna, "show_axis", PROP_BOOLEAN, PROP_NONE);
3301 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_AXIS);
3302 RNA_def_property_ui_text(prop, "Display Axes", "Display the object's origin and axes");
3303 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3305 prop = RNA_def_property(srna, "show_texture_space", PROP_BOOLEAN, PROP_NONE);
3306 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_TEXSPACE);
3307 RNA_def_property_ui_text(prop, "Display Texture Space", "Display the object's texture space");
3308 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3310 prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE);
3311 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWWIRE);
3312 RNA_def_property_ui_text(prop, "Display Wire", "Add the object's wireframe over solid drawing");
3313 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3315 prop = RNA_def_property(srna, "show_all_edges", PROP_BOOLEAN, PROP_NONE);
3316 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAW_ALL_EDGES);
3317 RNA_def_property_ui_text(prop, "Display All Edges", "Display all edges for mesh objects");
3318 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3320 prop = RNA_def_property(srna, "use_grease_pencil_lights", PROP_BOOLEAN, PROP_NONE);
3321 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_USE_GPENCIL_LIGHTS);
3322 RNA_def_property_boolean_default(prop, true);
3323 RNA_def_property_ui_text(prop, "Use Lights", "Lights affect grease pencil object");
3324 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_GPencil_update");
3326 prop = RNA_def_property(srna, "show_transparent", PROP_BOOLEAN, PROP_NONE);
3327 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWTRANSP);
3328 RNA_def_property_ui_text(
3329 prop, "Display Transparent", "Display material transparency in the object");
3330 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
3332 prop = RNA_def_property(srna, "show_in_front", PROP_BOOLEAN, PROP_NONE);
3333 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAW_IN_FRONT);
3334 RNA_def_property_ui_text(prop, "In Front", "Make the object draw in front of others");
3335 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_GPencil_update");
3338 prop = RNA_def_property(srna, "pose_library", PROP_POINTER, PROP_NONE);
3339 RNA_def_property_pointer_sdna(prop, NULL, "poselib");
3340 RNA_def_property_struct_type(prop, "Action");
3341 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
3342 RNA_def_property_ui_text(prop, "Pose Library", "Action used as a pose library for armatures");
3344 prop = RNA_def_property(srna, "pose", PROP_POINTER, PROP_NONE);
3345 RNA_def_property_pointer_sdna(prop, NULL, "pose");
3346 RNA_def_property_struct_type(prop, "Pose");
3347 RNA_def_property_ui_text(prop, "Pose", "Current pose for armatures");
3350 prop = RNA_def_property(srna, "show_only_shape_key", PROP_BOOLEAN, PROP_NONE);
3351 RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_LOCK);
3352 RNA_def_property_ui_text(
3353 prop, "Shape Key Lock", "Always show the current shape for this object");
3354 RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
3355 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
3357 prop = RNA_def_property(srna, "use_shape_key_edit_mode", PROP_BOOLEAN, PROP_NONE);
3358 RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_EDIT_MODE);
3359 RNA_def_property_ui_text(
3360 prop, "Shape Key Edit Mode", "Apply shape keys in edit mode (for meshes only)");
3361 RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0);
3362 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
3364 prop = RNA_def_property(srna, "active_shape_key", PROP_POINTER, PROP_NONE);
3365 RNA_def_property_struct_type(prop, "ShapeKey");
3366 RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE | PROPOVERRIDE_NO_COMPARISON);
3367 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
3368 RNA_def_property_pointer_funcs(prop, "rna_Object_active_shape_key_get", NULL, NULL, NULL);
3369 RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key");
3371 prop = RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE);
3372 RNA_def_property_int_sdna(prop, NULL, "shapenr");
3373 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* XXX this is really unpredictable... */
3374 RNA_def_property_int_funcs(prop,
3375 "rna_Object_active_shape_key_index_get",
3376 "rna_Object_active_shape_key_index_set",
3377 "rna_Object_active_shape_key_index_range");
3378 RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index");
3379 RNA_def_property_update(prop, 0, "rna_Object_active_shape_update");
3382 prop = RNA_def_property(srna, "use_dynamic_topology_sculpting", PROP_BOOLEAN, PROP_NONE);
3383 RNA_def_property_boolean_funcs(prop, "rna_Object_use_dynamic_topology_sculpting_get", NULL);
3384 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3385 RNA_def_property_ui_text(prop, "Dynamic Topology Sculpting", NULL);
3388 prop = RNA_def_property(srna, "is_from_instancer", PROP_BOOLEAN, PROP_NONE);
3389 RNA_def_property_boolean_sdna(prop, NULL, "base_flag", BASE_FROM_DUPLI);
3390 RNA_def_property_ui_text(prop, "Base from Instancer", "Object comes from a instancer");
3391 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3392 RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
3393 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
3395 prop = RNA_def_property(srna, "is_from_set", PROP_BOOLEAN, PROP_NONE);
3396 RNA_def_property_boolean_sdna(prop, NULL, "base_flag", BASE_FROM_SET);
3397 RNA_def_property_ui_text(prop, "Base from Set", "Object comes from a background set");
3398 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3399 RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
3400 RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
3402 /* Object Display */
3403 prop = RNA_def_property(srna, "display", PROP_POINTER, PROP_NONE);
3404 RNA_def_property_flag(prop, PROP_NEVER_NULL);
3405 RNA_def_property_struct_type(prop, "ObjectDisplay");
3406 RNA_def_property_pointer_funcs(prop, "rna_Object_display_get", NULL, NULL, NULL);
3407 RNA_def_property_ui_text(prop, "Object Display", "Object display settings for 3D viewport");
3409 RNA_define_lib_overridable(false);
3412 rna_def_animdata_common(srna);
3414 rna_def_animviz_common(srna);
3415 rna_def_motionpath_common(srna);
3417 RNA_api_object(srna);
3420 void RNA_def_object(BlenderRNA *brna)
3422 rna_def_object(brna);
3424 RNA_define_animate_sdna(false);
3425 rna_def_vertex_group(brna);
3426 rna_def_face_map(brna);
3427 rna_def_material_slot(brna);
3428 rna_def_object_display(brna);
3429 RNA_define_animate_sdna(true);