Blender V4.5
rna_object.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "DNA_action_types.h"
12#include "DNA_layer_types.h"
14#include "DNA_meta_types.h"
15#include "DNA_object_types.h"
16
17#include "BLI_math_rotation.h"
18
19#include "BLT_translation.hh"
20
21#include "BKE_paint.hh"
22
23#include "RNA_define.hh"
24#include "RNA_enum_types.hh"
25
26#include "rna_internal.hh"
27
28#include "ED_object_vgroup.hh"
29
30#include "WM_api.hh"
31#include "WM_types.hh"
32
34 {OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object Mode", ""},
35 {OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit Mode", ""},
36 {OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose Mode", ""},
37 {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""},
38 {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
39 {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
40 {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
41 {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""},
43 "EDIT_GPENCIL",
44 ICON_EDITMODE_HLT,
45 "Edit Mode",
46 "Edit Grease Pencil Strokes"},
48 "SCULPT_GREASE_PENCIL",
49 ICON_SCULPTMODE_HLT,
50 "Sculpt Mode",
51 "Sculpt Grease Pencil Strokes"},
53 "PAINT_GREASE_PENCIL",
54 ICON_GREASEPENCIL,
55 "Draw Mode",
56 "Paint Grease Pencil Strokes"},
58 "WEIGHT_GREASE_PENCIL",
59 ICON_WPAINT_HLT,
60 "Weight Paint",
61 "Grease Pencil Weight Paint Strokes"},
63 "VERTEX_GREASE_PENCIL",
64 ICON_VPAINT_HLT,
65 "Vertex Paint",
66 "Grease Pencil Vertex Paint Strokes"},
67 {OB_MODE_SCULPT_CURVES, "SCULPT_CURVES", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""},
68 {0, nullptr, 0, nullptr, nullptr},
69};
70
72 {OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object Mode", ""},
73 {OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit Mode", ""},
74 {OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose Mode", ""},
75 {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""},
76 {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
77 {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
78 {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
79 {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""},
81 "EDIT_GPENCIL",
82 ICON_EDITMODE_HLT,
83 "Grease Pencil Edit Mode",
84 "Edit Grease Pencil Strokes"},
86 "SCULPT_GREASE_PENCIL",
87 ICON_SCULPTMODE_HLT,
88 "Grease Pencil Sculpt Mode",
89 "Sculpt Grease Pencil Strokes"},
91 "PAINT_GREASE_PENCIL",
92 ICON_GREASEPENCIL,
93 "Grease Pencil Draw",
94 "Paint Grease Pencil Strokes"},
96 "VERTEX_GREASE_PENCIL",
97 ICON_VPAINT_HLT,
98 "Grease Pencil Vertex Paint",
99 "Grease Pencil Vertex Paint Strokes"},
101 "WEIGHT_GREASE_PENCIL",
102 ICON_WPAINT_HLT,
103 "Grease Pencil Weight Paint",
104 "Grease Pencil Weight Paint Strokes"},
105 {0, nullptr, 0, nullptr, nullptr},
106};
107
109 {OB_PLAINAXES, "PLAIN_AXES", ICON_EMPTY_AXIS, "Plain Axes", ""},
110 {OB_ARROWS, "ARROWS", ICON_EMPTY_ARROWS, "Arrows", ""},
111 {OB_SINGLE_ARROW, "SINGLE_ARROW", ICON_EMPTY_SINGLE_ARROW, "Single Arrow", ""},
112 {OB_CIRCLE, "CIRCLE", ICON_MESH_CIRCLE, "Circle", ""},
113 {OB_CUBE, "CUBE", ICON_CUBE, "Cube", ""},
114 {OB_EMPTY_SPHERE, "SPHERE", ICON_SPHERE, "Sphere", ""},
115 {OB_EMPTY_CONE, "CONE", ICON_CONE, "Cone", ""},
116 {OB_EMPTY_IMAGE, "IMAGE", ICON_FILE_IMAGE, "Image", ""},
117 {0, nullptr, 0, nullptr, nullptr},
118};
119
121 {OB_EMPTY_IMAGE_DEPTH_DEFAULT, "DEFAULT", 0, "Default", ""},
122 {OB_EMPTY_IMAGE_DEPTH_FRONT, "FRONT", 0, "Front", ""},
123 {OB_EMPTY_IMAGE_DEPTH_BACK, "BACK", 0, "Back", ""},
124 {0, nullptr, 0, nullptr, nullptr},
125};
126
128 {GP_EMPTY, "EMPTY", ICON_EMPTY_AXIS, "Blank", "Create an empty Grease Pencil object"},
129 {GP_STROKE, "STROKE", ICON_STROKE, "Stroke", "Create a simple stroke with basic colors"},
130 {GP_MONKEY, "MONKEY", ICON_MONKEY, "Monkey", "Construct a Suzanne Grease Pencil object"},
133 "LINEART_SCENE",
134 ICON_SCENE_DATA,
135 "Scene Line Art",
136 "Quickly set up Line Art for the entire scene"},
138 "LINEART_COLLECTION",
139 ICON_OUTLINER_COLLECTION,
140 "Collection Line Art",
141 "Quickly set up Line Art for the active collection"},
143 "LINEART_OBJECT",
144 ICON_OBJECT_DATA,
145 "Object Line Art",
146 "Quickly set up Line Art for the active object"},
147 {0, nullptr, 0, nullptr, nullptr}};
148
150 {PAROBJECT, "OBJECT", 0, "Object", "The object is parented to an object"},
151 {PARSKEL, "ARMATURE", 0, "Armature", ""},
152 /* PARSKEL reuse will give issues. */
153 {PARSKEL, "LATTICE", 0, "Lattice", "The object is parented to a lattice"},
154 {PARVERT1, "VERTEX", 0, "Vertex", "The object is parented to a vertex"},
155 {PARVERT3, "VERTEX_3", 0, "3 Vertices", ""},
156 {PARBONE, "BONE", 0, "Bone", "The object is parented to a bone"},
157 {0, nullptr, 0, nullptr, nullptr},
158};
159
160#define INSTANCE_ITEMS_SHARED \
161 {0, "NONE", 0, "None", ""}, \
162 {OB_DUPLIVERTS, "VERTS", 0, "Vertices", "Instantiate child objects on all vertices"}, \
163 { \
164 OB_DUPLIFACES, "FACES", 0, "Faces", "Instantiate child objects on all faces" \
165 }
166
167#define INSTANCE_ITEM_COLLECTION \
168 { \
169 OB_DUPLICOLLECTION, "COLLECTION", 0, "Collection", "Enable collection instancing" \
170 }
174 {0, nullptr, 0, nullptr, nullptr},
175};
176#ifdef RNA_RUNTIME
177static EnumPropertyItem instance_items_nogroup[] = {
179 {0, nullptr, 0, nullptr, nullptr},
180};
181
182static EnumPropertyItem instance_items_empty[] = {
183 {0, "NONE", 0, "None", ""},
185 {0, nullptr, 0, nullptr, nullptr},
186};
187
188static EnumPropertyItem instance_items_font[] = {
189 {0, "NONE", 0, "None", ""},
190 {OB_DUPLIVERTS, "VERTS", 0, "Vertices", "Use Object Font on characters"},
191 {0, nullptr, 0, nullptr, nullptr},
192};
193#endif
194#undef INSTANCE_ITEMS_SHARED
195#undef INSTANCE_ITEM_COLLECTION
196
198 {MB_BALL, "BALL", ICON_META_BALL, "Ball", ""},
199 {MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""},
200 {MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""},
201 /* NOTE: typo at original definition! */
202 {MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""},
203 {MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""},
204 {0, nullptr, 0, nullptr, nullptr},
205};
206
208 {LIGHTPROBE_TYPE_SPHERE, "SPHERE", ICON_LIGHTPROBE_SPHERE, "Sphere", ""},
209 {LIGHTPROBE_TYPE_PLANE, "PLANE", ICON_LIGHTPROBE_PLANE, "Plane", ""},
210 {LIGHTPROBE_TYPE_VOLUME, "VOLUME", ICON_LIGHTPROBE_VOLUME, "Volume", ""},
211 {0, nullptr, 0, nullptr, nullptr},
212};
213
214/* used for 2 enums */
215#define OBTYPE_CU_CURVE \
216 { \
217 OB_CURVES_LEGACY, "CURVE", ICON_OUTLINER_OB_CURVE, "Curve", "" \
218 }
219#define OBTYPE_CU_SURF \
220 { \
221 OB_SURF, "SURFACE", ICON_OUTLINER_OB_SURFACE, "Surface", "" \
222 }
223#define OBTYPE_CU_FONT \
224 { \
225 OB_FONT, "FONT", ICON_OUTLINER_OB_FONT, "Text", "" \
226 }
227
229 {OB_MESH, "MESH", ICON_OUTLINER_OB_MESH, "Mesh", ""},
232 {OB_MBALL, "META", ICON_OUTLINER_OB_META, "Metaball", ""},
234 {OB_CURVES, "CURVES", ICON_OUTLINER_OB_CURVES, "Hair Curves", ""},
235 {OB_POINTCLOUD, "POINTCLOUD", ICON_OUTLINER_OB_POINTCLOUD, "Point Cloud", ""},
236 {OB_VOLUME, "VOLUME", ICON_OUTLINER_OB_VOLUME, "Volume", ""},
237 {OB_GREASE_PENCIL, "GREASEPENCIL", ICON_OUTLINER_OB_GREASEPENCIL, "Grease Pencil", ""},
239 {OB_ARMATURE, "ARMATURE", ICON_OUTLINER_OB_ARMATURE, "Armature", ""},
240 {OB_LATTICE, "LATTICE", ICON_OUTLINER_OB_LATTICE, "Lattice", ""},
242 {OB_EMPTY, "EMPTY", ICON_OUTLINER_OB_EMPTY, "Empty", ""},
244 {OB_LAMP, "LIGHT", ICON_OUTLINER_OB_LIGHT, "Light", ""},
245 {OB_LIGHTPROBE, "LIGHT_PROBE", ICON_OUTLINER_OB_LIGHTPROBE, "Light Probe", ""},
247 {OB_CAMERA, "CAMERA", ICON_OUTLINER_OB_CAMERA, "Camera", ""},
249 {OB_SPEAKER, "SPEAKER", ICON_OUTLINER_OB_SPEAKER, "Speaker", ""},
250 {0, nullptr, 0, nullptr, nullptr},
251};
252
257 {0, nullptr, 0, nullptr, nullptr},
258};
259
261 {ROT_MODE_QUAT, "QUATERNION", 0, "Quaternion (WXYZ)", "No Gimbal Lock"},
262 {ROT_MODE_XYZ, "XYZ", 0, "XYZ Euler", "XYZ Rotation Order - prone to Gimbal Lock (default)"},
263 {ROT_MODE_XZY, "XZY", 0, "XZY Euler", "XZY Rotation Order - prone to Gimbal Lock"},
264 {ROT_MODE_YXZ, "YXZ", 0, "YXZ Euler", "YXZ Rotation Order - prone to Gimbal Lock"},
265 {ROT_MODE_YZX, "YZX", 0, "YZX Euler", "YZX Rotation Order - prone to Gimbal Lock"},
266 {ROT_MODE_ZXY, "ZXY", 0, "ZXY Euler", "ZXY Rotation Order - prone to Gimbal Lock"},
267 {ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order - prone to Gimbal Lock"},
269 "AXIS_ANGLE",
270 0,
271 "Axis Angle",
272 "Axis Angle (W+XYZ), defines a rotation around some axis defined by 3D-Vector"},
273 {0, nullptr, 0, nullptr, nullptr},
274};
275
277 {OB_POSX, "POS_X", 0, "+X", ""},
278 {OB_POSY, "POS_Y", 0, "+Y", ""},
279 {OB_POSZ, "POS_Z", 0, "+Z", ""},
280 {OB_NEGX, "NEG_X", 0, "-X", ""},
281 {OB_NEGY, "NEG_Y", 0, "-Y", ""},
282 {OB_NEGZ, "NEG_Z", 0, "-Z", ""},
283 {0, nullptr, 0, nullptr, nullptr},
284};
285
286#ifdef RNA_RUNTIME
287
288# include <algorithm>
289
290# include <fmt/format.h>
291
292# include "DNA_ID.h"
293# include "DNA_constraint_types.h"
296# include "DNA_key_types.h"
297# include "DNA_lattice_types.h"
298# include "DNA_material_types.h"
299# include "DNA_node_types.h"
300
301# include "BLI_math_matrix.h"
302# include "BLI_math_vector.h"
303
304# include "BKE_armature.hh"
305# include "BKE_brush.hh"
306# include "BKE_camera.h"
307# include "BKE_collection.hh"
308# include "BKE_constraint.h"
309# include "BKE_context.hh"
310# include "BKE_curve.hh"
311# include "BKE_deform.hh"
312# include "BKE_editlattice.h"
313# include "BKE_editmesh.hh"
314# include "BKE_effect.h"
315# include "BKE_global.hh"
316# include "BKE_key.hh"
317# include "BKE_layer.hh"
318# include "BKE_library.hh"
319# include "BKE_light_linking.h"
320# include "BKE_material.hh"
321# include "BKE_mesh.hh"
322# include "BKE_mesh_wrapper.hh"
323# include "BKE_modifier.hh"
324# include "BKE_object.hh"
325# include "BKE_object_deform.h"
326# include "BKE_particle.h"
327# include "BKE_scene.hh"
328
329# include "DEG_depsgraph.hh"
330# include "DEG_depsgraph_build.hh"
331
332# include "ED_curve.hh"
333# include "ED_lattice.hh"
334# include "ED_mesh.hh"
335# include "ED_object.hh"
336# include "ED_particle.hh"
337
338# include "DEG_depsgraph_query.hh"
339
340static void rna_Object_internal_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
341{
343}
344
345static void rna_Object_internal_update_draw(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
346{
349}
350
351static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr)
352{
353 /* Don't use compatibility so we get predictable rotation. */
354 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
355 BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), false, true);
356 rna_Object_internal_update(bmain, scene, ptr);
357}
358
359static void rna_Object_hide_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
360{
361 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
366}
367
368static void rna_Object_duplicator_visibility_flag_update(Main * /*bmain*/,
369 Scene * /*scene*/,
371{
372 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
374}
375
376static void rna_grease_pencil_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
377{
378 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
379 if (ob && ob->type == OB_GREASE_PENCIL) {
380 GreasePencil *grease_pencil = static_cast<GreasePencil *>(ob->data);
381 DEG_id_tag_update(&grease_pencil->id, ID_RECALC_GEOMETRY);
383 }
384}
385
386static void rna_Object_matrix_world_get(PointerRNA *ptr, float *values)
387{
388 Object *ob = static_cast<Object *>(ptr->data);
389 std::copy_n(ob->object_to_world().base_ptr(), 16, values);
390}
391
392static void rna_Object_matrix_world_set(PointerRNA *ptr, const float *values)
393{
394 Object *ob = static_cast<Object *>(ptr->data);
395 ob->runtime->object_to_world = blender::float4x4(values);
396}
397
398static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
399{
400 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
401 BKE_object_matrix_local_get(ob, (float(*)[4])values);
402}
403
404static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])
405{
406 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
407 float local_mat[4][4];
408
409 /* Local-space matrix is truly relative to the parent,
410 * but parameters stored in object are relative to parentinv matrix.
411 * Undo the parent inverse part before applying it as local matrix. */
412 if (ob->parent) {
413 float invmat[4][4];
414 invert_m4_m4(invmat, ob->parentinv);
415 mul_m4_m4m4(local_mat, invmat, (float(*)[4])values);
416 }
417 else {
418 copy_m4_m4(local_mat, (float(*)[4])values);
419 }
420
421 /* Don't use compatible so we get predictable rotation, and do not use parenting either,
422 * because it's a local matrix! */
423 BKE_object_apply_mat4(ob, local_mat, false, false);
424}
425
426static void rna_Object_matrix_basis_get(PointerRNA *ptr, float values[16])
427{
428 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
429 BKE_object_to_mat4(ob, (float(*)[4])values);
430}
431
432static void rna_Object_matrix_basis_set(PointerRNA *ptr, const float values[16])
433{
434 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
435 BKE_object_apply_mat4(ob, (float(*)[4])values, false, false);
436}
437
438void rna_Object_internal_update_data_impl(PointerRNA *ptr)
439{
442}
443
444void rna_Object_internal_update_data(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
445{
446 rna_Object_internal_update_data_impl(ptr);
447}
448
449void rna_Object_internal_update_data_dependency(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
450{
452 rna_Object_internal_update_data_impl(ptr);
453}
454
455static void rna_Object_active_shape_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
456{
457 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
458
460 /* exit/enter editmode to get new shape */
461 switch (ob->type) {
462 case OB_MESH: {
463 Mesh *mesh = static_cast<Mesh *>(ob->data);
464 BMEditMesh *em = mesh->runtime->edit_mesh.get();
465 int select_mode = em->selectmode;
466 EDBM_mesh_load(bmain, ob);
467 EDBM_mesh_make(ob, select_mode, true);
468 em = mesh->runtime->edit_mesh.get();
469
470 DEG_id_tag_update(&mesh->id, 0);
471
473 break;
474 }
475 case OB_CURVES_LEGACY:
476 case OB_SURF:
477 ED_curve_editnurb_load(bmain, ob);
479 break;
480 case OB_LATTICE:
483 break;
484 }
485 }
486
487 rna_Object_internal_update_data_impl(ptr);
488}
489
490static void rna_Object_dependency_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
491{
495}
496
497void rna_Object_data_update(Main *bmain, Scene *scene, PointerRNA *ptr)
498{
499 rna_Object_internal_update_data_dependency(bmain, scene, ptr);
500}
501
502static PointerRNA rna_Object_data_get(PointerRNA *ptr)
503{
504 Object *ob = static_cast<Object *>(ptr->data);
505 if (ob->type == OB_MESH) {
506 Mesh *mesh = static_cast<Mesh *>(ob->data);
508 return RNA_id_pointer_create(reinterpret_cast<ID *>(mesh));
509 }
510 return RNA_id_pointer_create(reinterpret_cast<ID *>(ob->data));
511}
512
513static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value, ReportList *reports)
514{
515 Object *ob = static_cast<Object *>(ptr->data);
516 ID *id = static_cast<ID *>(value.data);
517
518 if (ob->mode & OB_MODE_EDIT) {
519 return;
520 }
521
522 /* assigning nullptr only for empties */
523 if ((id == nullptr) && (ob->type != OB_EMPTY)) {
524 return;
525 }
526
527 if (id && ((id->tag & ID_TAG_NO_MAIN) != (ob->id.tag & ID_TAG_NO_MAIN))) {
529 RPT_ERROR,
530 "Can only assign evaluated data to evaluated object, or original data to "
531 "original object");
532 return;
533 }
534
535 if (ob->type == OB_EMPTY) {
536 if (ob->data) {
537 id_us_min(static_cast<ID *>(ob->data));
538 ob->data = nullptr;
539 }
540
541 if (!id || GS(id->name) == ID_IM) {
542 id_us_plus(id);
543 ob->data = id;
544 }
545 }
546 else if (ob->type == OB_MESH) {
547 BKE_mesh_assign_object(G_MAIN, ob, reinterpret_cast<Mesh *>(id));
548 }
549 else {
550 if (ob->data) {
551 id_us_min(static_cast<ID *>(ob->data));
552 }
553
554 /* no need to type-check here ID. this is done in the _typef() function */
556 id_us_plus(id);
557
558 ob->data = id;
560
561 if (GS(id->name) == ID_CU_LEGACY) {
562 BKE_curve_type_test(ob, true);
563 }
564 else if (ob->type == OB_ARMATURE) {
565 BKE_pose_rebuild(G_MAIN, ob, static_cast<bArmature *>(ob->data), true);
566 }
567 }
568}
569
570static StructRNA *rna_Object_data_typef(PointerRNA *ptr)
571{
572 Object *ob = static_cast<Object *>(ptr->data);
573
574 /* keep in sync with OB_DATA_SUPPORT_ID() macro */
575 switch (ob->type) {
576 case OB_EMPTY:
577 return &RNA_Image;
578 case OB_MESH:
579 return &RNA_Mesh;
580 case OB_CURVES_LEGACY:
581 return &RNA_Curve;
582 case OB_SURF:
583 return &RNA_Curve;
584 case OB_FONT:
585 return &RNA_Curve;
586 case OB_MBALL:
587 return &RNA_MetaBall;
588 case OB_LAMP:
589 return &RNA_Light;
590 case OB_CAMERA:
591 return &RNA_Camera;
592 case OB_LATTICE:
593 return &RNA_Lattice;
594 case OB_ARMATURE:
595 return &RNA_Armature;
596 case OB_SPEAKER:
597 return &RNA_Speaker;
598 case OB_LIGHTPROBE:
599 return &RNA_LightProbe;
601 return &RNA_GreasePencil;
602 case OB_GREASE_PENCIL:
603 return &RNA_GreasePencilv3;
604 case OB_CURVES:
605 return &RNA_Curves;
606 case OB_POINTCLOUD:
607 return &RNA_PointCloud;
608 case OB_VOLUME:
609 return &RNA_Volume;
610 default:
611 return &RNA_ID;
612 }
613}
614
615static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value, ReportList * /*reports*/)
616{
617 Object *ob = static_cast<Object *>(ptr->data);
618 Object *par = static_cast<Object *>(value.data);
619
620 {
622 }
623}
624
625static bool rna_Object_parent_override_apply(Main *bmain,
627{
628 PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
629 PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
630 PointerRNA *ptr_storage = &rnaapply_ctx.ptr_storage;
631 PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
632 PropertyRNA *prop_src = rnaapply_ctx.prop_src;
633 const int len_dst = rnaapply_ctx.len_src;
634 const int len_src = rnaapply_ctx.len_src;
635 const int len_storage = rnaapply_ctx.len_storage;
637
638 BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0);
640 "Unsupported RNA override operation on object parent pointer");
641 UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop);
642
643 /* We need a special handling here because setting parent resets invert parent matrix,
644 * which is evil in our case. */
645 Object *ob = static_cast<Object *>(ptr_dst->data);
646 Object *parent_dst = static_cast<Object *>(RNA_property_pointer_get(ptr_dst, prop_dst).data);
647 Object *parent_src = static_cast<Object *>(RNA_property_pointer_get(ptr_src, prop_src).data);
648
649 if (parent_src == parent_dst) {
650 return false;
651 }
652
653 if (parent_src == nullptr) {
654 /* The only case where we do want default behavior (with matrix reset). */
655 blender::ed::object::parent_set(ob, parent_src, ob->partype, ob->parsubstr);
656 }
657 else {
658 ob->parent = parent_src;
659 }
660 RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
661 return true;
662}
663
664static void rna_Object_parent_type_set(PointerRNA *ptr, int value)
665{
666 Object *ob = static_cast<Object *>(ptr->data);
667
668 /* Skip if type did not change (otherwise we loose parent inverse in
669 * blender::ed::object::parent_set). */
670 if (ob->partype == value) {
671 return;
672 }
673
675}
676
677static bool rna_Object_parent_type_override_apply(Main *bmain,
679{
680 PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
681 PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
682 PointerRNA *ptr_storage = &rnaapply_ctx.ptr_storage;
683 PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
684 PropertyRNA *prop_src = rnaapply_ctx.prop_src;
685 const int len_dst = rnaapply_ctx.len_src;
686 const int len_src = rnaapply_ctx.len_src;
687 const int len_storage = rnaapply_ctx.len_storage;
689
690 BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0);
692 "Unsupported RNA override operation on object parent pointer");
693 UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop);
694
695 /* We need a special handling here because setting parent resets invert parent matrix,
696 * which is evil in our case. */
697 Object *ob = (Object *)(ptr_dst->data);
698 const int parent_type_dst = RNA_property_enum_get(ptr_dst, prop_dst);
699 const int parent_type_src = RNA_property_enum_get(ptr_src, prop_src);
700
701 if (parent_type_dst == parent_type_src) {
702 return false;
703 }
704
705 ob->partype = parent_type_src;
706 RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
707 return true;
708}
709
710static const EnumPropertyItem *rna_Object_parent_type_itemf(bContext * /*C*/,
712 PropertyRNA * /*prop*/,
713 bool *r_free)
714{
715 Object *ob = static_cast<Object *>(ptr->data);
716 EnumPropertyItem *item = nullptr;
717 int totitem = 0;
718
720
721 if (ob->parent) {
722 Object *par = ob->parent;
723
724 if (par->type == OB_LATTICE) {
725 /* special hack: prevents this overriding others */
727 }
728 else if (par->type == OB_ARMATURE) {
729 /* special hack: prevents this being overridden */
732 }
733
734 if (OB_TYPE_SUPPORT_PARVERT(par->type)) {
737 }
738 }
739
740 RNA_enum_item_end(&item, &totitem);
741 *r_free = true;
742
743 return item;
744}
745
746static void rna_Object_empty_display_type_set(PointerRNA *ptr, int value)
747{
748 Object *ob = static_cast<Object *>(ptr->data);
749
751}
752
753static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value)
754{
755 Object *ob = static_cast<Object *>(ptr->data);
756
758}
759
760static bool rna_Object_parent_bone_override_apply(Main *bmain,
762{
763 PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
764 PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
765 PointerRNA *ptr_storage = &rnaapply_ctx.ptr_storage;
766 PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
767 PropertyRNA *prop_src = rnaapply_ctx.prop_src;
768 const int len_dst = rnaapply_ctx.len_src;
769 const int len_src = rnaapply_ctx.len_src;
770 const int len_storage = rnaapply_ctx.len_storage;
772
773 BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0);
775 "Unsupported RNA override operation on object parent bone property");
776 UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop);
777
778 /* We need a special handling here because setting parent resets invert parent matrix,
779 * which is evil in our case. */
780 Object *ob = (Object *)(ptr_dst->data);
781 char parent_bone_dst[MAX_ID_NAME - 2];
782 RNA_property_string_get(ptr_dst, prop_dst, parent_bone_dst);
783 char parent_bone_src[MAX_ID_NAME - 2];
784 RNA_property_string_get(ptr_src, prop_src, parent_bone_src);
785
786 if (STREQ(parent_bone_src, parent_bone_dst)) {
787 return false;
788 }
789
790 STRNCPY(ob->parsubstr, parent_bone_src);
791 RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
792 return true;
793}
794
795static const EnumPropertyItem *rna_Object_instance_type_itemf(bContext * /*C*/,
797 PropertyRNA * /*prop*/,
798 bool * /*r_free*/)
799{
800 Object *ob = static_cast<Object *>(ptr->data);
801 const EnumPropertyItem *item;
802
803 if (ob->type == OB_EMPTY) {
804 item = instance_items_empty;
805 }
806 else if (ob->type == OB_FONT) {
807 item = instance_items_font;
808 }
809 else {
810 item = instance_items_nogroup;
811 }
812
813 return item;
814}
815
816static void rna_Object_dup_collection_set(PointerRNA *ptr,
817 PointerRNA value,
818 ReportList * /*reports*/)
819{
820 Object *ob = static_cast<Object *>(ptr->data);
821 Collection *grp = static_cast<Collection *>(value.data);
822
823 /* Must not let this be set if the object belongs in this group already,
824 * thus causing a cycle/infinite-recursion leading to crashes on load #25298. */
825 if (BKE_collection_has_object_recursive(grp, ob) == 0) {
826 if (ob->type == OB_EMPTY) {
828 ob->instance_collection = grp;
830 }
831 else {
832 BKE_report(nullptr, RPT_ERROR, "Only empty objects support collection instances");
833 }
834 }
835 else {
837 nullptr,
838 RPT_ERROR,
839 "Cannot set instance-collection as object belongs in collection being instanced, thus "
840 "causing a cycle");
841 }
842}
843
844static void rna_Object_vertex_groups_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
845{
846 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
848 rna_Object_internal_update_data_impl(ptr);
849}
850
851static void rna_Object_vertex_groups_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
852{
853 Object *ob = static_cast<Object *>(ptr->data);
855 iter->valid = 0;
856 return;
857 }
858
860 iter->valid = defbase != nullptr;
861
862 rna_iterator_listbase_begin(iter, ptr, defbase, nullptr);
863}
864
865static void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
866{
867 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
869 return;
870 }
871
872 bDeformGroup *dg = static_cast<bDeformGroup *>(ptr->data);
873 BKE_object_defgroup_set_name(dg, ob, value);
874}
875
876static int rna_VertexGroup_index_get(PointerRNA *ptr)
877{
878 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
880 return -1;
881 }
882
883 const ListBase *defbase = BKE_object_defgroup_list(ob);
884 return BLI_findindex(defbase, ptr->data);
885}
886
887static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr)
888{
889 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
891 return PointerRNA_NULL;
892 }
893
894 const ListBase *defbase = BKE_object_defgroup_list(ob);
895
897 *ptr, &RNA_VertexGroup, BLI_findlink(defbase, BKE_object_defgroup_active_index_get(ob) - 1));
898}
899
900static void rna_Object_active_vertex_group_set(PointerRNA *ptr,
901 PointerRNA value,
903{
904 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
906 return;
907 }
908
909 const ListBase *defbase = BKE_object_defgroup_list(ob);
910
911 int index = BLI_findindex(defbase, value.data);
912 if (index == -1) {
914 RPT_ERROR,
915 "VertexGroup '%s' not found in object '%s'",
916 (static_cast<bDeformGroup *>(value.data))->name,
917 ob->id.name + 2);
918 return;
919 }
920
922}
923
924static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr)
925{
926 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
928 return -1;
929 }
930
932}
933
934static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value)
935{
936 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
938 return;
939 }
940
942}
943
944static void rna_Object_active_vertex_group_index_range(
945 PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
946{
947 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
948
949 *min = 0;
951 *max = 0;
952 return;
953 }
954 const ListBase *defbase = BKE_object_defgroup_list(ob);
955 *max = max_ii(0, BLI_listbase_count(defbase) - 1);
956}
957
958void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
959{
960 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
962 value[0] = '\0';
963 return;
964 }
965
966 const ListBase *defbase = BKE_object_defgroup_list(ob);
967 const bDeformGroup *dg = static_cast<bDeformGroup *>(BLI_findlink(defbase, index - 1));
968
969 if (dg) {
970 strcpy(value, dg->name);
971 }
972 else {
973 value[0] = '\0';
974 }
975}
976
978{
979 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
981 return 0;
982 }
983
984 const ListBase *defbase = BKE_object_defgroup_list(ob);
985 bDeformGroup *dg = static_cast<bDeformGroup *>(BLI_findlink(defbase, index - 1));
986 return (dg) ? strlen(dg->name) : 0;
987}
988
989void rna_object_vgroup_name_index_set(PointerRNA *ptr, const char *value, short *index)
990{
991 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
993 *index = -1;
994 return;
995 }
996
997 *index = BKE_object_defgroup_name_index(ob, value) + 1;
998}
999
1001 const char *value,
1002 char *result,
1003 int result_maxncpy)
1004{
1005 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1007 result[0] = '\0';
1008 return;
1009 }
1010
1012 if (dg) {
1013 /* No need for BLI_strncpy_utf8, since this matches an existing group. */
1014 BLI_strncpy(result, value, result_maxncpy);
1015 return;
1016 }
1017
1018 result[0] = '\0';
1019}
1020
1022 const char *value,
1023 char *result,
1024 int result_maxncpy)
1025{
1026 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1027 Mesh *mesh;
1028 CustomDataLayer *layer;
1029 int a;
1030
1031 if (ob->type == OB_MESH && ob->data) {
1032 mesh = static_cast<Mesh *>(ob->data);
1033
1034 for (a = 0; a < mesh->corner_data.totlayer; a++) {
1035 layer = &mesh->corner_data.layers[a];
1036
1037 if (layer->type == CD_PROP_FLOAT2 && STREQ(layer->name, value)) {
1038 BLI_strncpy(result, value, result_maxncpy);
1039 return;
1040 }
1041 }
1042 }
1043
1044 result[0] = '\0';
1045}
1046
1048 const char *value,
1049 char *result,
1050 int result_maxncpy)
1051{
1052 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1053 Mesh *mesh;
1054 CustomDataLayer *layer;
1055 int a;
1056
1057 if (ob->type == OB_MESH && ob->data) {
1058 mesh = static_cast<Mesh *>(ob->data);
1059
1060 for (a = 0; a < mesh->fdata_legacy.totlayer; a++) {
1061 layer = &mesh->fdata_legacy.layers[a];
1062
1063 if (layer->type == CD_MCOL && STREQ(layer->name, value)) {
1064 BLI_strncpy(result, value, result_maxncpy);
1065 return;
1066 }
1067 }
1068 }
1069
1070 result[0] = '\0';
1071}
1072
1073static int rna_Object_active_material_index_get(PointerRNA *ptr)
1074{
1075 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1076 return std::max<int>(ob->actcol - 1, 0);
1077}
1078
1079static void rna_Object_active_material_index_set(PointerRNA *ptr, int value)
1080{
1081 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1082
1083 value = std::max(std::min(value, ob->totcol - 1), 0);
1084 ob->actcol = value + 1;
1085
1086 if (ob->type == OB_MESH) {
1087 Mesh *mesh = static_cast<Mesh *>(ob->data);
1088
1089 if (mesh->runtime->edit_mesh) {
1090 mesh->runtime->edit_mesh->mat_nr = value;
1091 }
1092 }
1093}
1094
1095static void rna_Object_active_material_index_range(
1096 PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
1097{
1098 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1099 *min = 0;
1100 *max = max_ii(ob->totcol - 1, 0);
1101}
1102
1103/* returns active base material */
1104static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
1105{
1106 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1107 Material *ma;
1108
1109 ma = (ob->totcol) ? BKE_object_material_get(ob, ob->actcol) : nullptr;
1110 return RNA_id_pointer_create(reinterpret_cast<ID *>(ma));
1111}
1112
1113static void rna_Object_active_material_set(PointerRNA *ptr,
1114 PointerRNA value,
1115 ReportList * /*reports*/)
1116{
1117 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1118
1119 DEG_id_tag_update(static_cast<ID *>(value.data), 0);
1121 BLI_assert(BKE_id_is_in_global_main(static_cast<ID *>(value.data)));
1123 G_MAIN, ob, static_cast<Material *>(value.data), ob->actcol, BKE_MAT_ASSIGN_EXISTING);
1124}
1125
1126static int rna_Object_active_material_editable(const PointerRNA *ptr, const char ** /*r_info*/)
1127{
1128 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1129 bool is_editable;
1130
1131 if ((ob->matbits == nullptr) || (ob->actcol == 0) || ob->matbits[ob->actcol - 1]) {
1132 is_editable = ID_IS_EDITABLE(ob);
1133 }
1134 else {
1135 is_editable = ob->data ? ID_IS_EDITABLE(ob->data) : false;
1136 }
1137
1138 return is_editable ? int(PROP_EDITABLE) : 0;
1139}
1140
1141static void rna_Object_active_particle_system_index_range(
1142 PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
1143{
1144 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1145 *min = 0;
1147}
1148
1149static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
1150{
1151 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1152 return psys_get_current_num(ob);
1153}
1154
1155static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int value)
1156{
1157 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1158 psys_set_current_num(ob, value);
1159}
1160
1161static void rna_Object_particle_update(Main * /*bmain*/, Scene *scene, PointerRNA *ptr)
1162{
1163 /* TODO: Disabled for now, because bContext is not available. */
1164# if 0
1165 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1166 PE_current_changed(nullptr, scene, ob);
1167# else
1168 (void)scene;
1169 (void)ptr;
1170# endif
1171}
1172
1173/* rotation - axis-angle */
1174static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value)
1175{
1176 Object *ob = static_cast<Object *>(ptr->data);
1177
1178 /* for now, assume that rotation mode is axis-angle */
1179 value[0] = ob->rotAngle;
1180 copy_v3_v3(&value[1], ob->rotAxis);
1181}
1182
1183/* rotation - axis-angle */
1184static void rna_Object_rotation_axis_angle_set(PointerRNA *ptr, const float *value)
1185{
1186 Object *ob = static_cast<Object *>(ptr->data);
1187
1188 /* for now, assume that rotation mode is axis-angle */
1189 ob->rotAngle = value[0];
1190 copy_v3_v3(ob->rotAxis, &value[1]);
1191
1192 /* TODO: validate axis? */
1193}
1194
1195static void rna_Object_rotation_mode_set(PointerRNA *ptr, int value)
1196{
1197 Object *ob = static_cast<Object *>(ptr->data);
1198
1199 /* use API Method for conversions... */
1201 ob->quat, ob->rot, ob->rotAxis, &ob->rotAngle, ob->rotmode, short(value));
1202
1203 /* finally, set the new rotation type */
1204 ob->rotmode = value;
1205}
1206
1207static void rna_Object_dimensions_get(PointerRNA *ptr, float *value)
1208{
1209 Object *ob = static_cast<Object *>(ptr->data);
1211}
1212
1213static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value)
1214{
1215 Object *ob = static_cast<Object *>(ptr->data);
1216 BKE_object_dimensions_set(ob, value, 0);
1217}
1218
1219static int rna_Object_location_editable(const PointerRNA *ptr, int index)
1220{
1221 Object *ob = static_cast<Object *>(ptr->data);
1222
1223 /* only if the axis in question is locked, not editable... */
1224 if ((index == 0) && (ob->protectflag & OB_LOCK_LOCX)) {
1225 return 0;
1226 }
1227 else if ((index == 1) && (ob->protectflag & OB_LOCK_LOCY)) {
1228 return 0;
1229 }
1230 else if ((index == 2) && (ob->protectflag & OB_LOCK_LOCZ)) {
1231 return 0;
1232 }
1233 else {
1234 return PROP_EDITABLE;
1235 }
1236}
1237
1238static int rna_Object_scale_editable(const PointerRNA *ptr, int index)
1239{
1240 Object *ob = static_cast<Object *>(ptr->data);
1241
1242 /* only if the axis in question is locked, not editable... */
1243 if ((index == 0) && (ob->protectflag & OB_LOCK_SCALEX)) {
1244 return 0;
1245 }
1246 else if ((index == 1) && (ob->protectflag & OB_LOCK_SCALEY)) {
1247 return 0;
1248 }
1249 else if ((index == 2) && (ob->protectflag & OB_LOCK_SCALEZ)) {
1250 return 0;
1251 }
1252 else {
1253 return PROP_EDITABLE;
1254 }
1255}
1256
1257static int rna_Object_rotation_euler_editable(const PointerRNA *ptr, int index)
1258{
1259 Object *ob = static_cast<Object *>(ptr->data);
1260
1261 /* only if the axis in question is locked, not editable... */
1262 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTX)) {
1263 return 0;
1264 }
1265 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTY)) {
1266 return 0;
1267 }
1268 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTZ)) {
1269 return 0;
1270 }
1271 else {
1272 return PROP_EDITABLE;
1273 }
1274}
1275
1276static int rna_Object_rotation_4d_editable(const PointerRNA *ptr, int index)
1277{
1278 Object *ob = static_cast<Object *>(ptr->data);
1279
1280 /* only consider locks if locking components individually... */
1281 if (ob->protectflag & OB_LOCK_ROT4D) {
1282 /* only if the axis in question is locked, not editable... */
1283 if ((index == 0) && (ob->protectflag & OB_LOCK_ROTW)) {
1284 return 0;
1285 }
1286 else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTX)) {
1287 return 0;
1288 }
1289 else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTY)) {
1290 return 0;
1291 }
1292 else if ((index == 3) && (ob->protectflag & OB_LOCK_ROTZ)) {
1293 return 0;
1294 }
1295 }
1296
1297 return PROP_EDITABLE;
1298}
1299
1300static int rna_MaterialSlot_index(const PointerRNA *ptr)
1301{
1302 /* There is an offset, so that `ptr->data` is not null and unique across IDs. */
1303 return uintptr_t(ptr->data) - uintptr_t(ptr->owner_id);
1304}
1305
1306static int rna_MaterialSlot_index_get(PointerRNA *ptr)
1307{
1308 return rna_MaterialSlot_index(ptr);
1309}
1310
1311static int rna_MaterialSlot_material_editable(const PointerRNA *ptr, const char ** /*r_info*/)
1312{
1313 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1314 const int index = rna_MaterialSlot_index(ptr);
1315 bool is_editable;
1316
1317 if ((ob->matbits == nullptr) || ob->matbits[index]) {
1318 is_editable = ID_IS_EDITABLE(ob);
1319 }
1320 else {
1321 is_editable = ob->data ? ID_IS_EDITABLE(ob->data) : false;
1322 }
1323
1324 return is_editable ? int(PROP_EDITABLE) : 0;
1325}
1326
1327static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr)
1328{
1329 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1330 Material *ma;
1331 const int index = rna_MaterialSlot_index(ptr);
1332
1333 if (DEG_is_evaluated(ob)) {
1334 ma = BKE_object_material_get_eval(ob, index + 1);
1335 }
1336 else {
1337 ma = BKE_object_material_get(ob, index + 1);
1338 }
1339 return RNA_id_pointer_create(reinterpret_cast<ID *>(ma));
1340}
1341
1342static void rna_MaterialSlot_material_set(PointerRNA *ptr,
1343 PointerRNA value,
1344 ReportList * /*reports*/)
1345{
1346 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1347 int index = rna_MaterialSlot_index(ptr);
1348
1350 BLI_assert(BKE_id_is_in_global_main(static_cast<ID *>(value.data)));
1352 G_MAIN, ob, static_cast<Material *>(value.data), index + 1, BKE_MAT_ASSIGN_EXISTING);
1353}
1354
1355static bool rna_MaterialSlot_material_poll(PointerRNA *ptr, PointerRNA value)
1356{
1357 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1358 Material *ma = static_cast<Material *>(value.data);
1359
1360 if (ELEM(ob->type, OB_GREASE_PENCIL)) {
1361 /* GP Materials only */
1362 return (ma->gp_style != nullptr);
1363 }
1364 else {
1365 /* Everything except GP materials */
1366 return (ma->gp_style == nullptr);
1367 }
1368}
1369
1370static int rna_MaterialSlot_link_get(PointerRNA *ptr)
1371{
1372 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1373 int index = rna_MaterialSlot_index(ptr);
1374 if (index < ob->totcol) {
1375 return ob->matbits[index] != 0;
1376 }
1377 return false;
1378}
1379
1380static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value)
1381{
1382 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1383 int index = rna_MaterialSlot_index(ptr);
1384
1385 if (value) {
1386 ob->matbits[index] = 1;
1387 /* DEPRECATED */
1388 // ob->colbits |= (1 << index);
1389 }
1390 else {
1391 ob->matbits[index] = 0;
1392 /* DEPRECATED */
1393 // ob->colbits &= ~(1 << index);
1394 }
1395}
1396
1397static int rna_MaterialSlot_name_length(PointerRNA *ptr)
1398{
1399 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1400 Material *ma;
1401 int index = rna_MaterialSlot_index(ptr);
1402
1403 ma = BKE_object_material_get(ob, index + 1);
1404
1405 if (ma) {
1406 return strlen(ma->id.name + 2);
1407 }
1408
1409 return 0;
1410}
1411
1412static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *value)
1413{
1414 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1415 Material *ma;
1416 int index = rna_MaterialSlot_index(ptr);
1417
1418 ma = BKE_object_material_get(ob, index + 1);
1419
1420 if (ma) {
1421 strcpy(value, ma->id.name + 2);
1422 }
1423 else {
1424 value[0] = '\0';
1425 }
1426}
1427
1428static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr)
1429{
1430 rna_Object_internal_update(bmain, scene, ptr);
1431
1435}
1436
1437static std::optional<std::string> rna_MaterialSlot_path(const PointerRNA *ptr)
1438{
1439 int index = rna_MaterialSlot_index(ptr);
1440 return fmt::format("material_slots[{}]", index);
1441}
1442
1443static int rna_Object_material_slots_length(PointerRNA *ptr)
1444{
1445 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1446 if (DEG_is_evaluated(ob)) {
1448 }
1449 else {
1450 return ob->totcol;
1451 }
1452}
1453
1454static void rna_Object_material_slots_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
1455{
1456 const int length = rna_Object_material_slots_length(ptr);
1457 iter->parent = *ptr;
1458 iter->internal.count.item = 0;
1459 iter->internal.count.ptr = ptr->owner_id;
1460 iter->valid = length > 0;
1461}
1462
1463static void rna_Object_material_slots_next(CollectionPropertyIterator *iter)
1464{
1465 const int length = rna_Object_material_slots_length(&iter->ptr);
1466 iter->internal.count.item++;
1467 iter->valid = iter->internal.count.item < length;
1468}
1469
1470static PointerRNA rna_Object_material_slots_get(CollectionPropertyIterator *iter)
1471{
1472 ID *id = static_cast<ID *>(iter->internal.count.ptr);
1474 iter->parent,
1475 &RNA_MaterialSlot,
1476 /* Add offset, so that `ptr->data` is not null and unique across IDs. */
1477 (void *)(iter->internal.count.item + uintptr_t(id)));
1478 return ptr;
1479}
1480
1481static void rna_Object_material_slots_end(CollectionPropertyIterator * /*iter*/) {}
1482
1483static PointerRNA rna_Object_display_get(PointerRNA *ptr)
1484{
1485 return RNA_pointer_create_with_parent(*ptr, &RNA_ObjectDisplay, ptr->data);
1486}
1487
1488static std::optional<std::string> rna_ObjectDisplay_path(const PointerRNA * /*ptr*/)
1489{
1490 return "display";
1491}
1492
1493static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr)
1494{
1495 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1496 ParticleSystem *psys = psys_get_current(ob);
1497 return RNA_pointer_create_with_parent(*ptr, &RNA_ParticleSystem, psys);
1498}
1499
1500static void rna_Object_active_shape_key_index_range(
1501 PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
1502{
1503 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1504 Key *key = BKE_key_from_object(ob);
1505
1506 *min = 0;
1507 if (key) {
1508 *max = BLI_listbase_count(&key->block) - 1;
1509 if (*max < 0) {
1510 *max = 0;
1511 }
1512 }
1513 else {
1514 *max = 0;
1515 }
1516}
1517
1518static int rna_Object_active_shape_key_index_get(PointerRNA *ptr)
1519{
1520 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1521
1522 return std::max<int>(ob->shapenr - 1, 0);
1523}
1524
1525static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value)
1526{
1527 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1528
1529 ob->shapenr = value + 1;
1530}
1531
1532static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr)
1533{
1534 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1535 Key *key = BKE_key_from_object(ob);
1536 KeyBlock *kb;
1537
1538 if (key == nullptr) {
1539 return PointerRNA_NULL;
1540 }
1541
1542 kb = static_cast<KeyBlock *>(BLI_findlink(&key->block, ob->shapenr - 1));
1543 PointerRNA keyptr = RNA_pointer_create_discrete(reinterpret_cast<ID *>(key), &RNA_ShapeKey, kb);
1544 return keyptr;
1545}
1546
1547static PointerRNA rna_Object_field_get(PointerRNA *ptr)
1548{
1549 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1550
1551 return RNA_pointer_create_with_parent(*ptr, &RNA_FieldSettings, ob->pd);
1552}
1553
1554static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
1555{
1556 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1557
1558 if (ob->type != OB_MESH) {
1559 return PointerRNA_NULL;
1560 }
1561
1562 return RNA_pointer_create_with_parent(*ptr, &RNA_CollisionSettings, ob->pd);
1563}
1564
1565static PointerRNA rna_Object_active_constraint_get(PointerRNA *ptr)
1566{
1567 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1569 return RNA_pointer_create_with_parent(*ptr, &RNA_Constraint, con);
1570}
1571
1572static void rna_Object_active_constraint_set(PointerRNA *ptr,
1573 PointerRNA value,
1574 ReportList * /*reports*/)
1575{
1576 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1577 BKE_constraints_active_set(&ob->constraints, static_cast<bConstraint *>(value.data));
1578}
1579
1580static bConstraint *rna_Object_constraints_new(Object *object, Main *bmain, int type)
1581{
1582 bConstraint *new_con = BKE_constraint_add_for_object(object, nullptr, type);
1583
1584 blender::ed::object::constraint_tag_update(bmain, object, new_con);
1586
1587 /* The Depsgraph needs to be updated to reflect the new relationship that was added. */
1589
1590 return new_con;
1591}
1592
1593static void rna_Object_constraints_remove(Object *object,
1594 Main *bmain,
1596 PointerRNA *con_ptr)
1597{
1598 bConstraint *con = static_cast<bConstraint *>(con_ptr->data);
1599 if (BLI_findindex(&object->constraints, con) == -1) {
1601 RPT_ERROR,
1602 "Constraint '%s' not found in object '%s'",
1603 con->name,
1604 object->id.name + 2);
1605 return;
1606 }
1607
1608 BKE_constraint_remove_ex(&object->constraints, object, con);
1609 con_ptr->invalidate();
1610
1614}
1615
1616static void rna_Object_constraints_clear(Object *object, Main *bmain)
1617{
1619
1622
1624}
1625
1626static void rna_Object_constraints_move(
1627 Object *object, Main *bmain, ReportList *reports, int from, int to)
1628{
1629 if (from == to) {
1630 return;
1631 }
1632
1633 if (!BLI_listbase_move_index(&object->constraints, from, to)) {
1634 BKE_reportf(reports, RPT_ERROR, "Could not move constraint from index '%d' to '%d'", from, to);
1635 return;
1636 }
1637
1638 blender::ed::object::constraint_tag_update(bmain, object, nullptr);
1640}
1641
1642static bConstraint *rna_Object_constraints_copy(Object *object, Main *bmain, PointerRNA *con_ptr)
1643{
1644 bConstraint *con = static_cast<bConstraint *>(con_ptr->data);
1645 bConstraint *new_con = BKE_constraint_copy_for_object(object, con);
1647
1648 blender::ed::object::constraint_tag_update(bmain, object, new_con);
1650
1651 return new_con;
1652}
1653
1654bool rna_Object_constraints_override_apply(Main *bmain,
1655 RNAPropertyOverrideApplyContext &rnaapply_ctx)
1656{
1657 PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
1658 PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
1659 PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
1661
1663 "Unsupported RNA override operation on constraints collection");
1664
1665 Object *ob_dst = reinterpret_cast<Object *>(ptr_dst->owner_id);
1666 Object *ob_src = reinterpret_cast<Object *>(ptr_src->owner_id);
1667
1668 /* Remember that insertion operations are defined and stored in correct order, which means that
1669 * even if we insert several items in a row, we always insert first one, then second one, etc.
1670 * So we should always find 'anchor' constraint in both _src *and* _dst. */
1671 const size_t name_offset = offsetof(bConstraint, name);
1672 bConstraint *con_anchor = static_cast<bConstraint *>(
1675 name_offset,
1677 /* If `con_anchor` is nullptr, `con_src` will be inserted in first position. */
1678
1680 &ob_src->constraints, opop->subitem_local_name, name_offset, opop->subitem_local_index));
1681
1682 if (con_src == nullptr) {
1683 BLI_assert(con_src != nullptr);
1684 return false;
1685 }
1686
1687 bConstraint *con_dst = BKE_constraint_duplicate_ex(con_src, 0, true);
1688
1689 /* This handles nullptr anchor as expected by adding at head of list. */
1690 BLI_insertlinkafter(&ob_dst->constraints, con_anchor, con_dst);
1691
1692 /* This should actually *not* be needed in typical cases.
1693 * However, if overridden source was edited, we *may* have some new conflicting names. */
1694 BKE_constraint_unique_name(con_dst, &ob_dst->constraints);
1695
1696 // printf("%s: We inserted a constraint...\n", __func__);
1697 RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
1698 return true;
1699}
1700
1701static ModifierData *rna_Object_modifier_new(
1702 Object *object, bContext *C, ReportList *reports, const char *name, int type)
1703{
1705 reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
1706
1708
1709 return md;
1710}
1711
1712static void rna_Object_modifier_remove(Object *object,
1713 bContext *C,
1715 PointerRNA *md_ptr)
1716{
1717 ModifierData *md = static_cast<ModifierData *>(md_ptr->data);
1719 reports, CTX_data_main(C), CTX_data_scene(C), object, md) == false)
1720 {
1721 /* error is already set */
1722 return;
1723 }
1724
1725 md_ptr->invalidate();
1726
1728}
1729
1730static void rna_Object_modifier_clear(Object *object, bContext *C)
1731{
1733
1735}
1736
1737static void rna_Object_modifier_move(Object *object, ReportList *reports, int from, int to)
1738{
1739 ModifierData *md = static_cast<ModifierData *>(BLI_findlink(&object->modifiers, from));
1740
1741 if (!md) {
1742 BKE_reportf(reports, RPT_ERROR, "Invalid original modifier index '%d'", from);
1743 return;
1744 }
1745
1747}
1748
1749static PointerRNA rna_Object_active_modifier_get(PointerRNA *ptr)
1750{
1751 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1753 return RNA_pointer_create_with_parent(*ptr, &RNA_Modifier, md);
1754}
1755
1756static void rna_Object_active_modifier_set(PointerRNA *ptr, PointerRNA value, ReportList *reports)
1757{
1758 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1759 ModifierData *md = static_cast<ModifierData *>(value.data);
1760
1762
1763 if (RNA_pointer_is_null(&value)) {
1764 BKE_object_modifier_set_active(ob, nullptr);
1765 return;
1766 }
1767
1768 if (BLI_findindex(&ob->modifiers, md) == -1) {
1770 reports, RPT_ERROR, "Modifier \"%s\" is not in the object's modifier list", md->name);
1771 return;
1772 }
1773
1775}
1776
1777bool rna_Object_modifiers_override_apply(Main *bmain,
1778 RNAPropertyOverrideApplyContext &rnaapply_ctx)
1779{
1780 PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
1781 PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
1782 PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
1784
1786 "Unsupported RNA override operation on modifiers collection");
1787
1788 Object *ob_dst = reinterpret_cast<Object *>(ptr_dst->owner_id);
1789 Object *ob_src = reinterpret_cast<Object *>(ptr_src->owner_id);
1790
1791 /* Remember that insertion operations are defined and stored in correct order, which means that
1792 * even if we insert several items in a row, we always insert first one, then second one, etc.
1793 * So we should always find 'anchor' modifier in both _src *and* _dst. */
1794 const size_t name_offset = offsetof(ModifierData, name);
1795 ModifierData *mod_anchor = static_cast<ModifierData *>(
1798 name_offset,
1800 /* If `mod_anchor` is nullptr, `mod_src` will be inserted in first position. */
1801
1803 &ob_src->modifiers, opop->subitem_local_name, name_offset, opop->subitem_local_index));
1804
1805 if (mod_src == nullptr) {
1806 BLI_assert(mod_src != nullptr);
1807 return false;
1808 }
1809
1810 /* While it would be nicer to use lower-level BKE_modifier_new() here, this one is lacking
1811 * special-cases handling (particles and other physics modifiers mostly), so using the ED version
1812 * instead, to avoid duplicating code. */
1814 nullptr, bmain, nullptr, ob_dst, mod_src->name, mod_src->type);
1815
1816 if (mod_dst == nullptr) {
1817 /* This can happen e.g. when a modifier type is tagged as `eModifierTypeFlag_Single`, and that
1818 * modifier has somehow been added already by another code path (e.g.
1819 * `rna_CollisionSettings_dependency_update` does add the `eModifierType_Collision` singleton
1820 * modifier).
1821 *
1822 * Try to handle this by finding already existing one here. */
1824 if (mti->flags & eModifierTypeFlag_Single) {
1825 mod_dst = BKE_modifiers_findby_type(ob_dst, (ModifierType)mod_src->type);
1826 }
1827
1828 if (mod_dst == nullptr) {
1829 BLI_assert(mod_src != nullptr);
1830 return false;
1831 }
1832 }
1833
1834 /* XXX Current handling of 'copy' from particle-system modifier is *very* bad (it keeps same psys
1835 * pointer as source, then calling code copies psys of object separately and do some magic
1836 * remapping of pointers...), unfortunately several pieces of code in Object editing area rely on
1837 * this behavior. So for now, hacking around it to get it doing what we want it to do, as getting
1838 * a proper behavior would be everything but trivial, and this whole particle thingy is
1839 * end-of-life. */
1840 ParticleSystem *psys_dst = (mod_dst->type == eModifierType_ParticleSystem) ?
1841 (reinterpret_cast<ParticleSystemModifierData *>(mod_dst))->psys :
1842 nullptr;
1843 const int persistent_uid = mod_dst->persistent_uid;
1844 BKE_modifier_copydata(mod_src, mod_dst);
1845 mod_dst->persistent_uid = persistent_uid;
1846 if (mod_dst->type == eModifierType_ParticleSystem) {
1847 psys_dst->flag &= ~PSYS_DELETE;
1848 (reinterpret_cast<ParticleSystemModifierData *>(mod_dst))->psys = psys_dst;
1849 }
1850
1851 BLI_remlink(&ob_dst->modifiers, mod_dst);
1852 /* This handles nullptr anchor as expected by adding at head of list. */
1853 BLI_insertlinkafter(&ob_dst->modifiers, mod_anchor, mod_dst);
1854
1855 // printf("%s: We inserted a modifier '%s'...\n", __func__, mod_dst->name);
1856 RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
1857 return true;
1858}
1859
1860/* shader fx */
1861static ShaderFxData *rna_Object_shaderfx_new(
1862 Object *object, bContext *C, ReportList *reports, const char *name, int type)
1863{
1865 reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
1866}
1867
1868static void rna_Object_shaderfx_remove(Object *object,
1869 bContext *C,
1871 PointerRNA *gmd_ptr)
1872{
1873 ShaderFxData *gmd = static_cast<ShaderFxData *>(gmd_ptr->data);
1874 if (blender::ed::object::shaderfx_remove(reports, CTX_data_main(C), object, gmd) == false) {
1875 /* error is already set */
1876 return;
1877 }
1878
1879 gmd_ptr->invalidate();
1880
1882}
1883
1884static void rna_Object_shaderfx_clear(Object *object, bContext *C)
1885{
1888}
1889
1890static void rna_Object_boundbox_get(PointerRNA *ptr, float *values)
1891{
1892 using namespace blender;
1893 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
1894 if (const std::optional<Bounds<float3>> bounds = BKE_object_boundbox_eval_cached_get(ob)) {
1895 BoundBox bb;
1897 memcpy(values, bb.vec, sizeof(bb.vec));
1898 }
1899 else {
1900 copy_vn_fl(values, 8 * 3, 0.0f);
1901 }
1902}
1903
1904static bool check_object_vgroup_support_and_warn(const Object *ob,
1905 const char *op_name,
1907{
1909 const char *ob_type_name = "Unknown";
1911 BKE_reportf(reports, RPT_ERROR, "%s is not supported for '%s' objects", op_name, ob_type_name);
1912 return false;
1913 }
1914 return true;
1915}
1916
1917static bDeformGroup *rna_Object_vgroup_new(Object *ob,
1918 Main *bmain,
1920 const char *name)
1921{
1922 if (!check_object_vgroup_support_and_warn(ob, "VertexGroups.new()", reports)) {
1923 return nullptr;
1924 }
1925
1926 bDeformGroup *defgroup = BKE_object_defgroup_add_name(ob, name);
1927
1930
1931 return defgroup;
1932}
1933
1934static void rna_Object_vgroup_remove(Object *ob,
1935 Main *bmain,
1937 PointerRNA *defgroup_ptr)
1938{
1939 if (!check_object_vgroup_support_and_warn(ob, "VertexGroups.remove()", reports)) {
1940 return;
1941 }
1942
1943 bDeformGroup *defgroup = static_cast<bDeformGroup *>(defgroup_ptr->data);
1945
1946 if (BLI_findindex(defbase, defgroup) == -1) {
1948 RPT_ERROR,
1949 "DeformGroup '%s' not in object '%s'",
1950 defgroup->name,
1951 ob->id.name + 2);
1952 return;
1953 }
1954
1955 BKE_object_defgroup_remove(ob, defgroup);
1956 defgroup_ptr->invalidate();
1957
1960}
1961
1962static void rna_Object_vgroup_clear(Object *ob, Main *bmain, ReportList *reports)
1963{
1964 if (!check_object_vgroup_support_and_warn(ob, "VertexGroups.clear()", reports)) {
1965 return;
1966 }
1967
1969
1972}
1973
1974static void rna_VertexGroup_vertex_add(ID *id,
1975 bDeformGroup *def,
1977 const int *index,
1978 int index_num,
1979 float weight,
1980 int assignmode)
1981{
1982 Object *ob = reinterpret_cast<Object *>(id);
1983
1985 BKE_report(
1986 reports, RPT_ERROR, "VertexGroup.add(): cannot be called while object is in edit mode");
1987 return;
1988 }
1989
1990 while (index_num--) {
1991 /* XXX: not efficient calling within loop. */
1992 blender::ed::object::vgroup_vert_add(ob, def, *index++, weight, assignmode);
1993 }
1994
1996 WM_main_add_notifier(NC_GEOM | ND_DATA, static_cast<ID *>(ob->data));
1997}
1998
1999static void rna_VertexGroup_vertex_remove(
2000 ID *id, bDeformGroup *dg, ReportList *reports, const int *index, int index_num)
2001{
2002 Object *ob = reinterpret_cast<Object *>(id);
2003
2005 BKE_report(
2006 reports, RPT_ERROR, "VertexGroup.remove(): cannot be called while object is in edit mode");
2007 return;
2008 }
2009
2010 while (index_num--) {
2012 }
2013
2015 WM_main_add_notifier(NC_GEOM | ND_DATA, static_cast<ID *>(ob->data));
2016}
2017
2018static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *reports, int index)
2019{
2021 reinterpret_cast<Object *>(id), dg, index);
2022
2023 if (weight < 0) {
2024 BKE_report(reports, RPT_ERROR, "Vertex not in group");
2025 }
2026 return weight;
2027}
2028
2029/* generic poll functions */
2030bool rna_Lattice_object_poll(PointerRNA * /*ptr*/, PointerRNA value)
2031{
2032 return (reinterpret_cast<Object *>(value.owner_id))->type == OB_LATTICE;
2033}
2034
2035bool rna_Curve_object_poll(PointerRNA * /*ptr*/, PointerRNA value)
2036{
2037 return (reinterpret_cast<Object *>(value.owner_id))->type == OB_CURVES_LEGACY;
2038}
2039
2040bool rna_Armature_object_poll(PointerRNA * /*ptr*/, PointerRNA value)
2041{
2042 return (reinterpret_cast<Object *>(value.owner_id))->type == OB_ARMATURE;
2043}
2044
2045bool rna_Mesh_object_poll(PointerRNA * /*ptr*/, PointerRNA value)
2046{
2047 return (reinterpret_cast<Object *>(value.owner_id))->type == OB_MESH;
2048}
2049
2050bool rna_Camera_object_poll(PointerRNA * /*ptr*/, PointerRNA value)
2051{
2052 return (reinterpret_cast<Object *>(value.owner_id))->type == OB_CAMERA;
2053}
2054
2055bool rna_Light_object_poll(PointerRNA * /*ptr*/, PointerRNA value)
2056{
2057 return (reinterpret_cast<Object *>(value.owner_id))->type == OB_LAMP;
2058}
2059
2060bool rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr)
2061{
2062 return BKE_object_sculpt_use_dyntopo(reinterpret_cast<Object *>(ptr->owner_id));
2063}
2064
2065static void rna_object_lineart_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
2066{
2069}
2070
2071static std::optional<std::string> rna_ObjectLineArt_path(const PointerRNA * /*ptr*/)
2072{
2073 return "lineart";
2074}
2075
2076static bool mesh_symmetry_get_common(PointerRNA *ptr, const eMeshSymmetryType sym)
2077{
2078 const Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
2079 if (ob->type != OB_MESH) {
2080 return false;
2081 }
2082
2083 const Mesh *mesh = static_cast<Mesh *>(ob->data);
2084 return mesh->symmetry & sym;
2085}
2086
2087static bool rna_Object_mesh_symmetry_x_get(PointerRNA *ptr)
2088{
2089 return mesh_symmetry_get_common(ptr, ME_SYMMETRY_X);
2090}
2091
2092static bool rna_Object_mesh_symmetry_y_get(PointerRNA *ptr)
2093{
2094 return mesh_symmetry_get_common(ptr, ME_SYMMETRY_Y);
2095}
2096
2097static bool rna_Object_mesh_symmetry_z_get(PointerRNA *ptr)
2098{
2099 return mesh_symmetry_get_common(ptr, ME_SYMMETRY_Z);
2100}
2101
2102static void mesh_symmetry_set_common(PointerRNA *ptr,
2103 const bool value,
2104 const eMeshSymmetryType sym)
2105{
2106 Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
2107 if (ob->type != OB_MESH) {
2108 return;
2109 }
2110
2111 Mesh *mesh = static_cast<Mesh *>(ob->data);
2112 if (value) {
2113 mesh->symmetry |= sym;
2114 }
2115 else {
2116 mesh->symmetry &= ~sym;
2117 }
2118}
2119
2120static void rna_Object_mesh_symmetry_x_set(PointerRNA *ptr, bool value)
2121{
2122 mesh_symmetry_set_common(ptr, value, ME_SYMMETRY_X);
2123}
2124
2125static void rna_Object_mesh_symmetry_y_set(PointerRNA *ptr, bool value)
2126{
2127 mesh_symmetry_set_common(ptr, value, ME_SYMMETRY_Y);
2128}
2129
2130static void rna_Object_mesh_symmetry_z_set(PointerRNA *ptr, bool value)
2131{
2132 mesh_symmetry_set_common(ptr, value, ME_SYMMETRY_Z);
2133}
2134
2135static int rna_Object_mesh_symmetry_yz_editable(const PointerRNA *ptr, const char ** /*r_info*/)
2136{
2137 const Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
2138 if (ob->type != OB_MESH) {
2139 return 0;
2140 }
2141
2142 const Mesh *mesh = static_cast<Mesh *>(ob->data);
2144 /* Only X symmetry is available in weight-paint mode. */
2145 return 0;
2146 }
2147
2148 return PROP_EDITABLE;
2149}
2150
2151void rna_Object_lightgroup_get(PointerRNA *ptr, char *value)
2152{
2153 const LightgroupMembership *lgm = (reinterpret_cast<Object *>(ptr->owner_id))->lightgroup;
2154 char value_buf[sizeof(lgm->name)];
2155 int len = BKE_lightgroup_membership_get(lgm, value_buf);
2156 memcpy(value, value_buf, len + 1);
2157}
2158
2159int rna_Object_lightgroup_length(PointerRNA *ptr)
2160{
2161 const LightgroupMembership *lgm = (reinterpret_cast<Object *>(ptr->owner_id))->lightgroup;
2163}
2164
2165void rna_Object_lightgroup_set(PointerRNA *ptr, const char *value)
2166{
2167 BKE_lightgroup_membership_set(&(reinterpret_cast<Object *>(ptr->owner_id))->lightgroup, value);
2168}
2169
2170static PointerRNA rna_Object_light_linking_get(PointerRNA *ptr)
2171{
2172 return RNA_pointer_create_with_parent(*ptr, &RNA_ObjectLightLinking, ptr->data);
2173}
2174
2175static std::optional<std::string> rna_ObjectLightLinking_path(const PointerRNA * /*ptr*/)
2176{
2177 return "light_linking";
2178}
2179
2180static PointerRNA rna_LightLinking_receiver_collection_get(PointerRNA *ptr)
2181{
2182 Object *object = reinterpret_cast<Object *>(ptr->owner_id);
2183 PointerRNA collection_ptr = RNA_id_pointer_create(
2184 reinterpret_cast<ID *>(BKE_light_linking_collection_get(object, LIGHT_LINKING_RECEIVER)));
2185 return collection_ptr;
2186}
2187
2188static void rna_LightLinking_receiver_collection_set(PointerRNA *ptr,
2189 PointerRNA value,
2190 ReportList * /*reports*/)
2191{
2192 Object *object = reinterpret_cast<Object *>(ptr->owner_id);
2193 Collection *new_collection = static_cast<Collection *>(value.data);
2194
2196}
2197
2198static PointerRNA rna_LightLinking_blocker_collection_get(PointerRNA *ptr)
2199{
2200 Object *object = reinterpret_cast<Object *>(ptr->owner_id);
2201 PointerRNA collection_ptr = RNA_id_pointer_create(
2202 reinterpret_cast<ID *>(BKE_light_linking_collection_get(object, LIGHT_LINKING_BLOCKER)));
2203 return collection_ptr;
2204}
2205
2206static void rna_LightLinking_blocker_collection_set(PointerRNA *ptr,
2207 PointerRNA value,
2208 ReportList * /*reports*/)
2209{
2210 Object *object = reinterpret_cast<Object *>(ptr->owner_id);
2211 Collection *new_collection = static_cast<Collection *>(value.data);
2212
2214}
2215
2216static void rna_LightLinking_collection_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
2217{
2219
2222}
2223
2224#else
2225
2227{
2228 StructRNA *srna;
2229 PropertyRNA *prop;
2230 FunctionRNA *func;
2231 PropertyRNA *parm;
2232
2233 static const EnumPropertyItem assign_mode_items[] = {
2234 {WEIGHT_REPLACE, "REPLACE", 0, "Replace", "Replace"},
2235 {WEIGHT_ADD, "ADD", 0, "Add", "Add"},
2236 {WEIGHT_SUBTRACT, "SUBTRACT", 0, "Subtract", "Subtract"},
2237 {0, nullptr, 0, nullptr, nullptr},
2238 };
2239
2240 srna = RNA_def_struct(brna, "VertexGroup", nullptr);
2241 RNA_def_struct_sdna(srna, "bDeformGroup");
2243 srna, "Vertex Group", "Group of vertices, used for armature deform and other purposes");
2244 RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX);
2245
2246 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2247 RNA_def_property_ui_text(prop, "Name", "Vertex group name");
2248 RNA_def_struct_name_property(srna, prop);
2249 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_VertexGroup_name_set");
2250 /* update data because modifiers may use #24761. */
2252 prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data_dependency");
2253
2254 prop = RNA_def_property(srna, "lock_weight", PROP_BOOLEAN, PROP_NONE);
2255 RNA_def_property_ui_text(prop, "", "Maintain the relative weights for the group");
2256 RNA_def_property_boolean_sdna(prop, nullptr, "flag", 0);
2257 /* update data because modifiers may use #24761. */
2258 RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
2259
2260 prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
2262 RNA_def_property_int_funcs(prop, "rna_VertexGroup_index_get", nullptr, nullptr);
2263 RNA_def_property_ui_text(prop, "Index", "Index number of the vertex group");
2264
2265 func = RNA_def_function(srna, "add", "rna_VertexGroup_vertex_add");
2266 RNA_def_function_ui_description(func, "Add vertices to the group");
2268 /* TODO: see how array size of 0 works, this shouldn't be used. */
2269 parm = RNA_def_int_array(func, "index", 1, nullptr, 0, 0, "", "List of indices", 0, 0);
2271 parm = RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight", 0.0f, 1.0f);
2273 parm = RNA_def_enum(func, "type", assign_mode_items, 0, "", "Vertex assign mode");
2275
2276 func = RNA_def_function(srna, "remove", "rna_VertexGroup_vertex_remove");
2277 RNA_def_function_ui_description(func, "Remove vertices from the group");
2279 /* TODO: see how array size of 0 works, this shouldn't be used. */
2280 parm = RNA_def_int_array(func, "index", 1, nullptr, 0, 0, "", "List of indices", 0, 0);
2282
2283 func = RNA_def_function(srna, "weight", "rna_VertexGroup_weight");
2284 RNA_def_function_ui_description(func, "Get a vertex weight from the group");
2286 parm = RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "The index of the vertex", 0, INT_MAX);
2288 parm = RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight", 0.0f, 1.0f);
2289 RNA_def_function_return(func, parm);
2290}
2291
2293{
2294 StructRNA *srna;
2295 PropertyRNA *prop;
2296
2297 static const EnumPropertyItem link_items[] = {
2298 {1, "OBJECT", ICON_OBJECT_DATAMODE, "Object", ""},
2299 {0, "DATA", ICON_MESH_DATA, "Data", ""},
2300 {0, nullptr, 0, nullptr, nullptr},
2301 };
2302
2303 /* NOTE: there is no MaterialSlot equivalent in DNA, so the internal
2304 * pointer data points to ob->mat + index, and we manually implement
2305 * get/set for the properties. */
2306
2307 srna = RNA_def_struct(brna, "MaterialSlot", nullptr);
2308 RNA_def_struct_ui_text(srna, "Material Slot", "Material slot in an object");
2309 RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
2310
2312
2313 /* WARNING! Order is crucial for override to work properly here... :/
2314 * 'link' must come before material pointer,
2315 * since it defines where (in object or obdata) that one is set! */
2316 prop = RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE);
2317 RNA_def_property_enum_items(prop, link_items);
2319 prop, "rna_MaterialSlot_link_get", "rna_MaterialSlot_link_set", nullptr);
2320 RNA_def_property_ui_text(prop, "Link", "Link material to object or the object's data");
2321 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
2322
2323 prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
2324 RNA_def_property_struct_type(prop, "Material");
2326 RNA_def_property_editable_func(prop, "rna_MaterialSlot_material_editable");
2328 "rna_MaterialSlot_material_get",
2329 "rna_MaterialSlot_material_set",
2330 nullptr,
2331 "rna_MaterialSlot_material_poll");
2332 RNA_def_property_ui_text(prop, "Material", "Material data-block used by this material slot");
2333 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
2334
2335 prop = RNA_def_property(srna, "slot_index", PROP_INT, PROP_NONE);
2337 RNA_def_property_int_funcs(prop, "rna_MaterialSlot_index_get", nullptr, nullptr);
2338
2339 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2341 prop, "rna_MaterialSlot_name_get", "rna_MaterialSlot_name_length", nullptr);
2342 RNA_def_property_ui_text(prop, "Name", "Material slot name");
2346 RNA_def_struct_name_property(srna, prop);
2347
2349
2350 RNA_def_struct_path_func(srna, "rna_MaterialSlot_path");
2351}
2352
2354{
2355 StructRNA *srna;
2356 PropertyRNA *prop;
2357
2358 FunctionRNA *func;
2359 PropertyRNA *parm;
2360
2361 RNA_def_property_srna(cprop, "ObjectConstraints");
2362 srna = RNA_def_struct(brna, "ObjectConstraints", nullptr);
2363 RNA_def_struct_sdna(srna, "Object");
2364 RNA_def_struct_ui_text(srna, "Object Constraints", "Collection of object constraints");
2365
2366 /* Collection active property */
2367 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2368 RNA_def_property_struct_type(prop, "Constraint");
2370 "rna_Object_active_constraint_get",
2371 "rna_Object_active_constraint_set",
2372 nullptr,
2373 nullptr);
2375 RNA_def_property_ui_text(prop, "Active Constraint", "Active Object constraint");
2376
2377 /* Constraint collection */
2378 func = RNA_def_function(srna, "new", "rna_Object_constraints_new");
2379 RNA_def_function_ui_description(func, "Add a new constraint to this object");
2381 /* object to add */
2382 parm = RNA_def_enum(
2383 func, "type", rna_enum_constraint_type_items, 1, "", "Constraint type to add");
2385 /* return type */
2386 parm = RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint");
2387 RNA_def_function_return(func, parm);
2388
2389 func = RNA_def_function(srna, "remove", "rna_Object_constraints_remove");
2390 RNA_def_function_ui_description(func, "Remove a constraint from this object");
2392 /* constraint to remove */
2393 parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
2396
2397 func = RNA_def_function(srna, "clear", "rna_Object_constraints_clear");
2399 RNA_def_function_ui_description(func, "Remove all constraint from this object");
2400
2401 func = RNA_def_function(srna, "move", "rna_Object_constraints_move");
2402 RNA_def_function_ui_description(func, "Move a constraint to a different position");
2404 parm = RNA_def_int(
2405 func, "from_index", -1, INT_MIN, INT_MAX, "From Index", "Index to move", 0, 10000);
2407 parm = RNA_def_int(func, "to_index", -1, INT_MIN, INT_MAX, "To Index", "Target index", 0, 10000);
2409
2410 func = RNA_def_function(srna, "copy", "rna_Object_constraints_copy");
2411 RNA_def_function_ui_description(func, "Add a new constraint that is a copy of the given one");
2413 /* constraint to copy */
2414 parm = RNA_def_pointer(func,
2415 "constraint",
2416 "Constraint",
2417 "",
2418 "Constraint to copy - may belong to a different object");
2421 /* return type */
2422 parm = RNA_def_pointer(func, "new_constraint", "Constraint", "", "New constraint");
2423 RNA_def_function_return(func, parm);
2424}
2425
2426/* object.modifiers */
2428{
2429 StructRNA *srna;
2430
2431 FunctionRNA *func;
2432 PropertyRNA *parm;
2433 PropertyRNA *prop;
2434
2435 RNA_def_property_srna(cprop, "ObjectModifiers");
2436 srna = RNA_def_struct(brna, "ObjectModifiers", nullptr);
2437 RNA_def_struct_sdna(srna, "Object");
2438 RNA_def_struct_ui_text(srna, "Object Modifiers", "Collection of object modifiers");
2439
2440# if 0
2441 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2442 RNA_def_property_struct_type(prop, "EditBone");
2443 RNA_def_property_pointer_sdna(prop, nullptr, "act_edbone");
2445 RNA_def_property_ui_text(prop, "Active EditBone", "Armatures active edit bone");
2446 // RNA_def_property_update(prop, 0, "rna_Armature_act_editbone_update");
2448 prop, nullptr, "rna_Armature_act_edit_bone_set", nullptr, nullptr);
2449
2450 /* TODO: redraw. */
2451 // RNA_def_property_collection_active(prop, prop_act);
2452# endif
2453
2454 /* add modifier */
2455 func = RNA_def_function(srna, "new", "rna_Object_modifier_new");
2457 RNA_def_function_ui_description(func, "Add a new modifier");
2458 parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the modifier");
2460 /* modifier to add */
2461 parm = RNA_def_enum(
2462 func, "type", rna_enum_object_modifier_type_items, 1, "", "Modifier type to add");
2464 /* return type */
2465 parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Newly created modifier");
2466 RNA_def_function_return(func, parm);
2467
2468 /* remove modifier */
2469 func = RNA_def_function(srna, "remove", "rna_Object_modifier_remove");
2471 RNA_def_function_ui_description(func, "Remove an existing modifier from the object");
2472 /* modifier to remove */
2473 parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove");
2476
2477 /* clear all modifiers */
2478 func = RNA_def_function(srna, "clear", "rna_Object_modifier_clear");
2480 RNA_def_function_ui_description(func, "Remove all modifiers from the object");
2481
2482 /* move a modifier */
2483 func = RNA_def_function(srna, "move", "rna_Object_modifier_move");
2484 RNA_def_function_ui_description(func, "Move a modifier to a different position");
2486 parm = RNA_def_int(
2487 func, "from_index", -1, INT_MIN, INT_MAX, "From Index", "Index to move", 0, 10000);
2489 parm = RNA_def_int(func, "to_index", -1, INT_MIN, INT_MAX, "To Index", "Target index", 0, 10000);
2491
2492 /* Active modifier. */
2493 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2494 RNA_def_property_struct_type(prop, "Modifier");
2496 prop, "rna_Object_active_modifier_get", "rna_Object_active_modifier_set", nullptr, nullptr);
2500 RNA_def_property_ui_text(prop, "Active Modifier", "The active modifier in the list");
2502}
2503
2504/* object.shaderfxs */
2506{
2507 StructRNA *srna;
2508
2509 FunctionRNA *func;
2510 PropertyRNA *parm;
2511
2512 RNA_def_property_srna(cprop, "ObjectShaderFx");
2513 srna = RNA_def_struct(brna, "ObjectShaderFx", nullptr);
2514 RNA_def_struct_sdna(srna, "Object");
2515 RNA_def_struct_ui_text(srna, "Object Shader Effects", "Collection of object effects");
2516
2517 /* add shader_fx */
2518 func = RNA_def_function(srna, "new", "rna_Object_shaderfx_new");
2520 RNA_def_function_ui_description(func, "Add a new shader fx");
2521 parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the effect");
2523 /* shader to add */
2524 parm = RNA_def_enum(
2525 func, "type", rna_enum_object_shaderfx_type_items, 1, "", "Effect type to add");
2527 /* return type */
2528 parm = RNA_def_pointer(func, "shader_fx", "ShaderFx", "", "Newly created effect");
2529 RNA_def_function_return(func, parm);
2530
2531 /* remove shader_fx */
2532 func = RNA_def_function(srna, "remove", "rna_Object_shaderfx_remove");
2534 RNA_def_function_ui_description(func, "Remove an existing effect from the object");
2535 /* shader to remove */
2536 parm = RNA_def_pointer(func, "shader_fx", "ShaderFx", "", "Effect to remove");
2539
2540 /* clear all shader fx */
2541 func = RNA_def_function(srna, "clear", "rna_Object_shaderfx_clear");
2543 RNA_def_function_ui_description(func, "Remove all effects from the object");
2544}
2545
2546/* object.particle_systems */
2548{
2549 StructRNA *srna;
2550
2551 PropertyRNA *prop;
2552
2553 // FunctionRNA *func;
2554 // PropertyRNA *parm;
2555
2556 RNA_def_property_srna(cprop, "ParticleSystems");
2557 srna = RNA_def_struct(brna, "ParticleSystems", nullptr);
2558 RNA_def_struct_sdna(srna, "Object");
2559 RNA_def_struct_ui_text(srna, "Particle Systems", "Collection of particle systems");
2560
2561 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2562 RNA_def_property_struct_type(prop, "ParticleSystem");
2564 prop, "rna_Object_active_particle_system_get", nullptr, nullptr, nullptr);
2566 prop, "Active Particle System", "Active particle system being displayed");
2567 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
2568
2569 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
2572 "rna_Object_active_particle_system_index_get",
2573 "rna_Object_active_particle_system_index_set",
2574 "rna_Object_active_particle_system_index_range");
2576 prop, "Active Particle System Index", "Index of active particle system slot");
2577 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_particle_update");
2578}
2579
2580/* object.vertex_groups */
2582{
2583 StructRNA *srna;
2584
2585 PropertyRNA *prop;
2586
2587 FunctionRNA *func;
2588 PropertyRNA *parm;
2589
2590 RNA_def_property_srna(cprop, "VertexGroups");
2591 srna = RNA_def_struct(brna, "VertexGroups", nullptr);
2592 RNA_def_struct_sdna(srna, "Object");
2593 RNA_def_struct_ui_text(srna, "Vertex Groups", "Collection of vertex groups");
2594
2595 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2596 RNA_def_property_struct_type(prop, "VertexGroup");
2598 "rna_Object_active_vertex_group_get",
2599 "rna_Object_active_vertex_group_set",
2600 nullptr,
2601 nullptr);
2603 RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object");
2604 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_vertex_groups_update");
2605
2606 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
2609 "rna_Object_active_vertex_group_index_get",
2610 "rna_Object_active_vertex_group_index_set",
2611 "rna_Object_active_vertex_group_index_range");
2613 prop, "Active Vertex Group Index", "Active index in vertex group array");
2614 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_vertex_groups_update");
2615
2616 /* vertex groups */ /* add_vertex_group */
2617 func = RNA_def_function(srna, "new", "rna_Object_vgroup_new");
2619 RNA_def_function_ui_description(func, "Add vertex group to object");
2620 RNA_def_string(func, "name", "Group", 0, "", "Vertex group name"); /* optional */
2621 parm = RNA_def_pointer(func, "group", "VertexGroup", "", "New vertex group");
2622 RNA_def_function_return(func, parm);
2623
2624 func = RNA_def_function(srna, "remove", "rna_Object_vgroup_remove");
2626 RNA_def_function_ui_description(func, "Delete vertex group from object");
2627 parm = RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove");
2630
2631 func = RNA_def_function(srna, "clear", "rna_Object_vgroup_clear");
2633 RNA_def_function_ui_description(func, "Delete all vertex groups from object");
2634}
2635
2637{
2638 StructRNA *srna;
2639 PropertyRNA *prop;
2640
2641 srna = RNA_def_struct(brna, "ObjectDisplay", nullptr);
2642 RNA_def_struct_ui_text(srna, "Object Display", "Object display settings for 3D viewport");
2643 RNA_def_struct_sdna(srna, "Object");
2644 RNA_def_struct_nested(brna, srna, "Object");
2645 RNA_def_struct_path_func(srna, "rna_ObjectDisplay_path");
2646
2648
2649 prop = RNA_def_property(srna, "show_shadows", PROP_BOOLEAN, PROP_NONE);
2651 RNA_def_property_ui_text(prop, "Shadow", "Object cast shadows in the 3D viewport");
2652 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
2653
2655}
2656
2658{
2659 StructRNA *srna;
2660 PropertyRNA *prop;
2661
2662 static const EnumPropertyItem prop_feature_line_usage_items[] = {
2663 {OBJECT_LRT_INHERIT, "INHERIT", 0, "Inherit", "Use settings from the parent collection"},
2665 "INCLUDE",
2666 0,
2667 "Include",
2668 "Generate feature lines for this object's data"},
2670 "OCCLUSION_ONLY",
2671 0,
2672 "Occlusion Only",
2673 "Only use the object data to produce occlusion"},
2675 "EXCLUDE",
2676 0,
2677 "Exclude",
2678 "Don't use this object for Line Art rendering"},
2680 "INTERSECTION_ONLY",
2681 0,
2682 "Intersection Only",
2683 "Only generate intersection lines for this collection"},
2685 "NO_INTERSECTION",
2686 0,
2687 "No Intersection",
2688 "Include this object but do not generate intersection lines"},
2690 "FORCE_INTERSECTION",
2691 0,
2692 "Force Intersection",
2693 "Generate intersection lines even with objects that disabled intersection"},
2694 {0, nullptr, 0, nullptr, nullptr},
2695 };
2696
2697 srna = RNA_def_struct(brna, "ObjectLineArt", nullptr);
2698 RNA_def_struct_ui_text(srna, "Object Line Art", "Object Line Art settings");
2699 RNA_def_struct_sdna(srna, "ObjectLineArt");
2700 RNA_def_struct_path_func(srna, "rna_ObjectLineArt_path");
2701
2702 prop = RNA_def_property(srna, "usage", PROP_ENUM, PROP_NONE);
2703 RNA_def_property_enum_items(prop, prop_feature_line_usage_items);
2704 RNA_def_property_ui_text(prop, "Usage", "How to use this object in Line Art calculation");
2705 RNA_def_property_update(prop, 0, "rna_object_lineart_update");
2706
2707 prop = RNA_def_property(srna, "use_crease_override", PROP_BOOLEAN, PROP_NONE);
2710 prop, "Use Crease", "Use this object's crease setting to overwrite scene global");
2711 RNA_def_property_update(prop, 0, "rna_object_lineart_update");
2712
2713 prop = RNA_def_property(srna, "crease_threshold", PROP_FLOAT, PROP_ANGLE);
2714 RNA_def_property_range(prop, 0, DEG2RAD(180.0f));
2715 RNA_def_property_ui_range(prop, 0.0f, DEG2RAD(180.0f), 0.01f, 1);
2716 RNA_def_property_ui_text(prop, "Crease", "Angles smaller than this will be treated as creases");
2717 RNA_def_property_update(prop, 0, "rna_object_lineart_update");
2718
2719 prop = RNA_def_property(srna, "use_intersection_priority_override", PROP_BOOLEAN, PROP_NONE);
2722 prop,
2723 "Use Intersection Priority",
2724 "Use this object's intersection priority to override collection setting");
2725 RNA_def_property_update(prop, 0, "rna_object_lineart_update");
2726
2727 prop = RNA_def_property(srna, "intersection_priority", PROP_INT, PROP_NONE);
2728 RNA_def_property_range(prop, 0, 255);
2730 "Intersection Priority",
2731 "The intersection line will be included into the object with the "
2732 "higher intersection priority value");
2733 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_object_lineart_update");
2734}
2735
2737{
2738 PropertyRNA *prop;
2739
2740 /* Hide options. */
2741 prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE);
2742 RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HIDE_VIEWPORT);
2743 RNA_def_property_ui_text(prop, "Disable in Viewports", "Globally disable in viewports");
2744 RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, -1);
2745 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
2746
2747 prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
2748 RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HIDE_SELECT);
2750 RNA_def_property_ui_text(prop, "Disable Selection", "Disable selection in viewport");
2751 RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, -1);
2752 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
2753
2754 prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE);
2755 RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HIDE_RENDER);
2756 RNA_def_property_ui_text(prop, "Disable in Renders", "Globally disable in renders");
2757 RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, -1);
2758 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
2759
2760 prop = RNA_def_property(srna, "hide_probe_volume", PROP_BOOLEAN, PROP_NONE);
2761 RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HIDE_PROBE_VOLUME);
2762 RNA_def_property_ui_text(prop, "Disable in Volume Probes", "Globally disable in volume probes");
2763 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
2764
2765 prop = RNA_def_property(srna, "hide_probe_sphere", PROP_BOOLEAN, PROP_NONE);
2766 RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HIDE_PROBE_CUBEMAP);
2768 prop, "Disable in Spherical Light Probes", "Globally disable in spherical light probes");
2769 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
2770
2771 prop = RNA_def_property(srna, "hide_probe_plane", PROP_BOOLEAN, PROP_NONE);
2772 RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HIDE_PROBE_PLANAR);
2774 prop, "Disable in Planar Light Probes", "Globally disable in planar light probes");
2775 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
2776
2777 /* Instancer options. */
2778 prop = RNA_def_property(srna, "show_instancer_for_render", PROP_BOOLEAN, PROP_NONE);
2779 RNA_def_property_boolean_sdna(prop, nullptr, "duplicator_visibility_flag", OB_DUPLI_FLAG_RENDER);
2780 RNA_def_property_ui_text(prop, "Render Instancer", "Make instancer visible when rendering");
2782 prop, NC_OBJECT | ND_DRAW, "rna_Object_duplicator_visibility_flag_update");
2783
2784 prop = RNA_def_property(srna, "show_instancer_for_viewport", PROP_BOOLEAN, PROP_NONE);
2786 prop, nullptr, "duplicator_visibility_flag", OB_DUPLI_FLAG_VIEWPORT);
2787 RNA_def_property_ui_text(prop, "Display Instancer", "Make instancer visible in the viewport");
2789 prop, NC_OBJECT | ND_DRAW, "rna_Object_duplicator_visibility_flag_update");
2790
2791 /* Ray visibility. */
2792 prop = RNA_def_property(srna, "visible_camera", PROP_BOOLEAN, PROP_NONE);
2793 RNA_def_property_boolean_negative_sdna(prop, nullptr, "visibility_flag", OB_HIDE_CAMERA);
2794 RNA_def_property_ui_text(prop, "Camera Visibility", "Object visibility to camera rays");
2795 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
2796
2797 prop = RNA_def_property(srna, "visible_diffuse", PROP_BOOLEAN, PROP_NONE);
2798 RNA_def_property_boolean_negative_sdna(prop, nullptr, "visibility_flag", OB_HIDE_DIFFUSE);
2799 RNA_def_property_ui_text(prop, "Diffuse Visibility", "Object visibility to diffuse rays");
2800 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
2801
2802 prop = RNA_def_property(srna, "visible_glossy", PROP_BOOLEAN, PROP_NONE);
2803 RNA_def_property_boolean_negative_sdna(prop, nullptr, "visibility_flag", OB_HIDE_GLOSSY);
2804 RNA_def_property_ui_text(prop, "Glossy Visibility", "Object visibility to glossy rays");
2805 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
2806
2807 prop = RNA_def_property(srna, "visible_transmission", PROP_BOOLEAN, PROP_NONE);
2808 RNA_def_property_boolean_negative_sdna(prop, nullptr, "visibility_flag", OB_HIDE_TRANSMISSION);
2810 prop, "Transmission Visibility", "Object visibility to transmission rays");
2811 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
2812
2813 prop = RNA_def_property(srna, "visible_volume_scatter", PROP_BOOLEAN, PROP_NONE);
2814 RNA_def_property_boolean_negative_sdna(prop, nullptr, "visibility_flag", OB_HIDE_VOLUME_SCATTER);
2816 prop, "Volume Scatter Visibility", "Object visibility to volume scattering rays");
2817 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
2818
2819 prop = RNA_def_property(srna, "visible_shadow", PROP_BOOLEAN, PROP_NONE);
2820 RNA_def_property_boolean_negative_sdna(prop, nullptr, "visibility_flag", OB_HIDE_SHADOW);
2821 RNA_def_property_ui_text(prop, "Shadow Visibility", "Object visibility to shadow rays");
2822 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
2823
2824 /* Holdout and shadow catcher. */
2825 prop = RNA_def_property(srna, "is_holdout", PROP_BOOLEAN, PROP_NONE);
2826 RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HOLDOUT);
2828 prop,
2829 "Holdout",
2830 "Render objects as a holdout or matte, creating a hole in the image with zero alpha, to "
2831 "fill out in compositing with real footage or another render");
2832 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
2833
2834 prop = RNA_def_property(srna, "is_shadow_catcher", PROP_BOOLEAN, PROP_NONE);
2835 RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_SHADOW_CATCHER);
2837 prop,
2838 "Shadow Catcher",
2839 "Only render shadows and reflections on this object, for compositing renders into real "
2840 "footage. Objects with this setting are considered to already exist in the footage, "
2841 "objects without it are synthetic objects being composited into it.");
2842 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
2843}
2844
2845static void rna_def_object(BlenderRNA *brna)
2846{
2847 StructRNA *srna;
2848 PropertyRNA *prop;
2849
2850 static const EnumPropertyItem up_items[] = {
2851 {OB_POSX, "X", 0, "X", ""},
2852 {OB_POSY, "Y", 0, "Y", ""},
2853 {OB_POSZ, "Z", 0, "Z", ""},
2854 {0, nullptr, 0, nullptr, nullptr},
2855 };
2856
2857 static const EnumPropertyItem drawtype_items[] = {
2858 {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", "Display the bounds of the object"},
2859 {OB_WIRE, "WIRE", 0, "Wire", "Display the object as a wireframe"},
2860 {OB_SOLID,
2861 "SOLID",
2862 0,
2863 "Solid",
2864 "Display the object as a solid (if solid drawing is enabled in the viewport)"},
2865 {OB_TEXTURE,
2866 "TEXTURED",
2867 0,
2868 "Textured",
2869 "Display the object with textures (if textures are enabled in the viewport)"},
2870 {0, nullptr, 0, nullptr, nullptr},
2871 };
2872
2873 static const EnumPropertyItem boundtype_items[] = {
2874 {OB_BOUND_BOX, "BOX", 0, "Box", "Display bounds as box"},
2875 {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", "Display bounds as sphere"},
2876 {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", "Display bounds as cylinder"},
2877 {OB_BOUND_CONE, "CONE", 0, "Cone", "Display bounds as cone"},
2878 {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", "Display bounds as capsule"},
2879 {0, nullptr, 0, nullptr, nullptr},
2880 };
2881
2882 static int boundbox_dimsize[] = {8, 3};
2883
2884 srna = RNA_def_struct(brna, "Object", "ID");
2885 RNA_def_struct_ui_text(srna, "Object", "Object data-block defining an object in a scene");
2887 RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
2888
2890
2891 prop = RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
2892 RNA_def_property_struct_type(prop, "ID");
2894 prop, "rna_Object_data_get", "rna_Object_data_set", "rna_Object_data_typef", nullptr);
2896 RNA_def_property_ui_text(prop, "Data", "Object data");
2897 RNA_def_property_update(prop, 0, "rna_Object_data_update");
2898
2899 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2900 RNA_def_property_enum_sdna(prop, nullptr, "type");
2904 RNA_def_property_ui_text(prop, "Type", "Type of object");
2906
2907 prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
2908 RNA_def_property_enum_sdna(prop, nullptr, "mode");
2911 RNA_def_property_ui_text(prop, "Mode", "Object interaction mode");
2912
2913 /* for data access */
2914 prop = RNA_def_property(srna, "bound_box", PROP_FLOAT, PROP_NONE);
2915 RNA_def_property_multi_array(prop, 2, boundbox_dimsize);
2919 RNA_def_property_float_funcs(prop, "rna_Object_boundbox_get", nullptr, nullptr);
2921 prop,
2922 "Bounding Box",
2923 "Object's bounding box in object-space coordinates, all values are -1.0 when "
2924 "not available");
2925
2926 /* parent */
2927 prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
2928 RNA_def_property_pointer_funcs(prop, nullptr, "rna_Object_parent_set", nullptr, nullptr);
2930 RNA_def_property_override_funcs(prop, nullptr, nullptr, "rna_Object_parent_override_apply");
2931 RNA_def_property_ui_text(prop, "Parent", "Parent object");
2932 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2933
2934 prop = RNA_def_property(srna, "parent_type", PROP_ENUM, PROP_NONE);
2935 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "partype");
2938 prop, nullptr, "rna_Object_parent_type_set", "rna_Object_parent_type_itemf");
2939 RNA_def_property_override_funcs(prop, nullptr, nullptr, "rna_Object_parent_type_override_apply");
2940 RNA_def_property_ui_text(prop, "Parent Type", "Type of parent relation");
2941 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2942
2943 prop = RNA_def_property(srna, "parent_vertices", PROP_INT, PROP_UNSIGNED);
2944 RNA_def_property_int_sdna(prop, nullptr, "par1");
2945 RNA_def_property_array(prop, 3);
2947 prop, "Parent Vertices", "Indices of vertices in case of a vertex parenting relation");
2948 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2949
2950 prop = RNA_def_property(srna, "parent_bone", PROP_STRING, PROP_NONE);
2951 RNA_def_property_string_sdna(prop, nullptr, "parsubstr");
2952 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Object_parent_bone_set");
2953 RNA_def_property_override_funcs(prop, nullptr, nullptr, "rna_Object_parent_bone_override_apply");
2955 prop, "Parent Bone", "Name of parent bone in case of a bone parenting relation");
2956 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
2957
2958 prop = RNA_def_property(srna, "use_parent_final_indices", PROP_BOOLEAN, PROP_NONE);
2961 prop,
2962 "Use Final Indices",
2963 "Use the final evaluated indices rather than the original mesh indices");
2964 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2965
2966 prop = RNA_def_property(srna, "use_camera_lock_parent", PROP_BOOLEAN, PROP_NONE);
2968 prop, nullptr, "transflag", OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK);
2970 "Camera Parent Lock",
2971 "View Lock 3D viewport camera transformation affects the object's "
2972 "parent instead");
2973 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2974
2975 /* Track and Up flags */
2976 /* XXX: these have been saved here for a bit longer (after old track was removed),
2977 * since some other tools still refer to this */
2978 prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
2979 RNA_def_property_enum_sdna(prop, nullptr, "trackflag");
2982 prop,
2983 "Track Axis",
2984 "Axis that points in the 'forward' direction (applies to Instance Vertices when "
2985 "Align to Vertex Normal is enabled)");
2986 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2987
2988 prop = RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE);
2989 RNA_def_property_enum_sdna(prop, nullptr, "upflag");
2990 RNA_def_property_enum_items(prop, up_items);
2992 prop,
2993 "Up Axis",
2994 "Axis that points in the upward direction (applies to Instance Vertices when "
2995 "Align to Vertex Normal is enabled)");
2996 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
2997
2998 /* materials */
2999 prop = RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE);
3000 RNA_def_property_struct_type(prop, "MaterialSlot");
3002 /* Don't dereference the material slot pointer, it is the slot index encoded in a pointer. */
3004 "rna_Object_material_slots_begin",
3005 "rna_Object_material_slots_next",
3006 "rna_Object_material_slots_end",
3007 "rna_Object_material_slots_get",
3008 "rna_Object_material_slots_length",
3009 nullptr,
3010 nullptr,
3011 nullptr);
3012 RNA_def_property_ui_text(prop, "Material Slots", "Material slots in the object");
3013
3014 prop = RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE);
3015 RNA_def_property_struct_type(prop, "Material");
3017 "rna_Object_active_material_get",
3018 "rna_Object_active_material_set",
3019 nullptr,
3020 "rna_MaterialSlot_material_poll");
3022 RNA_def_property_editable_func(prop, "rna_Object_active_material_editable");
3023 RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed");
3024 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
3025
3026 prop = RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
3027 RNA_def_property_int_sdna(prop, nullptr, "actcol");
3031 "rna_Object_active_material_index_get",
3032 "rna_Object_active_material_index_set",
3033 "rna_Object_active_material_index_range");
3034 RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot");
3036
3037 /* transform */
3038 prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
3039 RNA_def_property_float_sdna(prop, nullptr, "loc");
3040 RNA_def_property_editable_array_func(prop, "rna_Object_location_editable");
3041 RNA_def_property_ui_text(prop, "Location", "Location of the object");
3043 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3044
3045 prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
3046 RNA_def_property_float_sdna(prop, nullptr, "quat");
3047 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
3048 RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions");
3049 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3050
3051 /* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but
3052 * having a single one is better for Keyframing and other property-management situations...
3053 */
3054 prop = RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
3055 RNA_def_property_array(prop, 4);
3057 prop, "rna_Object_rotation_axis_angle_get", "rna_Object_rotation_axis_angle_set", nullptr);
3058 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
3061 prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
3062 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3063
3064 prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
3065 RNA_def_property_float_sdna(prop, nullptr, "rot");
3066 RNA_def_property_editable_array_func(prop, "rna_Object_rotation_euler_editable");
3068 RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers");
3069 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3070
3071 prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
3072 RNA_def_property_enum_sdna(prop, nullptr, "rotmode");
3074 RNA_def_property_enum_funcs(prop, nullptr, "rna_Object_rotation_mode_set", nullptr);
3076 prop,
3077 "Rotation Mode",
3078 /* This description is shared by other "rotation_mode" properties. */
3079 "The kind of rotation to apply, values from other rotation modes aren't used");
3080 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3081
3082 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
3084 RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable");
3086 RNA_def_property_ui_text(prop, "Scale", "Scaling of the object");
3087 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3088
3089 prop = RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ_LENGTH);
3090 RNA_def_property_array(prop, 3);
3091 /* Only as convenient helper for py API, and conflicts with animating scale. */
3096 prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", nullptr);
3099 "Dimensions",
3100 "Absolute bounding box dimensions of the object.\n"
3101 "Warning: Assigning to it or its members multiple consecutive times "
3102 "will not work correctly, as this needs up-to-date evaluated data");
3103 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3104
3105 /* delta transforms */
3106 prop = RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_TRANSLATION);
3107 RNA_def_property_float_sdna(prop, nullptr, "dloc");
3109 prop, "Delta Location", "Extra translation added to the location of the object");
3111 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3112
3113 prop = RNA_def_property(srna, "delta_rotation_euler", PROP_FLOAT, PROP_EULER);
3114 RNA_def_property_float_sdna(prop, nullptr, "drot");
3116 prop,
3117 "Delta Rotation (Euler)",
3118 "Extra rotation added to the rotation of the object (when using Euler rotations)");
3120 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3121
3122 prop = RNA_def_property(srna, "delta_rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
3123 RNA_def_property_float_sdna(prop, nullptr, "dquat");
3125 prop,
3126 "Delta Rotation (Quaternion)",
3127 "Extra rotation added to the rotation of the object (when using Quaternion rotations)");
3128 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3129
3130# if 0 /* XXX not supported well yet... */
3131 prop = RNA_def_property(srna, "delta_rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
3132 /* FIXME: this is not a single field any more! (drotAxis and drotAngle) */
3133 RNA_def_property_float_sdna(prop, nullptr, "dquat");
3136 prop,
3137 "Delta Rotation (Axis Angle)",
3138 "Extra rotation added to the rotation of the object (when using Axis-Angle rotations)");
3139 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3140# endif
3141
3142 prop = RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_XYZ);
3143 RNA_def_property_float_sdna(prop, nullptr, "dscale");
3146 RNA_def_property_ui_text(prop, "Delta Scale", "Extra scaling added to the scale of the object");
3147 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3148
3149 /* transform locks */
3150 prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE);
3151 RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_LOCX, 3);
3152 RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location when transforming");
3153 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
3154 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3155
3156 prop = RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE);
3157 RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_ROTX, 3);
3158 RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation when transforming");
3159 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
3160 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3161
3162 /* XXX this is sub-optimal - it really should be included above,
3163 * but due to technical reasons we can't do this! */
3164 prop = RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE);
3165 RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_ROTW);
3166 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
3168 prop,
3169 "Lock Rotation (4D Angle)",
3170 "Lock editing of 'angle' component of four-component rotations when transforming");
3171 /* XXX this needs a better name */
3172 prop = RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE);
3173 RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_ROT4D);
3175 prop,
3176 "Lock Rotations (4D)",
3177 "Lock editing of four component rotations by components (instead of as Eulers)");
3178
3179 prop = RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_NONE);
3180 RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_SCALEX, 3);
3181 RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale when transforming");
3182 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
3183 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3184
3185 /* matrix */
3186 prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
3192 prop, "rna_Object_matrix_world_get", "rna_Object_matrix_world_set", nullptr);
3193 RNA_def_property_ui_text(prop, "Matrix World", "Worldspace transformation matrix");
3194 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_matrix_world_update");
3195
3196 prop = RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX);
3202 prop,
3203 "Local Matrix",
3204 "Parent relative transformation matrix.\n"
3205 "Warning: Only takes into account object parenting, so e.g. in case of bone parenting "
3206 "you get a matrix relative to the Armature object, not to the actual parent bone");
3208 prop, "rna_Object_matrix_local_get", "rna_Object_matrix_local_set", nullptr);
3209 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3210
3211 prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
3217 "Input Matrix",
3218 "Matrix access to location, rotation and scale (including deltas), "
3219 "before constraints and parenting are applied");
3221 prop, "rna_Object_matrix_basis_get", "rna_Object_matrix_basis_set", nullptr);
3222 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3223
3224 /* Parent_inverse. */
3225 prop = RNA_def_property(srna, "matrix_parent_inverse", PROP_FLOAT, PROP_MATRIX);
3226 RNA_def_property_float_sdna(prop, nullptr, "parentinv");
3229 prop, "Parent Inverse Matrix", "Inverse of object's parent matrix at time of parenting");
3230 RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
3231
3232 /* modifiers */
3233 prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
3234 RNA_def_property_struct_type(prop, "Modifier");
3236 prop, "Modifiers", "Modifiers affecting the geometric data of the object");
3237 RNA_def_property_override_funcs(prop, nullptr, nullptr, "rna_Object_modifiers_override_apply");
3239 rna_def_object_modifiers(brna, prop);
3240
3241 /* Shader FX. */
3242 prop = RNA_def_property(srna, "shader_effects", PROP_COLLECTION, PROP_NONE);
3243 RNA_def_property_collection_sdna(prop, nullptr, "shader_fx", nullptr);
3244 RNA_def_property_struct_type(prop, "ShaderFx");
3245 RNA_def_property_ui_text(prop, "Shader Effects", "Effects affecting display of object");
3247 rna_def_object_shaderfxs(brna, prop);
3249
3250 /* constraints */
3251 prop = RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE);
3252 RNA_def_property_struct_type(prop, "Constraint");
3255 prop, "Constraints", "Constraints affecting the transformation of the object");
3256 RNA_def_property_override_funcs(prop, nullptr, nullptr, "rna_Object_constraints_override_apply");
3257# if 0
3259 nullptr,
3260 nullptr,
3261 nullptr,
3262 nullptr,
3263 nullptr,
3264 nullptr,
3265 nullptr,
3266 "constraints__add",
3267 "constraints__remove");
3268# endif
3269 rna_def_object_constraints(brna, prop);
3270
3271 /* vertex groups */
3272 prop = RNA_def_property(srna, "vertex_groups", PROP_COLLECTION, PROP_NONE);
3274 "rna_Object_vertex_groups_begin",
3275 "rna_iterator_listbase_next",
3276 "rna_iterator_listbase_end",
3277 "rna_iterator_listbase_get",
3278 nullptr,
3279 nullptr,
3280 nullptr,
3281 nullptr);
3282 RNA_def_property_struct_type(prop, "VertexGroup");
3284 RNA_def_property_ui_text(prop, "Vertex Groups", "Vertex groups of the object");
3285 rna_def_object_vertex_groups(brna, prop);
3286
3287 /* empty */
3288 prop = RNA_def_property(srna, "empty_display_type", PROP_ENUM, PROP_NONE);
3289 RNA_def_property_enum_sdna(prop, nullptr, "empty_drawtype");
3291 RNA_def_property_enum_funcs(prop, nullptr, "rna_Object_empty_display_type_set", nullptr);
3292 RNA_def_property_ui_text(prop, "Empty Display Type", "Viewport display style for empties");
3293 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3294
3295 prop = RNA_def_property(srna, "empty_display_size", PROP_FLOAT, PROP_DISTANCE);
3296 RNA_def_property_float_sdna(prop, nullptr, "empty_drawsize");
3297 RNA_def_property_range(prop, 0.0001f, 1000.0f);
3298 RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);
3300 prop, "Empty Display Size", "Size of display for empties in the viewport");
3301 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3302
3303 prop = RNA_def_property(srna, "empty_image_offset", PROP_FLOAT, PROP_NONE);
3304 RNA_def_property_float_sdna(prop, nullptr, "ima_ofs");
3305 RNA_def_property_ui_text(prop, "Origin Offset", "Origin offset distance");
3306 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1f, 2);
3307 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3308
3309 prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE);
3311 RNA_def_property_pointer_sdna(prop, nullptr, "iuser");
3313 prop,
3314 "Image User",
3315 "Parameters defining which layer, pass and frame of the image is displayed");
3316 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3317
3318 prop = RNA_def_property(srna, "empty_image_depth", PROP_ENUM, PROP_NONE);
3321 prop, "Empty Image Depth", "Determine which other objects will occlude the image");
3322 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3323
3324 prop = RNA_def_property(srna, "show_empty_image_perspective", PROP_BOOLEAN, PROP_NONE);
3326 prop, nullptr, "empty_image_visibility_flag", OB_EMPTY_IMAGE_HIDE_PERSPECTIVE);
3328 prop, "Display in Perspective Mode", "Display image in perspective mode");
3329 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3330
3331 prop = RNA_def_property(srna, "show_empty_image_orthographic", PROP_BOOLEAN, PROP_NONE);
3333 prop, nullptr, "empty_image_visibility_flag", OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC);
3335 prop, "Display in Orthographic Mode", "Display image in orthographic mode");
3336 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3337
3338 prop = RNA_def_property(srna, "show_empty_image_only_axis_aligned", PROP_BOOLEAN, PROP_NONE);
3340 prop, nullptr, "empty_image_visibility_flag", OB_EMPTY_IMAGE_HIDE_NON_AXIS_ALIGNED);
3342 "Display Only Axis Aligned",
3343 "Only display the image when it is aligned with the view axis");
3344 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3345
3346 prop = RNA_def_property(srna, "use_empty_image_alpha", PROP_BOOLEAN, PROP_NONE);
3347 RNA_def_property_boolean_sdna(prop, nullptr, "empty_image_flag", OB_EMPTY_IMAGE_USE_ALPHA_BLEND);
3349 prop,
3350 "Use Alpha",
3351 "Use alpha blending instead of alpha test (can produce sorting artifacts)");
3352 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3353
3354 static const EnumPropertyItem prop_empty_image_side_items[] = {
3355 {0, "DOUBLE_SIDED", 0, "Both", ""},
3356 {OB_EMPTY_IMAGE_HIDE_BACK, "FRONT", 0, "Front", ""},
3357 {OB_EMPTY_IMAGE_HIDE_FRONT, "BACK", 0, "Back", ""},
3358 {0, nullptr, 0, nullptr, nullptr},
3359 };
3360 prop = RNA_def_property(srna, "empty_image_side", PROP_ENUM, PROP_NONE);
3361 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "empty_image_visibility_flag");
3362 RNA_def_property_enum_items(prop, prop_empty_image_side_items);
3363 RNA_def_property_ui_text(prop, "Empty Image Side", "Show front/back side");
3365 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3366
3367 prop = RNA_def_property(srna, "add_rest_position_attribute", PROP_BOOLEAN, PROP_NONE);
3369 prop, nullptr, "modifier_flag", OB_MODIFIER_FLAG_ADD_REST_POSITION);
3371 "Add Rest Position",
3372 "Add a \"rest_position\" attribute that is a copy of the position "
3373 "attribute before shape keys and modifiers are evaluated");
3374 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_data");
3375
3376 /* render */
3377 prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
3378 RNA_def_property_int_sdna(prop, nullptr, "index");
3380 prop, "Pass Index", "Index number for the \"Object Index\" render pass");
3381 RNA_def_property_update(prop, NC_OBJECT, "rna_Object_internal_update_draw");
3382
3383 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
3385 prop, "Color", "Object color and alpha, used when the Object Color mode is enabled");
3386 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
3387
3388 /* physics */
3389 prop = RNA_def_property(srna, "field", PROP_POINTER, PROP_NONE);
3390 RNA_def_property_pointer_sdna(prop, nullptr, "pd");
3391 RNA_def_property_struct_type(prop, "FieldSettings");
3392 RNA_def_property_pointer_funcs(prop, "rna_Object_field_get", nullptr, nullptr, nullptr);
3394 prop, "Field Settings", "Settings for using the object as a field in physics simulation");
3395
3396 prop = RNA_def_property(srna, "collision", PROP_POINTER, PROP_NONE);
3397 RNA_def_property_pointer_sdna(prop, nullptr, "pd");
3398 RNA_def_property_struct_type(prop, "CollisionSettings");
3399 RNA_def_property_pointer_funcs(prop, "rna_Object_collision_get", nullptr, nullptr, nullptr);
3401 "Collision Settings",
3402 "Settings for using the object as a collider in physics simulation");
3403
3404 prop = RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE);
3405 RNA_def_property_pointer_sdna(prop, nullptr, "soft");
3406 RNA_def_property_struct_type(prop, "SoftBodySettings");
3407 RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for soft body simulation");
3408
3409 prop = RNA_def_property(srna, "particle_systems", PROP_COLLECTION, PROP_NONE);
3410 RNA_def_property_collection_sdna(prop, nullptr, "particlesystem", nullptr);
3411 RNA_def_property_struct_type(prop, "ParticleSystem");
3412 RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object");
3414
3415 prop = RNA_def_property(srna, "rigid_body", PROP_POINTER, PROP_NONE);
3416 RNA_def_property_pointer_sdna(prop, nullptr, "rigidbody_object");
3417 RNA_def_property_struct_type(prop, "RigidBodyObject");
3418 RNA_def_property_ui_text(prop, "Rigid Body Settings", "Settings for rigid body simulation");
3419
3420 prop = RNA_def_property(srna, "rigid_body_constraint", PROP_POINTER, PROP_NONE);
3421 RNA_def_property_pointer_sdna(prop, nullptr, "rigidbody_constraint");
3422 RNA_def_property_struct_type(prop, "RigidBodyConstraint");
3423 RNA_def_property_ui_text(prop, "Rigid Body Constraint", "Constraint constraining rigid bodies");
3424
3425 prop = RNA_def_property(srna, "use_simulation_cache", PROP_BOOLEAN, PROP_NONE);
3428 prop, "Use Simulation Cache", "Cache frames during simulation nodes playback");
3430 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3431
3433
3434 /* instancing */
3435 prop = RNA_def_property(srna, "instance_type", PROP_ENUM, PROP_NONE);
3436 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "transflag");
3438 RNA_def_property_enum_funcs(prop, nullptr, nullptr, "rna_Object_instance_type_itemf");
3439 RNA_def_property_ui_text(prop, "Instance Type", "If not None, object instancing method to use");
3440 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
3441
3442 prop = RNA_def_property(srna, "use_instance_vertices_rotation", PROP_BOOLEAN, PROP_NONE);
3443 RNA_def_property_boolean_sdna(prop, nullptr, "transflag", OB_DUPLIROT);
3445 prop, "Orient with Normals", "Rotate instance according to vertex normal");
3446 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3447
3448 prop = RNA_def_property(srna, "use_instance_faces_scale", PROP_BOOLEAN, PROP_NONE);
3449 RNA_def_property_boolean_sdna(prop, nullptr, "transflag", OB_DUPLIFACES_SCALE);
3450 RNA_def_property_ui_text(prop, "Scale to Face Sizes", "Scale instance based on face size");
3451 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
3452
3453 prop = RNA_def_property(srna, "instance_faces_scale", PROP_FLOAT, PROP_NONE);
3454 RNA_def_property_float_sdna(prop, nullptr, "instance_faces_scale");
3455 RNA_def_property_range(prop, 0.001f, 10000.0f);
3456 RNA_def_property_ui_text(prop, "Instance Faces Scale", "Scale the face instance objects");
3457 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
3458
3459 prop = RNA_def_property(srna, "instance_collection", PROP_POINTER, PROP_NONE);
3460 RNA_def_property_struct_type(prop, "Collection");
3461 RNA_def_property_pointer_sdna(prop, nullptr, "instance_collection");
3463 RNA_def_property_pointer_funcs(prop, nullptr, "rna_Object_dup_collection_set", nullptr, nullptr);
3464 RNA_def_property_ui_text(prop, "Instance Collection", "Instance an existing collection");
3465 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
3466
3467 prop = RNA_def_property(srna, "is_instancer", PROP_BOOLEAN, PROP_NONE);
3468 RNA_def_property_boolean_sdna(prop, nullptr, "transflag", OB_DUPLI);
3472
3473 /* drawing */
3474 prop = RNA_def_property(srna, "display_type", PROP_ENUM, PROP_NONE);
3475 RNA_def_property_enum_sdna(prop, nullptr, "dt");
3476 RNA_def_property_enum_items(prop, drawtype_items);
3477 RNA_def_property_ui_text(prop, "Display As", "How to display object in viewport");
3478 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
3479
3480 prop = RNA_def_property(srna, "show_bounds", PROP_BOOLEAN, PROP_NONE);
3481 RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_DRAWBOUNDOX);
3482 RNA_def_property_ui_text(prop, "Display Bounds", "Display the object's bounds");
3483 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3484
3485 prop = RNA_def_property(srna, "display_bounds_type", PROP_ENUM, PROP_NONE);
3486 RNA_def_property_enum_sdna(prop, nullptr, "boundtype");
3487 RNA_def_property_enum_items(prop, boundtype_items);
3488 RNA_def_property_ui_text(prop, "Display Bounds Type", "Object boundary display type");
3489 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3490
3491 prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE);
3492 RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_DRAWNAME);
3493 RNA_def_property_ui_text(prop, "Display Name", "Display the object's name");
3494 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3495
3496 prop = RNA_def_property(srna, "show_axis", PROP_BOOLEAN, PROP_NONE);
3497 RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_AXIS);
3498 RNA_def_property_ui_text(prop, "Display Axes", "Display the object's origin and axes");
3499 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3500
3501 prop = RNA_def_property(srna, "show_texture_space", PROP_BOOLEAN, PROP_NONE);
3502 RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_TEXSPACE);
3503 RNA_def_property_ui_text(prop, "Display Texture Space", "Display the object's texture space");
3504 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3505
3506 prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE);
3507 RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_DRAWWIRE);
3509 prop, "Display Wire", "Display the object's wireframe over solid shading");
3510 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3511
3512 prop = RNA_def_property(srna, "show_all_edges", PROP_BOOLEAN, PROP_NONE);
3513 RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_DRAW_ALL_EDGES);
3514 RNA_def_property_ui_text(prop, "Display All Edges", "Display all edges for mesh objects");
3515 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3516
3517 prop = RNA_def_property(srna, "use_grease_pencil_lights", PROP_BOOLEAN, PROP_NONE);
3520 RNA_def_property_ui_text(prop, "Use Lights", "Lights affect Grease Pencil object");
3521 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_grease_pencil_update");
3522
3523 prop = RNA_def_property(srna, "show_transparent", PROP_BOOLEAN, PROP_NONE);
3524 RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_DRAWTRANSP);
3526 prop, "Display Transparent", "Display material transparency in the object");
3527 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3528
3529 prop = RNA_def_property(srna, "show_in_front", PROP_BOOLEAN, PROP_NONE);
3530 RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_DRAW_IN_FRONT);
3531 RNA_def_property_ui_text(prop, "In Front", "Make the object display in front of others");
3532 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_grease_pencil_update");
3533
3534 /* pose */
3535 prop = RNA_def_property(srna, "pose", PROP_POINTER, PROP_NONE);
3536 RNA_def_property_pointer_sdna(prop, nullptr, "pose");
3537 RNA_def_property_struct_type(prop, "Pose");
3538 RNA_def_property_ui_text(prop, "Pose", "Current pose for armatures");
3539
3540 /* shape keys */
3541 prop = RNA_def_property(srna, "show_only_shape_key", PROP_BOOLEAN, PROP_NONE);
3542 RNA_def_property_boolean_sdna(prop, nullptr, "shapeflag", OB_SHAPE_LOCK);
3544 prop, "Solo Active Shape Key", "Only show the active shape key at full value");
3545 RNA_def_property_ui_icon(prop, ICON_SOLO_OFF, 1);
3546 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
3547
3548 prop = RNA_def_property(srna, "use_shape_key_edit_mode", PROP_BOOLEAN, PROP_NONE);
3549 RNA_def_property_boolean_sdna(prop, nullptr, "shapeflag", OB_SHAPE_EDIT_MODE);
3551 prop, "Shape Key Edit Mode", "Display shape keys in edit mode (for meshes only)");
3552 RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0);
3553 RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
3554
3555 prop = RNA_def_property(srna, "active_shape_key", PROP_POINTER, PROP_NONE);
3556 RNA_def_property_struct_type(prop, "ShapeKey");
3560 prop, "rna_Object_active_shape_key_get", nullptr, nullptr, nullptr);
3561 RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key");
3562
3563 prop = RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE);
3564 RNA_def_property_int_sdna(prop, nullptr, "shapenr");
3565 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* XXX this is really unpredictable... */
3567 "rna_Object_active_shape_key_index_get",
3568 "rna_Object_active_shape_key_index_set",
3569 "rna_Object_active_shape_key_index_range");
3570 RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index");
3571 RNA_def_property_update(prop, 0, "rna_Object_active_shape_update");
3572
3573 /* sculpt */
3574 prop = RNA_def_property(srna, "use_dynamic_topology_sculpting", PROP_BOOLEAN, PROP_NONE);
3575 RNA_def_property_boolean_funcs(prop, "rna_Object_use_dynamic_topology_sculpting_get", nullptr);
3577 RNA_def_property_ui_text(prop, "Dynamic Topology Sculpting", nullptr);
3578
3579 /* Base Settings */
3580 prop = RNA_def_property(srna, "is_from_instancer", PROP_BOOLEAN, PROP_NONE);
3581 RNA_def_property_boolean_sdna(prop, nullptr, "base_flag", BASE_FROM_DUPLI);
3582 RNA_def_property_ui_text(prop, "Base from Instancer", "Object comes from a instancer");
3586
3587 prop = RNA_def_property(srna, "is_from_set", PROP_BOOLEAN, PROP_NONE);
3588 RNA_def_property_boolean_sdna(prop, nullptr, "base_flag", BASE_FROM_SET);
3589 RNA_def_property_ui_text(prop, "Base from Set", "Object comes from a background set");
3593
3594 /* Object Display */
3595 prop = RNA_def_property(srna, "display", PROP_POINTER, PROP_NONE);
3597 RNA_def_property_struct_type(prop, "ObjectDisplay");
3598 RNA_def_property_pointer_funcs(prop, "rna_Object_display_get", nullptr, nullptr, nullptr);
3599 RNA_def_property_ui_text(prop, "Object Display", "Object display settings for 3D viewport");
3600
3601 /* Line Art */
3602 prop = RNA_def_property(srna, "lineart", PROP_POINTER, PROP_NONE);
3603 RNA_def_property_struct_type(prop, "ObjectLineArt");
3604 RNA_def_property_ui_text(prop, "Line Art", "Line Art settings for the object");
3605
3606 /* Mesh Symmetry Settings */
3607
3608 prop = RNA_def_property(srna, "use_mesh_mirror_x", PROP_BOOLEAN, PROP_NONE);
3610 prop, "rna_Object_mesh_symmetry_x_get", "rna_Object_mesh_symmetry_x_set");
3612 RNA_def_property_ui_text(prop, "X", "Enable mesh symmetry in the X axis");
3613 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3614
3615 prop = RNA_def_property(srna, "use_mesh_mirror_y", PROP_BOOLEAN, PROP_NONE);
3617 prop, "rna_Object_mesh_symmetry_y_get", "rna_Object_mesh_symmetry_y_set");
3619 RNA_def_property_editable_func(prop, "rna_Object_mesh_symmetry_yz_editable");
3620 RNA_def_property_ui_text(prop, "Y", "Enable mesh symmetry in the Y axis");
3621 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3622
3623 prop = RNA_def_property(srna, "use_mesh_mirror_z", PROP_BOOLEAN, PROP_NONE);
3625 prop, "rna_Object_mesh_symmetry_z_get", "rna_Object_mesh_symmetry_z_set");
3627 RNA_def_property_editable_func(prop, "rna_Object_mesh_symmetry_yz_editable");
3628 RNA_def_property_ui_text(prop, "Z", "Enable mesh symmetry in the Z axis");
3629 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3630
3631 /* Lightgroup Membership */
3632 prop = RNA_def_property(srna, "lightgroup", PROP_STRING, PROP_NONE);
3634 "rna_Object_lightgroup_get",
3635 "rna_Object_lightgroup_length",
3636 "rna_Object_lightgroup_set");
3638 RNA_def_property_ui_text(prop, "Lightgroup", "Lightgroup that the object belongs to");
3639
3640 /* Light Linking. */
3641 prop = RNA_def_property(srna, "light_linking", PROP_POINTER, PROP_NONE);
3643 RNA_def_property_struct_type(prop, "ObjectLightLinking");
3644 RNA_def_property_pointer_funcs(prop, "rna_Object_light_linking_get", nullptr, nullptr, nullptr);
3645 RNA_def_property_ui_text(prop, "Light Linking", "Light linking settings");
3646
3647 /* Shadow terminator. */
3648 prop = RNA_def_property(srna, "shadow_terminator_normal_offset", PROP_FLOAT, PROP_DISTANCE);
3649 RNA_def_property_range(prop, 0.0f, FLT_MAX);
3650 RNA_def_property_ui_range(prop, 0.0, 10, 0.01f, 4);
3652 prop,
3653 "Shadow Terminator Normal Offset",
3654 "Offset rays from the surface to reduce shadow terminator artifact on low poly geometry. "
3655 "Only affect triangles that are affected by the geometry offset");
3656
3657 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3658
3659 prop = RNA_def_property(srna, "shadow_terminator_geometry_offset", PROP_FLOAT, PROP_FACTOR);
3660 RNA_def_property_range(prop, 0.0f, FLT_MAX);
3661 RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 2);
3663 "Shadow Terminator Geometry Offset",
3664 "Offset rays from the surface to reduce shadow terminator artifact on "
3665 "low poly geometry. Only affects triangles at grazing angles to light");
3666 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3667
3668 prop = RNA_def_property(srna, "shadow_terminator_shading_offset", PROP_FLOAT, PROP_FACTOR);
3669 RNA_def_property_range(prop, 0.0f, FLT_MAX);
3670 RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 2);
3672 prop,
3673 "Shadow Terminator Shading Offset",
3674 "Push the shadow terminator towards the light to hide artifacts on low poly geometry");
3675 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
3676
3678
3679 /* anim */
3681
3684
3685 RNA_api_object(srna);
3686}
3687
3689{
3690 StructRNA *srna;
3691 PropertyRNA *prop;
3692
3693 srna = RNA_def_struct(brna, "ObjectLightLinking", nullptr);
3694 RNA_def_struct_ui_text(srna, "Object Light Linking", "");
3695 RNA_def_struct_sdna(srna, "Object");
3696 RNA_def_struct_nested(brna, srna, "Object");
3697 RNA_def_struct_path_func(srna, "rna_ObjectLightLinking_path");
3698
3699 prop = RNA_def_property(srna, "receiver_collection", PROP_POINTER, PROP_NONE);
3700 RNA_def_property_struct_type(prop, "Collection");
3703 "rna_LightLinking_receiver_collection_get",
3704 "rna_LightLinking_receiver_collection_set",
3705 nullptr,
3706 nullptr);
3708 "Receiver Collection",
3709 "Collection which defines light linking relation of this emitter");
3710 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_LightLinking_collection_update");
3711
3712 prop = RNA_def_property(srna, "blocker_collection", PROP_POINTER, PROP_NONE);
3713 RNA_def_property_struct_type(prop, "Collection");
3716 "rna_LightLinking_blocker_collection_get",
3717 "rna_LightLinking_blocker_collection_set",
3718 nullptr,
3719 nullptr);
3721 "Blocker Collection",
3722 "Collection which defines objects which block light from this emitter");
3723 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_LightLinking_collection_update");
3724}
3725
3727{
3728 rna_def_object(brna);
3729
3737}
3738
3739#endif
void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, bool do_id_user)
Definition armature.cc:2877
void BKE_rotMode_change_values(float quat[4], float eul[3], float axis[3], float *angle, short oldMode, short newMode)
Definition armature.cc:2414
Camera data-block and utility functions.
bool BKE_collection_has_object_recursive(Collection *collection, Object *ob)
void BKE_constraints_free(struct ListBase *list)
bool BKE_constraint_remove_ex(ListBase *list, struct Object *ob, struct bConstraint *con)
struct bConstraint * BKE_constraint_add_for_object(struct Object *ob, const char *name, short type)
struct bConstraint * BKE_constraint_copy_for_object(struct Object *ob, struct bConstraint *src)
struct bConstraint * BKE_constraint_duplicate_ex(struct bConstraint *src, int flag, bool do_extern)
struct bConstraint * BKE_constraints_active_get(struct ListBase *list)
void BKE_constraints_active_set(ListBase *list, struct bConstraint *con)
void BKE_constraint_unique_name(struct bConstraint *con, struct ListBase *list)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
void BKE_curve_type_test(Object *ob, bool dimension_update)
Definition curve.cc:458
support for deformation groups and hooks.
void BKE_object_defgroup_active_index_set(Object *ob, int new_index)
Definition deform.cc:601
int BKE_object_defgroup_active_index_get(const Object *ob)
Definition deform.cc:596
bool BKE_object_supports_vertex_groups(const Object *ob)
Definition deform.cc:452
const ListBase * BKE_object_defgroup_list(const Object *ob)
Definition deform.cc:574
ListBase * BKE_object_defgroup_list_mutable(Object *ob)
Definition deform.cc:585
bDeformGroup * BKE_object_defgroup_find_name(const Object *ob, blender::StringRef name)
Definition deform.cc:515
int BKE_object_defgroup_name_index(const Object *ob, blender::StringRef name)
Definition deform.cc:580
void BKE_object_defgroup_set_name(bDeformGroup *dg, Object *ob, const char *new_name)
Definition deform.cc:751
void BKE_editlattice_load(struct Object *obedit)
void BKE_editlattice_make(struct Object *obedit)
void BKE_editmesh_looptris_and_normals_calc(BMEditMesh *em)
Definition editmesh.cc:95
#define G_MAIN
Key * BKE_key_from_object(Object *ob)
Definition key.cc:1824
void BKE_main_collection_sync_remap(const Main *bmain)
int BKE_lightgroup_membership_length(const LightgroupMembership *lgm)
void BKE_lightgroup_membership_set(LightgroupMembership **lgm, const char *name)
int BKE_lightgroup_membership_get(const LightgroupMembership *lgm, char *name)
void id_us_plus(ID *id)
Definition lib_id.cc:353
void id_us_min(ID *id)
Definition lib_id.cc:361
bool BKE_id_is_in_global_main(ID *id)
Definition lib_id.cc:2480
@ LIGHT_LINKING_BLOCKER
@ LIGHT_LINKING_RECEIVER
void BKE_light_linking_collection_assign_only(struct Object *object, struct Collection *new_collection, LightLinkingType link_type)
struct Collection * BKE_light_linking_collection_get(const struct Object *object, LightLinkingType link_type)
General operations, lookup, etc. for materials.
int BKE_object_material_count_eval(const Object *ob)
void BKE_object_materials_sync_length(Main *bmain, Object *ob, ID *id)
@ BKE_MAT_ASSIGN_EXISTING
Material * BKE_object_material_get(Object *ob, short act)
Material * BKE_object_material_get_eval(Object *ob, short act)
void BKE_object_material_assign(Main *bmain, Object *ob, Material *ma, short act, int assign_type)
void BKE_mesh_assign_object(Main *bmain, Object *ob, Mesh *mesh)
Mesh * BKE_mesh_wrapper_ensure_subdivision(Mesh *mesh)
ModifierData * BKE_modifiers_findby_type(const Object *ob, ModifierType type)
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
@ eModifierTypeFlag_Single
void BKE_modifier_copydata(const ModifierData *md, ModifierData *target)
General operations, lookup, etc. for blender objects.
void BKE_object_matrix_local_get(Object *ob, float r_mat[4][4])
void BKE_object_empty_draw_type_set(Object *ob, int value)
void BKE_object_modifier_set_active(Object *ob, ModifierData *md)
bool BKE_object_is_in_editmode(const Object *ob)
void BKE_object_dimensions_set(Object *ob, const float value[3], int axis_mask)
void BKE_object_apply_mat4(Object *ob, const float mat[4][4], bool use_compat, bool use_parent)
void BKE_object_dimensions_eval_cached_get(const Object *ob, float r_vec[3])
std::optional< blender::Bounds< blender::float3 > > BKE_object_boundbox_eval_cached_get(const Object *ob)
void BKE_boundbox_init_from_minmax(BoundBox *bb, const float min[3], const float max[3])
ModifierData * BKE_object_active_modifier(const Object *ob)
void BKE_object_to_mat4(const Object *ob, float r_mat[4][4])
bool BKE_object_is_in_editmode_vgroup(const Object *ob)
Functions for dealing with objects and deform verts, used by painting and tools.
void BKE_object_defgroup_remove(struct Object *ob, struct bDeformGroup *defgroup)
struct bDeformGroup * BKE_object_defgroup_add_name(struct Object *ob, const char *name)
void BKE_object_defgroup_remove_all(struct Object *ob)
bool BKE_object_sculpt_use_dyntopo(const Object *object)
Definition paint.cc:2923
void psys_set_current_num(struct Object *ob, int index)
Definition particle.cc:570
short psys_get_current_num(struct Object *ob)
Definition particle.cc:551
struct ParticleSystem * psys_get_current(struct Object *ob)
Definition particle.cc:537
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:126
#define BLI_assert(a)
Definition BLI_assert.h:46
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:586
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:534
bool BLI_listbase_move_index(ListBase *listbase, int from, int to) ATTR_NONNULL()
Definition listbase.cc:467
void void * BLI_listbase_string_or_index_find(const ListBase *listbase, const char *string, size_t string_offset, int index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:754
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:332
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:131
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:524
MINLINE int max_ii(int a, int b)
#define DEG2RAD(_deg)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void copy_vn_fl(float *array_tar, int size, float val)
char * STRNCPY(char(&dst)[N], const char *src)
Definition BLI_string.h:688
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define UNUSED_VARS_NDEBUG(...)
#define ELEM(...)
#define STREQ(a, b)
#define BLT_I18NCONTEXT_ID_IMAGE
#define BLT_I18NCONTEXT_ID_ID
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
bool DEG_is_evaluated(const T *id)
ID and Library types, which are fundamental for SDNA.
@ ID_RECALC_TRANSFORM
Definition DNA_ID.h:962
@ ID_RECALC_SHADING
Definition DNA_ID.h:1002
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1026
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:982
@ LIBOVERRIDE_OP_REPLACE
Definition DNA_ID.h:220
@ LIBOVERRIDE_OP_INSERT_AFTER
Definition DNA_ID.h:230
@ ID_TAG_NO_MAIN
Definition DNA_ID.h:886
@ ID_IM
@ ID_CU_LEGACY
@ ROT_MODE_XZY
@ ROT_MODE_QUAT
@ ROT_MODE_ZXY
@ ROT_MODE_AXISANGLE
@ ROT_MODE_ZYX
@ ROT_MODE_XYZ
@ ROT_MODE_YXZ
@ ROT_MODE_YZX
@ CONSTRAINT_OVERRIDE_LIBRARY_LOCAL
@ CD_PROP_FLOAT2
@ BASE_FROM_DUPLI
@ BASE_FROM_SET
@ LIGHTPROBE_TYPE_PLANE
@ LIGHTPROBE_TYPE_VOLUME
@ LIGHTPROBE_TYPE_SPHERE
eMeshSymmetryType
@ ME_SYMMETRY_X
@ ME_SYMMETRY_Y
@ ME_SYMMETRY_Z
@ ME_EDIT_MIRROR_VERTEX_GROUPS
@ MB_PLANE
@ MB_ELIPSOID
@ MB_TUBE
@ MB_CUBE
@ MB_BALL
@ eModifierType_ParticleSystem
@ OB_WIRE
@ OB_TEXTURE
@ OB_BOUNDBOX
@ OB_SOLID
@ OB_MODE_VERTEX_GREASE_PENCIL
@ OB_MODE_PARTICLE_EDIT
@ OB_MODE_EDIT_GPENCIL_LEGACY
@ OB_MODE_EDIT
@ OB_MODE_WEIGHT_PAINT
@ OB_MODE_SCULPT
@ OB_MODE_SCULPT_CURVES
@ OB_MODE_PAINT_GREASE_PENCIL
@ OB_MODE_SCULPT_GREASE_PENCIL
@ OB_MODE_POSE
@ OB_MODE_TEXTURE_PAINT
@ OB_MODE_OBJECT
@ OB_MODE_WEIGHT_GREASE_PENCIL
@ OB_MODE_VERTEX_PAINT
Object is a sort of wrapper for general info.
@ OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK
@ OB_DUPLI
@ OB_PARENT_USE_FINAL_INDICES
@ OB_DUPLIVERTS
@ OB_DUPLIROT
@ OB_DUPLIFACES_SCALE
@ OB_EMPTY_CONE
@ OB_SINGLE_ARROW
@ OB_PLAINAXES
@ OB_ARROWS
@ OB_CIRCLE
@ OB_CUBE
@ OB_EMPTY_IMAGE
@ OB_EMPTY_SPHERE
@ OB_HIDE_TRANSMISSION
@ OB_HOLDOUT
@ OB_HIDE_PROBE_VOLUME
@ OB_HIDE_RENDER
@ OB_HIDE_CAMERA
@ OB_HIDE_PROBE_PLANAR
@ OB_HIDE_PROBE_CUBEMAP
@ OB_HIDE_SELECT
@ OB_HIDE_GLOSSY
@ OB_HIDE_SHADOW
@ OB_SHADOW_CATCHER
@ OB_HIDE_VIEWPORT
@ OB_HIDE_DIFFUSE
@ OB_HIDE_VOLUME_SCATTER
@ OB_POSX
@ OB_NEGZ
@ OB_POSY
@ OB_NEGX
@ OB_POSZ
@ OB_NEGY
@ OB_LOCK_ROTZ
@ OB_LOCK_ROT4D
@ OB_LOCK_SCALEZ
@ OB_LOCK_ROTX
@ OB_LOCK_SCALEX
@ OB_LOCK_ROTW
@ OB_LOCK_LOCY
@ OB_LOCK_LOCZ
@ OB_LOCK_ROTY
@ OB_LOCK_SCALEY
@ OB_LOCK_LOCX
#define OB_DATA_SUPPORT_ID(_id_type)
@ GREASE_PENCIL_LINEART_SCENE
@ GP_STROKE
@ GREASE_PENCIL_LINEART_COLLECTION
@ GREASE_PENCIL_LINEART_OBJECT
@ GP_MONKEY
@ GP_EMPTY
@ OB_MODIFIER_FLAG_ADD_REST_POSITION
@ OB_SHAPE_EDIT_MODE
@ OB_SHAPE_LOCK
#define OB_TYPE_SUPPORT_PARVERT(_type)
@ OBJECT_LRT_OWN_INTERSECTION_PRIORITY
@ OBJECT_LRT_OWN_CREASE
@ OB_DUPLI_FLAG_VIEWPORT
@ OB_DUPLI_FLAG_RENDER
@ OB_SPEAKER
@ OB_LATTICE
@ OB_MBALL
@ OB_EMPTY
@ OB_SURF
@ OB_CAMERA
@ OB_FONT
@ OB_GREASE_PENCIL
@ OB_ARMATURE
@ OB_LAMP
@ OB_MESH
@ OB_POINTCLOUD
@ OB_VOLUME
@ OB_CURVES_LEGACY
@ OB_GPENCIL_LEGACY
@ OB_CURVES
@ OB_LIGHTPROBE
@ OB_DRAWNAME
@ OB_DRAWBOUNDOX
@ OB_DRAW_ALL_EDGES
@ OB_AXIS
@ OB_USE_GPENCIL_LIGHTS
@ OB_DRAW_NO_SHADOW_CAST
@ OB_DRAW_IN_FRONT
@ OB_TEXSPACE
@ OB_DRAWWIRE
@ OB_DRAWTRANSP
@ OB_EMPTY_IMAGE_HIDE_FRONT
@ OB_EMPTY_IMAGE_HIDE_NON_AXIS_ALIGNED
@ OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC
@ OB_EMPTY_IMAGE_HIDE_BACK
@ OB_EMPTY_IMAGE_HIDE_PERSPECTIVE
@ OB_BOUND_CAPSULE
@ OB_BOUND_SPHERE
@ OB_BOUND_CONE
@ OB_BOUND_BOX
@ OB_BOUND_CYLINDER
@ OB_EMPTY_IMAGE_USE_ALPHA_BLEND
@ PARVERT1
@ PARSKEL
@ PAROBJECT
@ PARVERT3
@ PARBONE
@ OBJECT_LRT_INCLUDE
@ OBJECT_LRT_NO_INTERSECTION
@ OBJECT_LRT_EXCLUDE
@ OBJECT_LRT_INHERIT
@ OBJECT_LRT_OCCLUSION_ONLY
@ OBJECT_LRT_INTERSECTION_ONLY
@ OBJECT_LRT_FORCE_INTERSECTION
@ OB_FLAG_USE_SIMULATION_CACHE
@ OB_EMPTY_IMAGE_DEPTH_DEFAULT
@ OB_EMPTY_IMAGE_DEPTH_FRONT
@ OB_EMPTY_IMAGE_DEPTH_BACK
@ PSYS_DELETE
void EDBM_mesh_make(Object *ob, int select_mode, bool add_key_index)
void EDBM_mesh_load(Main *bmain, Object *ob)
#define WEIGHT_REPLACE
#define WEIGHT_ADD
#define WEIGHT_SUBTRACT
void PE_current_changed(Depsgraph *depsgraph, Scene *scene, Object *ob)
ParameterFlag
Definition RNA_types.hh:510
@ PARM_RNAPTR
Definition RNA_types.hh:513
@ PARM_REQUIRED
Definition RNA_types.hh:511
@ FUNC_USE_REPORTS
Definition RNA_types.hh:805
@ FUNC_USE_MAIN
Definition RNA_types.hh:803
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:804
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:792
@ STRUCT_ID_REFCOUNT
Definition RNA_types.hh:845
@ PROP_FLOAT
Definition RNA_types.hh:152
@ PROP_BOOLEAN
Definition RNA_types.hh:150
@ PROP_ENUM
Definition RNA_types.hh:154
@ PROP_INT
Definition RNA_types.hh:151
@ PROP_STRING
Definition RNA_types.hh:153
@ PROP_POINTER
Definition RNA_types.hh:155
@ PROP_COLLECTION
Definition RNA_types.hh:156
#define RNA_ENUM_ITEM_SEPR
Definition RNA_types.hh:645
#define RNA_TRANSLATION_PREC_DEFAULT
Definition RNA_types.hh:212
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:469
@ PROPOVERRIDE_NO_COMPARISON
Definition RNA_types.hh:477
@ PROPOVERRIDE_IGNORE
Definition RNA_types.hh:489
@ PROPOVERRIDE_LIBRARY_INSERTION
Definition RNA_types.hh:494
@ PROPOVERRIDE_NO_PROP_NAME
Definition RNA_types.hh:502
PropertyFlag
Definition RNA_types.hh:286
@ PROP_THICK_WRAP
Definition RNA_types.hh:397
@ PROP_DYNAMIC
Definition RNA_types.hh:402
@ PROP_ANIMATABLE
Definition RNA_types.hh:305
@ PROP_PROPORTIONAL
Definition RNA_types.hh:335
@ PROP_NEVER_UNLINK
Definition RNA_types.hh:358
@ PROP_EDITABLE
Definition RNA_types.hh:292
@ PROP_NEVER_NULL
Definition RNA_types.hh:351
@ PROP_NO_DEG_UPDATE
Definition RNA_types.hh:413
@ PROP_ID_SELF_CHECK
Definition RNA_types.hh:344
@ PROP_MATRIX
Definition RNA_types.hh:253
@ PROP_XYZ
Definition RNA_types.hh:257
@ PROP_DISTANCE
Definition RNA_types.hh:244
@ PROP_COLOR
Definition RNA_types.hh:248
@ PROP_ANGLE
Definition RNA_types.hh:240
@ PROP_AXISANGLE
Definition RNA_types.hh:256
@ PROP_EULER
Definition RNA_types.hh:254
@ PROP_NONE
Definition RNA_types.hh:221
@ PROP_FACTOR
Definition RNA_types.hh:239
@ PROP_TRANSLATION
Definition RNA_types.hh:249
@ PROP_XYZ_LENGTH
Definition RNA_types.hh:258
@ PROP_UNSIGNED
Definition RNA_types.hh:237
@ PROP_QUATERNION
Definition RNA_types.hh:255
#define C
Definition RandGen.cpp:29
#define ND_SHADING
Definition WM_types.hh:474
#define NC_GEOM
Definition WM_types.hh:390
#define ND_DRAW
Definition WM_types.hh:458
#define ND_DATA
Definition WM_types.hh:506
#define ND_VERTEX_GROUP
Definition WM_types.hh:507
#define NA_ADDED
Definition WM_types.hh:583
#define ND_MODIFIER
Definition WM_types.hh:459
#define NA_EDITED
Definition WM_types.hh:581
#define ND_PARENT
Definition WM_types.hh:464
ReportList * reports
Definition WM_types.hh:1025
#define NC_MATERIAL
Definition WM_types.hh:377
#define ND_CONSTRAINT
Definition WM_types.hh:461
#define NA_REMOVED
Definition WM_types.hh:584
#define NC_GPENCIL
Definition WM_types.hh:396
#define ND_TRANSFORM
Definition WM_types.hh:453
#define NA_RENAME
Definition WM_types.hh:585
#define ND_OB_SHADING
Definition WM_types.hh:454
#define NC_OBJECT
Definition WM_types.hh:376
#define ND_SHADING_LINKS
Definition WM_types.hh:476
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
Definition btDbvt.cpp:299
#define offsetof(t, d)
void ED_curve_editnurb_make(Object *obedit)
void ED_curve_editnurb_load(Main *bmain, Object *obedit)
float length(VecOp< float, D >) RET
#define MAX_ID_NAME
#define ID_IS_EDITABLE(_id)
#define GS(a)
ModifierData * modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, const char *name, int type)
void constraint_active_set(Object *ob, bConstraint *con)
void shaderfx_clear(Main *bmain, Object *ob)
void constraint_update(Main *bmain, Object *ob)
ShaderFxData * shaderfx_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, const char *name, int type)
float vgroup_vert_weight(Object *ob, bDeformGroup *dg, int vertnum)
void constraint_tag_update(Main *bmain, Object *ob, bConstraint *con)
bool parent_set(ReportList *reports, const bContext *C, Scene *scene, Object *const ob, Object *const par, int partype, bool xmirror, bool keep_transform, const int vert_par[3])
bool modifier_move_to_index(ReportList *reports, eReportType error_type, Object *ob, ModifierData *md, int index, bool allow_partial)
bool shaderfx_remove(ReportList *reports, Main *bmain, Object *ob, ShaderFxData *fx)
void vgroup_vert_add(Object *ob, bDeformGroup *dg, int vertnum, float weight, int assignmode)
void vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum)
void modifiers_clear(Main *bmain, Scene *scene, Object *ob)
bool modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md)
SymEdge< T > * sym(const SymEdge< T > *se)
MatBase< float, 4, 4 > float4x4
const PointerRNA PointerRNA_NULL
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, PointerRNA *ptr, ListBase *lb, IteratorSkipFunc skip)
bool RNA_enum_name_from_value(const EnumPropertyItem *item, int value, const char **r_name)
void RNA_property_update_main(Main *bmain, Scene *scene, PointerRNA *ptr, PropertyRNA *prop)
bool RNA_pointer_is_null(const PointerRNA *ptr)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
std::string RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
PointerRNA RNA_id_pointer_create(ID *id)
void rna_def_animdata_common(StructRNA *srna)
void rna_def_animviz_common(StructRNA *srna)
void rna_def_motionpath_common(StructRNA *srna)
const EnumPropertyItem rna_enum_constraint_type_items[]
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_define_lib_overridable(const bool make_overridable)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_define_animate_sdna(bool animate)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_boolean_bitset_array_sdna(PropertyRNA *prop, const char *structname, const char *propname, const int64_t booleanbit, const int length)
void RNA_def_property_boolean_default(PropertyRNA *prop, bool value)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
const float rna_default_axis_angle[4]
void RNA_def_property_editable_array_func(PropertyRNA *prop, const char *editable)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_struct_clear_flag(StructRNA *srna, int flag)
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
const int rna_matrix_dimsize_4x4[]
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
void RNA_def_property_override_funcs(PropertyRNA *prop, const char *diff, const char *store, const char *apply)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_override_clear_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item, int value)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *structname)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
bool rna_Armature_object_poll(PointerRNA *ptr, PointerRNA value)
bool rna_Light_object_poll(PointerRNA *ptr, PointerRNA value)
int rna_object_vgroup_name_index_length(PointerRNA *ptr, int index)
bool rna_Lattice_object_poll(PointerRNA *ptr, PointerRNA value)
void rna_object_vgroup_name_set(PointerRNA *ptr, const char *value, char *result, int result_maxncpy)
bool rna_Mesh_object_poll(PointerRNA *ptr, PointerRNA value)
void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *result, int result_maxncpy)
void rna_object_vgroup_name_index_set(PointerRNA *ptr, const char *value, short *index)
bool rna_Camera_object_poll(PointerRNA *ptr, PointerRNA value)
void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *result, int result_maxncpy)
bool rna_Curve_object_poll(PointerRNA *ptr, PointerRNA value)
void rna_Object_internal_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
void RNA_api_object(StructRNA *srna)
const EnumPropertyItem rna_enum_object_modifier_type_items[]
const EnumPropertyItem rna_enum_object_empty_drawtype_items[]
const EnumPropertyItem rna_enum_metaelem_type_items[]
#define OBTYPE_CU_CURVE
static void rna_def_object_light_linking(BlenderRNA *brna)
#define OBTYPE_CU_FONT
const EnumPropertyItem rna_enum_workspace_object_mode_items[]
Definition rna_object.cc:71
static void rna_def_object_shaderfxs(BlenderRNA *brna, PropertyRNA *cprop)
static const EnumPropertyItem instance_items[]
static const EnumPropertyItem parent_type_items[]
const EnumPropertyItem rna_enum_object_gpencil_type_items[]
const EnumPropertyItem rna_enum_object_rotation_mode_items[]
static void rna_def_object_visibility(StructRNA *srna)
static void rna_def_material_slot(BlenderRNA *brna)
static void rna_def_object(BlenderRNA *brna)
const EnumPropertyItem rna_enum_lightprobes_type_items[]
static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
const EnumPropertyItem rna_enum_object_mode_items[]
Definition rna_object.cc:33
static void rna_def_object_lineart(BlenderRNA *brna)
const EnumPropertyItem rna_enum_object_axis_items[]
const EnumPropertyItem rna_enum_object_type_curve_items[]
#define INSTANCE_ITEM_COLLECTION
const EnumPropertyItem rna_enum_object_type_items[]
#define OBTYPE_CU_SURF
static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
static const EnumPropertyItem rna_enum_object_empty_image_depth_items[]
static void rna_def_vertex_group(BlenderRNA *brna)
static void rna_def_object_display(BlenderRNA *brna)
static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop)
void RNA_def_object(BlenderRNA *brna)
#define INSTANCE_ITEMS_SHARED
const EnumPropertyItem rna_enum_object_shaderfx_type_items[]
#define min(a, b)
Definition sort.cc:36
#define FLT_MAX
Definition stdcycles.h:14
short selectmode
float vec[8][3]
union CollectionPropertyIterator::@277172262001176145116102322066145204253046376362 internal
CustomDataLayer * layers
Definition DNA_ID.h:404
int tag
Definition DNA_ID.h:424
char name[66]
Definition DNA_ID.h:415
ListBase block
struct MaterialGPencilStyle * gp_style
char symmetry
MeshRuntimeHandle * runtime
CustomData corner_data
char editflag
CustomData fdata_legacy
ModifierTypeFlag flags
ListBase particlesystem
ListBase constraints
struct Collection * instance_collection
ObjectRuntimeHandle * runtime
ListBase modifiers
char * matbits
struct PartDeflect * pd
float rot[3]
float parentinv[4][4]
float quat[4]
float rotAxis[3]
short protectflag
struct Object * parent
char parsubstr[64]
ID * owner_id
Definition RNA_types.hh:51
void invalidate()
Definition RNA_types.hh:110
void * data
Definition RNA_types.hh:53
IDOverrideLibraryPropertyOperation * liboverride_operation
max
Definition text_draw.cc:251
uint len
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4226