Blender V4.3
rna_ID.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
9#include <cstdio>
10#include <cstdlib>
11
12#include "DNA_ID.h"
13#include "DNA_material_types.h"
14#include "DNA_object_types.h"
15#include "DNA_vfont_types.h"
16
17#include "BLI_utildefines.h"
18
19#include "BKE_icons.h"
20#include "BKE_lib_id.hh"
21#include "BKE_main_namemap.hh"
22#include "BKE_object.hh"
23
24#include "RNA_access.hh"
25#include "RNA_define.hh"
26#include "RNA_enum_types.hh"
27
28#include "WM_types.hh"
29
30#include "rna_internal.hh"
31
32/* enum of ID-block types
33 * NOTE: need to keep this in line with the other defines for these
34 */
36 {ID_AC, "ACTION", ICON_ACTION, "Action", ""},
37 {ID_AR, "ARMATURE", ICON_ARMATURE_DATA, "Armature", ""},
38 {ID_BR, "BRUSH", ICON_BRUSH_DATA, "Brush", ""},
39 {ID_CF, "CACHEFILE", ICON_FILE, "Cache File", ""},
40 {ID_CA, "CAMERA", ICON_CAMERA_DATA, "Camera", ""},
41 {ID_GR, "COLLECTION", ICON_OUTLINER_COLLECTION, "Collection", ""},
42 {ID_CU_LEGACY, "CURVE", ICON_CURVE_DATA, "Curve", ""},
43 {ID_CV, "CURVES", ICON_CURVES_DATA, "Curves", ""},
44 {ID_VF, "FONT", ICON_FONT_DATA, "Font", ""},
45 {ID_GD_LEGACY, "GREASEPENCIL", ICON_GREASEPENCIL, "Grease Pencil", ""},
46 {ID_GP, "GREASEPENCIL_V3", ICON_GREASEPENCIL, "Grease Pencil v3", ""},
47 {ID_IM, "IMAGE", ICON_IMAGE_DATA, "Image", ""},
48 {ID_KE, "KEY", ICON_SHAPEKEY_DATA, "Key", ""},
49 {ID_LT, "LATTICE", ICON_LATTICE_DATA, "Lattice", ""},
50 {ID_LI, "LIBRARY", ICON_LIBRARY_DATA_DIRECT, "Library", ""},
51 {ID_LA, "LIGHT", ICON_LIGHT_DATA, "Light", ""},
52 {ID_LP, "LIGHT_PROBE", ICON_LIGHTPROBE_SPHERE, "Light Probe", ""},
53 {ID_LS, "LINESTYLE", ICON_LINE_DATA, "Line Style", ""},
54 {ID_MSK, "MASK", ICON_MOD_MASK, "Mask", ""},
55 {ID_MA, "MATERIAL", ICON_MATERIAL_DATA, "Material", ""},
56 {ID_ME, "MESH", ICON_MESH_DATA, "Mesh", ""},
57 {ID_MB, "META", ICON_META_DATA, "Metaball", ""},
58 {ID_MC, "MOVIECLIP", ICON_TRACKER, "Movie Clip", ""},
59 {ID_NT, "NODETREE", ICON_NODETREE, "Node Tree", ""},
60 {ID_OB, "OBJECT", ICON_OBJECT_DATA, "Object", ""},
61 {ID_PC, "PAINTCURVE", ICON_CURVE_BEZCURVE, "Paint Curve", ""},
62 {ID_PAL, "PALETTE", ICON_COLOR, "Palette", ""},
63 {ID_PA, "PARTICLE", ICON_PARTICLE_DATA, "Particle", ""},
64 {ID_PT, "POINTCLOUD", ICON_POINTCLOUD_DATA, "Point Cloud", ""},
65 {ID_SCE, "SCENE", ICON_SCENE_DATA, "Scene", ""},
66 {ID_SCR, "SCREEN", ICON_WORKSPACE, "Screen", ""},
67 {ID_SO, "SOUND", ICON_SOUND, "Sound", ""},
68 {ID_SPK, "SPEAKER", ICON_SPEAKER, "Speaker", ""},
69 {ID_TXT, "TEXT", ICON_TEXT, "Text", ""},
70 {ID_TE, "TEXTURE", ICON_TEXTURE_DATA, "Texture", ""},
71 {ID_VO, "VOLUME", ICON_VOLUME_DATA, "Volume", ""},
72 {ID_WM, "WINDOWMANAGER", ICON_WINDOW, "Window Manager", ""},
73 {ID_WS, "WORKSPACE", ICON_WORKSPACE, "Workspace", ""},
74 {ID_WO, "WORLD", ICON_WORLD_DATA, "World", ""},
75 {0, nullptr, 0, nullptr, nullptr},
76};
77
80 "NOOP",
81 0,
82 "No-Op",
83 "Does nothing, prevents adding actual overrides (NOT USED)"},
85 "REPLACE",
86 0,
87 "Replace",
88 "Replace value of reference by overriding one"},
90 "DIFF_ADD",
91 0,
92 "Differential",
93 "Stores and apply difference between reference and local value (NOT USED)"},
95 "DIFF_SUB",
96 0,
97 "Differential",
98 "Stores and apply difference between reference and local value (NOT USED)"},
100 "FACT_MULTIPLY",
101 0,
102 "Factor",
103 "Stores and apply multiplication factor between reference and local value (NOT USED)"},
105 "INSERT_AFTER",
106 0,
107 "Insert After",
108 "Insert a new item into collection after the one referenced in "
109 "subitem_reference_name/_id or _index"},
111 "INSERT_BEFORE",
112 0,
113 "Insert Before",
114 "Insert a new item into collection before the one referenced in "
115 "subitem_reference_name/_id or _index (NOT USED)"},
116 {0, nullptr, 0, nullptr, nullptr},
117};
118
123 /* Datablocks */
124 {FILTER_ID_AC, "filter_action", ICON_ACTION, "Actions", "Show Action data-blocks"},
126 "filter_armature",
127 ICON_ARMATURE_DATA,
128 "Armatures",
129 "Show Armature data-blocks"},
130 {FILTER_ID_BR, "filter_brush", ICON_BRUSH_DATA, "Brushes", "Show Brushes data-blocks"},
131 {FILTER_ID_CA, "filter_camera", ICON_CAMERA_DATA, "Cameras", "Show Camera data-blocks"},
132 {FILTER_ID_CF, "filter_cachefile", ICON_FILE, "Cache Files", "Show Cache File data-blocks"},
133 {FILTER_ID_CU_LEGACY, "filter_curve", ICON_CURVE_DATA, "Curves", "Show Curve data-blocks"},
135 "filter_grease_pencil",
136 ICON_GREASEPENCIL,
137 "Grease Pencil",
138 "Show Grease pencil data-blocks"},
140 "filter_group",
141 ICON_OUTLINER_COLLECTION,
142 "Collections",
143 "Show Collection data-blocks"},
145 "filter_curves",
146 ICON_CURVES_DATA,
147 "Hair Curves",
148 "Show/hide Curves data-blocks"},
149 {FILTER_ID_IM, "filter_image", ICON_IMAGE_DATA, "Images", "Show Image data-blocks"},
150 {FILTER_ID_LA, "filter_light", ICON_LIGHT_DATA, "Lights", "Show Light data-blocks"},
152 "filter_light_probe",
153 ICON_OUTLINER_DATA_LIGHTPROBE,
154 "Light Probes",
155 "Show Light Probe data-blocks"},
157 "filter_linestyle",
158 ICON_LINE_DATA,
159 "Freestyle Linestyles",
160 "Show Freestyle's Line Style data-blocks"},
161 {FILTER_ID_LT, "filter_lattice", ICON_LATTICE_DATA, "Lattices", "Show Lattice data-blocks"},
163 "filter_material",
164 ICON_MATERIAL_DATA,
165 "Materials",
166 "Show Material data-blocks"},
167 {FILTER_ID_MB, "filter_metaball", ICON_META_DATA, "Metaballs", "Show Metaball data-blocks"},
169 "filter_movie_clip",
170 ICON_TRACKER,
171 "Movie Clips",
172 "Show Movie Clip data-blocks"},
173 {FILTER_ID_ME, "filter_mesh", ICON_MESH_DATA, "Meshes", "Show Mesh data-blocks"},
174 {FILTER_ID_MSK, "filter_mask", ICON_MOD_MASK, "Masks", "Show Mask data-blocks"},
175 {FILTER_ID_NT, "filter_node_tree", ICON_NODETREE, "Node Trees", "Show Node Tree data-blocks"},
176 {FILTER_ID_OB, "filter_object", ICON_OBJECT_DATA, "Objects", "Show Object data-blocks"},
178 "filter_particle_settings",
179 ICON_PARTICLE_DATA,
180 "Particles Settings",
181 "Show Particle Settings data-blocks"},
182 {FILTER_ID_PAL, "filter_palette", ICON_COLOR, "Palettes", "Show Palette data-blocks"},
184 "filter_paint_curve",
185 ICON_CURVE_BEZCURVE,
186 "Paint Curves",
187 "Show Paint Curve data-blocks"},
189 "filter_pointcloud",
190 ICON_POINTCLOUD_DATA,
191 "Point Clouds",
192 "Show/hide Point Cloud data-blocks"},
193 {FILTER_ID_SCE, "filter_scene", ICON_SCENE_DATA, "Scenes", "Show Scene data-blocks"},
194 {FILTER_ID_SPK, "filter_speaker", ICON_SPEAKER, "Speakers", "Show Speaker data-blocks"},
195 {FILTER_ID_SO, "filter_sound", ICON_SOUND, "Sounds", "Show Sound data-blocks"},
196 {FILTER_ID_TE, "filter_texture", ICON_TEXTURE_DATA, "Textures", "Show Texture data-blocks"},
197 {FILTER_ID_TXT, "filter_text", ICON_TEXT, "Texts", "Show Text data-blocks"},
198 {FILTER_ID_VF, "filter_font", ICON_FONT_DATA, "Fonts", "Show Font data-blocks"},
199 {FILTER_ID_VO, "filter_volume", ICON_VOLUME_DATA, "Volumes", "Show/hide Volume data-blocks"},
200 {FILTER_ID_WO, "filter_world", ICON_WORLD_DATA, "Worlds", "Show World data-blocks"},
202 "filter_work_space",
203 ICON_WORKSPACE,
204 "Workspaces",
205 "Show workspace data-blocks"},
206 {0, nullptr, 0, nullptr, nullptr},
207};
208
209#ifdef RNA_RUNTIME
210
211# include "DNA_anim_types.h"
212
213# include "BLI_listbase.h"
214# include "BLI_math_base.h"
215
216# include "BLT_translation.hh"
217
218# include "BLO_readfile.hh"
219
220# include "BKE_anim_data.hh"
221# include "BKE_global.hh" /* XXX, remove me */
222# include "BKE_idprop.hh"
223# include "BKE_idtype.hh"
224# include "BKE_lib_override.hh"
225# include "BKE_lib_query.hh"
226# include "BKE_lib_remap.hh"
227# include "BKE_library.hh"
228# include "BKE_material.h"
229# include "BKE_preview_image.hh"
230# include "BKE_vfont.hh"
231
232# include "DEG_depsgraph.hh"
233# include "DEG_depsgraph_build.hh"
234# include "DEG_depsgraph_query.hh"
235
236# include "ED_asset.hh"
237
238# include "WM_api.hh"
239
240# ifdef WITH_PYTHON
241# include "BPY_extern.hh"
242# endif
243
244void rna_ID_override_library_property_operation_refname_get(PointerRNA *ptr, char *value)
245{
247 ptr->data);
248 strcpy(value, (opop->subitem_reference_name == nullptr) ? "" : opop->subitem_reference_name);
249}
250
251int rna_ID_override_library_property_operation_refname_length(PointerRNA *ptr)
252{
254 ptr->data);
255 return (opop->subitem_reference_name == nullptr) ? 0 : strlen(opop->subitem_reference_name);
256}
257
258void rna_ID_override_library_property_operation_locname_get(PointerRNA *ptr, char *value)
259{
261 ptr->data);
262 strcpy(value, (opop->subitem_local_name == nullptr) ? "" : opop->subitem_local_name);
263}
264
265int rna_ID_override_library_property_operation_locname_length(PointerRNA *ptr)
266{
268 ptr->data);
269 return (opop->subitem_local_name == nullptr) ? 0 : strlen(opop->subitem_local_name);
270}
271
272/* name functions that ignore the first two ID characters */
273void rna_ID_name_get(PointerRNA *ptr, char *value)
274{
275 ID *id = (ID *)ptr->data;
276 strcpy(value, id->name + 2);
277}
278
280{
281 ID *id = (ID *)ptr->data;
282 return strlen(id->name + 2);
283}
284
285static int rna_ID_rename(ID *self, Main *bmain, const char *new_name, const int mode)
286{
287 IDNewNameResult result = BKE_id_rename(*bmain, *self, new_name, IDNewNameMode(mode));
288 return int(result.action);
289}
290
291void rna_ID_name_set(PointerRNA *ptr, const char *value)
292{
293 ID *id = (ID *)ptr->data;
294
295 rna_ID_rename(id, G_MAIN, value, int(IDNewNameMode::RenameExistingNever));
296}
297
298static int rna_ID_name_editable(const PointerRNA *ptr, const char **r_info)
299{
300 ID *id = (ID *)ptr->data;
301
302 /* NOTE: For the time being, allow rename of local liboverrides from the RNA API.
303 * While this is not allowed from the UI, this should work with modern liboverride code,
304 * and could be useful in some cases. */
305 if (!ID_IS_EDITABLE(id)) {
306 if (r_info) {
307 *r_info = N_("Linked data-blocks cannot be renamed");
308 }
309 return 0;
310 }
311
312 if (GS(id->name) == ID_VF) {
313 VFont *vfont = (VFont *)id;
314 if (BKE_vfont_is_builtin(vfont)) {
315 if (r_info) {
316 *r_info = N_("Built-in fonts cannot be renamed");
317 }
318 return 0;
319 }
320 }
321 else if (!BKE_id_is_in_global_main(id)) {
322 if (r_info) {
323 *r_info = N_("Datablocks not in global Main data-base cannot be renamed");
324 }
325 return 0;
326 }
327
328 return PROP_EDITABLE;
329}
330
331void rna_ID_name_full_get(PointerRNA *ptr, char *value)
332{
333 ID *id = (ID *)ptr->data;
334 BKE_id_full_name_get(value, id, 0);
335}
336
337int rna_ID_name_full_length(PointerRNA *ptr)
338{
339 ID *id = (ID *)ptr->data;
340 char name[MAX_ID_FULL_NAME];
341 BKE_id_full_name_get(name, id, 0);
342 return strlen(name);
343}
344
345static int rna_ID_type_get(PointerRNA *ptr)
346{
347 ID *id = static_cast<ID *>(ptr->data);
348 return GS(id->name);
349}
350
351static bool rna_ID_is_evaluated_get(PointerRNA *ptr)
352{
353 ID *id = (ID *)ptr->data;
354
355 return (DEG_get_original_id(id) != id);
356}
357
358static PointerRNA rna_ID_original_get(PointerRNA *ptr)
359{
360 ID *id = (ID *)ptr->data;
361
363}
364
365short RNA_type_to_ID_code(const StructRNA *type)
366{
367 const StructRNA *base_type = RNA_struct_base_child_of(type, &RNA_ID);
368 if (UNLIKELY(base_type == nullptr)) {
369 return 0;
370 }
371 if (base_type == &RNA_Action) {
372 return ID_AC;
373 }
374 if (base_type == &RNA_Armature) {
375 return ID_AR;
376 }
377 if (base_type == &RNA_Brush) {
378 return ID_BR;
379 }
380 if (base_type == &RNA_CacheFile) {
381 return ID_CF;
382 }
383 if (base_type == &RNA_Camera) {
384 return ID_CA;
385 }
386 if (base_type == &RNA_Curve) {
387 return ID_CU_LEGACY;
388 }
389 if (base_type == &RNA_GreasePencil) {
390 return ID_GD_LEGACY;
391 }
392 if (base_type == &RNA_GreasePencilv3) {
393 return ID_GP;
394 }
395 if (base_type == &RNA_Collection) {
396 return ID_GR;
397 }
398 if (base_type == &RNA_Image) {
399 return ID_IM;
400 }
401 if (base_type == &RNA_Key) {
402 return ID_KE;
403 }
404 if (base_type == &RNA_Light) {
405 return ID_LA;
406 }
407 if (base_type == &RNA_Library) {
408 return ID_LI;
409 }
410 if (base_type == &RNA_FreestyleLineStyle) {
411 return ID_LS;
412 }
413 if (base_type == &RNA_Curves) {
414 return ID_CV;
415 }
416 if (base_type == &RNA_Lattice) {
417 return ID_LT;
418 }
419 if (base_type == &RNA_Material) {
420 return ID_MA;
421 }
422 if (base_type == &RNA_MetaBall) {
423 return ID_MB;
424 }
425 if (base_type == &RNA_MovieClip) {
426 return ID_MC;
427 }
428 if (base_type == &RNA_Mesh) {
429 return ID_ME;
430 }
431 if (base_type == &RNA_Mask) {
432 return ID_MSK;
433 }
434 if (base_type == &RNA_NodeTree) {
435 return ID_NT;
436 }
437 if (base_type == &RNA_Object) {
438 return ID_OB;
439 }
440 if (base_type == &RNA_ParticleSettings) {
441 return ID_PA;
442 }
443 if (base_type == &RNA_Palette) {
444 return ID_PAL;
445 }
446 if (base_type == &RNA_PaintCurve) {
447 return ID_PC;
448 }
449 if (base_type == &RNA_PointCloud) {
450 return ID_PT;
451 }
452 if (base_type == &RNA_LightProbe) {
453 return ID_LP;
454 }
455 if (base_type == &RNA_Scene) {
456 return ID_SCE;
457 }
458 if (base_type == &RNA_Screen) {
459 return ID_SCR;
460 }
461 if (base_type == &RNA_Sound) {
462 return ID_SO;
463 }
464 if (base_type == &RNA_Speaker) {
465 return ID_SPK;
466 }
467 if (base_type == &RNA_Texture) {
468 return ID_TE;
469 }
470 if (base_type == &RNA_Text) {
471 return ID_TXT;
472 }
473 if (base_type == &RNA_VectorFont) {
474 return ID_VF;
475 }
476 if (base_type == &RNA_Volume) {
477 return ID_VO;
478 }
479 if (base_type == &RNA_WorkSpace) {
480 return ID_WS;
481 }
482 if (base_type == &RNA_World) {
483 return ID_WO;
484 }
485 if (base_type == &RNA_WindowManager) {
486 return ID_WM;
487 }
488
489 return 0;
490}
491
492StructRNA *ID_code_to_RNA_type(short idcode)
493{
494 /* NOTE: this switch doesn't use a 'default',
495 * so adding new ID's causes a warning. */
496 switch ((ID_Type)idcode) {
497 case ID_AC:
498 return &RNA_Action;
499 case ID_AR:
500 return &RNA_Armature;
501 case ID_BR:
502 return &RNA_Brush;
503 case ID_CA:
504 return &RNA_Camera;
505 case ID_CF:
506 return &RNA_CacheFile;
507 case ID_CU_LEGACY:
508 return &RNA_Curve;
509 case ID_GD_LEGACY:
510 return &RNA_GreasePencil;
511 case ID_GP:
512 return &RNA_GreasePencilv3;
513 case ID_GR:
514 return &RNA_Collection;
515 case ID_CV:
516 return &RNA_Curves;
517 case ID_IM:
518 return &RNA_Image;
519 case ID_KE:
520 return &RNA_Key;
521 case ID_LA:
522 return &RNA_Light;
523 case ID_LI:
524 return &RNA_Library;
525 case ID_LS:
526 return &RNA_FreestyleLineStyle;
527 case ID_LT:
528 return &RNA_Lattice;
529 case ID_MA:
530 return &RNA_Material;
531 case ID_MB:
532 return &RNA_MetaBall;
533 case ID_MC:
534 return &RNA_MovieClip;
535 case ID_ME:
536 return &RNA_Mesh;
537 case ID_MSK:
538 return &RNA_Mask;
539 case ID_NT:
540 return &RNA_NodeTree;
541 case ID_OB:
542 return &RNA_Object;
543 case ID_PA:
544 return &RNA_ParticleSettings;
545 case ID_PAL:
546 return &RNA_Palette;
547 case ID_PC:
548 return &RNA_PaintCurve;
549 case ID_PT:
550 return &RNA_PointCloud;
551 case ID_LP:
552 return &RNA_LightProbe;
553 case ID_SCE:
554 return &RNA_Scene;
555 case ID_SCR:
556 return &RNA_Screen;
557 case ID_SO:
558 return &RNA_Sound;
559 case ID_SPK:
560 return &RNA_Speaker;
561 case ID_TE:
562 return &RNA_Texture;
563 case ID_TXT:
564 return &RNA_Text;
565 case ID_VF:
566 return &RNA_VectorFont;
567 case ID_VO:
568 return &RNA_Volume;
569 case ID_WM:
570 return &RNA_WindowManager;
571 case ID_WO:
572 return &RNA_World;
573 case ID_WS:
574 return &RNA_WorkSpace;
575
576 /* deprecated */
577 case ID_IP:
578 break;
579 }
580
581 return &RNA_ID;
582}
583
585{
586 ID *id = (ID *)ptr->data;
587
588 return ID_code_to_RNA_type(GS(id->name));
589}
590
592{
593 ID *id = (ID *)ptr->data;
594 return &id->properties;
595}
596
597int rna_ID_is_runtime_editable(const PointerRNA *ptr, const char **r_info)
598{
599 ID *id = (ID *)ptr->data;
600 /* TODO: This should be abstracted in a BKE function or define, somewhat related to #88555. */
603 {
604 *r_info =
605 "Cannot edit 'runtime' status of non-blendfile data-blocks, as they are by definition "
606 "always runtime";
607 return 0;
608 }
609
610 return PROP_EDITABLE;
611}
612
613bool rna_ID_is_runtime_get(PointerRNA *ptr)
614{
615 ID *id = (ID *)ptr->data;
616 /* TODO: This should be abstracted in a BKE function or define, somewhat related to #88555. */
619 {
620 return true;
621 }
622
623 return (id->tag & ID_TAG_RUNTIME) != 0;
624}
625
626bool rna_ID_is_editable_get(PointerRNA *ptr)
627{
628 ID *id = (ID *)ptr->data;
629 return ID_IS_EDITABLE(id);
630}
631
632void rna_ID_fake_user_set(PointerRNA *ptr, bool value)
633{
634 ID *id = (ID *)ptr->data;
635
636 if (value) {
638 }
639 else {
641 }
642}
643
644void rna_ID_extra_user_set(PointerRNA *ptr, bool value)
645{
646 ID *id = (ID *)ptr->data;
647
648 if (value) {
650 }
651 else {
653 }
654}
655
657{
658 return (IDProperty **)&ptr->data;
659}
660
661bool rna_PropertyGroup_unregister(Main * /*bmain*/, StructRNA *type)
662{
664 return true;
665}
666
668 ReportList *reports,
669 void *data,
670 const char *identifier,
671 StructValidateFunc validate,
672 StructCallbackFunc /*call*/,
673 StructFreeFunc /*free*/)
674{
675 /* create dummy pointer */
676 PointerRNA dummy_ptr = RNA_pointer_create(nullptr, &RNA_PropertyGroup, nullptr);
677
678 /* validate the python class */
679 if (validate(&dummy_ptr, data, nullptr) != 0) {
680 return nullptr;
681 }
682
683 /* NOTE: it looks like there is no length limit on the srna id since its
684 * just a char pointer, but take care here, also be careful that python
685 * owns the string pointer which it could potentially free while blender
686 * is running. */
687 if (BLI_strnlen(identifier, MAX_IDPROP_NAME) == MAX_IDPROP_NAME) {
688 BKE_reportf(reports,
689 RPT_ERROR,
690 "Registering id property class: '%s' is too long, maximum length is %d",
691 identifier,
693 return nullptr;
694 }
695
696 return RNA_def_struct_ptr(&BLENDER_RNA, identifier, &RNA_PropertyGroup); /* XXX */
697}
698
700{
701 return ptr->type;
702}
703
704static ID *rna_ID_evaluated_get(ID *id, Depsgraph *depsgraph)
705{
707}
708
709static ID *rna_ID_copy(ID *id, Main *bmain)
710{
711 ID *newid = BKE_id_copy_for_use_in_bmain(bmain, id);
712
713 if (newid != nullptr) {
714 id_us_min(newid);
715 }
716
718
719 return newid;
720}
721
722static void rna_ID_asset_mark(ID *id)
723{
727 }
728}
729
730static void rna_ID_asset_generate_preview(ID *id, bContext *C)
731{
733
736}
737
738static void rna_ID_asset_clear(ID *id)
739{
743 }
744}
745
746static void rna_ID_asset_data_set(PointerRNA *ptr, PointerRNA value, ReportList *reports)
747{
748 ID *destination = static_cast<ID *>(ptr->data);
749
750 /* Avoid marking as asset by assigning. This should be done with `.asset_mark()`.
751 * This is just for clarity of the API, and to accommodate future changes. */
752 if (destination->asset_data == nullptr) {
753 BKE_report(reports,
754 RPT_ERROR,
755 "Asset data can only be assigned to assets. Use asset_mark() to mark as an asset.");
756 return;
757 }
758
759 const AssetMetaData *asset_data = static_cast<const AssetMetaData *>(value.data);
760 if (asset_data == nullptr) {
761 /* Avoid clearing the asset data on assets. Un-marking as asset should be done with
762 * `.asset_clear()`. This is just for clarity of the API, and to accommodate future changes. */
763 BKE_report(reports, RPT_ERROR, "Asset data cannot be None");
764 return;
765 }
766
767 const bool assigned_ok = blender::ed::asset::copy_to_id(asset_data, destination);
768 if (!assigned_ok) {
770 reports, RPT_ERROR, "'%s' is of a type that cannot be an asset", destination->name + 2);
771 return;
772 }
773
776}
777
778static ID *rna_ID_override_create(ID *id, Main *bmain, bool remap_local_usages)
779{
780 if (!ID_IS_OVERRIDABLE_LIBRARY(id)) {
781 return nullptr;
782 }
783
784 if (remap_local_usages) {
785 BKE_main_id_tag_all(bmain, ID_TAG_DOIT, true);
786 }
787
788 ID *local_id = nullptr;
789# ifdef WITH_PYTHON
791# endif
792
793 local_id = BKE_lib_override_library_create_from_id(bmain, id, remap_local_usages);
794
795# ifdef WITH_PYTHON
797# endif
798
799 if (remap_local_usages) {
800 BKE_main_id_tag_all(bmain, ID_TAG_DOIT, false);
801 }
802
805
806 return local_id;
807}
808
809static ID *rna_ID_override_hierarchy_create(ID *id,
810 Main *bmain,
811 Scene *scene,
812 ViewLayer *view_layer,
813 ID *id_instance_hint,
814 bool do_fully_editable)
815{
816 if (!ID_IS_OVERRIDABLE_LIBRARY(id)) {
817 return nullptr;
818 }
819
820 BKE_main_id_tag_all(bmain, ID_TAG_DOIT, false);
821
822 ID *id_root_override = nullptr;
823
824# ifdef WITH_PYTHON
826# endif
827
829 scene,
830 view_layer,
831 nullptr,
832 id,
833 id,
834 id_instance_hint,
835 &id_root_override,
836 do_fully_editable);
837
838# ifdef WITH_PYTHON
840# endif
841
844
845 return id_root_override;
846}
847
848static void rna_ID_override_library_operations_update(ID *id,
849 IDOverrideLibrary * /*override_library*/,
850 Main *bmain,
851 ReportList *reports)
852{
854 BKE_reportf(reports, RPT_ERROR, "ID '%s' isn't an override", id->name);
855 return;
856 }
857
858 if (ID_IS_LINKED(id)) {
859 BKE_reportf(reports, RPT_ERROR, "ID '%s' is linked, cannot edit its overrides", id->name);
860 return;
861 }
862
864
866}
867
868static void rna_ID_override_library_reset(ID *id,
869 IDOverrideLibrary * /*override_library*/,
870 Main *bmain,
871 ReportList *reports,
872 bool do_hierarchy,
873 bool set_system_override)
874{
876 BKE_reportf(reports, RPT_ERROR, "ID '%s' isn't an override", id->name);
877 return;
878 }
879
880 if (do_hierarchy) {
881 BKE_lib_override_library_id_hierarchy_reset(bmain, id, set_system_override);
882 }
883 else {
884 BKE_lib_override_library_id_reset(bmain, id, set_system_override);
885 }
886
888}
889
890static void rna_ID_override_library_destroy(ID *id,
891 IDOverrideLibrary * /*override_library*/,
892 Main *bmain,
893 ReportList *reports,
894 bool do_hierarchy)
895{
897 BKE_reportf(reports, RPT_ERROR, "ID '%s' isn't an override", id->name);
898 return;
899 }
900
901 if (do_hierarchy) {
903 }
904 else {
905 BKE_libblock_remap(bmain, id, id->override_library->reference, ID_REMAP_SKIP_INDIRECT_USAGE);
906 BKE_id_delete(bmain, id);
907 }
908
910}
911
912static bool rna_ID_override_library_resync(ID *id,
913 IDOverrideLibrary *override_library,
914 Main *bmain,
915 ReportList *reports,
916 Scene *scene,
917 ViewLayer *view_layer,
918 Collection *override_resync_residual_storage,
919 bool do_hierarchy_enforce,
920 bool do_whole_hierarchy)
921{
922 BLI_assert(id->override_library == override_library);
923
924 if (!override_library->hierarchy_root ||
925 (override_library->flag & LIBOVERRIDE_FLAG_NO_HIERARCHY) != 0)
926 {
928 reports,
930 "Data-block '%s' is not a library override, or not part of a library override hierarchy",
931 id->name);
932 return false;
933 }
934
935 ID *id_root = do_whole_hierarchy ? override_library->hierarchy_root : id;
936 BlendFileReadReport bf_reports = {};
937 bf_reports.reports = reports;
938
939 const bool success = BKE_lib_override_library_resync(bmain,
940 scene,
941 view_layer,
942 id_root,
943 override_resync_residual_storage,
944 do_hierarchy_enforce,
945 &bf_reports);
946
948 return success;
949}
950
951static IDOverrideLibraryProperty *rna_ID_override_library_properties_add(
952 IDOverrideLibrary *override_library, ReportList *reports, const char rna_path[])
953{
954 bool created;
956 override_library, rna_path, &created);
957
958 if (!created) {
959 BKE_report(reports, RPT_DEBUG, "No new override property created, property already exists");
960 }
961
963 return result;
964}
965
966static void rna_ID_override_library_properties_remove(IDOverrideLibrary *override_library,
967 ReportList *reports,
968 IDOverrideLibraryProperty *override_property)
969{
970 if (BLI_findindex(&override_library->properties, override_property) == -1) {
971 BKE_report(reports, RPT_ERROR, "Override property cannot be removed");
972 return;
973 }
974
975 BKE_lib_override_library_property_delete(override_library, override_property);
976
978}
979
980static IDOverrideLibraryPropertyOperation *rna_ID_override_library_property_operations_add(
981 IDOverrideLibraryProperty *override_property,
982 ReportList *reports,
983 int operation,
984 const bool use_id,
985 const char *subitem_refname,
986 const char *subitem_locname,
987 ID *subitem_refid,
988 ID *subitem_locid,
989 int subitem_refindex,
990 int subitem_locindex)
991{
992 bool created;
993 bool strict;
995 override_property,
996 operation,
997 subitem_refname,
998 subitem_locname,
999 use_id ? std::optional(subitem_refid) : std::nullopt,
1000 use_id ? std::optional(subitem_locid) : std::nullopt,
1001 subitem_refindex,
1002 subitem_locindex,
1003 false,
1004 &strict,
1005 &created);
1006 if (!created) {
1007 BKE_report(reports, RPT_DEBUG, "No new override operation created, operation already exists");
1008 }
1009
1011 return result;
1012}
1013
1014static void rna_ID_override_library_property_operations_remove(
1015 IDOverrideLibraryProperty *override_property,
1016 ReportList *reports,
1017 IDOverrideLibraryPropertyOperation *override_operation)
1018{
1019 if (BLI_findindex(&override_property->operations, override_operation) == -1) {
1020 BKE_report(reports, RPT_ERROR, "Override operation cannot be removed");
1021 return;
1022 }
1023
1024 BKE_lib_override_library_property_operation_delete(override_property, override_operation);
1025
1027}
1028
1029static void rna_ID_update_tag(ID *id, Main *bmain, ReportList *reports, int flag)
1030{
1031/* XXX, new function for this! */
1032# if 0
1033 if (ob->type == OB_FONT) {
1034 Curve *cu = ob->data;
1035 freedisplist(&cu->disp);
1036 BKE_vfont_to_curve(bmain, sce, ob, FO_EDIT, nullptr);
1037 }
1038# endif
1039
1040 if (flag == 0) {
1041 /* pass */
1042 }
1043 else {
1044 int allow_flag = 0;
1045
1046 /* ensure flag us correct for the type */
1047 switch (GS(id->name)) {
1048 case ID_OB:
1049 /* TODO(sergey): This is kind of difficult to predict since different
1050 * object types supports different flags. Maybe does not worth checking
1051 * for this at all. Or maybe let dependency graph to return whether
1052 * the tag was valid or not. */
1053 allow_flag = ID_RECALC_ALL;
1054 break;
1055/* Could add particle updates later */
1056# if 0
1057 case ID_PA:
1058 allow_flag = OB_RECALC_ALL | PSYS_RECALC;
1059 break;
1060# endif
1061 case ID_AC:
1062 allow_flag = ID_RECALC_ANIMATION;
1063 break;
1064 default:
1065 if (id_can_have_animdata(id)) {
1066 allow_flag = ID_RECALC_ANIMATION;
1067 }
1068 }
1069
1070 if (flag & ~allow_flag) {
1071 StructRNA *srna = ID_code_to_RNA_type(GS(id->name));
1072 BKE_reportf(reports,
1073 RPT_ERROR,
1074 allow_flag ? N_("%s is not compatible with the specified 'refresh' options") :
1075 N_("%s is not compatible with any 'refresh' options"),
1076 RNA_struct_identifier(srna));
1077 return;
1078 }
1079 }
1080
1081 DEG_id_tag_update_ex(bmain, id, flag);
1082}
1083
1084static void rna_ID_user_clear(ID *id)
1085{
1087 id->us = 0; /* don't save */
1088}
1089
1090static void rna_ID_user_remap(ID *id, Main *bmain, ID *new_id)
1091{
1092 if ((GS(id->name) == GS(new_id->name)) && (id != new_id)) {
1093 /* For now, do not allow remapping data in linked data from here... */
1096
1098 }
1099}
1100
1101static ID *rna_ID_make_local(
1102 ID *self, Main *bmain, bool /*clear_proxy*/, bool clear_liboverride, bool clear_asset_data)
1103{
1104 if (ID_IS_LINKED(self)) {
1105 int flags = 0;
1106 if (clear_asset_data) {
1108 }
1109
1110 BKE_lib_id_make_local(bmain, self, flags);
1111 }
1114 }
1115
1116 ID *ret_id = self->newid ? self->newid : self;
1118
1119 if (clear_liboverride && ID_IS_OVERRIDE_LIBRARY_REAL(ret_id)) {
1121 }
1122
1123 return ret_id;
1124}
1125
1126static AnimData *rna_ID_animation_data_create(ID *id, Main *bmain)
1127{
1130 return adt;
1131}
1132
1133static void rna_ID_animation_data_free(ID *id, Main *bmain)
1134{
1135 BKE_animdata_free(id, true);
1137}
1138
1139# ifdef WITH_PYTHON
1141{
1142 ID *id = (ID *)ptr->data;
1143 return &id->py_instance;
1144}
1145# endif
1146
1147static void rna_IDPArray_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
1148{
1149 IDProperty *prop = (IDProperty *)ptr->data;
1150 rna_iterator_array_begin(iter, IDP_IDPArray(prop), sizeof(IDProperty), prop->len, 0, nullptr);
1151}
1152
1153static int rna_IDPArray_length(PointerRNA *ptr)
1154{
1155 IDProperty *prop = (IDProperty *)ptr->data;
1156 return prop->len;
1157}
1158
1159bool rna_IDMaterials_assign_int(PointerRNA *ptr, int key, const PointerRNA *assign_ptr)
1160{
1161 ID *id = ptr->owner_id;
1162 short *totcol = BKE_id_material_len_p(id);
1163 Material *mat_id = (Material *)assign_ptr->owner_id;
1164 if (totcol && (key >= 0 && key < *totcol)) {
1167 BKE_id_material_assign(G_MAIN, id, mat_id, key + 1);
1168 return true;
1169 }
1170 else {
1171 return false;
1172 }
1173}
1174
1175static void rna_IDMaterials_append_id(ID *id, Main *bmain, Material *ma)
1176{
1177 BKE_id_material_append(bmain, id, ma);
1178
1181}
1182
1183static Material *rna_IDMaterials_pop_id(ID *id, Main *bmain, ReportList *reports, int index_i)
1184{
1185 Material *ma;
1186 short *totcol = BKE_id_material_len_p(id);
1187 const short totcol_orig = *totcol;
1188 if (index_i < 0) {
1189 index_i += (*totcol);
1190 }
1191
1192 if ((index_i < 0) || (index_i >= (*totcol))) {
1193 BKE_report(reports, RPT_ERROR, "Index out of range");
1194 return nullptr;
1195 }
1196
1197 ma = BKE_id_material_pop(bmain, id, index_i);
1198
1199 if (*totcol == totcol_orig) {
1200 BKE_report(reports, RPT_ERROR, "No material to removed");
1201 return nullptr;
1202 }
1203
1207
1208 return ma;
1209}
1210
1211static void rna_IDMaterials_clear_id(ID *id, Main *bmain)
1212{
1213 BKE_id_material_clear(bmain, id);
1214
1218}
1219
1220static void rna_Library_filepath_set(PointerRNA *ptr, const char *value)
1221{
1222 Library *lib = (Library *)ptr->data;
1225}
1226
1227/* ***** ImagePreview ***** */
1228
1229static void rna_ImagePreview_is_custom_set(PointerRNA *ptr, int value, enum eIconSizes size)
1230{
1231 ID *id = ptr->owner_id;
1232 PreviewImage *prv_img = (PreviewImage *)ptr->data;
1233
1234 if (id != nullptr) {
1235 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1236 }
1237
1238 if ((value && (prv_img->flag[size] & PRV_USER_EDITED)) ||
1239 (!value && !(prv_img->flag[size] & PRV_USER_EDITED)))
1240 {
1241 return;
1242 }
1243
1244 if (value) {
1245 prv_img->flag[size] |= PRV_USER_EDITED;
1246 }
1247 else {
1248 prv_img->flag[size] &= ~PRV_USER_EDITED;
1249 }
1250
1251 prv_img->flag[size] |= PRV_CHANGED;
1252
1253 BKE_previewimg_clear_single(prv_img, size);
1254}
1255
1256static void rna_ImagePreview_size_get(PointerRNA *ptr, int *values, enum eIconSizes size)
1257{
1258 ID *id = ptr->owner_id;
1259 PreviewImage *prv_img = (PreviewImage *)ptr->data;
1260
1261 if (id != nullptr) {
1262 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1263 }
1264
1265 BKE_previewimg_ensure(prv_img, size);
1266
1267 values[0] = prv_img->w[size];
1268 values[1] = prv_img->h[size];
1269}
1270
1271static void rna_ImagePreview_size_set(PointerRNA *ptr, const int *values, enum eIconSizes size)
1272{
1273 ID *id = ptr->owner_id;
1274 PreviewImage *prv_img = (PreviewImage *)ptr->data;
1275
1276 if (id != nullptr) {
1277 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1278 }
1279
1280 BKE_previewimg_clear_single(prv_img, size);
1281
1282 if (values[0] && values[1]) {
1283 prv_img->rect[size] = static_cast<unsigned int *>(
1284 MEM_callocN(values[0] * values[1] * sizeof(uint), "prv_rect"));
1285
1286 prv_img->w[size] = values[0];
1287 prv_img->h[size] = values[1];
1288 }
1289
1290 prv_img->flag[size] |= (PRV_CHANGED | PRV_USER_EDITED);
1291}
1292
1293static int rna_ImagePreview_pixels_get_length(const PointerRNA *ptr,
1294 int length[RNA_MAX_ARRAY_DIMENSION],
1295 enum eIconSizes size)
1296{
1297 ID *id = ptr->owner_id;
1298 PreviewImage *prv_img = (PreviewImage *)ptr->data;
1299
1300 if (id != nullptr) {
1301 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1302 }
1303
1304 BKE_previewimg_ensure(prv_img, size);
1305
1306 length[0] = prv_img->w[size] * prv_img->h[size];
1307
1308 return length[0];
1309}
1310
1311static void rna_ImagePreview_pixels_get(PointerRNA *ptr, int *values, enum eIconSizes size)
1312{
1313 ID *id = ptr->owner_id;
1314 PreviewImage *prv_img = (PreviewImage *)ptr->data;
1315
1316 if (id != nullptr) {
1317 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1318 }
1319
1320 BKE_previewimg_ensure(prv_img, size);
1321
1322 memcpy(values, prv_img->rect[size], prv_img->w[size] * prv_img->h[size] * sizeof(uint));
1323}
1324
1325static void rna_ImagePreview_pixels_set(PointerRNA *ptr, const int *values, enum eIconSizes size)
1326{
1327 ID *id = ptr->owner_id;
1328 PreviewImage *prv_img = (PreviewImage *)ptr->data;
1329
1330 if (id != nullptr) {
1331 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1332 }
1333
1334 memcpy(prv_img->rect[size], values, prv_img->w[size] * prv_img->h[size] * sizeof(uint));
1335 prv_img->flag[size] |= PRV_USER_EDITED;
1336}
1337
1338static int rna_ImagePreview_pixels_float_get_length(const PointerRNA *ptr,
1339 int length[RNA_MAX_ARRAY_DIMENSION],
1340 enum eIconSizes size)
1341{
1342 ID *id = ptr->owner_id;
1343 PreviewImage *prv_img = (PreviewImage *)ptr->data;
1344
1345 BLI_assert(sizeof(uint) == 4);
1346
1347 if (id != nullptr) {
1348 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1349 }
1350
1351 BKE_previewimg_ensure(prv_img, size);
1352
1353 length[0] = prv_img->w[size] * prv_img->h[size] * 4;
1354
1355 return length[0];
1356}
1357
1358static void rna_ImagePreview_pixels_float_get(PointerRNA *ptr, float *values, enum eIconSizes size)
1359{
1360 ID *id = ptr->owner_id;
1361 PreviewImage *prv_img = (PreviewImage *)ptr->data;
1362
1363 uchar *data = (uchar *)prv_img->rect[size];
1364 const size_t len = prv_img->w[size] * prv_img->h[size] * 4;
1365 size_t i;
1366
1367 BLI_assert(sizeof(uint) == 4);
1368
1369 if (id != nullptr) {
1370 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1371 }
1372
1373 BKE_previewimg_ensure(prv_img, size);
1374
1375 for (i = 0; i < len; i++) {
1376 values[i] = data[i] * (1.0f / 255.0f);
1377 }
1378}
1379
1380static void rna_ImagePreview_pixels_float_set(PointerRNA *ptr,
1381 const float *values,
1382 enum eIconSizes size)
1383{
1384 ID *id = ptr->owner_id;
1385 PreviewImage *prv_img = (PreviewImage *)ptr->data;
1386
1387 uchar *data = (uchar *)prv_img->rect[size];
1388 const size_t len = prv_img->w[size] * prv_img->h[size] * 4;
1389 size_t i;
1390
1391 BLI_assert(sizeof(uint) == 4);
1392
1393 if (id != nullptr) {
1394 BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1395 }
1396
1397 for (i = 0; i < len; i++) {
1398 data[i] = unit_float_to_uchar_clamp(values[i]);
1399 }
1400 prv_img->flag[size] |= PRV_USER_EDITED;
1401}
1402
1403static void rna_ImagePreview_is_image_custom_set(PointerRNA *ptr, bool value)
1404{
1405 rna_ImagePreview_is_custom_set(ptr, value, ICON_SIZE_PREVIEW);
1406}
1407
1408static void rna_ImagePreview_image_size_get(PointerRNA *ptr, int *values)
1409{
1410 rna_ImagePreview_size_get(ptr, values, ICON_SIZE_PREVIEW);
1411}
1412
1413static void rna_ImagePreview_image_size_set(PointerRNA *ptr, const int *values)
1414{
1415 rna_ImagePreview_size_set(ptr, values, ICON_SIZE_PREVIEW);
1416}
1417
1418static int rna_ImagePreview_image_pixels_get_length(const PointerRNA *ptr,
1419 int length[RNA_MAX_ARRAY_DIMENSION])
1420{
1421 return rna_ImagePreview_pixels_get_length(ptr, length, ICON_SIZE_PREVIEW);
1422}
1423
1424static void rna_ImagePreview_image_pixels_get(PointerRNA *ptr, int *values)
1425{
1426 rna_ImagePreview_pixels_get(ptr, values, ICON_SIZE_PREVIEW);
1427}
1428
1429static void rna_ImagePreview_image_pixels_set(PointerRNA *ptr, const int *values)
1430{
1431 rna_ImagePreview_pixels_set(ptr, values, ICON_SIZE_PREVIEW);
1432}
1433
1434static int rna_ImagePreview_image_pixels_float_get_length(const PointerRNA *ptr,
1435 int length[RNA_MAX_ARRAY_DIMENSION])
1436{
1437 return rna_ImagePreview_pixels_float_get_length(ptr, length, ICON_SIZE_PREVIEW);
1438}
1439
1440static void rna_ImagePreview_image_pixels_float_get(PointerRNA *ptr, float *values)
1441{
1442 rna_ImagePreview_pixels_float_get(ptr, values, ICON_SIZE_PREVIEW);
1443}
1444
1445static void rna_ImagePreview_image_pixels_float_set(PointerRNA *ptr, const float *values)
1446{
1447 rna_ImagePreview_pixels_float_set(ptr, values, ICON_SIZE_PREVIEW);
1448}
1449
1450static void rna_ImagePreview_is_icon_custom_set(PointerRNA *ptr, bool value)
1451{
1452 rna_ImagePreview_is_custom_set(ptr, value, ICON_SIZE_ICON);
1453}
1454
1455static void rna_ImagePreview_icon_size_get(PointerRNA *ptr, int *values)
1456{
1457 rna_ImagePreview_size_get(ptr, values, ICON_SIZE_ICON);
1458}
1459
1460static void rna_ImagePreview_icon_size_set(PointerRNA *ptr, const int *values)
1461{
1462 rna_ImagePreview_size_set(ptr, values, ICON_SIZE_ICON);
1463}
1464
1465static int rna_ImagePreview_icon_pixels_get_length(const PointerRNA *ptr,
1466 int length[RNA_MAX_ARRAY_DIMENSION])
1467{
1468 return rna_ImagePreview_pixels_get_length(ptr, length, ICON_SIZE_ICON);
1469}
1470
1471static void rna_ImagePreview_icon_pixels_get(PointerRNA *ptr, int *values)
1472{
1473 rna_ImagePreview_pixels_get(ptr, values, ICON_SIZE_ICON);
1474}
1475
1476static void rna_ImagePreview_icon_pixels_set(PointerRNA *ptr, const int *values)
1477{
1478 rna_ImagePreview_pixels_set(ptr, values, ICON_SIZE_ICON);
1479}
1480
1481static int rna_ImagePreview_icon_pixels_float_get_length(const PointerRNA *ptr,
1482 int length[RNA_MAX_ARRAY_DIMENSION])
1483{
1484 return rna_ImagePreview_pixels_float_get_length(ptr, length, ICON_SIZE_ICON);
1485}
1486
1487static void rna_ImagePreview_icon_pixels_float_get(PointerRNA *ptr, float *values)
1488{
1489 rna_ImagePreview_pixels_float_get(ptr, values, ICON_SIZE_ICON);
1490}
1491
1492static void rna_ImagePreview_icon_pixels_float_set(PointerRNA *ptr, const float *values)
1493{
1494 rna_ImagePreview_pixels_float_set(ptr, values, ICON_SIZE_ICON);
1495}
1496
1497static int rna_ImagePreview_icon_id_get(PointerRNA *ptr)
1498{
1499 /* Using a callback here allows us to only generate icon matching
1500 * that preview when icon_id is requested. */
1502}
1503static void rna_ImagePreview_icon_reload(PreviewImage *prv)
1504{
1505 /* will lazy load on next use, but only in case icon is not user-modified! */
1506 if (!(prv->flag[ICON_SIZE_ICON] & PRV_USER_EDITED) &&
1508 {
1510 }
1511}
1512
1513static PointerRNA rna_IDPreview_get(PointerRNA *ptr)
1514{
1515 ID *id = (ID *)ptr->data;
1516 PreviewImage *prv_img = BKE_previewimg_id_get(id);
1517
1518 return rna_pointer_inherit_refine(ptr, &RNA_ImagePreview, prv_img);
1519}
1520
1521static IDProperty **rna_IDPropertyWrapPtr_idprops(PointerRNA *ptr)
1522{
1523 if (ptr == nullptr) {
1524 return nullptr;
1525 }
1526 return (IDProperty **)&ptr->data;
1527}
1528
1529static void rna_Library_version_get(PointerRNA *ptr, int *value)
1530{
1531 Library *lib = (Library *)ptr->data;
1532 value[0] = lib->runtime.versionfile / 100;
1533 value[1] = lib->runtime.versionfile % 100;
1534 value[2] = lib->runtime.subversionfile;
1535}
1536
1537static void rna_Library_reload(Library *lib, bContext *C, ReportList *reports)
1538{
1539# ifdef WITH_PYTHON
1541# endif
1542
1543 WM_lib_reload(lib, C, reports);
1544
1545# ifdef WITH_PYTHON
1547# endif
1548}
1549
1550#else
1551
1553{
1554 StructRNA *srna;
1555 PropertyRNA *prop;
1556
1557 /* this is struct is used for holding the virtual
1558 * PropertyRNA's for ID properties */
1559 srna = RNA_def_struct(brna, "PropertyGroupItem", nullptr);
1560 RNA_def_struct_sdna(srna, "IDProperty");
1562 srna, "ID Property", "Property that stores arbitrary, user defined properties");
1563
1564 /* IDP_STRING */
1565 prop = RNA_def_property(srna, "string", PROP_STRING, PROP_NONE);
1567
1568 /* IDP_INT */
1569 prop = RNA_def_property(srna, "int", PROP_INT, PROP_NONE);
1571
1572 prop = RNA_def_property(srna, "int_array", PROP_INT, PROP_NONE);
1574 RNA_def_property_array(prop, 1);
1575
1576 /* IDP_FLOAT */
1577 prop = RNA_def_property(srna, "float", PROP_FLOAT, PROP_NONE);
1579
1580 prop = RNA_def_property(srna, "float_array", PROP_FLOAT, PROP_NONE);
1582 RNA_def_property_array(prop, 1);
1583
1584 /* IDP_DOUBLE */
1585 prop = RNA_def_property(srna, "double", PROP_FLOAT, PROP_NONE);
1587
1588 prop = RNA_def_property(srna, "double_array", PROP_FLOAT, PROP_NONE);
1590 RNA_def_property_array(prop, 1);
1591
1592 /* IDP_BOOLEAN */
1593 prop = RNA_def_property(srna, "bool", PROP_BOOLEAN, PROP_NONE);
1595
1596 prop = RNA_def_property(srna, "bool_array", PROP_BOOLEAN, PROP_NONE);
1598 RNA_def_property_array(prop, 1);
1599
1600 /* IDP_ENUM */
1601 prop = RNA_def_property(srna, "enum", PROP_ENUM, PROP_NONE);
1604
1605 /* IDP_GROUP */
1606 prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
1609 RNA_def_property_struct_type(prop, "PropertyGroup");
1610
1611 prop = RNA_def_property(srna, "collection", PROP_COLLECTION, PROP_NONE);
1613 RNA_def_property_struct_type(prop, "PropertyGroup");
1614
1615 prop = RNA_def_property(srna, "idp_array", PROP_COLLECTION, PROP_NONE);
1616 RNA_def_property_struct_type(prop, "PropertyGroup");
1618 "rna_IDPArray_begin",
1619 "rna_iterator_array_next",
1620 "rna_iterator_array_end",
1621 "rna_iterator_array_get",
1622 "rna_IDPArray_length",
1623 nullptr,
1624 nullptr,
1625 nullptr);
1627
1628/* never tested, maybe its useful to have this? */
1629# if 0
1630 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1633 RNA_def_property_ui_text(prop, "Name", "Unique name used in the code and scripting");
1634 RNA_def_struct_name_property(srna, prop);
1635# endif
1636
1637 /* IDP_ID */
1638 prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
1640 RNA_def_property_struct_type(prop, "ID");
1641
1642 /* ID property groups > level 0, since level 0 group is merged
1643 * with native RNA properties. the builtin_properties will take
1644 * care of the properties here */
1645 srna = RNA_def_struct(brna, "PropertyGroup", nullptr);
1646 RNA_def_struct_sdna(srna, "IDPropertyGroup");
1647 RNA_def_struct_ui_text(srna, "ID Property Group", "Group of ID properties");
1648 RNA_def_struct_idprops_func(srna, "rna_PropertyGroup_idprops");
1650 srna, "rna_PropertyGroup_register", "rna_PropertyGroup_unregister", nullptr);
1651 RNA_def_struct_refine_func(srna, "rna_PropertyGroup_refine");
1652
1653 /* important so python types can have their name used in list views
1654 * however this isn't perfect because it overrides how python would set the name
1655 * when we only really want this so RNA_def_struct_name_property() is set to something useful */
1656 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1658 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1659 RNA_def_property_ui_text(prop, "Name", "Unique name used in the code and scripting");
1660 RNA_def_struct_name_property(srna, prop);
1661}
1662
1664{
1665 StructRNA *srna;
1666 FunctionRNA *func;
1667 PropertyRNA *parm;
1668
1669 /* For mesh/meta-ball/curve materials. */
1670 srna = RNA_def_struct(brna, "IDMaterials", nullptr);
1671 RNA_def_struct_sdna(srna, "ID");
1672 RNA_def_struct_ui_text(srna, "ID Materials", "Collection of materials");
1673
1674 func = RNA_def_function(srna, "append", "rna_IDMaterials_append_id");
1676 RNA_def_function_ui_description(func, "Add a new material to the data-block");
1677 parm = RNA_def_pointer(func, "material", "Material", "", "Material to add");
1679
1680 func = RNA_def_function(srna, "pop", "rna_IDMaterials_pop_id");
1682 RNA_def_function_ui_description(func, "Remove a material from the data-block");
1683 parm = RNA_def_int(
1684 func, "index", -1, -MAXMAT, MAXMAT, "", "Index of material to remove", 0, MAXMAT);
1685 parm = RNA_def_pointer(func, "material", "Material", "", "Material to remove");
1686 RNA_def_function_return(func, parm);
1687
1688 func = RNA_def_function(srna, "clear", "rna_IDMaterials_clear_id");
1690 RNA_def_function_ui_description(func, "Remove all materials from the data-block");
1691}
1692
1694{
1695 StructRNA *srna;
1696 FunctionRNA *func;
1697 PropertyRNA *prop;
1698
1699 srna = RNA_def_struct(brna, "ImagePreview", nullptr);
1700 RNA_def_struct_sdna(srna, "PreviewImage");
1701 RNA_def_struct_ui_text(srna, "Image Preview", "Preview image and icon");
1702
1703 prop = RNA_def_property(srna, "is_image_custom", PROP_BOOLEAN, PROP_NONE);
1704 RNA_def_property_boolean_sdna(prop, nullptr, "flag[ICON_SIZE_PREVIEW]", PRV_USER_EDITED);
1705 RNA_def_property_boolean_funcs(prop, nullptr, "rna_ImagePreview_is_image_custom_set");
1707 "Custom Image",
1708 "True if this preview image has been modified by py script, "
1709 "and is no more auto-generated by Blender");
1710
1711 prop = RNA_def_int_vector(
1712 srna, "image_size", 2, nullptr, 0, 0, "Image Size", "Width and height in pixels", 0, 0);
1715 prop, "rna_ImagePreview_image_size_get", "rna_ImagePreview_image_size_set", nullptr);
1716
1717 prop = RNA_def_property(srna, "image_pixels", PROP_INT, PROP_NONE);
1719 RNA_def_property_multi_array(prop, 1, nullptr);
1720 RNA_def_property_ui_text(prop, "Image Pixels", "Image pixels, as bytes (always 32-bit RGBA)");
1721 RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_image_pixels_get_length");
1723 prop, "rna_ImagePreview_image_pixels_get", "rna_ImagePreview_image_pixels_set", nullptr);
1724
1725 prop = RNA_def_property(srna, "image_pixels_float", PROP_FLOAT, PROP_NONE);
1727 RNA_def_property_multi_array(prop, 1, nullptr);
1729 prop, "Float Image Pixels", "Image pixels components, as floats (RGBA concatenated values)");
1730 RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_image_pixels_float_get_length");
1732 "rna_ImagePreview_image_pixels_float_get",
1733 "rna_ImagePreview_image_pixels_float_set",
1734 nullptr);
1735
1736 prop = RNA_def_property(srna, "is_icon_custom", PROP_BOOLEAN, PROP_NONE);
1737 RNA_def_property_boolean_sdna(prop, nullptr, "flag[ICON_SIZE_ICON]", PRV_USER_EDITED);
1738 RNA_def_property_boolean_funcs(prop, nullptr, "rna_ImagePreview_is_icon_custom_set");
1740 "Custom Icon",
1741 "True if this preview icon has been modified by py script, "
1742 "and is no more auto-generated by Blender");
1743
1744 prop = RNA_def_int_vector(
1745 srna, "icon_size", 2, nullptr, 0, 0, "Icon Size", "Width and height in pixels", 0, 0);
1748 prop, "rna_ImagePreview_icon_size_get", "rna_ImagePreview_icon_size_set", nullptr);
1749
1750 prop = RNA_def_property(srna, "icon_pixels", PROP_INT, PROP_NONE);
1752 RNA_def_property_multi_array(prop, 1, nullptr);
1753 RNA_def_property_ui_text(prop, "Icon Pixels", "Icon pixels, as bytes (always 32-bit RGBA)");
1754 RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_icon_pixels_get_length");
1756 prop, "rna_ImagePreview_icon_pixels_get", "rna_ImagePreview_icon_pixels_set", nullptr);
1757
1758 prop = RNA_def_property(srna, "icon_pixels_float", PROP_FLOAT, PROP_NONE);
1760 RNA_def_property_multi_array(prop, 1, nullptr);
1762 prop, "Float Icon Pixels", "Icon pixels components, as floats (RGBA concatenated values)");
1763 RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_icon_pixels_float_get_length");
1765 "rna_ImagePreview_icon_pixels_float_get",
1766 "rna_ImagePreview_icon_pixels_float_set",
1767 nullptr);
1768
1769 prop = RNA_def_int(srna,
1770 "icon_id",
1771 0,
1772 INT_MIN,
1773 INT_MAX,
1774 "Icon ID",
1775 "Unique integer identifying this preview as an icon (zero means invalid)",
1776 INT_MIN,
1777 INT_MAX);
1779 RNA_def_property_int_funcs(prop, "rna_ImagePreview_icon_id_get", nullptr, nullptr);
1780
1781 func = RNA_def_function(srna, "reload", "rna_ImagePreview_icon_reload");
1782 RNA_def_function_ui_description(func, "Reload the preview from its source path");
1783}
1784
1786{
1787 StructRNA *srna;
1788 PropertyRNA *prop;
1789
1790 static const EnumPropertyItem override_library_property_flag_items[] = {
1792 "MANDATORY",
1793 0,
1794 "Mandatory",
1795 "For templates, prevents the user from removing predefined operation (NOT USED)"},
1797 "LOCKED",
1798 0,
1799 "Locked",
1800 "Prevents the user from modifying that override operation (NOT USED)"},
1802 "IDPOINTER_MATCH_REFERENCE",
1803 0,
1804 "Match Reference",
1805 "The ID pointer overridden by this operation is expected to match the reference hierarchy"},
1807 "IDPOINTER_ITEM_USE_ID",
1808 0,
1809 "ID Item Use ID Pointer",
1810 "RNA collections of IDs only, the reference to the item also uses the ID pointer itself, "
1811 "not only its name"},
1812 {0, nullptr, 0, nullptr, nullptr},
1813 };
1814
1815 srna = RNA_def_struct(brna, "IDOverrideLibraryPropertyOperation", nullptr);
1817 "ID Library Override Property Operation",
1818 "Description of an override operation over an overridden property");
1819
1820 prop = RNA_def_enum(srna,
1821 "operation",
1824 "Operation",
1825 "What override operation is performed");
1826 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1827
1828 prop = RNA_def_enum(
1829 srna, "flag", override_library_property_flag_items, 0, "Flags", "Status flags");
1831 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1832
1833 prop = RNA_def_string(srna,
1834 "subitem_reference_name",
1835 nullptr,
1836 INT_MAX,
1837 "Subitem Reference Name",
1838 "Used to handle changes into collection");
1839 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1841 "rna_ID_override_library_property_operation_refname_get",
1842 "rna_ID_override_library_property_operation_refname_length",
1843 nullptr);
1844
1845 prop = RNA_def_string(srna,
1846 "subitem_local_name",
1847 nullptr,
1848 INT_MAX,
1849 "Subitem Local Name",
1850 "Used to handle changes into collection");
1851 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1853 "rna_ID_override_library_property_operation_locname_get",
1854 "rna_ID_override_library_property_operation_locname_length",
1855 nullptr);
1856
1857 prop = RNA_def_pointer(srna,
1858 "subitem_reference_id",
1859 "ID",
1860 "Subitem Reference ID",
1861 "Collection of IDs only, used to disambiguate between potential IDs with "
1862 "same name from different libraries");
1863 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1864
1865 prop = RNA_def_pointer(srna,
1866 "subitem_local_id",
1867 "ID",
1868 "Subitem Local ID",
1869 "Collection of IDs only, used to disambiguate between potential IDs with "
1870 "same name from different libraries");
1871 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1872
1873 prop = RNA_def_int(srna,
1874 "subitem_reference_index",
1875 -1,
1876 -1,
1877 INT_MAX,
1878 "Subitem Reference Index",
1879 "Used to handle changes into collection",
1880 -1,
1881 INT_MAX);
1882 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1883
1884 prop = RNA_def_int(srna,
1885 "subitem_local_index",
1886 -1,
1887 -1,
1888 INT_MAX,
1889 "Subitem Local Index",
1890 "Used to handle changes into collection",
1891 -1,
1892 INT_MAX);
1893 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1894}
1895
1897{
1898 StructRNA *srna;
1899 FunctionRNA *func;
1900 PropertyRNA *parm;
1901
1902 RNA_def_property_srna(cprop, "IDOverrideLibraryPropertyOperations");
1903 srna = RNA_def_struct(brna, "IDOverrideLibraryPropertyOperations", nullptr);
1904 RNA_def_struct_sdna(srna, "IDOverrideLibraryProperty");
1905 RNA_def_struct_ui_text(srna, "Override Operations", "Collection of override operations");
1906
1907 /* Add Property */
1908 func = RNA_def_function(srna, "add", "rna_ID_override_library_property_operations_add");
1909 RNA_def_function_ui_description(func, "Add a new operation");
1911 parm = RNA_def_enum(func,
1912 "operation",
1915 "Operation",
1916 "What override operation is performed");
1918 parm = RNA_def_boolean(
1919 func,
1920 "use_id",
1921 false,
1922 "Use ID Pointer Subitem",
1923 "Whether the found or created liboverride operation should use ID pointers or not");
1924 parm = RNA_def_string(func,
1925 "subitem_reference_name",
1926 nullptr,
1927 INT_MAX,
1928 "Subitem Reference Name",
1929 "Used to handle insertions or ID replacements into collection");
1930 parm = RNA_def_string(func,
1931 "subitem_local_name",
1932 nullptr,
1933 INT_MAX,
1934 "Subitem Local Name",
1935 "Used to handle insertions or ID replacements into collection");
1936 parm = RNA_def_pointer(func,
1937 "subitem_reference_id",
1938 "ID",
1939 "Subitem Reference ID",
1940 "Used to handle ID replacements into collection");
1941 parm = RNA_def_pointer(func,
1942 "subitem_local_id",
1943 "ID",
1944 "Subitem Local ID",
1945 "Used to handle ID replacements into collection");
1946 parm = RNA_def_int(func,
1947 "subitem_reference_index",
1948 -1,
1949 -1,
1950 INT_MAX,
1951 "Subitem Reference Index",
1952 "Used to handle insertions or ID replacements into collection",
1953 -1,
1954 INT_MAX);
1955 parm = RNA_def_int(func,
1956 "subitem_local_index",
1957 -1,
1958 -1,
1959 INT_MAX,
1960 "Subitem Local Index",
1961 "Used to handle insertions or ID replacements into collection",
1962 -1,
1963 INT_MAX);
1964 parm = RNA_def_pointer(func,
1965 "property",
1966 "IDOverrideLibraryPropertyOperation",
1967 "New Operation",
1968 "Created operation");
1969 RNA_def_function_return(func, parm);
1970
1971 func = RNA_def_function(srna, "remove", "rna_ID_override_library_property_operations_remove");
1972 RNA_def_function_ui_description(func, "Remove and delete an operation");
1974 parm = RNA_def_pointer(func,
1975 "operation",
1976 "IDOverrideLibraryPropertyOperation",
1977 "Operation",
1978 "Override operation to be deleted");
1980}
1981
1983{
1984 StructRNA *srna;
1985 PropertyRNA *prop;
1986
1987 srna = RNA_def_struct(brna, "IDOverrideLibraryProperty", nullptr);
1989 srna, "ID Library Override Property", "Description of an overridden property");
1990
1991 /* String pointer, we *should* add get/set/etc.
1992 * But nullptr rna_path would be a nasty bug anyway. */
1993 prop = RNA_def_string(srna,
1994 "rna_path",
1995 nullptr,
1996 INT_MAX,
1997 "RNA Path",
1998 "RNA path leading to that property, from owning ID");
1999 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
2000
2001 prop = RNA_def_collection(srna,
2002 "operations",
2003 "IDOverrideLibraryPropertyOperation",
2004 "Operations",
2005 "List of overriding operations for a property");
2008
2010}
2011
2013{
2014 StructRNA *srna;
2015 FunctionRNA *func;
2016 PropertyRNA *parm;
2017
2018 RNA_def_property_srna(cprop, "IDOverrideLibraryProperties");
2019 srna = RNA_def_struct(brna, "IDOverrideLibraryProperties", nullptr);
2020 RNA_def_struct_sdna(srna, "IDOverrideLibrary");
2021 RNA_def_struct_ui_text(srna, "Override Properties", "Collection of override properties");
2022
2023 /* Add Property */
2024 func = RNA_def_function(srna, "add", "rna_ID_override_library_properties_add");
2026 func, "Add a property to the override library when it doesn't exist yet");
2028 parm = RNA_def_pointer(func,
2029 "property",
2030 "IDOverrideLibraryProperty",
2031 "New Property",
2032 "Newly created override property or existing one");
2033 RNA_def_function_return(func, parm);
2034 parm = RNA_def_string(
2035 func, "rna_path", nullptr, 256, "RNA Path", "RNA-Path of the property to add");
2037
2038 func = RNA_def_function(srna, "remove", "rna_ID_override_library_properties_remove");
2039 RNA_def_function_ui_description(func, "Remove and delete a property");
2041 parm = RNA_def_pointer(func,
2042 "property",
2043 "IDOverrideLibraryProperty",
2044 "Property",
2045 "Override property to be deleted");
2047}
2048
2050{
2051 StructRNA *srna;
2052 PropertyRNA *prop;
2053 FunctionRNA *func;
2054 PropertyRNA *parm;
2055
2056 srna = RNA_def_struct(brna, "IDOverrideLibrary", nullptr);
2058 srna, "ID Library Override", "Struct gathering all data needed by overridden linked IDs");
2059
2060 prop = RNA_def_pointer(
2061 srna, "reference", "ID", "Reference ID", "Linked ID used as reference by this override");
2063
2065 srna,
2066 "hierarchy_root",
2067 "ID",
2068 "Hierarchy Root ID",
2069 "Library override ID used as root of the override hierarchy this ID is a member of");
2070
2071 prop = RNA_def_boolean(srna,
2072 "is_in_hierarchy",
2073 true,
2074 "Is In Hierarchy",
2075 "Whether this library override is defined as part of a library "
2076 "hierarchy, or as a single, isolated and autonomous override");
2080
2081 prop = RNA_def_boolean(srna,
2082 "is_system_override",
2083 false,
2084 "Is System Override",
2085 "Whether this library override exists only for the override hierarchy, "
2086 "or if it is actually editable by the user");
2090
2091 prop = RNA_def_collection(srna,
2092 "properties",
2093 "IDOverrideLibraryProperty",
2094 "Properties",
2095 "List of overridden properties");
2098
2099 /* Update function. */
2100 func = RNA_def_function(srna, "operations_update", "rna_ID_override_library_operations_update");
2103 "Update the library override operations based on the "
2104 "differences between this override ID and its reference");
2105
2106 func = RNA_def_function(srna, "reset", "rna_ID_override_library_reset");
2108 "Reset this override to match again its linked reference ID");
2111 func,
2112 "do_hierarchy",
2113 true,
2114 "",
2115 "Also reset all the dependencies of this override to match their reference linked IDs");
2116 RNA_def_boolean(func,
2117 "set_system_override",
2118 false,
2119 "",
2120 "Reset all user-editable overrides as (non-editable) system overrides");
2121
2122 func = RNA_def_function(srna, "destroy", "rna_ID_override_library_destroy");
2124 func, "Delete this override ID and remap its usages to its linked reference ID instead");
2126 RNA_def_boolean(func,
2127 "do_hierarchy",
2128 true,
2129 "",
2130 "Also delete all the dependencies of this override and remap their usages to "
2131 "their reference linked IDs");
2132
2133 func = RNA_def_function(srna, "resync", "rna_ID_override_library_resync");
2135 func, "Resync the data-block and its sub-hierarchy, or the whole hierarchy if requested");
2137 parm = RNA_def_boolean(
2138 func, "success", false, "Success", "Whether the resync process was successful or not");
2139 RNA_def_function_return(func, parm);
2140 parm = RNA_def_pointer(
2141 func,
2142 "scene",
2143 "Scene",
2144 "",
2145 "The scene to operate in (for contextual things like keeping active object active, ensuring "
2146 "all overridden objects remain instantiated, etc.)");
2148 parm = RNA_def_pointer(func,
2149 "view_layer",
2150 "ViewLayer",
2151 "",
2152 "The view layer to operate in (same usage as the ``scene`` data, in case "
2153 "it is not provided the scene's collection will be used instead)");
2154 parm = RNA_def_pointer(
2155 func,
2156 "residual_storage",
2157 "Collection",
2158 "",
2159 "Collection where to store objects that are instantiated in any other collection anymore "
2160 "(garbage collection, will be created if needed and none is provided)");
2161 RNA_def_boolean(func,
2162 "do_hierarchy_enforce",
2163 false,
2164 "",
2165 "Enforce restoring the dependency hierarchy between data-blocks to match the "
2166 "one from the reference linked hierarchy (WARNING: if some ID pointers have "
2167 "been purposedly overridden, these will be reset to their default value)");
2169 func,
2170 "do_whole_hierarchy",
2171 false,
2172 "",
2173 "Resync the whole hierarchy this data-block belongs to, not only its own sub-hierarchy");
2174
2176}
2177
2178static void rna_def_ID(BlenderRNA *brna)
2179{
2180 StructRNA *srna;
2181 FunctionRNA *func;
2182 PropertyRNA *prop, *parm;
2183
2184 static const EnumPropertyItem update_flag_items[] = {
2185 {ID_RECALC_TRANSFORM, "OBJECT", 0, "Object", ""},
2186 {ID_RECALC_GEOMETRY, "DATA", 0, "Data", ""},
2187 {ID_RECALC_ANIMATION, "TIME", 0, "Time", ""},
2188 {0, nullptr, 0, nullptr, nullptr},
2189 };
2190
2191 static const EnumPropertyItem rename_mode_items[] = {
2193 "NEVER",
2194 0,
2195 "Never Rename",
2196 "Never rename an exisitng ID whose name would conflict, the currently renamed ID will get "
2197 "a numeric suffix appended to its new name"},
2199 "ALWAYS",
2200 0,
2201 "Always Rename",
2202 "Always rename an exisitng ID whose name would conflict, ensuring that the currently "
2203 "renamed ID will get requested name"},
2205 "SAME_ROOT",
2206 0,
2207 "Rename If Same Root",
2208 "Only rename an exisitng ID whose name would conflict if its name root (everything besides "
2209 "the numerical suffix) is the same as the existing name of the currently renamed ID"},
2210 {0, nullptr, 0, nullptr, nullptr},
2211 };
2212
2213 static const EnumPropertyItem rename_result_items[] = {
2215 "UNCHANGED",
2216 0,
2217 "Unchanged",
2218 "The ID was not renamed, e.g. because it is already named as requested"},
2220 "UNCHANGED_COLLISION",
2221 0,
2222 "Unchanged Due to Collision",
2223 "The ID was not renamed, because requested name would have collided with another existing "
2224 "ID's name, and the automatically adjusted name was the same as the current ID's name"},
2226 "RENAMED_NO_COLLISION",
2227 0,
2228 "Renamed Without Collision",
2229 "The ID was renamed as requested, without creating any name collision"},
2231 "RENAMED_COLLISION_ADJUSTED",
2232 0,
2233 "Renamed With Collision",
2234 "The ID was renamed with adjustement of the requested name, to avoid a name collision"},
2236 "RENAMED_COLLISION_FORCED",
2237 0,
2238 "Renamed Enforced With Collision",
2239 "The ID was renamed as requested, also renaming another ID to avoid a name collision"},
2240 {0, nullptr, 0, nullptr, nullptr},
2241 };
2242
2243 srna = RNA_def_struct(brna, "ID", nullptr);
2245 srna,
2246 "ID",
2247 "Base type for data-blocks, defining a unique name, linking from other libraries "
2248 "and garbage collection");
2250 RNA_def_struct_refine_func(srna, "rna_ID_refine");
2251 RNA_def_struct_idprops_func(srna, "rna_ID_idprops");
2252
2253 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2255 prop, "Name", "Unique data-block ID name (within a same type and library)");
2256 RNA_def_property_string_funcs(prop, "rna_ID_name_get", "rna_ID_name_length", "rna_ID_name_set");
2258 RNA_def_property_editable_func(prop, "rna_ID_name_editable");
2259 RNA_def_property_update(prop, NC_ID | NA_RENAME, nullptr);
2261 RNA_def_struct_name_property(srna, prop);
2262
2263 prop = RNA_def_property(srna, "name_full", PROP_STRING, PROP_NONE);
2265 prop, "Full Name", "Unique data-block ID name, including library one is any");
2266 RNA_def_property_string_funcs(prop, "rna_ID_name_full_get", "rna_ID_name_full_length", nullptr);
2269
2270 prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
2271 RNA_def_property_ui_text(prop, "Type", "Type identifier of this data-block");
2273 RNA_def_property_enum_funcs(prop, "rna_ID_type_get", nullptr, nullptr);
2276
2277 prop = RNA_def_property(srna, "session_uid", PROP_INT, PROP_NONE);
2279 prop,
2280 "Session UID",
2281 "A session-wide unique identifier for the data block that remains the "
2282 "same across renames and internal reallocations, unchanged when reloading the file");
2284
2285 prop = RNA_def_property(srna, "is_evaluated", PROP_BOOLEAN, PROP_NONE);
2287 prop,
2288 "Is Evaluated",
2289 "Whether this ID is runtime-only, evaluated data-block, or actual data from .blend file");
2290 RNA_def_property_boolean_funcs(prop, "rna_ID_is_evaluated_get", nullptr);
2292
2293 prop = RNA_def_property(srna, "original", PROP_POINTER, PROP_NONE);
2294 RNA_def_property_struct_type(prop, "ID");
2296 prop,
2297 "Original ID",
2298 "Actual data-block from .blend file (Main database) that generated that evaluated one");
2299 RNA_def_property_pointer_funcs(prop, "rna_ID_original_get", nullptr, nullptr, nullptr);
2303
2304 prop = RNA_def_property(srna, "users", PROP_INT, PROP_UNSIGNED);
2305 RNA_def_property_int_sdna(prop, nullptr, "us");
2307 RNA_def_property_ui_text(prop, "Users", "Number of times this data-block is referenced");
2308
2309 prop = RNA_def_property(srna, "use_fake_user", PROP_BOOLEAN, PROP_NONE);
2310 RNA_def_property_boolean_sdna(prop, nullptr, "flag", ID_FLAG_FAKEUSER);
2311 RNA_def_property_ui_text(prop, "Fake User", "Save this data-block even if it has no users");
2312 RNA_def_property_ui_icon(prop, ICON_FAKE_USER_OFF, true);
2313 RNA_def_property_boolean_funcs(prop, nullptr, "rna_ID_fake_user_set");
2314
2315 prop = RNA_def_property(srna, "use_extra_user", PROP_BOOLEAN, PROP_NONE);
2316 RNA_def_property_boolean_sdna(prop, nullptr, "tag", ID_TAG_EXTRAUSER);
2318 prop,
2319 "Extra User",
2320 "Indicates whether an extra user is set or not (mainly for internal/debug usages)");
2321 RNA_def_property_boolean_funcs(prop, nullptr, "rna_ID_extra_user_set");
2322
2323 prop = RNA_def_property(srna, "is_embedded_data", PROP_BOOLEAN, PROP_NONE);
2327 prop,
2328 "Embedded Data",
2329 "This data-block is not an independent one, but is actually a sub-data of another ID "
2330 "(typical example: root node trees or master collections)");
2331
2332 prop = RNA_def_property(srna, "is_missing", PROP_BOOLEAN, PROP_NONE);
2333 RNA_def_property_boolean_sdna(prop, nullptr, "tag", ID_TAG_MISSING);
2336 "Missing Data",
2337 "This data-block is a place-holder for missing linked data (i.e. it is "
2338 "[an override of] a linked data that could not be found anymore)");
2339
2340 prop = RNA_def_property(srna, "is_runtime_data", PROP_BOOLEAN, PROP_NONE);
2341 RNA_def_property_boolean_sdna(prop, nullptr, "tag", ID_TAG_RUNTIME);
2342 RNA_def_property_editable_func(prop, "rna_ID_is_runtime_editable");
2343 RNA_def_property_boolean_funcs(prop, "rna_ID_is_runtime_get", nullptr);
2346 "Runtime Data",
2347 "This data-block is runtime data, i.e. it won't be saved in .blend "
2348 "file. Note that e.g. evaluated IDs are always runtime, so this value "
2349 "is only editable for data-blocks in Main data-base.");
2350
2351 prop = RNA_def_property(srna, "is_editable", PROP_BOOLEAN, PROP_NONE);
2352 RNA_def_property_boolean_funcs(prop, "rna_ID_is_editable_get", nullptr);
2355 "Editable",
2356 "This data-block is editable in the user interface. Linked datablocks "
2357 "are not editable, except if they were loaded as editable assets.");
2358
2359 prop = RNA_def_property(srna, "tag", PROP_BOOLEAN, PROP_NONE);
2360 RNA_def_property_boolean_sdna(prop, nullptr, "tag", ID_TAG_DOIT);
2363 "Tag",
2364 "Tools can use this to tag data for their own purposes "
2365 "(initial state is undefined)");
2366
2367 prop = RNA_def_property(srna, "is_library_indirect", PROP_BOOLEAN, PROP_NONE);
2368 RNA_def_property_boolean_sdna(prop, nullptr, "tag", ID_TAG_INDIRECT);
2370 RNA_def_property_ui_text(prop, "Is Indirect", "Is this ID block linked indirectly");
2371
2372 prop = RNA_def_property(srna, "library", PROP_POINTER, PROP_NONE);
2373 RNA_def_property_pointer_sdna(prop, nullptr, "lib");
2376 RNA_def_property_ui_text(prop, "Library", "Library file the data-block is linked from");
2377
2378 prop = RNA_def_pointer(srna,
2379 "library_weak_reference",
2380 "LibraryWeakReference",
2381 "Library Weak Reference",
2382 "Weak reference to a data-block in another library .blend file (used to "
2383 "re-use already appended data instead of appending new copies)");
2386
2387 prop = RNA_def_property(srna, "asset_data", PROP_POINTER, PROP_NONE);
2389 RNA_def_property_pointer_funcs(prop, nullptr, "rna_ID_asset_data_set", nullptr, nullptr);
2391 RNA_def_property_ui_text(prop, "Asset Data", "Additional data for an asset data-block");
2392
2393 prop = RNA_def_pointer(
2394 srna, "override_library", "IDOverrideLibrary", "Library Override", "Library override data");
2398
2399 prop = RNA_def_pointer(srna,
2400 "preview",
2401 "ImagePreview",
2402 "Preview",
2403 "Preview image and icon of this data-block (always None if not supported "
2404 "for this type of data)");
2407 RNA_def_property_pointer_funcs(prop, "rna_IDPreview_get", nullptr, nullptr, nullptr);
2408
2409 /* functions */
2410 func = RNA_def_function(srna, "rename", "rna_ID_rename");
2412 func, "More refined handling in case the new name collides with another ID's name");
2414 parm = RNA_def_string(func,
2415 "name",
2416 nullptr,
2417 MAX_NAME,
2418 "",
2419 "New name to rename the ID to, if empty will re-use the current ID name");
2421 parm = RNA_def_enum(func,
2422 "mode",
2423 rename_mode_items,
2425 "",
2426 "How to handle name collision, in case the requested new name is already "
2427 "used by another ID of the same type");
2428 parm = RNA_def_enum(func,
2429 "id_rename_result",
2430 rename_result_items,
2432 "",
2433 "How did the renaming of the data-block went on");
2434 RNA_def_function_return(func, parm);
2435
2436 func = RNA_def_function(srna, "evaluated_get", "rna_ID_evaluated_get");
2438 func,
2439 "Get corresponding evaluated ID from the given dependency graph. Note that this does not "
2440 "ensure the dependency graph is fully evaluated, it just returns the result of the last "
2441 "evaluation.");
2442 parm = RNA_def_pointer(
2443 func, "depsgraph", "Depsgraph", "", "Dependency graph to perform lookup in");
2445 parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID");
2446 RNA_def_function_return(func, parm);
2447
2448 func = RNA_def_function(srna, "copy", "rna_ID_copy");
2450 func,
2451 "Create a copy of this data-block (not supported for all data-blocks). "
2452 "The result is added to the Blend-File Data (Main database), with all references to other "
2453 "data-blocks ensured to be from within the same Blend-File Data.");
2455 parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID");
2456 RNA_def_function_return(func, parm);
2457
2458 func = RNA_def_function(srna, "asset_mark", "rna_ID_asset_mark");
2460 func,
2461 "Enable easier reuse of the data-block through the Asset Browser, with the help of "
2462 "customizable metadata (like previews, descriptions and tags)");
2463
2464 func = RNA_def_function(srna, "asset_clear", "rna_ID_asset_clear");
2466 func,
2467 "Delete all asset metadata and turn the asset data-block back into a normal data-block");
2468
2469 func = RNA_def_function(srna, "asset_generate_preview", "rna_ID_asset_generate_preview");
2471 func, "Generate preview image (might be scheduled in a background thread)");
2473
2474 func = RNA_def_function(srna, "override_create", "rna_ID_override_create");
2476 "Create an overridden local copy of this linked data-block (not "
2477 "supported for all data-blocks)");
2479 parm = RNA_def_pointer(func, "id", "ID", "", "New overridden local copy of the ID");
2480 RNA_def_function_return(func, parm);
2481 RNA_def_boolean(func,
2482 "remap_local_usages",
2483 false,
2484 "",
2485 "Whether local usages of the linked ID should be remapped to the new "
2486 "library override of it");
2487
2488 func = RNA_def_function(srna, "override_hierarchy_create", "rna_ID_override_hierarchy_create");
2490 func,
2491 "Create an overridden local copy of this linked data-block, and most of its dependencies "
2492 "when it is a Collection or and Object");
2494 parm = RNA_def_pointer(func, "id", "ID", "", "New overridden local copy of the root ID");
2495 RNA_def_function_return(func, parm);
2496 parm = RNA_def_pointer(
2497 func, "scene", "Scene", "", "In which scene the new overrides should be instantiated");
2499 parm = RNA_def_pointer(func,
2500 "view_layer",
2501 "ViewLayer",
2502 "",
2503 "In which view layer the new overrides should be instantiated");
2505 RNA_def_pointer(func,
2506 "reference",
2507 "ID",
2508 "",
2509 "Another ID (usually an Object or Collection) used as a hint to decide where to "
2510 "instantiate the new overrides");
2511 RNA_def_boolean(func,
2512 "do_fully_editable",
2513 false,
2514 "",
2515 "Make all library overrides generated by this call fully editable by the user "
2516 "(none will be 'system overrides')");
2517
2518 func = RNA_def_function(srna, "user_clear", "rna_ID_user_clear");
2520 "Clear the user count of a data-block so its not saved, "
2521 "on reload the data will be removed");
2522
2523 func = RNA_def_function(srna, "user_remap", "rna_ID_user_remap");
2525 func, "Replace all usage in the .blend file of this ID by new given one");
2527 parm = RNA_def_pointer(func, "new_id", "ID", "", "New ID to use");
2529
2530 func = RNA_def_function(srna, "make_local", "rna_ID_make_local");
2532 func,
2533 "Make this datablock local, return local one "
2534 "(may be a copy of the original, in case it is also indirectly used)");
2536 parm = RNA_def_boolean(func, "clear_proxy", true, "", "Deprecated, has no effect");
2537 parm = RNA_def_boolean(func,
2538 "clear_liboverride",
2539 false,
2540 "",
2541 "Remove potential library override data from the newly made local data");
2543 func,
2544 "clear_asset_data",
2545 true,
2546 "",
2547 "Remove potential asset metadata so the newly local data-block is not treated as asset "
2548 "data-block and won't show up in asset libraries");
2549 parm = RNA_def_pointer(func, "id", "ID", "", "This ID, or the new ID if it was copied");
2550 RNA_def_function_return(func, parm);
2551
2552 func = RNA_def_function(srna, "user_of_id", "BKE_library_ID_use_ID");
2554 "Count the number of times that ID uses/references given one");
2555 parm = RNA_def_pointer(func, "id", "ID", "", "ID to count usages");
2557 parm = RNA_def_int(func,
2558 "count",
2559 0,
2560 0,
2561 INT_MAX,
2562 "",
2563 "Number of usages/references of given id by current data-block",
2564 0,
2565 INT_MAX);
2566 RNA_def_function_return(func, parm);
2567
2568 func = RNA_def_function(srna, "animation_data_create", "rna_ID_animation_data_create");
2571 func, "Create animation data to this ID, note that not all ID types support this");
2572 parm = RNA_def_pointer(func, "anim_data", "AnimData", "", "New animation data or nullptr");
2573 RNA_def_function_return(func, parm);
2574
2575 func = RNA_def_function(srna, "animation_data_clear", "rna_ID_animation_data_free");
2577 RNA_def_function_ui_description(func, "Clear animation on this ID");
2578
2579 func = RNA_def_function(srna, "update_tag", "rna_ID_update_tag");
2582 "Tag the ID to update its display data, "
2583 "e.g. when calling :class:`bpy.types.Scene.update`");
2584 RNA_def_enum_flag(func, "refresh", update_flag_items, 0, "", "Type of updates to perform");
2585
2586 func = RNA_def_function(srna, "preview_ensure", "BKE_previewimg_id_ensure");
2588 "Ensure that this ID has preview data (if ID type supports it)");
2589 parm = RNA_def_pointer(
2590 func, "preview_image", "ImagePreview", "", "The existing or created preview");
2591 RNA_def_function_return(func, parm);
2592
2593# ifdef WITH_PYTHON
2594 RNA_def_struct_register_funcs(srna, nullptr, nullptr, "rna_ID_instance");
2595# endif
2596}
2597
2598static void rna_def_library(BlenderRNA *brna)
2599{
2600 StructRNA *srna;
2601 FunctionRNA *func;
2602 PropertyRNA *prop;
2603
2604 srna = RNA_def_struct(brna, "Library", "ID");
2605 RNA_def_struct_ui_text(srna, "Library", "External .blend file from which data is linked");
2606 RNA_def_struct_ui_icon(srna, ICON_LIBRARY_DATA_DIRECT);
2607
2608 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
2609 RNA_def_property_string_sdna(prop, nullptr, "filepath");
2610 RNA_def_property_ui_text(prop, "File Path", "Path to the library .blend file");
2611 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Library_filepath_set");
2612
2613 prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
2614 RNA_def_property_pointer_sdna(prop, nullptr, "runtime.parent");
2615 RNA_def_property_struct_type(prop, "Library");
2617 RNA_def_property_ui_text(prop, "Parent", "");
2618
2619 prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
2620 RNA_def_property_pointer_sdna(prop, nullptr, "packedfile");
2621 RNA_def_property_ui_text(prop, "Packed File", "");
2622
2623 prop = RNA_def_int_vector(srna,
2624 "version",
2625 3,
2626 nullptr,
2627 0,
2628 INT_MAX,
2629 "Version",
2630 "Version of Blender the library .blend was saved with",
2631 0,
2632 INT_MAX);
2633 RNA_def_property_int_funcs(prop, "rna_Library_version_get", nullptr, nullptr);
2636
2637 prop = RNA_def_property(srna, "needs_liboverride_resync", PROP_BOOLEAN, PROP_NONE);
2638 RNA_def_property_boolean_sdna(prop, nullptr, "runtime.tag", LIBRARY_TAG_RESYNC_REQUIRED);
2640 "Library Overrides Need resync",
2641 "True if this library contains library overrides that are linked in "
2642 "current blendfile, and that had to be recursively resynced on load "
2643 "(it is recommended to open and re-save that library blendfile then)");
2644
2645 prop = RNA_def_property(srna, "is_editable", PROP_BOOLEAN, PROP_NONE);
2646 RNA_def_property_boolean_sdna(prop, nullptr, "runtime.tag", LIBRARY_ASSET_EDITABLE);
2649 "Editable",
2650 "Datablocks in this library are editable despite being linked. Used by "
2651 "brush assets and their dependencies.");
2652
2653 func = RNA_def_function(srna, "reload", "rna_Library_reload");
2655 RNA_def_function_ui_description(func, "Reload this library and all its linked data-blocks");
2656}
2657
2659{
2660 StructRNA *srna;
2661 PropertyRNA *prop;
2662
2663 srna = RNA_def_struct(brna, "LibraryWeakReference", nullptr);
2665 srna,
2666 "LibraryWeakReference",
2667 "Read-only external reference to a linked data-block and its library file");
2668
2669 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
2670 RNA_def_property_string_sdna(prop, nullptr, "library_filepath");
2672 RNA_def_property_ui_text(prop, "File Path", "Path to the library .blend file");
2673
2674 prop = RNA_def_property(srna, "id_name", PROP_STRING, PROP_FILEPATH);
2675 RNA_def_property_string_sdna(prop, nullptr, "library_id_name");
2678 prop,
2679 "ID name",
2680 "Full ID name in the library .blend file (including the two leading 'id type' chars)");
2681}
2682
2688{
2689 StructRNA *srna;
2690
2691 srna = RNA_def_struct(brna, "IDPropertyWrapPtr", nullptr);
2692 RNA_def_struct_idprops_func(srna, "rna_IDPropertyWrapPtr_idprops");
2694}
2695
2697{
2698 StructRNA *srna;
2699
2700 /* built-in unknown type */
2701 srna = RNA_def_struct(brna, "UnknownType", nullptr);
2703 srna, "Unknown Type", "Stub RNA type used for pointers to unknown or internal data");
2704
2705 /* built-in any type */
2706 srna = RNA_def_struct(brna, "AnyType", nullptr);
2707 RNA_def_struct_ui_text(srna, "Any Type", "RNA type used for pointers to any possible data");
2708
2709 rna_def_ID(brna);
2714 rna_def_library(brna);
2717}
2718
2719#endif
AnimData * BKE_animdata_ensure_id(ID *id)
Definition anim_data.cc:103
bool id_can_have_animdata(const ID *id)
Definition anim_data.cc:79
void BKE_animdata_free(ID *id, bool do_id_user)
Definition anim_data.cc:263
#define G_MAIN
int BKE_icon_preview_ensure(struct ID *id, struct PreviewImage *preview)
Definition icons.cc:336
#define IDP_IDPArray(prop)
void BKE_id_newptr_and_tag_clear(ID *id)
Definition lib_id.cc:405
void BKE_id_delete(Main *bmain, void *idv) ATTR_NONNULL()
ID * BKE_id_copy_for_use_in_bmain(Main *bmain, const ID *id)
Definition lib_id.cc:834
IDNewNameMode
void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const ID *id, char separator_char)
Definition lib_id.cc:2365
void id_fake_user_set(ID *id)
Definition lib_id.cc:389
IDNewNameResult BKE_id_rename(Main &bmain, ID &id, blender::StringRefNull name, const IDNewNameMode mode=IDNewNameMode::RenameExistingNever)
Definition lib_id.cc:2338
bool BKE_lib_id_make_local(Main *bmain, ID *id, int flags)
Definition lib_id.cc:584
void id_us_ensure_real(ID *id)
Definition lib_id.cc:306
void id_fake_user_clear(ID *id)
Definition lib_id.cc:397
void id_us_clear_real(ID *id)
Definition lib_id.cc:324
@ LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR
void id_us_min(ID *id)
Definition lib_id.cc:359
#define MAX_ID_FULL_NAME
void BKE_main_id_tag_all(Main *mainvar, int tag, bool value)
Definition lib_id.cc:1198
bool BKE_id_is_in_global_main(ID *id)
Definition lib_id.cc:2433
ID * BKE_lib_override_library_create_from_id(Main *bmain, ID *reference_id, bool do_tagged_remap)
void BKE_lib_override_library_property_operation_delete(IDOverrideLibraryProperty *liboverride_property, IDOverrideLibraryPropertyOperation *liboverride_property_operation)
IDOverrideLibraryProperty * BKE_lib_override_library_property_get(IDOverrideLibrary *liboverride, const char *rna_path, bool *r_created)
IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_get(IDOverrideLibraryProperty *liboverride_property, short operation, const char *subitem_refname, const char *subitem_locname, const std::optional< ID * > &subitem_refid, const std::optional< ID * > &subitem_locid, int subitem_refindex, int subitem_locindex, bool strict, bool *r_strict, bool *r_created)
void BKE_lib_override_library_id_reset(Main *bmain, ID *id_root, bool do_reset_system_override)
bool BKE_lib_override_library_resync(Main *bmain, Scene *scene, ViewLayer *view_layer, ID *id_root, Collection *override_resync_residual_storage, bool do_hierarchy_enforce, BlendFileReadReport *reports)
bool BKE_lib_override_library_create(Main *bmain, Scene *scene, ViewLayer *view_layer, Library *owner_library, ID *id_root_reference, ID *id_hierarchy_root_reference, ID *id_instance_hint, ID **r_id_root_override, const bool do_fully_editable)
void BKE_lib_override_library_id_hierarchy_reset(Main *bmain, ID *id_root, bool do_reset_system_override)
void BKE_lib_override_library_operations_create(Main *bmain, ID *local, int *r_report_flags)
void BKE_lib_override_library_make_local(Main *bmain, ID *id)
void BKE_lib_override_library_delete(Main *bmain, ID *id_root)
void BKE_lib_override_library_property_delete(IDOverrideLibrary *liboverride, IDOverrideLibraryProperty *liboverride_property)
@ ID_REMAP_SKIP_NEVER_NULL_USAGE
@ ID_REMAP_SKIP_INDIRECT_USAGE
void void BKE_libblock_remap(Main *bmain, void *old_idv, void *new_idv, int remap_flags) ATTR_NONNULL(1
void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
Definition library.cc:135
General operations, lookup, etc. for materials.
struct Material * BKE_id_material_pop(struct Main *bmain, struct ID *id, int index)
void BKE_id_material_assign(struct Main *bmain, struct ID *id, struct Material *ma, short act)
void BKE_id_material_append(struct Main *bmain, struct ID *id, struct Material *ma)
void BKE_id_material_clear(struct Main *bmain, struct ID *id)
short * BKE_id_material_len_p(struct ID *id)
General operations, lookup, etc. for blender objects.
PreviewImage * BKE_previewimg_id_get(const ID *id)
void BKE_previewimg_ensure(PreviewImage *prv, int size)
PreviewImage * BKE_previewimg_id_ensure(ID *id)
void BKE_previewimg_clear_single(PreviewImage *prv, enum eIconSizes size)
void BKE_previewimg_clear(PreviewImage *prv)
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:125
@ FO_EDIT
Definition BKE_vfont.hh:69
bool BKE_vfont_is_builtin(const VFont *vfont)
Definition vfont.cc:232
bool BKE_vfont_to_curve(Object *ob, eEditFontMode mode)
Definition vfont.cc:2044
#define BLI_assert(a)
Definition BLI_assert.h:50
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int char char int int int int size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition string.c:909
unsigned char uchar
unsigned int uint
#define UNLIKELY(x)
external readfile function prototypes.
#define BPy_BEGIN_ALLOW_THREADS
Definition BPY_extern.hh:50
#define BPy_END_ALLOW_THREADS
Definition BPY_extern.hh:54
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_id_tag_update_ex(Main *bmain, ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
ID * DEG_get_original_id(ID *id)
ID * DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
ID and Library types, which are fundamental for SDNA.
#define FILTER_ID_GD_LEGACY
Definition DNA_ID.h:1169
#define FILTER_ID_OB
Definition DNA_ID.h:1181
#define FILTER_ID_MC
Definition DNA_ID.h:1177
#define FILTER_ID_SPK
Definition DNA_ID.h:1185
#define FILTER_ID_CF
Definition DNA_ID.h:1192
@ ID_RECALC_TRANSFORM
Definition DNA_ID.h:1021
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1044
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1041
@ ID_RECALC_ALL
Definition DNA_ID.h:1155
#define FILTER_ID_AC
Definition DNA_ID.h:1164
#define FILTER_ID_MA
Definition DNA_ID.h:1175
#define ID_IS_OVERRIDE_LIBRARY_REAL(_id)
Definition DNA_ID.h:676
#define FILTER_ID_CA
Definition DNA_ID.h:1167
#define FILTER_ID_SO
Definition DNA_ID.h:1186
#define FILTER_ID_PT
Definition DNA_ID.h:1196
#define ID_IS_OVERRIDABLE_LIBRARY(_id)
Definition DNA_ID.h:669
#define FILTER_ID_CU_LEGACY
Definition DNA_ID.h:1168
#define FILTER_ID_BR
Definition DNA_ID.h:1166
#define FILTER_ID_WS
Definition DNA_ID.h:1193
@ LIBOVERRIDE_OP_FLAG_MANDATORY
Definition DNA_ID.h:247
@ LIBOVERRIDE_OP_FLAG_LOCKED
Definition DNA_ID.h:249
@ LIBOVERRIDE_OP_FLAG_IDPOINTER_ITEM_USE_ID
Definition DNA_ID.h:261
@ LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE
Definition DNA_ID.h:255
#define FILTER_ID_MB
Definition DNA_ID.h:1176
#define FILTER_ID_VF
Definition DNA_ID.h:1189
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:654
#define MAX_ID_NAME
Definition DNA_ID.h:377
#define FILTER_ID_LA
Definition DNA_ID.h:1172
#define FILTER_ID_GR
Definition DNA_ID.h:1170
#define FILTER_ID_TE
Definition DNA_ID.h:1187
#define FILTER_ID_LT
Definition DNA_ID.h:1174
#define FILTER_ID_LS
Definition DNA_ID.h:1173
#define FILTER_ID_PA
Definition DNA_ID.h:1191
#define FILTER_ID_CV
Definition DNA_ID.h:1195
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:658
@ ID_FLAG_FAKEUSER
Definition DNA_ID.h:720
@ ID_FLAG_EMBEDDED_DATA
Definition DNA_ID.h:725
#define FILTER_ID_ME
Definition DNA_ID.h:1178
#define FILTER_ID_AR
Definition DNA_ID.h:1165
#define MAX_IDPROP_NAME
Definition DNA_ID.h:185
@ LIBOVERRIDE_OP_NOOP
Definition DNA_ID.h:227
@ LIBOVERRIDE_OP_ADD
Definition DNA_ID.h:232
@ LIBOVERRIDE_OP_SUBTRACT
Definition DNA_ID.h:234
@ LIBOVERRIDE_OP_REPLACE
Definition DNA_ID.h:229
@ LIBOVERRIDE_OP_MULTIPLY
Definition DNA_ID.h:236
@ LIBOVERRIDE_OP_INSERT_BEFORE
Definition DNA_ID.h:240
@ LIBOVERRIDE_OP_INSERT_AFTER
Definition DNA_ID.h:239
@ ID_TAG_COPIED_ON_EVAL
Definition DNA_ID.h:964
@ ID_TAG_EXTRAUSER
Definition DNA_ID.h:824
@ ID_TAG_TEMP_MAIN
Definition DNA_ID.h:938
@ ID_TAG_INDIRECT
Definition DNA_ID.h:794
@ ID_TAG_RUNTIME
Definition DNA_ID.h:805
@ ID_TAG_LOCALIZED
Definition DNA_ID.h:954
@ ID_TAG_MISSING
Definition DNA_ID.h:813
@ ID_TAG_COPIED_ON_EVAL_FINAL_RESULT
Definition DNA_ID.h:974
@ ID_TAG_DOIT
Definition DNA_ID.h:1003
@ ID_TAG_NO_MAIN
Definition DNA_ID.h:945
#define FILTER_ID_MSK
Definition DNA_ID.h:1179
@ LIBOVERRIDE_FLAG_NO_HIERARCHY
Definition DNA_ID.h:362
@ LIBOVERRIDE_FLAG_SYSTEM_DEFINED
Definition DNA_ID.h:367
#define FILTER_ID_PC
Definition DNA_ID.h:1183
#define FILTER_ID_PAL
Definition DNA_ID.h:1182
#define FILTER_ID_IM
Definition DNA_ID.h:1171
#define FILTER_ID_SCE
Definition DNA_ID.h:1184
#define FILTER_ID_LP
Definition DNA_ID.h:1194
@ LIBRARY_ASSET_EDITABLE
Definition DNA_ID.h:549
@ LIBRARY_TAG_RESYNC_REQUIRED
Definition DNA_ID.h:541
#define FILTER_ID_VO
Definition DNA_ID.h:1197
@ PRV_CHANGED
Definition DNA_ID.h:581
@ PRV_USER_EDITED
Definition DNA_ID.h:583
#define FILTER_ID_WO
Definition DNA_ID.h:1190
#define FILTER_ID_NT
Definition DNA_ID.h:1180
#define FILTER_ID_TXT
Definition DNA_ID.h:1188
eIconSizes
@ ICON_SIZE_PREVIEW
@ ICON_SIZE_ICON
ID_Type
@ ID_WM
@ ID_CA
@ ID_AR
@ ID_MC
@ ID_CF
@ ID_LI
@ ID_TE
@ ID_IM
@ ID_VO
@ ID_WS
@ ID_NT
@ ID_LA
@ ID_KE
@ ID_TXT
@ ID_SO
@ ID_SCE
@ ID_LS
@ ID_MSK
@ ID_CV
@ ID_PAL
@ ID_BR
@ ID_LP
@ ID_WO
@ ID_MA
@ ID_AC
@ ID_SCR
@ ID_CU_LEGACY
@ ID_GD_LEGACY
@ ID_VF
@ ID_ME
@ ID_IP
@ ID_GR
@ ID_SPK
@ ID_MB
@ ID_LT
@ ID_OB
@ ID_GP
@ ID_PA
@ ID_PT
@ ID_PC
#define MAX_NAME
Definition DNA_defs.h:50
#define MAXMAT
Object is a sort of wrapper for general info.
@ OB_FONT
@ RPT_ERROR_INVALID_INPUT
short RNA_type_to_ID_code(const StructRNA *type)
StructRNA * ID_code_to_RNA_type(short idcode)
#define RNA_MAX_ARRAY_DIMENSION
Definition RNA_define.hh:26
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_USE_MAIN
Definition RNA_types.hh:678
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:679
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:667
@ STRUCT_ID_REFCOUNT
Definition RNA_types.hh:720
@ STRUCT_ID
Definition RNA_types.hh:719
@ STRUCT_NO_DATABLOCK_IDPROPERTIES
Definition RNA_types.hh:731
int(*)(PointerRNA *ptr, void *data, bool *have_function) StructValidateFunc
Definition RNA_types.hh:746
@ PROP_FLOAT
Definition RNA_types.hh:67
@ PROP_BOOLEAN
Definition RNA_types.hh:65
@ PROP_ENUM
Definition RNA_types.hh:69
@ PROP_INT
Definition RNA_types.hh:66
@ PROP_STRING
Definition RNA_types.hh:68
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_COLLECTION
Definition RNA_types.hh:71
void(*)(void *data) StructFreeFunc
Definition RNA_types.hh:751
int(*)(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *list) StructCallbackFunc
Definition RNA_types.hh:747
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:355
@ PROPOVERRIDE_NO_COMPARISON
Definition RNA_types.hh:363
@ PROPOVERRIDE_IGNORE
Definition RNA_types.hh:375
PropertyFlag
Definition RNA_types.hh:201
@ PROP_THICK_WRAP
Definition RNA_types.hh:312
@ PROP_DYNAMIC
Definition RNA_types.hh:317
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_ENUM_FLAG
Definition RNA_types.hh:293
@ PROP_LIB_EXCEPTION
Definition RNA_types.hh:213
@ PROP_NEVER_NULL
Definition RNA_types.hh:266
@ PROP_PTR_NO_OWNERSHIP
Definition RNA_types.hh:284
@ PROP_HIDDEN
Definition RNA_types.hh:239
@ PROP_IDPROPERTY
Definition RNA_types.hh:315
@ PROP_PIXEL
Definition RNA_types.hh:151
@ PROP_NONE
Definition RNA_types.hh:136
@ PROP_UNSIGNED
Definition RNA_types.hh:152
@ PROP_FILEPATH
Definition RNA_types.hh:139
#define NC_WINDOW
Definition WM_types.hh:342
#define NC_ID
Definition WM_types.hh:362
#define ND_DRAW
Definition WM_types.hh:428
#define NC_WM
Definition WM_types.hh:341
#define ND_LIB_OVERRIDE_CHANGED
Definition WM_types.hh:386
#define NA_ADDED
Definition WM_types.hh:552
#define NA_EDITED
Definition WM_types.hh:550
#define NC_ASSET
Definition WM_types.hh:371
#define NA_REMOVED
Definition WM_types.hh:553
#define NA_RENAME
Definition WM_types.hh:554
#define ND_OB_SHADING
Definition WM_types.hh:424
#define NC_OBJECT
Definition WM_types.hh:346
PyObject * self
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
const Depsgraph * depsgraph
int len
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
#define GS(x)
Definition iris.cc:202
void *(* MEM_callocN)(size_t len, const char *str)
Definition mallocn.cc:42
#define unit_float_to_uchar_clamp(val)
bool copy_to_id(const AssetMetaData *asset_data, ID *destination)
void generate_preview(const bContext *C, ID *id)
static void rna_def_ID_override_library(BlenderRNA *brna)
Definition rna_ID.cc:2049
static const EnumPropertyItem rna_enum_override_library_property_operation_items[]
Definition rna_ID.cc:78
static void rna_def_ID_override_library_property_operation(BlenderRNA *brna)
Definition rna_ID.cc:1785
static void rna_def_ID_override_library_property(BlenderRNA *brna)
Definition rna_ID.cc:1982
const EnumPropertyItem rna_enum_id_type_items[]
Definition rna_ID.cc:35
static void rna_def_ID_override_library_properties(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_ID.cc:2012
const IDFilterEnumPropertyItem rna_enum_id_type_filter_items[]
Definition rna_ID.cc:122
void RNA_def_ID(BlenderRNA *brna)
Definition rna_ID.cc:2696
static void rna_def_ID(BlenderRNA *brna)
Definition rna_ID.cc:2178
static void rna_def_library_weak_reference(BlenderRNA *brna)
Definition rna_ID.cc:2658
static void rna_def_ID_properties(BlenderRNA *brna)
Definition rna_ID.cc:1552
static void rna_def_idproperty_wrap_ptr(BlenderRNA *brna)
Definition rna_ID.cc:2687
static void rna_def_image_preview(BlenderRNA *brna)
Definition rna_ID.cc:1693
static void rna_def_library(BlenderRNA *brna)
Definition rna_ID.cc:2598
static void rna_def_ID_override_library_property_operations(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_ID.cc:1896
static void rna_def_ID_materials(BlenderRNA *brna)
Definition rna_ID.cc:1663
const StructRNA * RNA_struct_base_child_of(const StructRNA *type, const StructRNA *parent_type)
const char * RNA_struct_identifier(const StructRNA *type)
void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, bool free_ptr, IteratorSkipFunc skip)
PointerRNA rna_pointer_inherit_refine(const PointerRNA *ptr, StructRNA *type, void *data)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
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)
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_flag(StructRNA *srna, int flag)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
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)
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_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance)
void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength)
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)
PropertyRNA * RNA_def_int_vector(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_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_property_array(PropertyRNA *prop, int length)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
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)
StructRNA * RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
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_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
PropertyRNA * RNA_def_collection(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
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_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
int rna_ID_name_length(PointerRNA *ptr)
void rna_ID_name_get(PointerRNA *ptr, char *value)
StructRNA * rna_ID_refine(PointerRNA *ptr)
StructRNA * rna_PropertyGroup_refine(PointerRNA *ptr)
BlenderRNA BLENDER_RNA
bool rna_IDMaterials_assign_int(PointerRNA *ptr, int key, const PointerRNA *assign_ptr)
void ** rna_ID_instance(PointerRNA *ptr)
bool rna_PropertyGroup_unregister(Main *bmain, StructRNA *type)
IDProperty ** rna_PropertyGroup_idprops(PointerRNA *ptr)
StructRNA * rna_PropertyGroup_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
void rna_ID_fake_user_set(PointerRNA *ptr, bool value)
StructRNA RNA_PropertyGroup
void rna_ID_name_set(PointerRNA *ptr, const char *value)
IDProperty ** rna_ID_idprops(PointerRNA *ptr)
const EnumPropertyItem rna_enum_dummy_DEFAULT_items[]
Definition rna_rna.cc:35
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
ListBase properties
Definition DNA_ID.h:335
unsigned int flag
Definition DNA_ID.h:352
struct ID * hierarchy_root
Definition DNA_ID.h:343
Definition DNA_ID.h:413
struct ID * newid
Definition DNA_ID.h:417
char name[66]
Definition DNA_ID.h:425
ID * owner_id
Definition RNA_types.hh:40
StructRNA * type
Definition RNA_types.hh:41
void * data
Definition RNA_types.hh:42
short flag[2]
Definition DNA_ID.h:605
#define N_(msgid)
static DynamicLibrary lib
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4126
uint8_t flag
Definition wm_window.cc:138