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