Blender V5.0
DNA_ID.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9
10#pragma once
11
12#include "DNA_ID_enums.h"
13#include "DNA_defs.h"
14#include "DNA_listBase.h"
15
16#include "BLI_assert.h"
18
20#ifdef __cplusplus
21# include <cstring>
22# include <type_traits>
23
24namespace blender::bke::id {
25struct ID_Runtime;
26}
27namespace blender::bke {
29}
30namespace blender::bke::idprop {
32}
33namespace blender::bke::library {
34struct LibraryRuntime;
35}
40#else
45#endif
46
47struct FileData;
48struct GHash;
49struct ID;
50struct Library;
51struct PackedFile;
52struct UniqueName_Map;
53
62
63/* DNA version of #EnumPropertyItem. */
65 /* Unique identifier, used for string lookup. */
67 /* UI name of the item. */
68 char *name;
69 /* Optional description. */
71 /* Unique integer value, should never change. */
72 int value;
73 /* Optional icon. */
74 int icon;
76
77/* IDP_UI_DATA_TYPE_INT */
93
95typedef struct IDPropertyUIDataBool {
97 int8_t *default_array; /* Only for array properties. */
99 char _pad[3];
100
103
105typedef struct IDPropertyUIDataFloat {
107 double *default_array; /* Only for array properties. */
109 char _pad[4];
110
111 float step;
113
114 double min;
115 double max;
116 double soft_min;
117 double soft_max;
120
126
140
152
153typedef struct IDProperty {
156 char type;
163 short flag;
164 char name[/*MAX_IDPROP_NAME*/ 64];
165
166 char _pad0[4];
167
170
175 int len;
182
185
186#define MAX_IDPROP_NAME 64
187#define DEFAULT_ALLOC_FOR_NULL_STRINGS 64
188
189/* add any future new id property types here. */
190
191/* Static ID override structs. */
192
195
196 /* Type of override. */
198 short flag;
199
201 short tag;
202 char _pad0[2];
203
204 /* Sub-item references, if needed (for arrays or collections only).
205 * We need both reference and local values to allow e.g. insertion into RNA collections
206 * (constraints, modifiers...).
207 * In RNA collection case, if names are defined, they are used in priority.
208 * Names are pointers (instead of char[64]) to save some space, NULL or empty string when unset.
209 * Indices are -1 when unset.
210 *
211 * NOTE: For insertion operations in RNA collections, reference may not actually exist in the
212 * linked reference data. It is used to identify the anchor of the insertion operation (i.e. the
213 * item after or before which the new local item should be inserted), in the local override. */
224
225/* IDOverrideLibraryPropertyOperation->operation. */
226enum {
227 /* Basic operations. */
228 LIBOVERRIDE_OP_NOOP = 0, /* Special value, forbids any overriding. */
229
230 LIBOVERRIDE_OP_REPLACE = 1, /* Fully replace local value by reference one. */
231
232 /* Numeric-only operations. */
233 LIBOVERRIDE_OP_ADD = 101, /* Add local value to reference one. */
234 /* Subtract local value from reference one (needed due to unsigned values etc.). */
236 /* Multiply reference value by local one (more useful than diff for scales and the like). */
238
239 /* Collection-only operations. */
240 LIBOVERRIDE_OP_INSERT_AFTER = 201, /* Insert after given reference's subitem. */
241 LIBOVERRIDE_OP_INSERT_BEFORE = 202, /* Insert before given reference's subitem. */
242 /* We can add more if needed (move, delete, ...). */
243};
244
245/* IDOverrideLibraryPropertyOperation->flag. */
246enum {
251
263};
264
290
291/* IDOverrideLibraryProperty->tag and IDOverrideLibraryPropertyOperation->tag. */
292enum {
295
298};
299
300#
301#
306
307/* IDOverrideLibraryRuntime->tag. */
308enum {
311
317
329};
330
331/* Main container for all overriding data info of a data-block. */
351
352/* IDOverrideLibrary->flag */
353enum {
364};
365
366/* watch it: Strip has identical beginning. */
371
372/* 2 characters for ID code and 256 for actual name */
373#define MAX_ID_NAME 258
374
376enum {
381};
382
383typedef struct IDHash {
384 char data[16];
385
386#ifdef __cplusplus
387 uint64_t hash() const
388 {
389 return *reinterpret_cast<const uint64_t *>(this->data);
390 }
391
392 static constexpr IDHash get_null()
393 {
394 return {};
395 }
396 bool is_null() const
397 {
398 return *this == IDHash::get_null();
399 }
400
401 friend bool operator==(const IDHash &a, const IDHash &b)
402 {
403 return memcmp(a.data, b.data, sizeof(a.data)) == 0;
404 }
405
406 friend bool operator!=(const IDHash &a, const IDHash &b)
407 {
408 return !(a == b);
409 }
410
411#endif
413
414typedef struct ID {
415 /* There's a nasty circular dependency here.... 'void *' to the rescue! I
416 * really wonder why this is needed. */
417 void *next, *prev;
418 struct ID *newid;
419
420 struct Library *lib;
421
424
432 char name[/*MAX_ID_NAME*/ 258];
433
438 short flag;
442 int tag;
443 int us;
445 unsigned int recalc;
457
462 unsigned int session_uid;
463
475
481
490
491 void *_pad1;
492
495
501 struct ID *orig_id;
502
519
527
540
544typedef struct Library {
545#ifdef __cplusplus
547 static constexpr ID_Type id_type = ID_LI;
548#endif
549
552 char filepath[/*FILE_MAX*/ 1024];
553
555 uint16_t flag;
556 char _pad[6];
557
564
573
580
581 void *_pad2;
583
595
606typedef struct LibraryWeakReference {
608 char library_filepath[/*FILE_MAX*/ 1024];
609
611 char library_id_name[/*MAX_ID_NAME*/ 258];
612
613 char _pad[2];
615
616/* PreviewImage.flag */
618 PRV_CHANGED = (1 << 0),
620 PRV_USER_EDITED = (1 << 1),
621 /* Rendering was invoked. Cleared on file read. */
622 PRV_RENDERING = (1 << 2),
623};
624
625/* PreviewImage.tag */
626enum {
633};
634
639typedef struct PreviewImage {
641 /* All values of 2 are really NUM_ICON_SIZES */
642 unsigned int w[2];
643 unsigned int h[2];
644 short flag[2];
646 unsigned int *rect[2];
647
650
655#define ID_FAKE_USERS(id) ((((const ID *)id)->flag & ID_FLAG_FAKEUSER) ? 1 : 0)
662#define ID_EXTRA_USERS(id) (((const ID *)id)->tag & ID_TAG_EXTRAUSER ? 1 : 0)
671#define ID_EXTRA_REAL_USERS(id) (((const ID *)id)->tag & ID_TAG_EXTRAUSER_SET ? 1 : 0)
676#define ID_REAL_USERS(id) (((const ID *)id)->us - ID_FAKE_USERS(id))
681#define ID_REFCOUNTING_USERS(id) (ID_REAL_USERS(id) - ID_EXTRA_REAL_USERS(id))
682
683#define ID_CHECK_UNDO(id) (!ELEM(GS((id)->name), ID_SCR, ID_WM, ID_WS, ID_BR))
684
685#define ID_BLEND_PATH(_bmain, _id) \
686 ((_id)->lib ? BKE_main_blendfile_path_from_library(*(_id)->lib) : \
687 BKE_main_blendfile_path((_bmain)))
688#define ID_BLEND_PATH_FROM_GLOBAL(_id) \
689 ((_id)->lib ? BKE_main_blendfile_path_from_library(*(_id)->lib) : \
690 BKE_main_blendfile_path_from_global())
691
692#define ID_MISSING(_id) ((((const ID *)(_id))->tag & ID_TAG_MISSING) != 0)
693
694#define ID_IS_LINKED(_id) (((const ID *)(_id))->lib != NULL)
700#define ID_IS_PACKED(_id) (ID_IS_LINKED(_id) && ((_id)->flag & ID_FLAG_LINKED_AND_PACKED))
701
702#define ID_TYPE_SUPPORTS_ASSET_EDITABLE(id_type) \
703 ELEM(id_type, ID_BR, ID_TE, ID_NT, ID_IM, ID_PC, ID_MA)
704
705#define ID_IS_EDITABLE(_id) \
706 ((((const ID *)(_id))->lib == NULL) || \
707 ((((const ID *)(_id))->lib->runtime->tag & LIBRARY_ASSET_EDITABLE) && \
708 ID_TYPE_SUPPORTS_ASSET_EDITABLE(GS((((const ID *)(_id))->name)))))
709
710/* Note that these are fairly high-level checks, should be used at user interaction level, not in
711 * BKE_library_override typically (especially due to the check on ID_TAG_EXTERN). */
712#define ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(_id) \
713 (ID_IS_LINKED(_id) && !ID_MISSING(_id) && \
714 (BKE_idtype_get_info_from_id((const ID *)(_id))->flags & IDTYPE_FLAGS_NO_LIBLINKING) == 0 && \
715 !ELEM(GS(((ID *)(_id))->name), ID_SCE))
716#define ID_IS_OVERRIDABLE_LIBRARY(_id) \
717 (ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY((_id)) && (((const ID *)(_id))->tag & ID_TAG_EXTERN) != 0)
718
719/* NOTE: The three checks below do not take into account whether given ID is linked or not (when
720 * chaining overrides over several libraries). User must ensure the ID is not linked itself
721 * currently. */
722/* TODO: add `_EDITABLE` versions of those macros (that would check if ID is linked or not)? */
723#define ID_IS_OVERRIDE_LIBRARY_REAL(_id) \
724 (((const ID *)(_id))->override_library != NULL && \
725 ((const ID *)(_id))->override_library->reference != NULL)
726
727#define ID_IS_OVERRIDE_LIBRARY_VIRTUAL(_id) \
728 ((((const ID *)(_id))->flag & ID_FLAG_EMBEDDED_DATA_LIB_OVERRIDE) != 0)
729
730#define ID_IS_OVERRIDE_LIBRARY(_id) \
731 (ID_IS_OVERRIDE_LIBRARY_REAL(_id) || ID_IS_OVERRIDE_LIBRARY_VIRTUAL(_id))
732
733#define ID_IS_OVERRIDE_LIBRARY_HIERARCHY_ROOT(_id) \
734 (!ID_IS_OVERRIDE_LIBRARY_REAL(_id) || \
735 ((ID *)(_id))->override_library->hierarchy_root == ((ID *)(_id)))
736
737#define ID_IS_ASSET(_id) (((const ID *)(_id))->asset_data != NULL)
738
739/* Check whether datablock type is covered by copy-on-evaluation. */
740#define ID_TYPE_USE_COPY_ON_EVAL(_id_type) \
741 (!ELEM(_id_type, ID_LI, ID_SCR, ID_VF, ID_BR, ID_WM, ID_PAL, ID_PC, ID_WS, ID_IM))
742
743/* Check whether data-block type requires copy-on-evaluation from #ID_RECALC_PARAMETERS.
744 * Keep in sync with #BKE_id_eval_properties_copy. */
745#define ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW(id_type) ELEM(id_type, ID_ME)
746
747/* This used to be ELEM(id_type, ID_IP), currently there is no deprecated ID
748 * type. ID_IP was removed in Blender 5.0. */
749#define ID_TYPE_IS_DEPRECATED(id_type) false
750
751#ifdef GS
752# undef GS
753#endif
754#define GS(a) (CHECK_TYPE_ANY(a, char *, const char *), (ID_Type)(*((const short *)(a))))
755
756#define ID_NEW_SET(_id, _idn) \
757 (((ID *)(_id))->newid = (ID *)(_idn), \
758 ((ID *)(_id))->newid->tag |= ID_TAG_NEW, \
759 (void *)((ID *)(_id))->newid)
760#define ID_NEW_REMAP(a) \
761 if ((a) && (a)->id.newid) { \
762 *(void **)&(a) = (a)->id.newid; \
763 } \
764 ((void)0)
765
767enum {
805};
806
824enum {
830
849
860
868
885
907
911
919 ID_TAG_NEW = 1 << 12,
927
955
956 /* ------------------------------------------------------------------------------------------- */
962
978 ID_TAG_NO_MAIN = 1 << 21,
1008
1012
1026
1027 /* ------------------------------------------------------------------------------------------- */
1028
1036 ID_TAG_DOIT = 1u << 31,
1037};
1038
1046#define ID_TAG_KEEP_ON_UNDO (ID_TAG_EXTRAUSER | ID_TAG_MISSING | ID_TAG_RUNTIME)
1047
1048/* Tag given ID for an update in all the dependency graphs. */
1049typedef enum IDRecalcFlag {
1050 /***************************************************************************
1051 * Individual update tags, this is what ID gets tagged for update with. */
1052
1053 /* ** Object transformation changed. ** */
1055
1056 /* ** Geometry changed. **
1057 *
1058 * When object of armature type gets tagged with this flag, its pose is
1059 * re-evaluated.
1060 *
1061 * When object of other type is tagged with this flag it makes the modifier
1062 * stack to be re-evaluated.
1063 *
1064 * When object data type (mesh, curve, ...) gets tagged with this flag it
1065 * makes all objects which shares this data-block to be updated.
1066 *
1067 * Note that the evaluation depends on the object-mode.
1068 * So edit-mesh data for example only reevaluate with the updated edit-mesh.
1069 * When geometry in the original ID has been modified #ID_RECALC_GEOMETRY_ALL_MODES
1070 * must be used instead.
1071 *
1072 * When a collection gets tagged with this flag, all objects depending on the geometry and
1073 * transforms on any of the objects in the collection are updated. */
1075
1076 /* ** Animation or time changed and animation is to be re-evaluated. ** */
1078
1079 /* ** Particle system changed. ** */
1080 /* Only do path-cache etc. */
1082 /* Reset everything including point-cache. */
1084 /* Only child settings changed. */
1086 /* Physics type changed. */
1088
1089 /* ** Material and shading ** */
1090
1091 /* For materials and node trees this means that topology of the shader tree
1092 * changed, and the shader is to be recompiled.
1093 * For objects it means that the draw batch cache is to be redone. */
1095 /* TODO(sergey): Consider adding an explicit ID_RECALC_SHADING_PARAMETERS
1096 * which can be used for cases when only socket value changed, to speed up
1097 * redraw update in that case. */
1098
1099 /* Selection of the ID itself or its components (for example, vertices) did
1100 * change, and all the drawing data is to be updated. */
1102 /* Flags on the base did change, and is to be copied onto all the copies of
1103 * corresponding objects. */
1106 /* Only inform editors about the change. Is used to force update of editors
1107 * when data-block which is not a part of dependency graph did change.
1108 *
1109 * For example, brush texture did change and the preview is to be
1110 * re-rendered. */
1112
1113 /* ** Update evaluated copy component. **
1114 *
1115 * This is most generic tag which should only be used when nothing else matches.
1116 * It is not to explicitly mixed in with other recalculation flags.
1117 */
1119
1120 /* Sequences in the sequencer did change.
1121 * Use this tag with a scene ID which owns the sequences. */
1123
1124 /* Runs on frame-change (used for seeking audio too). */
1126
1131
1132 ID_RECALC_AUDIO = (1 << 20),
1133
1134 /* NOTE: This triggers copy-on-eval for types that require it.
1135 * Exceptions to this can be added using #ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW,
1136 * this has the advantage that large arrays stored in the idea data don't
1137 * have to be copied on every update. */
1139
1140 /* Input has changed and data-block is to be reload from disk.
1141 * Applies to movie clips to inform that copy-on-written version is to be refreshed for the new
1142 * input file or for color space changes. */
1143 ID_RECALC_SOURCE = (1 << 23),
1144
1145 /* Virtual recalc tag/marker required for undo in some cases, where actual data does not change
1146 * and hence do not require an update, but conceptually we are dealing with something new.
1147 *
1148 * Current known case: linked IDs made local without requiring any copy. While their users do not
1149 * require any update, they have actually been 'virtually' remapped from the linked ID to the
1150 * local one.
1151 */
1153
1154 /* The node tree has changed in a way that affects its output nodes. */
1156
1157 /* Hierarchy of collection and object within collection changed. */
1159
1160 /* Provisioned flags.
1161 *
1162 * Not for actual use. The idea of them is to have all bits of the `IDRecalcFlag` defined to a
1163 * known value, silencing sanitizer warnings when checking bits of the ID_RECALC_ALL. */
1169
1170 /***************************************************************************
1171 * Pseudonyms, to have more semantic meaning in the actual code without
1172 * using too much low-level and implementation specific tags. */
1173
1174 /* Update animation data-block itself, without doing full re-evaluation of
1175 * all dependent objects. */
1177
1178 /* Ensure geometry of object and edit modes are both up-to-date in the evaluated data-block.
1179 * Example usage is when mesh validation modifies the non-edit-mode data,
1180 * which we want to be copied over to the evaluated data-block. */
1182
1183 /***************************************************************************
1184 * Aggregate flags, use only for checks on runtime.
1185 * Do NOT use those for tagging. */
1186
1187 /* Identifies that SOMETHING has been changed in this ID. */
1188 ID_RECALC_ALL = (0xffffffff),
1189
1190 /* Identifies that something in particle system did change. */
1193
1195
1196/* To filter ID types (filter_id). 64 bit to fit all types. */
1197#define FILTER_ID_AC (1ULL << 0)
1198#define FILTER_ID_AR (1ULL << 1)
1199#define FILTER_ID_BR (1ULL << 2)
1200#define FILTER_ID_CA (1ULL << 3)
1201#define FILTER_ID_CU_LEGACY (1ULL << 4)
1202#define FILTER_ID_GD_LEGACY (1ULL << 5)
1203#define FILTER_ID_GR (1ULL << 6)
1204#define FILTER_ID_IM (1ULL << 7)
1205#define FILTER_ID_LA (1ULL << 8)
1206#define FILTER_ID_LS (1ULL << 9)
1207#define FILTER_ID_LT (1ULL << 10)
1208#define FILTER_ID_MA (1ULL << 11)
1209#define FILTER_ID_MB (1ULL << 12)
1210#define FILTER_ID_MC (1ULL << 13)
1211#define FILTER_ID_ME (1ULL << 14)
1212#define FILTER_ID_MSK (1ULL << 15)
1213#define FILTER_ID_NT (1ULL << 16)
1214#define FILTER_ID_OB (1ULL << 17)
1215#define FILTER_ID_PAL (1ULL << 18)
1216#define FILTER_ID_PC (1ULL << 19)
1217#define FILTER_ID_SCE (1ULL << 20)
1218#define FILTER_ID_SPK (1ULL << 21)
1219#define FILTER_ID_SO (1ULL << 22)
1220#define FILTER_ID_TE (1ULL << 23)
1221#define FILTER_ID_TXT (1ULL << 24)
1222#define FILTER_ID_VF (1ULL << 25)
1223#define FILTER_ID_WO (1ULL << 26)
1224#define FILTER_ID_PA (1ULL << 27)
1225#define FILTER_ID_CF (1ULL << 28)
1226#define FILTER_ID_WS (1ULL << 29)
1227#define FILTER_ID_LP (1ULL << 31)
1228#define FILTER_ID_CV (1ULL << 32)
1229#define FILTER_ID_PT (1ULL << 33)
1230#define FILTER_ID_VO (1ULL << 34)
1231#define FILTER_ID_SIM (1ULL << 35)
1232#define FILTER_ID_KE (1ULL << 36)
1233#define FILTER_ID_SCR (1ULL << 37)
1234#define FILTER_ID_WM (1ULL << 38)
1235#define FILTER_ID_LI (1ULL << 39)
1236#define FILTER_ID_GP (1ULL << 40)
1237#define FILTER_ID_IP (1ULL << 41)
1238
1239#define FILTER_ID_ALL \
1240 (FILTER_ID_AC | FILTER_ID_AR | FILTER_ID_BR | FILTER_ID_CA | FILTER_ID_CU_LEGACY | \
1241 FILTER_ID_GD_LEGACY | FILTER_ID_GR | FILTER_ID_IM | FILTER_ID_LA | FILTER_ID_LS | \
1242 FILTER_ID_LT | FILTER_ID_MA | FILTER_ID_MB | FILTER_ID_MC | FILTER_ID_ME | FILTER_ID_MSK | \
1243 FILTER_ID_NT | FILTER_ID_OB | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_SCE | \
1244 FILTER_ID_SPK | FILTER_ID_SO | FILTER_ID_TE | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_WO | \
1245 FILTER_ID_CF | FILTER_ID_WS | FILTER_ID_LP | FILTER_ID_CV | FILTER_ID_PT | FILTER_ID_VO | \
1246 FILTER_ID_SIM | FILTER_ID_KE | FILTER_ID_SCR | FILTER_ID_WM | FILTER_ID_LI | FILTER_ID_GP | \
1247 FILTER_ID_IP)
1248
1279typedef enum eID_Index {
1280 /* Special case: Library, should never ever depend on any other type. */
1282
1283 /* Animation types, might be used by almost all other types. */
1285
1286 /* Grease Pencil, special case, should be with the other obdata, but it can also be used by many
1287 * other ID types, including node trees e.g.
1288 * So there is no proper place for those, for now keep close to the lower end of the processing
1289 * hierarchy, but we may want to re-evaluate that at some point. */
1291
1292 /* Node trees, abstraction for procedural data, potentially used by many other ID types.
1293 *
1294 * NOTE: While node trees can also use many other ID types, they should not /own/ any of those,
1295 * while they are being owned by many other ID types. This is why they are placed here. */
1297
1298 /* File-wrapper types, those usually 'embed' external files in Blender, with no dependencies to
1299 * other ID types. */
1303
1304 /* Image/movie types, can be used by shading ID types, but also directly by Objects, Scenes, etc.
1305 */
1309
1310 /* Shading types. */
1315
1316 /* Simulation-related types. */
1319
1320 /* Shape Keys snow-flake, can be used by several obdata types. */
1322
1323 /* Object data types. */
1337
1338 /* Collection and object types. */
1341
1342 /* Preset-like, not-really-data types, can use many other ID types but should never be used by
1343 * any actual data type (besides Scene, due to tool settings). */
1347
1348 /* Scene, after preset-like ID types because of tool settings. */
1350
1351 /* UI-related types, should never be used by any other data type. */
1355
1356 /* Special values, keep last. */
1359
1360#define INDEX_ID_MAX (INDEX_ID_NULL + 1)
1361
1362#ifdef __cplusplus
1363namespace blender::dna {
1364namespace detail {
1365template<typename, typename = void> struct has_ID_member : std::false_type {};
1366template<typename T> struct has_ID_member<T, std::void_t<decltype(&T::id)>> : std::true_type {};
1367template<typename T> constexpr bool has_ID_as_first_member()
1368{
1369 if constexpr (std::is_standard_layout_v<T> && has_ID_member<T>::value) {
1370 return offsetof(T, id) == 0 && std::is_same_v<decltype(T::id), ID>;
1371 }
1372 else {
1373 return false;
1374 }
1375}
1376} // namespace detail
1377
1382template<typename T>
1383constexpr bool is_ID_v = detail::has_ID_as_first_member<T>() || std::is_same_v<T, ID>;
1384
1385} // namespace blender::dna
1386
1387namespace blender {
1388
1389namespace dna::detail {
1390template<typename Dst, typename Src, typename SrcRuntime>
1391constexpr void id_cast_assert([[maybe_unused]] SrcRuntime *src)
1392{
1393 static_assert(blender::dna::is_ID_v<Src>);
1394 static_assert(blender::dna::is_ID_v<Dst>);
1395 if constexpr (std::is_same_v<Src, ID> && !std::is_same_v<Dst, ID>) {
1396 /* Runtime check for when converting from #ID to subtype like #Object. */
1397 BLI_assert(src == nullptr || GS(src->name) == Dst::id_type);
1398 }
1399 else if constexpr (!std::is_same_v<Src, ID> && std::is_same_v<Dst, ID>) {
1400 /* Converting from subtype like #Object to #ID is always allowed. */
1401 }
1402 else {
1403 /* Converting between the same types is always allowed. */
1404 static_assert(std::is_same_v<Src, Dst>);
1405 }
1406}
1407} // namespace dna::detail
1408
1417template<typename Dst, typename Src> inline Dst id_cast(Src &&id)
1418{
1419 using DstDecay = std::decay_t<Dst>;
1420 using SrcDecay = std::decay_t<Src>;
1421 static_assert(std::is_pointer_v<SrcDecay> == std::is_pointer_v<DstDecay>);
1422 if constexpr (std::is_pointer_v<SrcDecay>) {
1423 dna::detail::id_cast_assert<std::decay_t<std::remove_pointer_t<DstDecay>>,
1424 std::decay_t<std::remove_pointer_t<SrcDecay>>>(id);
1425 }
1426 else {
1427 static_assert(std::is_lvalue_reference_v<Src> && std::is_lvalue_reference_v<Dst>);
1428 dna::detail::id_cast_assert<DstDecay, SrcDecay>(&id);
1429 }
1430 /* This also makes sure that we don't cast away constness. */
1431 return reinterpret_cast<Dst>(id);
1432}
1433
1434} // namespace blender
1435#endif
#define BLI_assert(a)
Definition BLI_assert.h:46
BLI_INLINE bool operator!=(const ListBase &a, const ListBase &b)
unsigned int uint
struct LibraryRuntimeHandle LibraryRuntimeHandle
Definition DNA_ID.h:42
@ ID_TAG_UNDO_OLD_ID_REUSED_UNCHANGED
Definition DNA_ID.h:936
@ ID_TAG_NEW
Definition DNA_ID.h:919
@ ID_TAG_UNDO_OLD_ID_REUSED_NOUNDO
Definition DNA_ID.h:947
@ ID_TAG_COPIED_ON_EVAL
Definition DNA_ID.h:997
@ ID_TAG_EXTRAUSER
Definition DNA_ID.h:878
@ ID_TAG_NO_USER_REFCOUNT
Definition DNA_ID.h:1018
@ ID_TAG_TEMP_MAIN
Definition DNA_ID.h:971
@ ID_TAG_LIBOVERRIDE_AUTOREFRESH
Definition DNA_ID.h:897
@ ID_TAG_INDIRECT
Definition DNA_ID.h:848
@ ID_TAG_RUNTIME
Definition DNA_ID.h:859
@ ID_TAG_PRE_EXISTING
Definition DNA_ID.h:926
@ ID_TAG_EXTERN
Definition DNA_ID.h:842
@ ID_TAG_LOCALIZED
Definition DNA_ID.h:987
@ ID_TAG_MISSING
Definition DNA_ID.h:867
@ ID_TAG_LOCAL
Definition DNA_ID.h:836
@ ID_TAG_UNDO_OLD_ID_REREAD_IN_PLACE
Definition DNA_ID.h:954
@ ID_TAG_COPIED_ON_EVAL_FINAL_RESULT
Definition DNA_ID.h:1007
@ ID_TAG_DOIT
Definition DNA_ID.h:1036
@ ID_TAG_NOT_ALLOCATED
Definition DNA_ID.h:1025
@ ID_TAG_LIBOVERRIDE_NEED_RESYNC
Definition DNA_ID.h:906
@ ID_TAG_EXTRAUSER_SET
Definition DNA_ID.h:884
@ ID_TAG_LIBOVERRIDE_REFOK
Definition DNA_ID.h:891
@ ID_TAG_NO_MAIN
Definition DNA_ID.h:978
@ LIBOVERRIDE_TAG_NEEDS_RESTORE
Definition DNA_ID.h:316
@ LIBOVERRIDE_TAG_RESYNC_ISOLATED_FROM_ROOT
Definition DNA_ID.h:322
@ LIBOVERRIDE_TAG_NEEDS_RELOAD
Definition DNA_ID.h:310
@ LIBOVERRIDE_TAG_NEED_RESYNC_ORIGINAL
Definition DNA_ID.h:328
struct IDPropertyGroupChildrenSet IDPropertyGroupChildrenSet
Definition DNA_ID.h:43
struct IDHash IDHash
IDRecalcFlag
Definition DNA_ID.h:1049
@ ID_RECALC_PARAMETERS
Definition DNA_ID.h:1138
@ ID_RECALC_AUDIO_FPS
Definition DNA_ID.h:1127
@ ID_RECALC_PSYS_PHYS
Definition DNA_ID.h:1087
@ ID_RECALC_AUDIO_LISTENER
Definition DNA_ID.h:1130
@ ID_RECALC_TRANSFORM
Definition DNA_ID.h:1054
@ ID_RECALC_PROVISION_29
Definition DNA_ID.h:1166
@ ID_RECALC_SHADING
Definition DNA_ID.h:1094
@ ID_RECALC_PROVISION_30
Definition DNA_ID.h:1167
@ ID_RECALC_FRAME_CHANGE
Definition DNA_ID.h:1125
@ ID_RECALC_AUDIO
Definition DNA_ID.h:1132
@ ID_RECALC_POINT_CACHE
Definition DNA_ID.h:1105
@ ID_RECALC_SELECT
Definition DNA_ID.h:1101
@ ID_RECALC_PSYS_REDO
Definition DNA_ID.h:1081
@ ID_RECALC_PROVISION_31
Definition DNA_ID.h:1168
@ ID_RECALC_PSYS_CHILD
Definition DNA_ID.h:1085
@ ID_RECALC_HIERARCHY
Definition DNA_ID.h:1158
@ ID_RECALC_PROVISION_27
Definition DNA_ID.h:1164
@ ID_RECALC_SOURCE
Definition DNA_ID.h:1143
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ ID_RECALC_EDITORS
Definition DNA_ID.h:1111
@ ID_RECALC_GEOMETRY_ALL_MODES
Definition DNA_ID.h:1181
@ ID_RECALC_PSYS_ALL
Definition DNA_ID.h:1191
@ ID_RECALC_AUDIO_MUTE
Definition DNA_ID.h:1129
@ ID_RECALC_SEQUENCER_STRIPS
Definition DNA_ID.h:1122
@ ID_RECALC_TAG_FOR_UNDO
Definition DNA_ID.h:1152
@ ID_RECALC_NTREE_OUTPUT
Definition DNA_ID.h:1155
@ ID_RECALC_PSYS_RESET
Definition DNA_ID.h:1083
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1077
@ ID_RECALC_PROVISION_28
Definition DNA_ID.h:1165
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ ID_RECALC_ALL
Definition DNA_ID.h:1188
@ ID_RECALC_AUDIO_VOLUME
Definition DNA_ID.h:1128
@ ID_RECALC_ANIMATION_NO_FLUSH
Definition DNA_ID.h:1176
@ ID_RECALC_BASE_FLAGS
Definition DNA_ID.h:1104
@ LIBOVERRIDE_OP_FLAG_MANDATORY
Definition DNA_ID.h:248
@ LIBOVERRIDE_OP_FLAG_LOCKED
Definition DNA_ID.h:250
@ LIBOVERRIDE_OP_FLAG_IDPOINTER_ITEM_USE_ID
Definition DNA_ID.h:262
@ LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE
Definition DNA_ID.h:256
@ PRV_TAG_DEFFERED_DELETE
Definition DNA_ID.h:630
@ PRV_TAG_DEFFERED_RENDERING
Definition DNA_ID.h:628
@ PRV_TAG_DEFFERED_INVALID
Definition DNA_ID.h:632
@ ID_REMAP_IS_LINKED_DIRECT
Definition DNA_ID.h:378
@ ID_REMAP_IS_USER_ONE_SKIPPED
Definition DNA_ID.h:380
eID_Index
Definition DNA_ID.h:1279
@ INDEX_ID_TXT
Definition DNA_ID.h:1301
@ INDEX_ID_WM
Definition DNA_ID.h:1354
@ INDEX_ID_VO
Definition DNA_ID.h:1330
@ INDEX_ID_NULL
Definition DNA_ID.h:1357
@ INDEX_ID_CF
Definition DNA_ID.h:1317
@ INDEX_ID_CV
Definition DNA_ID.h:1328
@ INDEX_ID_PT
Definition DNA_ID.h:1329
@ INDEX_ID_GR
Definition DNA_ID.h:1340
@ INDEX_ID_LA
Definition DNA_ID.h:1332
@ INDEX_ID_LT
Definition DNA_ID.h:1331
@ INDEX_ID_PC
Definition DNA_ID.h:1345
@ INDEX_ID_MA
Definition DNA_ID.h:1312
@ INDEX_ID_IM
Definition DNA_ID.h:1307
@ INDEX_ID_OB
Definition DNA_ID.h:1339
@ INDEX_ID_ME
Definition DNA_ID.h:1325
@ INDEX_ID_SO
Definition DNA_ID.h:1302
@ INDEX_ID_VF
Definition DNA_ID.h:1300
@ INDEX_ID_MC
Definition DNA_ID.h:1308
@ INDEX_ID_MSK
Definition DNA_ID.h:1306
@ INDEX_ID_BR
Definition DNA_ID.h:1346
@ INDEX_ID_WS
Definition DNA_ID.h:1353
@ INDEX_ID_SCR
Definition DNA_ID.h:1352
@ INDEX_ID_SPK
Definition DNA_ID.h:1334
@ INDEX_ID_MB
Definition DNA_ID.h:1327
@ INDEX_ID_CU_LEGACY
Definition DNA_ID.h:1326
@ INDEX_ID_LI
Definition DNA_ID.h:1281
@ INDEX_ID_NT
Definition DNA_ID.h:1296
@ INDEX_ID_WO
Definition DNA_ID.h:1314
@ INDEX_ID_TE
Definition DNA_ID.h:1311
@ INDEX_ID_PAL
Definition DNA_ID.h:1344
@ INDEX_ID_GP
Definition DNA_ID.h:1336
@ INDEX_ID_LS
Definition DNA_ID.h:1313
@ INDEX_ID_SCE
Definition DNA_ID.h:1349
@ INDEX_ID_GD_LEGACY
Definition DNA_ID.h:1290
@ INDEX_ID_LP
Definition DNA_ID.h:1335
@ INDEX_ID_AC
Definition DNA_ID.h:1284
@ INDEX_ID_CA
Definition DNA_ID.h:1333
@ INDEX_ID_AR
Definition DNA_ID.h:1324
@ INDEX_ID_PA
Definition DNA_ID.h:1318
@ INDEX_ID_KE
Definition DNA_ID.h:1321
@ LIBOVERRIDE_PROP_TAG_NEEDS_RETORE
Definition DNA_ID.h:297
@ LIBOVERRIDE_PROP_OP_TAG_UNUSED
Definition DNA_ID.h:294
@ LIBOVERRIDE_OP_NOOP
Definition DNA_ID.h:228
@ LIBOVERRIDE_OP_ADD
Definition DNA_ID.h:233
@ LIBOVERRIDE_OP_SUBTRACT
Definition DNA_ID.h:235
@ LIBOVERRIDE_OP_REPLACE
Definition DNA_ID.h:230
@ LIBOVERRIDE_OP_MULTIPLY
Definition DNA_ID.h:237
@ LIBOVERRIDE_OP_INSERT_BEFORE
Definition DNA_ID.h:241
@ LIBOVERRIDE_OP_INSERT_AFTER
Definition DNA_ID.h:240
@ LIBOVERRIDE_FLAG_NO_HIERARCHY
Definition DNA_ID.h:358
@ LIBOVERRIDE_FLAG_SYSTEM_DEFINED
Definition DNA_ID.h:363
struct ID_RuntimeHandle ID_RuntimeHandle
Definition DNA_ID.h:44
struct PreviewImageRuntimeHandle PreviewImageRuntimeHandle
Definition DNA_ID.h:41
@ ID_FLAG_INDIRECT_WEAK_LINK
Definition DNA_ID.h:780
@ ID_FLAG_EMBEDDED_DATA_LIB_OVERRIDE
Definition DNA_ID.h:785
@ ID_FLAG_CLIPBOARD_MARK
Definition DNA_ID.h:799
@ ID_FLAG_LINKED_AND_PACKED
Definition DNA_ID.h:804
@ ID_FLAG_LIB_OVERRIDE_RESYNC_LEFTOVER
Definition DNA_ID.h:790
@ ID_FLAG_FAKEUSER
Definition DNA_ID.h:769
@ ID_FLAG_EMBEDDED_DATA
Definition DNA_ID.h:774
LibraryFlag
Definition DNA_ID.h:591
@ LIBRARY_FLAG_IS_ARCHIVE
Definition DNA_ID.h:593
ePreviewImage_Flag
Definition DNA_ID.h:617
@ PRV_RENDERING
Definition DNA_ID.h:622
@ PRV_CHANGED
Definition DNA_ID.h:618
@ PRV_USER_EDITED
Definition DNA_ID.h:620
Enumerations for DNA_ID.h.
ID_Type
@ ID_LI
#define DNA_DEFINE_CXX_METHODS(class_name)
Definition DNA_defs.h:66
These structs are the foundation for all linked lists in the library system.
bool operator==(const AssetWeakReference &a, const AssetWeakReference &b)
unsigned long long int uint64_t
#define offsetof(t, d)
#define GS(x)
#define unsigned
#define T
#define hash
Definition noise_c.cc:154
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
char data[16]
Definition DNA_ID.h:384
struct IDOverrideLibraryPropertyOperation * next
Definition DNA_ID.h:194
struct IDOverrideLibraryPropertyOperation * prev
Definition DNA_ID.h:194
struct IDOverrideLibraryProperty * prev
Definition DNA_ID.h:267
unsigned int rna_prop_type
Definition DNA_ID.h:288
struct IDOverrideLibraryProperty * next
Definition DNA_ID.h:267
struct GHash * rna_path_to_override_properties
Definition DNA_ID.h:303
char _pad_1[4]
Definition DNA_ID.h:349
ListBase properties
Definition DNA_ID.h:336
unsigned int flag
Definition DNA_ID.h:348
struct ID * hierarchy_root
Definition DNA_ID.h:344
struct ID * reference
Definition DNA_ID.h:334
IDOverrideLibraryRuntime * runtime
Definition DNA_ID.h:346
IDPropertyGroupChildrenSet * children_map
Definition DNA_ID.h:148
ListBase group
Definition DNA_ID.h:143
void * pointer
Definition DNA_ID.h:142
int8_t * default_array
Definition DNA_ID.h:97
IDPropertyUIData base
Definition DNA_ID.h:96
double * default_array
Definition DNA_ID.h:107
IDPropertyUIData base
Definition DNA_ID.h:106
IDPropertyUIData base
Definition DNA_ID.h:129
IDPropertyUIData base
Definition DNA_ID.h:79
IDPropertyUIDataEnumItem * enum_items
Definition DNA_ID.h:91
int * default_array
Definition DNA_ID.h:80
IDPropertyUIData base
Definition DNA_ID.h:123
char _pad[4]
Definition DNA_ID.h:60
char * description
Definition DNA_ID.h:56
short flag
Definition DNA_ID.h:163
int len
Definition DNA_ID.h:175
struct IDProperty * next
Definition DNA_ID.h:154
IDPropertyUIData * ui_data
Definition DNA_ID.h:183
char name[64]
Definition DNA_ID.h:164
IDPropertyData data
Definition DNA_ID.h:169
struct IDProperty * prev
Definition DNA_ID.h:154
char _pad0[4]
Definition DNA_ID.h:166
char subtype
Definition DNA_ID.h:161
int totallen
Definition DNA_ID.h:181
char type
Definition DNA_ID.h:156
Definition DNA_ID.h:414
unsigned int recalc_after_undo_push
Definition DNA_ID.h:456
unsigned int recalc
Definition DNA_ID.h:445
void * py_instance
Definition DNA_ID.h:518
int tag
Definition DNA_ID.h:442
ID_RuntimeHandle * runtime
Definition DNA_ID.h:538
struct AssetMetaData * asset_data
Definition DNA_ID.h:423
struct Library * lib
Definition DNA_ID.h:420
char name[258]
Definition DNA_ID.h:432
IDProperty * system_properties
Definition DNA_ID.h:489
int us
Definition DNA_ID.h:443
int icon_id
Definition DNA_ID.h:444
struct ID * newid
Definition DNA_ID.h:418
void * prev
Definition DNA_ID.h:417
IDProperty * properties
Definition DNA_ID.h:480
IDOverrideLibrary * override_library
Definition DNA_ID.h:494
struct ID * orig_id
Definition DNA_ID.h:501
short flag
Definition DNA_ID.h:438
void * next
Definition DNA_ID.h:417
void * _pad1
Definition DNA_ID.h:491
IDHash deep_hash
Definition DNA_ID.h:474
unsigned int recalc_up_to_undo_push
Definition DNA_ID.h:455
unsigned int session_uid
Definition DNA_ID.h:462
struct LibraryWeakReference * library_weak_reference
Definition DNA_ID.h:526
char library_filepath[1024]
Definition DNA_ID.h:608
char library_id_name[258]
Definition DNA_ID.h:611
struct PackedFile * packedfile
Definition DNA_ID.h:572
char filepath[1024]
Definition DNA_ID.h:552
ID id
Definition DNA_ID.h:550
uint16_t flag
Definition DNA_ID.h:555
LibraryRuntimeHandle * runtime
Definition DNA_ID.h:579
char _pad[6]
Definition DNA_ID.h:556
struct Library * archive_parent_library
Definition DNA_ID.h:563
void * _pad2
Definition DNA_ID.h:581
PreviewImageRuntimeHandle * runtime
Definition DNA_ID.h:648
unsigned int h[2]
Definition DNA_ID.h:643
short changed_timestamp[2]
Definition DNA_ID.h:645
short flag[2]
Definition DNA_ID.h:644
unsigned int * rect[2]
Definition DNA_ID.h:646
unsigned int w[2]
Definition DNA_ID.h:642