Blender  V2.93
rna_ID.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include <stdio.h>
22 #include <stdlib.h>
23 
24 #include "DNA_ID.h"
25 #include "DNA_material_types.h"
26 #include "DNA_object_types.h"
27 #include "DNA_vfont_types.h"
28 
29 #include "BLI_utildefines.h"
30 
31 #include "BKE_icons.h"
32 #include "BKE_lib_id.h"
33 #include "BKE_object.h"
34 
35 #include "RNA_access.h"
36 #include "RNA_define.h"
37 #include "RNA_enum_types.h"
38 
39 #include "WM_types.h"
40 
41 #include "rna_internal.h"
42 
43 /* enum of ID-block types
44  * NOTE: need to keep this in line with the other defines for these
45  */
47  {ID_AC, "ACTION", ICON_ACTION, "Action", ""},
48  {ID_AR, "ARMATURE", ICON_ARMATURE_DATA, "Armature", ""},
49  {ID_BR, "BRUSH", ICON_BRUSH_DATA, "Brush", ""},
50  {ID_CA, "CAMERA", ICON_CAMERA_DATA, "Camera", ""},
51  {ID_CF, "CACHEFILE", ICON_FILE, "Cache File", ""},
52  {ID_CU, "CURVE", ICON_CURVE_DATA, "Curve", ""},
53  {ID_VF, "FONT", ICON_FONT_DATA, "Font", ""},
54  {ID_GD, "GREASEPENCIL", ICON_GREASEPENCIL, "Grease Pencil", ""},
55  {ID_GR, "COLLECTION", ICON_OUTLINER_COLLECTION, "Collection", ""},
56  {ID_IM, "IMAGE", ICON_IMAGE_DATA, "Image", ""},
57  {ID_KE, "KEY", ICON_SHAPEKEY_DATA, "Key", ""},
58  {ID_LA, "LIGHT", ICON_LIGHT_DATA, "Light", ""},
59  {ID_LI, "LIBRARY", ICON_LIBRARY_DATA_DIRECT, "Library", ""},
60  {ID_LS, "LINESTYLE", ICON_LINE_DATA, "Line Style", ""},
61  {ID_LT, "LATTICE", ICON_LATTICE_DATA, "Lattice", ""},
62  {ID_MSK, "MASK", ICON_MOD_MASK, "Mask", ""},
63  {ID_MA, "MATERIAL", ICON_MATERIAL_DATA, "Material", ""},
64  {ID_MB, "META", ICON_META_DATA, "Metaball", ""},
65  {ID_ME, "MESH", ICON_MESH_DATA, "Mesh", ""},
66  {ID_MC, "MOVIECLIP", ICON_TRACKER, "Movie Clip", ""},
67  {ID_NT, "NODETREE", ICON_NODETREE, "Node Tree", ""},
68  {ID_OB, "OBJECT", ICON_OBJECT_DATA, "Object", ""},
69  {ID_PC, "PAINTCURVE", ICON_CURVE_BEZCURVE, "Paint Curve", ""},
70  {ID_PAL, "PALETTE", ICON_COLOR, "Palette", ""},
71  {ID_PA, "PARTICLE", ICON_PARTICLE_DATA, "Particle", ""},
72  {ID_LP, "LIGHT_PROBE", ICON_LIGHTPROBE_CUBEMAP, "Light Probe", ""},
73  {ID_SCE, "SCENE", ICON_SCENE_DATA, "Scene", ""},
74  {ID_SIM, "SIMULATION", ICON_PHYSICS, "Simulation", ""}, /* TODO: Use correct icon. */
75  {ID_SO, "SOUND", ICON_SOUND, "Sound", ""},
76  {ID_SPK, "SPEAKER", ICON_SPEAKER, "Speaker", ""},
77  {ID_TXT, "TEXT", ICON_TEXT, "Text", ""},
78  {ID_TE, "TEXTURE", ICON_TEXTURE_DATA, "Texture", ""},
79  {ID_HA, "HAIR", ICON_HAIR_DATA, "Hair", ""},
80  {ID_PT, "POINTCLOUD", ICON_POINTCLOUD_DATA, "Point Cloud", ""},
81  {ID_VO, "VOLUME", ICON_VOLUME_DATA, "Volume", ""},
82  {ID_WM, "WINDOWMANAGER", ICON_WINDOW, "Window Manager", ""},
83  {ID_WO, "WORLD", ICON_WORLD_DATA, "World", ""},
84  {ID_WS, "WORKSPACE", ICON_WORKSPACE, "Workspace", ""},
85  {0, NULL, 0, NULL, NULL},
86 };
87 
90  "NOOP",
91  0,
92  "No-Op",
93  "Does nothing, prevents adding actual overrides (NOT USED)"},
95  "REPLACE",
96  0,
97  "Replace",
98  "Replace value of reference by overriding one"},
100  "DIFF_ADD",
101  0,
102  "Differential",
103  "Stores and apply difference between reference and local value (NOT USED)"},
105  "DIFF_SUB",
106  0,
107  "Differential",
108  "Stores and apply difference between reference and local value (NOT USED)"},
110  "FACT_MULTIPLY",
111  0,
112  "Factor",
113  "Stores and apply multiplication factor between reference and local value (NOT USED)"},
115  "INSERT_AFTER",
116  0,
117  "Insert After",
118  "Insert a new item into collection after the one referenced in subitem_reference_name or "
119  "_index"},
121  "INSERT_BEFORE",
122  0,
123  "Insert Before",
124  "Insert a new item into collection after the one referenced in subitem_reference_name or "
125  "_index (NOT USED)"},
126  {0, NULL, 0, NULL, NULL},
127 };
128 
129 #ifdef RNA_RUNTIME
130 
131 # include "DNA_anim_types.h"
132 
133 # include "BLI_listbase.h"
134 # include "BLI_math_base.h"
135 
136 # include "BKE_anim_data.h"
137 # include "BKE_font.h"
138 # include "BKE_global.h" /* XXX, remove me */
139 # include "BKE_idprop.h"
140 # include "BKE_idtype.h"
141 # include "BKE_lib_override.h"
142 # include "BKE_lib_query.h"
143 # include "BKE_lib_remap.h"
144 # include "BKE_library.h"
145 # include "BKE_material.h"
146 
147 # include "DEG_depsgraph.h"
148 # include "DEG_depsgraph_build.h"
149 # include "DEG_depsgraph_query.h"
150 
151 # include "WM_api.h"
152 
153 void rna_ID_override_library_property_operation_refname_get(PointerRNA *ptr, char *value)
154 {
156  strcpy(value, (opop->subitem_reference_name == NULL) ? "" : opop->subitem_reference_name);
157 }
158 
159 int rna_ID_override_library_property_operation_refname_length(PointerRNA *ptr)
160 {
162  return (opop->subitem_reference_name == NULL) ? 0 : strlen(opop->subitem_reference_name);
163 }
164 
165 void rna_ID_override_library_property_operation_locname_get(PointerRNA *ptr, char *value)
166 {
168  strcpy(value, (opop->subitem_local_name == NULL) ? "" : opop->subitem_local_name);
169 }
170 
171 int rna_ID_override_library_property_operation_locname_length(PointerRNA *ptr)
172 {
174  return (opop->subitem_local_name == NULL) ? 0 : strlen(opop->subitem_local_name);
175 }
176 
177 /* name functions that ignore the first two ID characters */
178 void rna_ID_name_get(PointerRNA *ptr, char *value)
179 {
180  ID *id = (ID *)ptr->data;
181  BLI_strncpy(value, id->name + 2, sizeof(id->name) - 2);
182 }
183 
185 {
186  ID *id = (ID *)ptr->data;
187  return strlen(id->name + 2);
188 }
189 
190 void rna_ID_name_set(PointerRNA *ptr, const char *value)
191 {
192  ID *id = (ID *)ptr->data;
193  BLI_strncpy_utf8(id->name + 2, value, sizeof(id->name) - 2);
196 
197  if (GS(id->name) == ID_OB) {
198  Object *ob = (Object *)id;
199  if (ob->type == OB_MBALL) {
201  }
202  }
203 }
204 
205 static int rna_ID_name_editable(PointerRNA *ptr, const char **UNUSED(r_info))
206 {
207  ID *id = (ID *)ptr->data;
208 
209  if (GS(id->name) == ID_VF) {
210  VFont *vfont = (VFont *)id;
211  if (BKE_vfont_is_builtin(vfont)) {
212  return 0;
213  }
214  }
215  else if (!BKE_id_is_in_global_main(id)) {
216  return 0;
217  }
218 
219  return PROP_EDITABLE;
220 }
221 
222 void rna_ID_name_full_get(PointerRNA *ptr, char *value)
223 {
224  ID *id = (ID *)ptr->data;
225  BKE_id_full_name_get(value, id, 0);
226 }
227 
228 int rna_ID_name_full_length(PointerRNA *ptr)
229 {
230  ID *id = (ID *)ptr->data;
231  char name[MAX_ID_FULL_NAME];
232  BKE_id_full_name_get(name, id, 0);
233  return strlen(name);
234 }
235 
236 static int rna_ID_is_evaluated_get(PointerRNA *ptr)
237 {
238  ID *id = (ID *)ptr->data;
239 
240  return (DEG_get_original_id(id) != id);
241 }
242 
243 static PointerRNA rna_ID_original_get(PointerRNA *ptr)
244 {
245  ID *id = (ID *)ptr->data;
246 
248 }
249 
250 short RNA_type_to_ID_code(const StructRNA *type)
251 {
252  const StructRNA *base_type = RNA_struct_base_child_of(type, &RNA_ID);
253  if (UNLIKELY(base_type == NULL)) {
254  return 0;
255  }
256  if (base_type == &RNA_Action) {
257  return ID_AC;
258  }
259  if (base_type == &RNA_Armature) {
260  return ID_AR;
261  }
262  if (base_type == &RNA_Brush) {
263  return ID_BR;
264  }
265  if (base_type == &RNA_CacheFile) {
266  return ID_CF;
267  }
268  if (base_type == &RNA_Camera) {
269  return ID_CA;
270  }
271  if (base_type == &RNA_Curve) {
272  return ID_CU;
273  }
274  if (base_type == &RNA_GreasePencil) {
275  return ID_GD;
276  }
277  if (base_type == &RNA_Collection) {
278  return ID_GR;
279  }
280  if (base_type == &RNA_Image) {
281  return ID_IM;
282  }
283  if (base_type == &RNA_Key) {
284  return ID_KE;
285  }
286  if (base_type == &RNA_Light) {
287  return ID_LA;
288  }
289  if (base_type == &RNA_Library) {
290  return ID_LI;
291  }
292  if (base_type == &RNA_FreestyleLineStyle) {
293  return ID_LS;
294  }
295 # ifdef WITH_HAIR_NODES
296  if (base_type == &RNA_Hair) {
297  return ID_HA;
298  }
299 # endif
300  if (base_type == &RNA_Lattice) {
301  return ID_LT;
302  }
303  if (base_type == &RNA_Material) {
304  return ID_MA;
305  }
306  if (base_type == &RNA_MetaBall) {
307  return ID_MB;
308  }
309  if (base_type == &RNA_MovieClip) {
310  return ID_MC;
311  }
312  if (base_type == &RNA_Mesh) {
313  return ID_ME;
314  }
315  if (base_type == &RNA_Mask) {
316  return ID_MSK;
317  }
318  if (base_type == &RNA_NodeTree) {
319  return ID_NT;
320  }
321  if (base_type == &RNA_Object) {
322  return ID_OB;
323  }
324  if (base_type == &RNA_ParticleSettings) {
325  return ID_PA;
326  }
327  if (base_type == &RNA_Palette) {
328  return ID_PAL;
329  }
330  if (base_type == &RNA_PaintCurve) {
331  return ID_PC;
332  }
333 # ifdef WITH_POINT_CLOUD
334  if (base_type == &RNA_PointCloud) {
335  return ID_PT;
336  }
337 # endif
338  if (base_type == &RNA_LightProbe) {
339  return ID_LP;
340  }
341  if (base_type == &RNA_Scene) {
342  return ID_SCE;
343  }
344  if (base_type == &RNA_Screen) {
345  return ID_SCR;
346  }
347 # ifdef WITH_GEOMETRY_NODES
348  if (base_type == &RNA_Simulation) {
349  return ID_SIM;
350  }
351 # endif
352  if (base_type == &RNA_Sound) {
353  return ID_SO;
354  }
355  if (base_type == &RNA_Speaker) {
356  return ID_SPK;
357  }
358  if (base_type == &RNA_Texture) {
359  return ID_TE;
360  }
361  if (base_type == &RNA_Text) {
362  return ID_TXT;
363  }
364  if (base_type == &RNA_VectorFont) {
365  return ID_VF;
366  }
367  if (base_type == &RNA_Volume) {
368  return ID_VO;
369  }
370  if (base_type == &RNA_WorkSpace) {
371  return ID_WS;
372  }
373  if (base_type == &RNA_World) {
374  return ID_WO;
375  }
376  if (base_type == &RNA_WindowManager) {
377  return ID_WM;
378  }
379 
380  return 0;
381 }
382 
383 StructRNA *ID_code_to_RNA_type(short idcode)
384 {
385  /* Note, this switch doesn't use a 'default',
386  * so adding new ID's causes a warning. */
387  switch ((ID_Type)idcode) {
388  case ID_AC:
389  return &RNA_Action;
390  case ID_AR:
391  return &RNA_Armature;
392  case ID_BR:
393  return &RNA_Brush;
394  case ID_CA:
395  return &RNA_Camera;
396  case ID_CF:
397  return &RNA_CacheFile;
398  case ID_CU:
399  return &RNA_Curve;
400  case ID_GD:
401  return &RNA_GreasePencil;
402  case ID_GR:
403  return &RNA_Collection;
404  case ID_HA:
405 # ifdef WITH_HAIR_NODES
406  return &RNA_Hair;
407 # else
408  return &RNA_ID;
409 # endif
410  case ID_IM:
411  return &RNA_Image;
412  case ID_KE:
413  return &RNA_Key;
414  case ID_LA:
415  return &RNA_Light;
416  case ID_LI:
417  return &RNA_Library;
418  case ID_LS:
419  return &RNA_FreestyleLineStyle;
420  case ID_LT:
421  return &RNA_Lattice;
422  case ID_MA:
423  return &RNA_Material;
424  case ID_MB:
425  return &RNA_MetaBall;
426  case ID_MC:
427  return &RNA_MovieClip;
428  case ID_ME:
429  return &RNA_Mesh;
430  case ID_MSK:
431  return &RNA_Mask;
432  case ID_NT:
433  return &RNA_NodeTree;
434  case ID_OB:
435  return &RNA_Object;
436  case ID_PA:
437  return &RNA_ParticleSettings;
438  case ID_PAL:
439  return &RNA_Palette;
440  case ID_PC:
441  return &RNA_PaintCurve;
442  case ID_PT:
443 # ifdef WITH_POINT_CLOUD
444  return &RNA_PointCloud;
445 # else
446  return &RNA_ID;
447 # endif
448  case ID_LP:
449  return &RNA_LightProbe;
450  case ID_SCE:
451  return &RNA_Scene;
452  case ID_SCR:
453  return &RNA_Screen;
454  case ID_SIM:
455 # ifdef WITH_GEOMETRY_NODES
456  return &RNA_Simulation;
457 # else
458  return &RNA_ID;
459 # endif
460  case ID_SO:
461  return &RNA_Sound;
462  case ID_SPK:
463  return &RNA_Speaker;
464  case ID_TE:
465  return &RNA_Texture;
466  case ID_TXT:
467  return &RNA_Text;
468  case ID_VF:
469  return &RNA_VectorFont;
470  case ID_VO:
471  return &RNA_Volume;
472  case ID_WM:
473  return &RNA_WindowManager;
474  case ID_WO:
475  return &RNA_World;
476  case ID_WS:
477  return &RNA_WorkSpace;
478 
479  /* deprecated */
480  case ID_IP:
481  break;
482  }
483 
484  return &RNA_ID;
485 }
486 
488 {
489  ID *id = (ID *)ptr->data;
490 
491  return ID_code_to_RNA_type(GS(id->name));
492 }
493 
494 IDProperty *rna_ID_idprops(PointerRNA *ptr, bool create)
495 {
496  return IDP_GetProperties(ptr->data, create);
497 }
498 
499 void rna_ID_fake_user_set(PointerRNA *ptr, bool value)
500 {
501  ID *id = (ID *)ptr->data;
502 
503  if (value) {
504  id_fake_user_set(id);
505  }
506  else {
507  id_fake_user_clear(id);
508  }
509 }
510 
512 {
513  return ptr->data;
514 }
515 
517 {
519 }
520 
522  ReportList *reports,
523  void *data,
524  const char *identifier,
525  StructValidateFunc validate,
528 {
529  PointerRNA dummyptr;
530 
531  /* create dummy pointer */
533 
534  /* validate the python class */
535  if (validate(&dummyptr, data, NULL) != 0) {
536  return NULL;
537  }
538 
539  /* note: it looks like there is no length limit on the srna id since its
540  * just a char pointer, but take care here, also be careful that python
541  * owns the string pointer which it could potentially free while blender
542  * is running. */
543  if (BLI_strnlen(identifier, MAX_IDPROP_NAME) == MAX_IDPROP_NAME) {
544  BKE_reportf(reports,
545  RPT_ERROR,
546  "Registering id property class: '%s' is too long, maximum length is %d",
547  identifier,
549  return NULL;
550  }
551 
552  return RNA_def_struct_ptr(&BLENDER_RNA, identifier, &RNA_PropertyGroup); /* XXX */
553 }
554 
556 {
557  return ptr->type;
558 }
559 
560 static ID *rna_ID_evaluated_get(ID *id, struct Depsgraph *depsgraph)
561 {
562  return DEG_get_evaluated_id(depsgraph, id);
563 }
564 
565 static ID *rna_ID_copy(ID *id, Main *bmain)
566 {
567  ID *newid = BKE_id_copy(bmain, id);
568 
569  if (newid != NULL) {
570  id_us_min(newid);
571  }
572 
574 
575  return newid;
576 }
577 
578 static ID *rna_ID_override_create(ID *id, Main *bmain, bool remap_local_usages)
579 {
580  if (!ID_IS_OVERRIDABLE_LIBRARY(id)) {
581  return NULL;
582  }
583 
584  if (remap_local_usages) {
585  BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, true);
586  }
587 
588  ID *local_id = BKE_lib_override_library_create_from_id(bmain, id, remap_local_usages);
589 
590  if (remap_local_usages) {
591  BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
592  }
593  return local_id;
594 }
595 
596 static void rna_ID_override_template_create(ID *id, ReportList *reports)
597 {
598  if (!U.experimental.use_override_templates) {
599  BKE_report(reports, RPT_ERROR, "Override template experimental feature is disabled");
600  return;
601  }
602  if (ID_IS_LINKED(id)) {
603  BKE_report(reports, RPT_ERROR, "Unable to create override template for linked data-blocks");
604  return;
605  }
606  if (ID_IS_OVERRIDE_LIBRARY(id)) {
607  BKE_report(
608  reports, RPT_ERROR, "Unable to create override template for overridden data-blocks");
609  return;
610  }
612 }
613 
614 static IDOverrideLibraryProperty *rna_ID_override_library_properties_add(
615  IDOverrideLibrary *override_library, ReportList *reports, const char rna_path[])
616 {
617  bool created;
619  override_library, rna_path, &created);
620 
621  if (!created) {
622  BKE_report(reports, RPT_DEBUG, "No new override property created, property already exists");
623  }
624 
625  return result;
626 }
627 
628 static IDOverrideLibraryPropertyOperation *rna_ID_override_library_property_operations_add(
629  IDOverrideLibraryProperty *override_property,
630  ReportList *reports,
631  int operation,
632  const char *subitem_refname,
633  const char *subitem_locname,
634  int subitem_refindex,
635  int subitem_locindex)
636 {
637  bool created;
638  bool strict;
640  override_property,
641  operation,
642  subitem_refname,
643  subitem_locname,
644  subitem_refindex,
645  subitem_locindex,
646  false,
647  &strict,
648  &created);
649  if (!created) {
650  BKE_report(reports, RPT_DEBUG, "No new override operation created, operation already exists");
651  }
652  return result;
653 }
654 
655 static void rna_ID_update_tag(ID *id, Main *bmain, ReportList *reports, int flag)
656 {
657  /* XXX, new function for this! */
658 # if 0
659  if (ob->type == OB_FONT) {
660  Curve *cu = ob->data;
661  freedisplist(&cu->disp);
662  BKE_vfont_to_curve(bmain, sce, ob, FO_EDIT, NULL);
663  }
664 # endif
665 
666  if (flag == 0) {
667  /* pass */
668  }
669  else {
670  int allow_flag = 0;
671 
672  /* ensure flag us correct for the type */
673  switch (GS(id->name)) {
674  case ID_OB:
675  /* TODO(sergey): This is kind of difficult to predict since different
676  * object types supports different flags. Maybe does not worth checking
677  * for this at all. Or maybe let dependency graph to return whether
678  * the tag was valid or not. */
679  allow_flag = ID_RECALC_ALL;
680  break;
681  /* Could add particle updates later */
682 # if 0
683  case ID_PA:
684  allow_flag = OB_RECALC_ALL | PSYS_RECALC;
685  break;
686 # endif
687  case ID_AC:
688  allow_flag = ID_RECALC_ANIMATION;
689  break;
690  default:
691  if (id_can_have_animdata(id)) {
692  allow_flag = ID_RECALC_ANIMATION;
693  }
694  }
695 
696  if (flag & ~allow_flag) {
698  BKE_reportf(reports,
699  RPT_ERROR,
700  "%s is not compatible with %s 'refresh' options",
701  RNA_struct_identifier(srna),
702  allow_flag ? "the specified" : "any");
703  return;
704  }
705  }
706 
707  DEG_id_tag_update_ex(bmain, id, flag);
708 }
709 
710 static void rna_ID_user_clear(ID *id)
711 {
712  id_fake_user_clear(id);
713  id->us = 0; /* don't save */
714 }
715 
716 static void rna_ID_user_remap(ID *id, Main *bmain, ID *new_id)
717 {
718  if ((GS(id->name) == GS(new_id->name)) && (id != new_id)) {
719  /* For now, do not allow remapping data in linked data from here... */
722  }
723 }
724 
725 static struct ID *rna_ID_make_local(struct ID *self, Main *bmain, bool clear_proxy)
726 {
728  bmain, self, false, clear_proxy ? 0 : LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING);
729 
730  ID *ret_id = self->newid ? self->newid : self;
731  BKE_id_clear_newpoin(self);
732  return ret_id;
733 }
734 
735 static AnimData *rna_ID_animation_data_create(ID *id, Main *bmain)
736 {
737  AnimData *adt = BKE_animdata_add_id(id);
739  return adt;
740 }
741 
742 static void rna_ID_animation_data_free(ID *id, Main *bmain)
743 {
744  BKE_animdata_free(id, true);
746 }
747 
748 # ifdef WITH_PYTHON
750 {
751  ID *id = (ID *)ptr->data;
752  return &id->py_instance;
753 }
754 # endif
755 
756 static void rna_IDPArray_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
757 {
758  IDProperty *prop = (IDProperty *)ptr->data;
759  rna_iterator_array_begin(iter, IDP_IDPArray(prop), sizeof(IDProperty), prop->len, 0, NULL);
760 }
761 
762 static int rna_IDPArray_length(PointerRNA *ptr)
763 {
764  IDProperty *prop = (IDProperty *)ptr->data;
765  return prop->len;
766 }
767 
768 int rna_IDMaterials_assign_int(PointerRNA *ptr, int key, const PointerRNA *assign_ptr)
769 {
770  ID *id = ptr->owner_id;
771  short *totcol = BKE_id_material_len_p(id);
772  Material *mat_id = (Material *)assign_ptr->owner_id;
773  if (totcol && (key >= 0 && key < *totcol)) {
776  BKE_id_material_assign(G_MAIN, id, mat_id, key + 1);
777  return 1;
778  }
779  else {
780  return 0;
781  }
782 }
783 
784 static void rna_IDMaterials_append_id(ID *id, Main *bmain, Material *ma)
785 {
786  BKE_id_material_append(bmain, id, ma);
787 
790 }
791 
792 static Material *rna_IDMaterials_pop_id(ID *id, Main *bmain, ReportList *reports, int index_i)
793 {
794  Material *ma;
795  short *totcol = BKE_id_material_len_p(id);
796  const short totcol_orig = *totcol;
797  if (index_i < 0) {
798  index_i += (*totcol);
799  }
800 
801  if ((index_i < 0) || (index_i >= (*totcol))) {
802  BKE_report(reports, RPT_ERROR, "Index out of range");
803  return NULL;
804  }
805 
806  ma = BKE_id_material_pop(bmain, id, index_i);
807 
808  if (*totcol == totcol_orig) {
809  BKE_report(reports, RPT_ERROR, "No material to removed");
810  return NULL;
811  }
812 
816 
817  return ma;
818 }
819 
820 static void rna_IDMaterials_clear_id(ID *id, Main *bmain)
821 {
822  BKE_id_material_clear(bmain, id);
823 
827 }
828 
829 static void rna_Library_filepath_set(PointerRNA *ptr, const char *value)
830 {
831  Library *lib = (Library *)ptr->data;
834 }
835 
836 /* ***** ImagePreview ***** */
837 
838 static void rna_ImagePreview_is_custom_set(PointerRNA *ptr, int value, enum eIconSizes size)
839 {
840  ID *id = ptr->owner_id;
841  PreviewImage *prv_img = (PreviewImage *)ptr->data;
842 
843  if (id != NULL) {
844  BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
845  }
846 
847  if ((value && (prv_img->flag[size] & PRV_USER_EDITED)) ||
848  (!value && !(prv_img->flag[size] & PRV_USER_EDITED))) {
849  return;
850  }
851 
852  if (value) {
853  prv_img->flag[size] |= PRV_USER_EDITED;
854  }
855  else {
856  prv_img->flag[size] &= ~PRV_USER_EDITED;
857  }
858 
859  prv_img->flag[size] |= PRV_CHANGED;
860 
862 }
863 
864 static void rna_ImagePreview_size_get(PointerRNA *ptr, int *values, enum eIconSizes size)
865 {
866  ID *id = ptr->owner_id;
867  PreviewImage *prv_img = (PreviewImage *)ptr->data;
868 
869  if (id != NULL) {
870  BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
871  }
872 
873  BKE_previewimg_ensure(prv_img, size);
874 
875  values[0] = prv_img->w[size];
876  values[1] = prv_img->h[size];
877 }
878 
879 static void rna_ImagePreview_size_set(PointerRNA *ptr, const int *values, enum eIconSizes size)
880 {
881  ID *id = ptr->owner_id;
882  PreviewImage *prv_img = (PreviewImage *)ptr->data;
883 
884  if (id != NULL) {
885  BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
886  }
887 
889 
890  if (values[0] && values[1]) {
891  prv_img->rect[size] = MEM_callocN(values[0] * values[1] * sizeof(unsigned int), "prv_rect");
892 
893  prv_img->w[size] = values[0];
894  prv_img->h[size] = values[1];
895  }
896 
897  prv_img->flag[size] |= (PRV_CHANGED | PRV_USER_EDITED);
898 }
899 
900 static int rna_ImagePreview_pixels_get_length(PointerRNA *ptr,
902  enum eIconSizes size)
903 {
904  ID *id = ptr->owner_id;
905  PreviewImage *prv_img = (PreviewImage *)ptr->data;
906 
907  if (id != NULL) {
908  BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
909  }
910 
911  BKE_previewimg_ensure(prv_img, size);
912 
913  length[0] = prv_img->w[size] * prv_img->h[size];
914 
915  return length[0];
916 }
917 
918 static void rna_ImagePreview_pixels_get(PointerRNA *ptr, int *values, enum eIconSizes size)
919 {
920  ID *id = ptr->owner_id;
921  PreviewImage *prv_img = (PreviewImage *)ptr->data;
922 
923  if (id != NULL) {
924  BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
925  }
926 
927  BKE_previewimg_ensure(prv_img, size);
928 
929  memcpy(values, prv_img->rect[size], prv_img->w[size] * prv_img->h[size] * sizeof(unsigned int));
930 }
931 
932 static void rna_ImagePreview_pixels_set(PointerRNA *ptr, const int *values, enum eIconSizes size)
933 {
934  ID *id = ptr->owner_id;
935  PreviewImage *prv_img = (PreviewImage *)ptr->data;
936 
937  if (id != NULL) {
938  BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
939  }
940 
941  memcpy(prv_img->rect[size], values, prv_img->w[size] * prv_img->h[size] * sizeof(unsigned int));
942  prv_img->flag[size] |= PRV_USER_EDITED;
943 }
944 
945 static int rna_ImagePreview_pixels_float_get_length(PointerRNA *ptr,
947  enum eIconSizes size)
948 {
949  ID *id = ptr->owner_id;
950  PreviewImage *prv_img = (PreviewImage *)ptr->data;
951 
952  BLI_assert(sizeof(unsigned int) == 4);
953 
954  if (id != NULL) {
955  BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
956  }
957 
958  BKE_previewimg_ensure(prv_img, size);
959 
960  length[0] = prv_img->w[size] * prv_img->h[size] * 4;
961 
962  return length[0];
963 }
964 
965 static void rna_ImagePreview_pixels_float_get(PointerRNA *ptr, float *values, enum eIconSizes size)
966 {
967  ID *id = ptr->owner_id;
968  PreviewImage *prv_img = (PreviewImage *)ptr->data;
969 
970  unsigned char *data = (unsigned char *)prv_img->rect[size];
971  const size_t len = prv_img->w[size] * prv_img->h[size] * 4;
972  size_t i;
973 
974  BLI_assert(sizeof(unsigned int) == 4);
975 
976  if (id != NULL) {
977  BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
978  }
979 
980  BKE_previewimg_ensure(prv_img, size);
981 
982  for (i = 0; i < len; i++) {
983  values[i] = data[i] * (1.0f / 255.0f);
984  }
985 }
986 
987 static void rna_ImagePreview_pixels_float_set(PointerRNA *ptr,
988  const float *values,
989  enum eIconSizes size)
990 {
991  ID *id = ptr->owner_id;
992  PreviewImage *prv_img = (PreviewImage *)ptr->data;
993 
994  unsigned char *data = (unsigned char *)prv_img->rect[size];
995  const size_t len = prv_img->w[size] * prv_img->h[size] * 4;
996  size_t i;
997 
998  BLI_assert(sizeof(unsigned int) == 4);
999 
1000  if (id != NULL) {
1001  BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
1002  }
1003 
1004  for (i = 0; i < len; i++) {
1005  data[i] = unit_float_to_uchar_clamp(values[i]);
1006  }
1007  prv_img->flag[size] |= PRV_USER_EDITED;
1008 }
1009 
1010 static void rna_ImagePreview_is_image_custom_set(PointerRNA *ptr, bool value)
1011 {
1012  rna_ImagePreview_is_custom_set(ptr, value, ICON_SIZE_PREVIEW);
1013 }
1014 
1015 static void rna_ImagePreview_image_size_get(PointerRNA *ptr, int *values)
1016 {
1017  rna_ImagePreview_size_get(ptr, values, ICON_SIZE_PREVIEW);
1018 }
1019 
1020 static void rna_ImagePreview_image_size_set(PointerRNA *ptr, const int *values)
1021 {
1022  rna_ImagePreview_size_set(ptr, values, ICON_SIZE_PREVIEW);
1023 }
1024 
1025 static int rna_ImagePreview_image_pixels_get_length(PointerRNA *ptr,
1027 {
1028  return rna_ImagePreview_pixels_get_length(ptr, length, ICON_SIZE_PREVIEW);
1029 }
1030 
1031 static void rna_ImagePreview_image_pixels_get(PointerRNA *ptr, int *values)
1032 {
1033  rna_ImagePreview_pixels_get(ptr, values, ICON_SIZE_PREVIEW);
1034 }
1035 
1036 static void rna_ImagePreview_image_pixels_set(PointerRNA *ptr, const int *values)
1037 {
1038  rna_ImagePreview_pixels_set(ptr, values, ICON_SIZE_PREVIEW);
1039 }
1040 
1041 static int rna_ImagePreview_image_pixels_float_get_length(PointerRNA *ptr,
1043 {
1044  return rna_ImagePreview_pixels_float_get_length(ptr, length, ICON_SIZE_PREVIEW);
1045 }
1046 
1047 static void rna_ImagePreview_image_pixels_float_get(PointerRNA *ptr, float *values)
1048 {
1049  rna_ImagePreview_pixels_float_get(ptr, values, ICON_SIZE_PREVIEW);
1050 }
1051 
1052 static void rna_ImagePreview_image_pixels_float_set(PointerRNA *ptr, const float *values)
1053 {
1054  rna_ImagePreview_pixels_float_set(ptr, values, ICON_SIZE_PREVIEW);
1055 }
1056 
1057 static void rna_ImagePreview_is_icon_custom_set(PointerRNA *ptr, bool value)
1058 {
1059  rna_ImagePreview_is_custom_set(ptr, value, ICON_SIZE_ICON);
1060 }
1061 
1062 static void rna_ImagePreview_icon_size_get(PointerRNA *ptr, int *values)
1063 {
1064  rna_ImagePreview_size_get(ptr, values, ICON_SIZE_ICON);
1065 }
1066 
1067 static void rna_ImagePreview_icon_size_set(PointerRNA *ptr, const int *values)
1068 {
1069  rna_ImagePreview_size_set(ptr, values, ICON_SIZE_ICON);
1070 }
1071 
1072 static int rna_ImagePreview_icon_pixels_get_length(PointerRNA *ptr,
1074 {
1075  return rna_ImagePreview_pixels_get_length(ptr, length, ICON_SIZE_ICON);
1076 }
1077 
1078 static void rna_ImagePreview_icon_pixels_get(PointerRNA *ptr, int *values)
1079 {
1080  rna_ImagePreview_pixels_get(ptr, values, ICON_SIZE_ICON);
1081 }
1082 
1083 static void rna_ImagePreview_icon_pixels_set(PointerRNA *ptr, const int *values)
1084 {
1085  rna_ImagePreview_pixels_set(ptr, values, ICON_SIZE_ICON);
1086 }
1087 
1088 static int rna_ImagePreview_icon_pixels_float_get_length(PointerRNA *ptr,
1090 {
1091  return rna_ImagePreview_pixels_float_get_length(ptr, length, ICON_SIZE_ICON);
1092 }
1093 
1094 static void rna_ImagePreview_icon_pixels_float_get(PointerRNA *ptr, float *values)
1095 {
1096  rna_ImagePreview_pixels_float_get(ptr, values, ICON_SIZE_ICON);
1097 }
1098 
1099 static void rna_ImagePreview_icon_pixels_float_set(PointerRNA *ptr, const float *values)
1100 {
1101  rna_ImagePreview_pixels_float_set(ptr, values, ICON_SIZE_ICON);
1102 }
1103 
1104 static int rna_ImagePreview_icon_id_get(PointerRNA *ptr)
1105 {
1106  /* Using a callback here allows us to only generate icon matching
1107  * that preview when icon_id is requested. */
1109 }
1110 static void rna_ImagePreview_icon_reload(PreviewImage *prv)
1111 {
1112  /* will lazy load on next use, but only in case icon is not user-modified! */
1113  if (!(prv->flag[ICON_SIZE_ICON] & PRV_USER_EDITED) &&
1114  !(prv->flag[ICON_SIZE_PREVIEW] & PRV_USER_EDITED)) {
1115  BKE_previewimg_clear(prv);
1116  }
1117 }
1118 
1119 static PointerRNA rna_IDPreview_get(PointerRNA *ptr)
1120 {
1121  ID *id = (ID *)ptr->data;
1122  PreviewImage *prv_img = BKE_previewimg_id_ensure(id);
1123 
1124  return rna_pointer_inherit_refine(ptr, &RNA_ImagePreview, prv_img);
1125 }
1126 
1127 static IDProperty *rna_IDPropertyWrapPtr_idprops(PointerRNA *ptr, bool UNUSED(create))
1128 {
1129  if (ptr == NULL) {
1130  return NULL;
1131  }
1132  return ptr->data;
1133 }
1134 
1135 static void rna_Library_version_get(PointerRNA *ptr, int *value)
1136 {
1137  Library *lib = (Library *)ptr->data;
1138  value[0] = lib->versionfile / 100;
1139  value[1] = lib->versionfile % 100;
1140  value[2] = lib->subversionfile;
1141 }
1142 
1143 #else
1144 
1146 {
1147  StructRNA *srna;
1148  PropertyRNA *prop;
1149 
1150  /* this is struct is used for holding the virtual
1151  * PropertyRNA's for ID properties */
1152  srna = RNA_def_struct(brna, "PropertyGroupItem", NULL);
1153  RNA_def_struct_sdna(srna, "IDProperty");
1155  srna, "ID Property", "Property that stores arbitrary, user defined properties");
1156 
1157  /* IDP_STRING */
1158  prop = RNA_def_property(srna, "string", PROP_STRING, PROP_NONE);
1160 
1161  /* IDP_INT */
1162  prop = RNA_def_property(srna, "int", PROP_INT, PROP_NONE);
1164 
1165  prop = RNA_def_property(srna, "int_array", PROP_INT, PROP_NONE);
1167  RNA_def_property_array(prop, 1);
1168 
1169  /* IDP_FLOAT */
1170  prop = RNA_def_property(srna, "float", PROP_FLOAT, PROP_NONE);
1172 
1173  prop = RNA_def_property(srna, "float_array", PROP_FLOAT, PROP_NONE);
1175  RNA_def_property_array(prop, 1);
1176 
1177  /* IDP_DOUBLE */
1178  prop = RNA_def_property(srna, "double", PROP_FLOAT, PROP_NONE);
1180 
1181  prop = RNA_def_property(srna, "double_array", PROP_FLOAT, PROP_NONE);
1183  RNA_def_property_array(prop, 1);
1184 
1185  /* IDP_GROUP */
1186  prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
1189  RNA_def_property_struct_type(prop, "PropertyGroup");
1190 
1191  prop = RNA_def_property(srna, "collection", PROP_COLLECTION, PROP_NONE);
1193  RNA_def_property_struct_type(prop, "PropertyGroup");
1194 
1195  prop = RNA_def_property(srna, "idp_array", PROP_COLLECTION, PROP_NONE);
1196  RNA_def_property_struct_type(prop, "PropertyGroup");
1198  "rna_IDPArray_begin",
1199  "rna_iterator_array_next",
1200  "rna_iterator_array_end",
1201  "rna_iterator_array_get",
1202  "rna_IDPArray_length",
1203  NULL,
1204  NULL,
1205  NULL);
1207 
1208  /* never tested, maybe its useful to have this? */
1209 # if 0
1210  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1213  RNA_def_property_ui_text(prop, "Name", "Unique name used in the code and scripting");
1214  RNA_def_struct_name_property(srna, prop);
1215 # endif
1216 
1217  /* IDP_ID */
1218  prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
1220  RNA_def_property_struct_type(prop, "ID");
1221 
1222  /* ID property groups > level 0, since level 0 group is merged
1223  * with native RNA properties. the builtin_properties will take
1224  * care of the properties here */
1225  srna = RNA_def_struct(brna, "PropertyGroup", NULL);
1226  RNA_def_struct_sdna(srna, "IDPropertyGroup");
1227  RNA_def_struct_ui_text(srna, "ID Property Group", "Group of ID properties");
1228  RNA_def_struct_idprops_func(srna, "rna_PropertyGroup_idprops");
1230  srna, "rna_PropertyGroup_register", "rna_PropertyGroup_unregister", NULL);
1231  RNA_def_struct_refine_func(srna, "rna_PropertyGroup_refine");
1232 
1233  /* important so python types can have their name used in list views
1234  * however this isn't prefect because it overrides how python would set the name
1235  * when we only really want this so RNA_def_struct_name_property() is set to something useful */
1236  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1238  /*RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1239  RNA_def_property_ui_text(prop, "Name", "Unique name used in the code and scripting");
1240  RNA_def_struct_name_property(srna, prop);
1241 }
1242 
1244 {
1245  StructRNA *srna;
1246  FunctionRNA *func;
1247  PropertyRNA *parm;
1248 
1249  /* for mesh/mball/curve materials */
1250  srna = RNA_def_struct(brna, "IDMaterials", NULL);
1251  RNA_def_struct_sdna(srna, "ID");
1252  RNA_def_struct_ui_text(srna, "ID Materials", "Collection of materials");
1253 
1254  func = RNA_def_function(srna, "append", "rna_IDMaterials_append_id");
1256  RNA_def_function_ui_description(func, "Add a new material to the data-block");
1257  parm = RNA_def_pointer(func, "material", "Material", "", "Material to add");
1259 
1260  func = RNA_def_function(srna, "pop", "rna_IDMaterials_pop_id");
1262  RNA_def_function_ui_description(func, "Remove a material from the data-block");
1263  parm = RNA_def_int(
1264  func, "index", -1, -MAXMAT, MAXMAT, "", "Index of material to remove", 0, MAXMAT);
1265  parm = RNA_def_pointer(func, "material", "Material", "", "Material to remove");
1266  RNA_def_function_return(func, parm);
1267 
1268  func = RNA_def_function(srna, "clear", "rna_IDMaterials_clear_id");
1270  RNA_def_function_ui_description(func, "Remove all materials from the data-block");
1271 }
1272 
1274 {
1275  StructRNA *srna;
1276  FunctionRNA *func;
1277  PropertyRNA *prop;
1278 
1279  srna = RNA_def_struct(brna, "ImagePreview", NULL);
1280  RNA_def_struct_sdna(srna, "PreviewImage");
1281  RNA_def_struct_ui_text(srna, "Image Preview", "Preview image and icon");
1282 
1283  prop = RNA_def_property(srna, "is_image_custom", PROP_BOOLEAN, PROP_NONE);
1284  RNA_def_property_boolean_sdna(prop, NULL, "flag[ICON_SIZE_PREVIEW]", PRV_USER_EDITED);
1285  RNA_def_property_boolean_funcs(prop, NULL, "rna_ImagePreview_is_image_custom_set");
1287  "Custom Image",
1288  "True if this preview image has been modified by py script,"
1289  "and is no more auto-generated by Blender");
1290 
1291  prop = RNA_def_int_vector(
1292  srna, "image_size", 2, NULL, 0, 0, "Image Size", "Width and height in pixels", 0, 0);
1295  prop, "rna_ImagePreview_image_size_get", "rna_ImagePreview_image_size_set", NULL);
1296 
1297  prop = RNA_def_property(srna, "image_pixels", PROP_INT, PROP_NONE);
1300  RNA_def_property_ui_text(prop, "Image Pixels", "Image pixels, as bytes (always 32-bit RGBA)");
1301  RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_image_pixels_get_length");
1303  prop, "rna_ImagePreview_image_pixels_get", "rna_ImagePreview_image_pixels_set", NULL);
1304 
1305  prop = RNA_def_property(srna, "image_pixels_float", PROP_FLOAT, PROP_NONE);
1309  prop, "Float Image Pixels", "Image pixels components, as floats (RGBA concatenated values)");
1310  RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_image_pixels_float_get_length");
1312  "rna_ImagePreview_image_pixels_float_get",
1313  "rna_ImagePreview_image_pixels_float_set",
1314  NULL);
1315 
1316  prop = RNA_def_property(srna, "is_icon_custom", PROP_BOOLEAN, PROP_NONE);
1317  RNA_def_property_boolean_sdna(prop, NULL, "flag[ICON_SIZE_ICON]", PRV_USER_EDITED);
1318  RNA_def_property_boolean_funcs(prop, NULL, "rna_ImagePreview_is_icon_custom_set");
1320  "Custom Icon",
1321  "True if this preview icon has been modified by py script,"
1322  "and is no more auto-generated by Blender");
1323 
1324  prop = RNA_def_int_vector(
1325  srna, "icon_size", 2, NULL, 0, 0, "Icon Size", "Width and height in pixels", 0, 0);
1328  prop, "rna_ImagePreview_icon_size_get", "rna_ImagePreview_icon_size_set", NULL);
1329 
1330  prop = RNA_def_property(srna, "icon_pixels", PROP_INT, PROP_NONE);
1333  RNA_def_property_ui_text(prop, "Icon Pixels", "Icon pixels, as bytes (always 32-bit RGBA)");
1334  RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_icon_pixels_get_length");
1336  prop, "rna_ImagePreview_icon_pixels_get", "rna_ImagePreview_icon_pixels_set", NULL);
1337 
1338  prop = RNA_def_property(srna, "icon_pixels_float", PROP_FLOAT, PROP_NONE);
1342  prop, "Float Icon Pixels", "Icon pixels components, as floats (RGBA concatenated values)");
1343  RNA_def_property_dynamic_array_funcs(prop, "rna_ImagePreview_icon_pixels_float_get_length");
1345  "rna_ImagePreview_icon_pixels_float_get",
1346  "rna_ImagePreview_icon_pixels_float_set",
1347  NULL);
1348 
1349  prop = RNA_def_int(srna,
1350  "icon_id",
1351  0,
1352  INT_MIN,
1353  INT_MAX,
1354  "Icon ID",
1355  "Unique integer identifying this preview as an icon (zero means invalid)",
1356  INT_MIN,
1357  INT_MAX);
1359  RNA_def_property_int_funcs(prop, "rna_ImagePreview_icon_id_get", NULL, NULL);
1360 
1361  func = RNA_def_function(srna, "reload", "rna_ImagePreview_icon_reload");
1362  RNA_def_function_ui_description(func, "Reload the preview from its source path");
1363 }
1364 
1366 {
1367  StructRNA *srna;
1368  PropertyRNA *prop;
1369 
1370  static const EnumPropertyItem override_library_property_flag_items[] = {
1372  "MANDATORY",
1373  0,
1374  "Mandatory",
1375  "For templates, prevents the user from removing predefined operation (NOT USED)"},
1377  "LOCKED",
1378  0,
1379  "Locked",
1380  "Prevents the user from modifying that override operation (NOT USED)"},
1381  {0, NULL, 0, NULL, NULL},
1382  };
1383 
1384  srna = RNA_def_struct(brna, "IDOverrideLibraryPropertyOperation", NULL);
1386  "ID Library Override Property Operation",
1387  "Description of an override operation over an overridden property");
1388 
1389  prop = RNA_def_enum(srna,
1390  "operation",
1393  "Operation",
1394  "What override operation is performed");
1395  RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1396 
1397  prop = RNA_def_enum(
1398  srna, "flag", override_library_property_flag_items, 0, "Flags", "Optional flags (NOT USED)");
1399  RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1400 
1401  prop = RNA_def_string(srna,
1402  "subitem_reference_name",
1403  NULL,
1404  INT_MAX,
1405  "Subitem Reference Name",
1406  "Used to handle insertions into collection");
1407  RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1409  "rna_ID_override_library_property_operation_refname_get",
1410  "rna_ID_override_library_property_operation_refname_length",
1411  NULL);
1412 
1413  prop = RNA_def_string(srna,
1414  "subitem_local_name",
1415  NULL,
1416  INT_MAX,
1417  "Subitem Local Name",
1418  "Used to handle insertions into collection");
1419  RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1421  "rna_ID_override_library_property_operation_locname_get",
1422  "rna_ID_override_library_property_operation_locname_length",
1423  NULL);
1424 
1425  prop = RNA_def_int(srna,
1426  "subitem_reference_index",
1427  -1,
1428  -1,
1429  INT_MAX,
1430  "Subitem Reference Index",
1431  "Used to handle insertions into collection",
1432  -1,
1433  INT_MAX);
1434  RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1435 
1436  prop = RNA_def_int(srna,
1437  "subitem_local_index",
1438  -1,
1439  -1,
1440  INT_MAX,
1441  "Subitem Local Index",
1442  "Used to handle insertions into collection",
1443  -1,
1444  INT_MAX);
1445  RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1446 }
1447 
1449 {
1450  StructRNA *srna;
1451  FunctionRNA *func;
1452  PropertyRNA *parm;
1453 
1454  RNA_def_property_srna(cprop, "IDOverrideLibraryPropertyOperations");
1455  srna = RNA_def_struct(brna, "IDOverrideLibraryPropertyOperations", NULL);
1456  RNA_def_struct_sdna(srna, "IDOverrideLibraryProperty");
1457  RNA_def_struct_ui_text(srna, "Override Operations", "Collection of override operations");
1458 
1459  /* Add Property */
1460  func = RNA_def_function(srna, "add", "rna_ID_override_library_property_operations_add");
1461  RNA_def_function_ui_description(func, "Add a new operation");
1463  parm = RNA_def_enum(func,
1464  "operation",
1467  "Operation",
1468  "What override operation is performed");
1470  parm = RNA_def_string(func,
1471  "subitem_reference_name",
1472  NULL,
1473  INT_MAX,
1474  "Subitem Reference Name",
1475  "Used to handle insertions into collection");
1476  parm = RNA_def_string(func,
1477  "subitem_local_name",
1478  NULL,
1479  INT_MAX,
1480  "Subitem Local Name",
1481  "Used to handle insertions into collection");
1482  parm = RNA_def_int(func,
1483  "subitem_reference_index",
1484  -1,
1485  -1,
1486  INT_MAX,
1487  "Subitem Reference Index",
1488  "Used to handle insertions into collection",
1489  -1,
1490  INT_MAX);
1491  parm = RNA_def_int(func,
1492  "subitem_local_index",
1493  -1,
1494  -1,
1495  INT_MAX,
1496  "Subitem Local Index",
1497  "Used to handle insertions into collection",
1498  -1,
1499  INT_MAX);
1500  parm = RNA_def_pointer(func,
1501  "property",
1502  "IDOverrideLibraryPropertyOperation",
1503  "New Operation",
1504  "Created operation");
1505  RNA_def_function_return(func, parm);
1506 }
1507 
1509 {
1510  StructRNA *srna;
1511  PropertyRNA *prop;
1512 
1513  srna = RNA_def_struct(brna, "IDOverrideLibraryProperty", NULL);
1515  srna, "ID Library Override Property", "Description of an overridden property");
1516 
1517  /* String pointer, we *should* add get/set/etc.
1518  * But NULL rna_path would be a nasty bug anyway. */
1519  prop = RNA_def_string(srna,
1520  "rna_path",
1521  NULL,
1522  INT_MAX,
1523  "RNA Path",
1524  "RNA path leading to that property, from owning ID");
1525  RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */
1526 
1527  prop = RNA_def_collection(srna,
1528  "operations",
1529  "IDOverrideLibraryPropertyOperation",
1530  "Operations",
1531  "List of overriding operations for a property");
1533 
1535 }
1536 
1538 {
1539  StructRNA *srna;
1540  FunctionRNA *func;
1541  PropertyRNA *parm;
1542 
1543  RNA_def_property_srna(cprop, "IDOverrideLibraryProperties");
1544  srna = RNA_def_struct(brna, "IDOverrideLibraryProperties", NULL);
1545  RNA_def_struct_sdna(srna, "IDOverrideLibrary");
1546  RNA_def_struct_ui_text(srna, "Override Properties", "Collection of override properties");
1547 
1548  /* Add Property */
1549  func = RNA_def_function(srna, "add", "rna_ID_override_library_properties_add");
1551  func, "Add a property to the override library when it doesn't exist yet");
1553  parm = RNA_def_pointer(func,
1554  "property",
1555  "IDOverrideLibraryProperty",
1556  "New Property",
1557  "Newly created override property or existing one");
1558  RNA_def_function_return(func, parm);
1559  parm = RNA_def_string(
1560  func, "rna_path", NULL, 256, "RNA Path", "RNA-Path of the property to add");
1562 }
1563 
1565 {
1566  StructRNA *srna;
1567  PropertyRNA *prop;
1568 
1569  srna = RNA_def_struct(brna, "IDOverrideLibrary", NULL);
1571  srna, "ID Library Override", "Struct gathering all data needed by overridden linked IDs");
1572 
1574  srna, "reference", "ID", "Reference ID", "Linked ID used as reference by this override");
1575 
1576  prop = RNA_def_collection(srna,
1577  "properties",
1578  "IDOverrideLibraryProperty",
1579  "Properties",
1580  "List of overridden properties");
1582 
1584 }
1585 
1586 static void rna_def_ID(BlenderRNA *brna)
1587 {
1588  StructRNA *srna;
1589  FunctionRNA *func;
1590  PropertyRNA *prop, *parm;
1591 
1592  static const EnumPropertyItem update_flag_items[] = {
1593  {ID_RECALC_TRANSFORM, "OBJECT", 0, "Object", ""},
1594  {ID_RECALC_GEOMETRY, "DATA", 0, "Data", ""},
1595  {ID_RECALC_ANIMATION, "TIME", 0, "Time", ""},
1596  {0, NULL, 0, NULL, NULL},
1597  };
1598 
1599  srna = RNA_def_struct(brna, "ID", NULL);
1601  srna,
1602  "ID",
1603  "Base type for data-blocks, defining a unique name, linking from other libraries "
1604  "and garbage collection");
1606  RNA_def_struct_refine_func(srna, "rna_ID_refine");
1607  RNA_def_struct_idprops_func(srna, "rna_ID_idprops");
1608 
1609  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1610  RNA_def_property_ui_text(prop, "Name", "Unique data-block ID name");
1611  RNA_def_property_string_funcs(prop, "rna_ID_name_get", "rna_ID_name_length", "rna_ID_name_set");
1613  RNA_def_property_editable_func(prop, "rna_ID_name_editable");
1616  RNA_def_struct_name_property(srna, prop);
1617 
1618  prop = RNA_def_property(srna, "name_full", PROP_STRING, PROP_NONE);
1620  prop, "Full Name", "Unique data-block ID name, including library one is any");
1621  RNA_def_property_string_funcs(prop, "rna_ID_name_full_get", "rna_ID_name_full_length", NULL);
1624 
1625  prop = RNA_def_property(srna, "is_evaluated", PROP_BOOLEAN, PROP_NONE);
1627  prop,
1628  "Is Evaluated",
1629  "Whether this ID is runtime-only, evaluated data-block, or actual data from .blend file");
1630  RNA_def_property_boolean_funcs(prop, "rna_ID_is_evaluated_get", NULL);
1632 
1633  prop = RNA_def_property(srna, "original", PROP_POINTER, PROP_NONE);
1634  RNA_def_property_struct_type(prop, "ID");
1636  prop,
1637  "Original ID",
1638  "Actual data-block from .blend file (Main database) that generated that evaluated one");
1639  RNA_def_property_pointer_funcs(prop, "rna_ID_original_get", NULL, NULL, NULL);
1643 
1644  prop = RNA_def_property(srna, "users", PROP_INT, PROP_UNSIGNED);
1645  RNA_def_property_int_sdna(prop, NULL, "us");
1647  RNA_def_property_ui_text(prop, "Users", "Number of times this data-block is referenced");
1648 
1649  prop = RNA_def_property(srna, "use_fake_user", PROP_BOOLEAN, PROP_NONE);
1651  RNA_def_property_ui_text(prop, "Fake User", "Save this data-block even if it has no users");
1652  RNA_def_property_ui_icon(prop, ICON_FAKE_USER_OFF, true);
1653  RNA_def_property_boolean_funcs(prop, NULL, "rna_ID_fake_user_set");
1654 
1655  prop = RNA_def_property(srna, "is_embedded_data", PROP_BOOLEAN, PROP_NONE);
1659  prop,
1660  "Embedded Data",
1661  "This data-block is not an independent one, but is actually a sub-data of another ID "
1662  "(typical example: root node trees or master collections)");
1663 
1664  prop = RNA_def_property(srna, "tag", PROP_BOOLEAN, PROP_NONE);
1668  "Tag",
1669  "Tools can use this to tag data for their own purposes "
1670  "(initial state is undefined)");
1671 
1672  prop = RNA_def_property(srna, "is_library_indirect", PROP_BOOLEAN, PROP_NONE);
1675  RNA_def_property_ui_text(prop, "Is Indirect", "Is this ID block linked indirectly");
1676 
1677  prop = RNA_def_property(srna, "library", PROP_POINTER, PROP_NONE);
1678  RNA_def_property_pointer_sdna(prop, NULL, "lib");
1681  RNA_def_property_ui_text(prop, "Library", "Library file the data-block is linked from");
1682 
1683  prop = RNA_def_property(srna, "asset_data", PROP_POINTER, PROP_NONE);
1686  RNA_def_property_ui_text(prop, "Asset Data", "Additional data for an asset data-block");
1687 
1688  prop = RNA_def_pointer(
1689  srna, "override_library", "IDOverrideLibrary", "Library Override", "Library override data");
1691 
1692  prop = RNA_def_pointer(
1693  srna,
1694  "preview",
1695  "ImagePreview",
1696  "Preview",
1697  "Preview image and icon of this data-block (None if not supported for this type of data)");
1700  RNA_def_property_pointer_funcs(prop, "rna_IDPreview_get", NULL, NULL, NULL);
1701 
1702  /* functions */
1703  func = RNA_def_function(srna, "evaluated_get", "rna_ID_evaluated_get");
1705  func, "Get corresponding evaluated ID from the given dependency graph");
1706  parm = RNA_def_pointer(
1707  func, "depsgraph", "Depsgraph", "", "Dependency graph to perform lookup in");
1709  parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID");
1710  RNA_def_function_return(func, parm);
1711 
1712  func = RNA_def_function(srna, "copy", "rna_ID_copy");
1714  func, "Create a copy of this data-block (not supported for all data-blocks)");
1716  parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID");
1717  RNA_def_function_return(func, parm);
1718 
1719  func = RNA_def_function(srna, "override_create", "rna_ID_override_create");
1721  "Create an overridden local copy of this linked data-block (not "
1722  "supported for all data-blocks)");
1724  parm = RNA_def_pointer(func, "id", "ID", "", "New overridden local copy of the ID");
1725  RNA_def_function_return(func, parm);
1726  RNA_def_boolean(func,
1727  "remap_local_usages",
1728  false,
1729  "",
1730  "Whether local usages of the linked ID should be remapped to the new "
1731  "library override of it");
1732 
1733  func = RNA_def_function(srna, "override_template_create", "rna_ID_override_template_create");
1734  RNA_def_function_ui_description(func, "Create an override template for this ID");
1736 
1737  func = RNA_def_function(srna, "user_clear", "rna_ID_user_clear");
1739  "Clear the user count of a data-block so its not saved, "
1740  "on reload the data will be removed");
1741 
1742  func = RNA_def_function(srna, "user_remap", "rna_ID_user_remap");
1744  func, "Replace all usage in the .blend file of this ID by new given one");
1746  parm = RNA_def_pointer(func, "new_id", "ID", "", "New ID to use");
1748 
1749  func = RNA_def_function(srna, "make_local", "rna_ID_make_local");
1751  func,
1752  "Make this datablock local, return local one "
1753  "(may be a copy of the original, in case it is also indirectly used)");
1755  parm = RNA_def_boolean(
1756  func,
1757  "clear_proxy",
1758  true,
1759  "",
1760  "Whether to clear proxies (the default behavior, "
1761  "note that if object has to be duplicated to be made local, proxies are always cleared)");
1762  parm = RNA_def_pointer(func, "id", "ID", "", "This ID, or the new ID if it was copied");
1763  RNA_def_function_return(func, parm);
1764 
1765  func = RNA_def_function(srna, "user_of_id", "BKE_library_ID_use_ID");
1767  "Count the number of times that ID uses/references given one");
1768  parm = RNA_def_pointer(func, "id", "ID", "", "ID to count usages");
1770  parm = RNA_def_int(func,
1771  "count",
1772  0,
1773  0,
1774  INT_MAX,
1775  "",
1776  "Number of usages/references of given id by current data-block",
1777  0,
1778  INT_MAX);
1779  RNA_def_function_return(func, parm);
1780 
1781  func = RNA_def_function(srna, "animation_data_create", "rna_ID_animation_data_create");
1784  func, "Create animation data to this ID, note that not all ID types support this");
1785  parm = RNA_def_pointer(func, "anim_data", "AnimData", "", "New animation data or NULL");
1786  RNA_def_function_return(func, parm);
1787 
1788  func = RNA_def_function(srna, "animation_data_clear", "rna_ID_animation_data_free");
1790  RNA_def_function_ui_description(func, "Clear animation on this this ID");
1791 
1792  func = RNA_def_function(srna, "update_tag", "rna_ID_update_tag");
1795  "Tag the ID to update its display data, "
1796  "e.g. when calling :class:`bpy.types.Scene.update`");
1797  RNA_def_enum_flag(func, "refresh", update_flag_items, 0, "", "Type of updates to perform");
1798 
1799 # ifdef WITH_PYTHON
1800  RNA_def_struct_register_funcs(srna, NULL, NULL, "rna_ID_instance");
1801 # endif
1802 }
1803 
1804 static void rna_def_library(BlenderRNA *brna)
1805 {
1806  StructRNA *srna;
1807  FunctionRNA *func;
1808  PropertyRNA *prop;
1809 
1810  srna = RNA_def_struct(brna, "Library", "ID");
1811  RNA_def_struct_ui_text(srna, "Library", "External .blend file from which data is linked");
1812  RNA_def_struct_ui_icon(srna, ICON_LIBRARY_DATA_DIRECT);
1813 
1814  prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
1815  RNA_def_property_string_sdna(prop, NULL, "filepath");
1816  RNA_def_property_ui_text(prop, "File Path", "Path to the library .blend file");
1817  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Library_filepath_set");
1818 
1819  prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
1820  RNA_def_property_struct_type(prop, "Library");
1822  RNA_def_property_ui_text(prop, "Parent", "");
1823 
1824  prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
1825  RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
1826  RNA_def_property_ui_text(prop, "Packed File", "");
1827 
1828  prop = RNA_def_int_vector(srna,
1829  "version",
1830  3,
1831  NULL,
1832  0,
1833  INT_MAX,
1834  "Version",
1835  "Version of Blender the library .blend was saved with",
1836  0,
1837  INT_MAX);
1838  RNA_def_property_int_funcs(prop, "rna_Library_version_get", NULL, NULL);
1841 
1842  func = RNA_def_function(srna, "reload", "WM_lib_reload");
1844  RNA_def_function_ui_description(func, "Reload this library and all its linked data-blocks");
1845 }
1846 
1852 {
1853  StructRNA *srna;
1854 
1855  srna = RNA_def_struct(brna, "IDPropertyWrapPtr", NULL);
1856  RNA_def_struct_idprops_func(srna, "rna_IDPropertyWrapPtr_idprops");
1858 }
1859 
1861 {
1862  StructRNA *srna;
1863 
1864  /* built-in unknown type */
1865  srna = RNA_def_struct(brna, "UnknownType", NULL);
1867  srna, "Unknown Type", "Stub RNA type used for pointers to unknown or internal data");
1868 
1869  /* built-in any type */
1870  srna = RNA_def_struct(brna, "AnyType", NULL);
1871  RNA_def_struct_ui_text(srna, "Any Type", "RNA type used for pointers to any possible data");
1872 
1873  rna_def_ID(brna);
1875  rna_def_image_preview(brna);
1876  rna_def_ID_properties(brna);
1877  rna_def_ID_materials(brna);
1878  rna_def_library(brna);
1880 }
1881 
1882 #endif
bool id_can_have_animdata(const struct ID *id)
void BKE_animdata_free(struct ID *id, const bool do_id_user)
Definition: anim_data.c:230
struct AnimData * BKE_animdata_add_id(struct ID *id)
Definition: anim_data.c:113
bool BKE_vfont_is_builtin(struct VFont *vfont)
Definition: font.c:222
bool BKE_vfont_to_curve(struct Object *ob, int mode)
Definition: font.c:1743
#define G_MAIN
Definition: BKE_global.h:232
struct PreviewImage * BKE_previewimg_id_ensure(struct ID *id)
Definition: icons.cc:400
void BKE_previewimg_ensure(struct PreviewImage *prv, const int size)
Definition: icons.cc:543
void BKE_previewimg_clear(struct PreviewImage *prv)
Definition: icons.cc:315
void BKE_previewimg_clear_single(struct PreviewImage *prv, enum eIconSizes size)
Definition: icons.cc:303
int BKE_icon_preview_ensure(struct ID *id, struct PreviewImage *preview)
Definition: icons.cc:811
#define IDP_IDPArray(prop)
Definition: BKE_idprop.h:182
struct IDProperty * IDP_GetProperties(struct ID *id, const bool create_if_needed) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: idprop.c:769
struct ID * BKE_id_copy(struct Main *bmain, const struct ID *id)
void id_us_min(struct ID *id)
Definition: lib_id.c:297
void BKE_main_id_tag_all(struct Main *mainvar, const int tag, const bool value)
Definition: lib_id.c:923
void id_fake_user_set(struct ID *id)
Definition: lib_id.c:328
bool BKE_lib_id_make_local(struct Main *bmain, struct ID *id, const bool test, const int flags)
Definition: lib_id.c:479
@ LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING
Definition: BKE_lib_id.h:244
bool BKE_id_is_in_global_main(struct ID *id)
Definition: lib_id.c:2287
void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const struct ID *id, char separator_char)
void BKE_id_clear_newpoin(struct ID *id)
Definition: lib_id.c:344
void BLI_libblock_ensure_unique_name(struct Main *bmain, const char *name) ATTR_NONNULL()
Definition: lib_id.c:2165
void id_fake_user_clear(struct ID *id)
Definition: lib_id.c:336
#define MAX_ID_FULL_NAME
Definition: BKE_lib_id.h:293
struct IDOverrideLibraryProperty * BKE_lib_override_library_property_get(struct IDOverrideLibrary *override, const char *rna_path, bool *r_created)
struct ID * BKE_lib_override_library_create_from_id(struct Main *bmain, struct ID *reference_id, const bool do_tagged_remap)
Definition: lib_override.c:254
bool BKE_lib_override_library_template_create(struct ID *id)
Definition: lib_override.c:813
struct IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_get(struct IDOverrideLibraryProperty *override_property, const short operation, const char *subitem_refname, const char *subitem_locname, const int subitem_refindex, const int subitem_locindex, const bool strict, bool *r_strict, bool *r_created)
void void BKE_libblock_remap(struct Main *bmain, void *old_idv, void *new_idv, const short remap_flags) ATTR_NONNULL(1
@ ID_REMAP_SKIP_NEVER_NULL_USAGE
Definition: BKE_lib_remap.h:55
@ ID_REMAP_SKIP_INDIRECT_USAGE
Definition: BKE_lib_remap.h:46
void BKE_library_filepath_set(struct Main *bmain, struct Library *lib, const char *filepath)
Definition: library.c:92
General operations, lookup, etc. for materials.
void BKE_id_material_assign(struct Main *bmain, struct ID *id, struct Material *ma, short act)
Definition: material.c:803
void BKE_id_material_append(struct Main *bmain, struct ID *id, struct Material *ma)
Definition: material.c:560
short * BKE_id_material_len_p(struct ID *id)
Definition: material.c:416
struct Material * BKE_id_material_pop(struct Main *bmain, struct ID *id, int index)
Definition: material.c:584
void BKE_id_material_clear(struct Main *bmain, struct ID *id)
Definition: material.c:622
General operations, lookup, etc. for blender objects.
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#define BLI_assert(a)
Definition: BLI_assert.h:58
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:116
size_t BLI_strnlen(const char *str, const size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:878
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string_utf8.c:258
#define UNUSED(x)
#define UNLIKELY(x)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
void DEG_id_tag_update_ex(struct Main *bmain, struct ID *id, int flag)
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
struct ID * DEG_get_evaluated_id(const struct Depsgraph *depsgraph, struct ID *id)
struct ID * DEG_get_original_id(struct ID *id)
ID and Library types, which are fundamental for sdna.
@ ID_RECALC_TRANSFORM
Definition: DNA_ID.h:599
@ ID_RECALC_ANIMATION
Definition: DNA_ID.h:614
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:611
@ ID_RECALC_ALL
Definition: DNA_ID.h:697
@ LIB_TAG_INDIRECT
Definition: DNA_ID.h:524
@ LIB_TAG_DOIT
Definition: DNA_ID.h:554
#define ID_IS_OVERRIDABLE_LIBRARY(_id)
Definition: DNA_ID.h:430
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:426
#define MAX_ID_NAME
Definition: DNA_ID.h:269
@ LIB_EMBEDDED_DATA
Definition: DNA_ID.h:482
@ LIB_FAKEUSER
Definition: DNA_ID.h:477
#define MAX_IDPROP_NAME
Definition: DNA_ID.h:92
@ IDOVERRIDE_LIBRARY_FLAG_LOCKED
Definition: DNA_ID.h:196
@ IDOVERRIDE_LIBRARY_FLAG_MANDATORY
Definition: DNA_ID.h:194
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition: DNA_ID.h:445
struct IDProperty IDProperty
@ PRV_CHANGED
Definition: DNA_ID.h:377
@ PRV_USER_EDITED
Definition: DNA_ID.h:378
@ IDOVERRIDE_LIBRARY_OP_MULTIPLY
Definition: DNA_ID.h:183
@ IDOVERRIDE_LIBRARY_OP_INSERT_AFTER
Definition: DNA_ID.h:186
@ IDOVERRIDE_LIBRARY_OP_NOOP
Definition: DNA_ID.h:174
@ IDOVERRIDE_LIBRARY_OP_SUBTRACT
Definition: DNA_ID.h:181
@ IDOVERRIDE_LIBRARY_OP_ADD
Definition: DNA_ID.h:179
@ IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE
Definition: DNA_ID.h:187
@ IDOVERRIDE_LIBRARY_OP_REPLACE
Definition: DNA_ID.h:176
eIconSizes
Definition: DNA_ID_enums.h:28
@ ICON_SIZE_PREVIEW
Definition: DNA_ID_enums.h:30
@ ICON_SIZE_ICON
Definition: DNA_ID_enums.h:29
ID_Type
Definition: DNA_ID_enums.h:56
@ ID_WM
Definition: DNA_ID_enums.h:84
@ ID_CA
Definition: DNA_ID_enums.h:68
@ ID_AR
Definition: DNA_ID_enums.h:78
@ ID_MC
Definition: DNA_ID_enums.h:85
@ ID_CF
Definition: DNA_ID_enums.h:90
@ ID_LI
Definition: DNA_ID_enums.h:58
@ ID_TE
Definition: DNA_ID_enums.h:64
@ ID_IM
Definition: DNA_ID_enums.h:65
@ ID_VO
Definition: DNA_ID_enums.h:95
@ ID_WS
Definition: DNA_ID_enums.h:91
@ ID_NT
Definition: DNA_ID_enums.h:80
@ ID_LA
Definition: DNA_ID_enums.h:67
@ ID_KE
Definition: DNA_ID_enums.h:70
@ ID_TXT
Definition: DNA_ID_enums.h:74
@ ID_SO
Definition: DNA_ID_enums.h:76
@ ID_SCE
Definition: DNA_ID_enums.h:57
@ ID_LS
Definition: DNA_ID_enums.h:87
@ ID_MSK
Definition: DNA_ID_enums.h:86
@ ID_GD
Definition: DNA_ID_enums.h:83
@ ID_PAL
Definition: DNA_ID_enums.h:88
@ ID_BR
Definition: DNA_ID_enums.h:81
@ ID_LP
Definition: DNA_ID_enums.h:92
@ ID_HA
Definition: DNA_ID_enums.h:93
@ ID_WO
Definition: DNA_ID_enums.h:71
@ ID_SIM
Definition: DNA_ID_enums.h:96
@ ID_MA
Definition: DNA_ID_enums.h:63
@ ID_AC
Definition: DNA_ID_enums.h:79
@ ID_SCR
Definition: DNA_ID_enums.h:72
@ ID_VF
Definition: DNA_ID_enums.h:73
@ ID_ME
Definition: DNA_ID_enums.h:60
@ ID_IP
Definition: DNA_ID_enums.h:69
@ ID_GR
Definition: DNA_ID_enums.h:77
@ ID_SPK
Definition: DNA_ID_enums.h:75
@ ID_MB
Definition: DNA_ID_enums.h:62
@ ID_LT
Definition: DNA_ID_enums.h:66
@ ID_OB
Definition: DNA_ID_enums.h:59
@ ID_PA
Definition: DNA_ID_enums.h:82
@ ID_PT
Definition: DNA_ID_enums.h:94
@ ID_CU
Definition: DNA_ID_enums.h:61
@ ID_PC
Definition: DNA_ID_enums.h:89
#define MAXMAT
Object is a sort of wrapper for general info.
@ OB_MBALL
@ OB_FONT
#define FO_EDIT
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
StructRNA RNA_Palette
StructRNA RNA_CacheFile
StructRNA RNA_Collection
StructRNA RNA_Material
StructRNA RNA_Key
StructRNA RNA_Mask
StructRNA RNA_Scene
StructRNA RNA_Armature
short RNA_type_to_ID_code(const StructRNA *type)
StructRNA RNA_MetaBall
StructRNA RNA_PaintCurve
StructRNA RNA_Curve
StructRNA RNA_ImagePreview
StructRNA RNA_WindowManager
StructRNA RNA_Simulation
StructRNA RNA_Screen
StructRNA RNA_Mesh
StructRNA RNA_Light
StructRNA RNA_WorkSpace
StructRNA RNA_Hair
StructRNA RNA_LightProbe
StructRNA RNA_GreasePencil
StructRNA RNA_Library
StructRNA RNA_ID
StructRNA RNA_Speaker
StructRNA RNA_Sound
StructRNA RNA_Object
StructRNA RNA_Camera
StructRNA RNA_FreestyleLineStyle
StructRNA RNA_World
StructRNA RNA_NodeTree
StructRNA RNA_Brush
StructRNA RNA_Text
StructRNA RNA_PointCloud
StructRNA RNA_Volume
StructRNA RNA_Action
StructRNA RNA_Texture
StructRNA * ID_code_to_RNA_type(short idcode)
StructRNA RNA_ParticleSettings
StructRNA RNA_VectorFont
StructRNA RNA_Image
StructRNA RNA_Lattice
#define RNA_MAX_ARRAY_DIMENSION
Definition: RNA_define.h:42
@ PARM_REQUIRED
Definition: RNA_types.h:337
void(* StructFreeFunc)(void *data)
Definition: RNA_types.h:652
int(* StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_function)
Definition: RNA_types.h:647
@ FUNC_USE_REPORTS
Definition: RNA_types.h:578
@ FUNC_USE_MAIN
Definition: RNA_types.h:576
@ FUNC_USE_CONTEXT
Definition: RNA_types.h:577
@ STRUCT_ID_REFCOUNT
Definition: RNA_types.h:621
@ STRUCT_ID
Definition: RNA_types.h:620
@ STRUCT_NO_DATABLOCK_IDPROPERTIES
Definition: RNA_types.h:632
int(* StructCallbackFunc)(struct bContext *C, struct PointerRNA *ptr, struct FunctionRNA *func, ParameterList *list)
Definition: RNA_types.h:648
@ PROP_FLOAT
Definition: RNA_types.h:75
@ PROP_BOOLEAN
Definition: RNA_types.h:73
@ PROP_INT
Definition: RNA_types.h:74
@ PROP_STRING
Definition: RNA_types.h:76
@ PROP_POINTER
Definition: RNA_types.h:78
@ PROP_COLLECTION
Definition: RNA_types.h:79
@ PROPOVERRIDE_NO_COMPARISON
Definition: RNA_types.h:305
@ PROPOVERRIDE_IGNORE
Definition: RNA_types.h:317
@ PROP_THICK_WRAP
Definition: RNA_types.h:270
@ PROP_DYNAMIC
Definition: RNA_types.h:275
@ PROP_EDITABLE
Definition: RNA_types.h:175
@ PROP_LIB_EXCEPTION
Definition: RNA_types.h:181
@ PROP_NEVER_NULL
Definition: RNA_types.h:225
@ PROP_PTR_NO_OWNERSHIP
Definition: RNA_types.h:242
@ PROP_HIDDEN
Definition: RNA_types.h:202
@ PROP_IDPROPERTY
Definition: RNA_types.h:273
@ PROP_PIXEL
Definition: RNA_types.h:128
@ PROP_NONE
Definition: RNA_types.h:113
@ PROP_UNSIGNED
Definition: RNA_types.h:129
@ PROP_FILEPATH
Definition: RNA_types.h:116
#define NC_ID
Definition: WM_types.h:296
#define ND_DRAW
Definition: WM_types.h:362
#define NA_ADDED
Definition: WM_types.h:464
#define NA_RENAME
Definition: WM_types.h:466
#define ND_OB_SHADING
Definition: WM_types.h:358
#define NC_OBJECT
Definition: WM_types.h:280
return(oflags[bm->toolflag_index].f &oflag) !=0
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
unsigned int U
Definition: btGjkEpa3.h:78
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
Definition: btQuaternion.h:895
const Depsgraph * depsgraph
DRWShaderLibrary * lib
#define GS(x)
Definition: iris.c:241
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
static void rna_def_ID_override_library(BlenderRNA *brna)
Definition: rna_ID.c:1564
static const EnumPropertyItem rna_enum_override_library_property_operation_items[]
Definition: rna_ID.c:88
static void rna_def_ID_override_library_property_operation(BlenderRNA *brna)
Definition: rna_ID.c:1365
static void rna_def_ID_override_library_property(BlenderRNA *brna)
Definition: rna_ID.c:1508
const EnumPropertyItem rna_enum_id_type_items[]
Definition: rna_ID.c:46
static void rna_def_ID_override_library_properties(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_ID.c:1537
void RNA_def_ID(BlenderRNA *brna)
Definition: rna_ID.c:1860
static void rna_def_ID(BlenderRNA *brna)
Definition: rna_ID.c:1586
static void rna_def_ID_properties(BlenderRNA *brna)
Definition: rna_ID.c:1145
static void rna_def_idproperty_wrap_ptr(BlenderRNA *brna)
Definition: rna_ID.c:1851
static void rna_def_image_preview(BlenderRNA *brna)
Definition: rna_ID.c:1273
static void rna_def_library(BlenderRNA *brna)
Definition: rna_ID.c:1804
static void rna_def_ID_override_library_property_operations(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_ID.c:1448
static void rna_def_ID_materials(BlenderRNA *brna)
Definition: rna_ID.c:1243
const char * RNA_struct_identifier(const StructRNA *type)
Definition: rna_access.c:723
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:146
void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, bool free_ptr, IteratorSkipFunc skip)
Definition: rna_access.c:4875
PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *data)
Definition: rna_access.c:196
const StructRNA * RNA_struct_base_child_of(const StructRNA *type, const StructRNA *parent_type)
Definition: rna_access.c:786
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
Definition: rna_define.c:1167
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2762
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3795
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4159
void RNA_def_struct_flag(StructRNA *srna, int flag)
Definition: rna_define.c:1152
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
Definition: rna_define.c:2257
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
Definition: rna_define.c:3312
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4302
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3153
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1676
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2717
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
Definition: rna_define.c:1684
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4262
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
Definition: rna_define.c:3462
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)
Definition: rna_define.c:3408
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1259
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
Definition: rna_define.c:2971
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance)
Definition: rna_define.c:1191
void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength)
Definition: rna_define.c:2953
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
Definition: rna_define.c:1629
StructRNA * RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom)
Definition: rna_define.c:919
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
Definition: rna_define.c:1067
void RNA_def_property_array(PropertyRNA *prop, int length)
Definition: rna_define.c:1568
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
Definition: rna_define.c:1940
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
Definition: rna_define.c:1792
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4337
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2927
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
Definition: rna_define.c:2877
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1279
PropertyRNA * RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const int *default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3611
void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
Definition: rna_define.c:1122
void RNA_def_function_flag(FunctionRNA *func, int flag)
Definition: rna_define.c:4332
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1517
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
Definition: rna_define.c:3373
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1047
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3055
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
Definition: rna_define.c:1267
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
Definition: rna_define.c:795
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3675
void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
Definition: rna_define.c:1179
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3585
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
Definition: rna_define.c:1563
PropertyRNA * RNA_def_collection(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4194
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3771
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2364
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
Definition: rna_define.c:1525
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1547
void rna_PropertyGroup_unregister(struct Main *bmain, struct StructRNA *type)
void rna_ID_name_set(struct PointerRNA *ptr, const char *value)
int rna_ID_name_length(struct PointerRNA *ptr)
struct StructRNA * rna_PropertyGroup_register(struct Main *bmain, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
int rna_IDMaterials_assign_int(struct PointerRNA *ptr, int key, const struct PointerRNA *assign_ptr)
struct IDProperty * rna_ID_idprops(struct PointerRNA *ptr, bool create)
struct StructRNA * rna_ID_refine(struct PointerRNA *ptr)
BlenderRNA BLENDER_RNA
struct StructRNA * rna_PropertyGroup_refine(struct PointerRNA *ptr)
StructRNA RNA_PropertyGroup
void rna_ID_name_get(struct PointerRNA *ptr, char *value)
void rna_ID_fake_user_set(struct PointerRNA *ptr, bool value)
void ** rna_ID_instance(PointerRNA *ptr)
struct IDProperty * rna_PropertyGroup_idprops(struct PointerRNA *ptr, bool create)
int len
Definition: DNA_ID.h:84
Definition: DNA_ID.h:273
void * py_instance
Definition: DNA_ID.h:340
struct ID * newid
Definition: DNA_ID.h:275
char name[66]
Definition: DNA_ID.h:283
Definition: BKE_main.h:116
struct StructRNA * type
Definition: RNA_types.h:51
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
unsigned int h[2]
Definition: DNA_ID.h:392
short flag[2]
Definition: DNA_ID.h:393
unsigned int * rect[2]
Definition: DNA_ID.h:395
unsigned int w[2]
Definition: DNA_ID.h:391
uint len
void WM_main_add_notifier(unsigned int type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3157