Blender V5.3
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.hh"
18
19#include <cstring>
20#include <type_traits>
21
22namespace blender {
23
24namespace bke::id {
25struct ID_Runtime;
26}
27namespace bke {
29}
30namespace bke::idprop {
32}
33namespace bke::library {
34struct LibraryRuntime;
35}
36
37struct FileData;
38struct GHash;
39struct ID;
40struct Library;
41struct PackedFile;
42struct UniqueName_Map;
43
46 char *description = nullptr;
48 int rna_subtype = 0;
49
50 char _pad[4] = {};
51};
52
53/* DNA version of #EnumPropertyItem. */
55 /* Unique identifier, used for string lookup. */
56 char *identifier = nullptr;
57 /* UI name of the item. */
58 char *name = nullptr;
59 /* Optional description. */
60 char *description = nullptr;
61 /* Unique integer value, should never change. */
62 int value = 0;
63 /* Optional icon. */
64 int icon = 0;
65};
66
67/* IDP_UI_DATA_TYPE_INT */
70 int *default_array = nullptr; /* Only for array properties. */
72
73 int min = 0;
74 int max = 0;
75 int soft_min = 0;
76 int soft_max = 0;
77 int step = 0;
79
82};
83
87 int8_t *default_array = nullptr; /* Only for array properties. */
89 char _pad[3] = {};
90
92};
93
97 double *default_array = nullptr; /* Only for array properties. */
99 char _pad[4] = {};
100
101 float step = 0;
102 int precision = 0;
103
104 double min = 0;
105 double max = 0;
106 double soft_min = 0;
107 double soft_max = 0;
108 double default_value = 0;
109};
110
116
127 short id_type = 0;
128 char _pad[6] = {};
129};
130
132 void *pointer = nullptr;
133 ListBaseT<struct IDProperty> group = {nullptr, nullptr};
140 int val = 0, val2 = 0;
141};
142
144 struct IDProperty *next = nullptr, *prev = nullptr;
150 char subtype = 0;
152 char name[/*MAX_IDPROP_NAME*/ 64] = "";
153
154 char _pad0[4] = {};
155
158
163 int len = 0;
169 int totallen = 0;
170
172};
173
174#define MAX_IDPROP_NAME 64
175#define DEFAULT_ALLOC_FOR_NULL_STRINGS 64
176
177/* add any future new id property types here. */
178
179/* Static ID override structs. */
180
181/* IDOverrideLibraryPropertyOperation->operation. */
182enum eID_OverrideLib_Op : short {
183 /* Basic operations. */
186
189
190 /* Numeric-only operations. */
197
198 /* Collection-only operations. */
203 /* We can add more if needed (move, delete, ...). */
204
209 /* Note: Currently there is no dedicated 'extra data' for these custom operations.
210 * If needs arise, the padding in `IDOverrideLibraryPropertyOperation` could be used for some
211 * custom data... */
213};
214
215/* IDOverrideLibraryPropertyOperation->flag. */
235
236/* IDOverrideLibraryProperty->tag and IDOverrideLibraryPropertyOperation->tag. */
245
247 struct IDOverrideLibraryPropertyOperation *next = nullptr, *prev = nullptr;
248
249 /* Type of override. */
252
255 char _pad0[2] = {};
256
257 /* Sub-item references, if needed (for arrays or collections only).
258 * We need both reference and local values to allow e.g. insertion into RNA collections
259 * (constraints, modifiers...).
260 * In RNA collection case, if names are defined, they are used in priority.
261 * Names are pointers (instead of char[64]) to save some space, NULL or empty string when unset.
262 * Indices are -1 when unset.
263 *
264 * NOTE: For insertion operations in RNA collections, reference may not actually exist in the
265 * linked reference data. It is used to identify the anchor of the insertion operation (i.e. the
266 * item after or before which the new local item should be inserted), in the local override. */
267 char *subitem_reference_name = nullptr;
268 char *subitem_local_name = nullptr;
274 struct ID *subitem_reference_id = nullptr;
275 struct ID *subitem_local_id = nullptr;
276
284 char *label = nullptr;
290 char *tooltip = nullptr;
291
292#ifdef __cplusplus
294#endif
295};
296
297/* IDOverrideLibrary->flag */
311
312
314 struct IDOverrideLibraryProperty *next = nullptr, *prev = nullptr;
315
320 char *rna_path = nullptr;
321
326 ListBaseT<IDOverrideLibraryPropertyOperation> operations = {nullptr, nullptr};
327
332 char _pad[2] = {};
333
335 unsigned int rna_prop_type = 0;
336};
337
339
340/* Main container for all overriding data info of a data-block. */
343 struct ID *reference = nullptr;
344 ListBaseT<IDOverrideLibraryProperty> properties = {nullptr, nullptr};
345
352 struct ID *hierarchy_root = nullptr;
353
355
357 char _pad_1[4] = {};
358};
359
360/* watch it: Strip has identical beginning. */
365
366/* 2 characters for ID code and 256 for actual name */
367#define MAX_ID_NAME 258
368
377
378struct IDHash {
379 char data[16] = "";
380
381#ifdef __cplusplus
382 uint64_t hash() const
383 {
384 return *reinterpret_cast<const uint64_t *>(this->data);
385 }
386
387 static constexpr IDHash get_null()
388 {
389 return {};
390 }
391 bool is_null() const
392 {
393 return *this == IDHash::get_null();
394 }
395
396 friend bool operator==(const IDHash &a, const IDHash &b)
397 {
398 return memcmp(a.data, b.data, sizeof(a.data)) == 0;
399 }
400
401 friend bool operator!=(const IDHash &a, const IDHash &b)
402 {
403 return !(a == b);
404 }
405
406#endif
407};
408
410inline ID_Type GS(const char *name)
411{
412 return ID_Type(*reinterpret_cast<const short *>(name));
413}
414
415struct ID {
416 /* There's a nasty circular dependency here.... 'void *' to the rescue! I
417 * really wonder why this is needed. */
418 void *next = nullptr, *prev = nullptr;
419 struct ID *newid = nullptr;
420
421 struct Library *lib = nullptr;
422
424 struct AssetMetaData *asset_data = nullptr;
425
433 char name[/*MAX_ID_NAME*/ 258] = "";
434
439 short flag = 0;
443 int tag = 0;
444 int us = 0;
445 int icon_id = 0;
446 unsigned int recalc = 0;
456 unsigned int recalc_up_to_undo_push = 0;
457 unsigned int recalc_after_undo_push = 0;
458
463 unsigned int session_uid = 0;
464
476
482
491
492 void *_pad1 = nullptr;
493
496
502 struct ID *orig_id = nullptr;
503
519 void *py_instance = nullptr;
520
530
542
543#ifdef __cplusplus
544 ID_Type id_type() const
545 {
546 return GS(this->name);
547 }
548#endif
549};
550
554struct Library {
555#ifdef __cplusplus
557 static constexpr ID_Type id_type = ID_LI;
558#endif
559
562 char filepath[/*FILE_MAX*/ 1024] = "";
563
568 char _pad[4] = {};
569
576
584 struct PackedFile *packedfile = nullptr;
585
592
593 void *_pad2 = nullptr;
594};
595
608 char library_filepath[/*FILE_MAX*/ 1024] = "";
609
611 char library_id_name[/*MAX_ID_NAME*/ 258] = "";
612
613 char _pad[2] = {};
614};
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 ePreviewImage_Tag : short {
633 /* Rendering was interrupted and needs restart. */
635};
637
638
644 /* All values of 2 are really NUM_ICON_SIZES */
645 unsigned int w[2] = {};
646 unsigned int h[2] = {};
647 short flag[2] = {};
648 short changed_timestamp[2] = {};
649 unsigned int *rect[2] = {};
650
652};
653
658#define ID_FAKE_USERS(id) ((id_cast<const ID *>(id)->flag & ID_FLAG_FAKEUSER) ? 1 : 0)
665#define ID_EXTRA_USERS(id) (id_cast<const ID *>(id)->tag & ID_TAG_EXTRAUSER ? 1 : 0)
674#define ID_EXTRA_REAL_USERS(id) (id_cast<const ID *>(id)->tag & ID_TAG_EXTRAUSER_SET ? 1 : 0)
679#define ID_REAL_USERS(id) (id_cast<const ID *>(id)->us - ID_FAKE_USERS(id))
684#define ID_REFCOUNTING_USERS(id) (ID_REAL_USERS(id) - ID_EXTRA_REAL_USERS(id))
685
686#define ID_CHECK_UNDO(id) (!ELEM(GS((id)->name), ID_SCR, ID_WM, ID_WS, ID_BR))
687
688#define ID_BLEND_PATH(_bmain, _id) \
689 ((_id)->lib ? BKE_main_blendfile_path_from_library(*(_id)->lib) : \
690 BKE_main_blendfile_path((_bmain)))
691#define ID_BLEND_PATH_FROM_GLOBAL(_id) \
692 ((_id)->lib ? BKE_main_blendfile_path_from_library(*(_id)->lib) : \
693 BKE_main_blendfile_path_from_global())
694
695#define ID_MISSING(_id) ((id_cast<const ID *>(_id)->tag & ID_TAG_MISSING) != 0)
696
697#define ID_IS_LINKED(_id) (id_cast<const ID *>(_id)->lib != NULL)
703#define ID_IS_PACKED(_id) (ID_IS_LINKED(_id) && ((_id)->flag & ID_FLAG_LINKED_AND_PACKED))
704
705#define ID_TYPE_SUPPORTS_ASSET_EDITABLE(id_type) \
706 ELEM(id_type, ID_BR, ID_TE, ID_NT, ID_IM, ID_PC, ID_MA)
707
708#define ID_IS_EDITABLE(_id) \
709 ((id_cast<const ID *>(_id)->lib == NULL) || \
710 ((id_cast<const ID *>(_id)->lib->runtime->tag & LIBRARY_ASSET_EDITABLE) && \
711 ID_TYPE_SUPPORTS_ASSET_EDITABLE(id_cast<const ID *>(_id)->id_type())))
712
713/* Note that these are fairly high-level checks, should be used at user interaction level, not in
714 * BKE_library_override typically (especially due to the check on ID_TAG_EXTERN). */
715#define ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(_id) \
716 (ID_IS_LINKED(_id) && !ID_MISSING(_id) && \
717 (id_cast<const ID *>(_id)->flag & ID_FLAG_EMBEDDED_DATA) == 0 && \
718 (BKE_idtype_get_info_from_id(id_cast<const ID *>(_id))->flags & IDTYPE_FLAGS_NO_LIBLINKING) == \
719 0 && \
720 !ELEM((id_cast<const ID *>(_id))->id_type(), ID_SCE))
721#define ID_IS_OVERRIDABLE_LIBRARY(_id) \
722 (ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY((_id)) && \
723 (id_cast<const ID *>(_id)->tag & ID_TAG_EXTERN) != 0)
724
725/* NOTE: The three checks below do not take into account whether given ID is linked or not (when
726 * chaining overrides over several libraries). User must ensure the ID is not linked itself
727 * currently. */
728/* TODO: add `_EDITABLE` versions of those macros (that would check if ID is linked or not)? */
729#define ID_IS_OVERRIDE_LIBRARY_REAL(_id) \
730 (id_cast<const ID *>(_id)->override_library != NULL && \
731 id_cast<const ID *>(_id)->override_library->reference != NULL)
732
733#define ID_IS_OVERRIDE_LIBRARY_VIRTUAL(_id) \
734 ((id_cast<const ID *>(_id)->flag & ID_FLAG_EMBEDDED_DATA_LIB_OVERRIDE) != 0)
735
736#define ID_IS_OVERRIDE_LIBRARY(_id) \
737 (ID_IS_OVERRIDE_LIBRARY_REAL(_id) || ID_IS_OVERRIDE_LIBRARY_VIRTUAL(_id))
738
739#define ID_IS_OVERRIDE_LIBRARY_HIERARCHY_ROOT(_id) \
740 (!ID_IS_OVERRIDE_LIBRARY_REAL(_id) || \
741 (id_cast<ID *>(_id))->override_library->hierarchy_root == (id_cast<ID *>(_id)))
742
743#define ID_IS_ASSET(_id) (id_cast<const ID *>(_id)->asset_data != NULL)
744
745/* Check whether datablock type is covered by copy-on-evaluation. */
746#define ID_TYPE_USE_COPY_ON_EVAL(_id_type) \
747 (!ELEM(_id_type, ID_LI, ID_SCR, ID_VF, ID_BR, ID_WM, ID_PAL, ID_PC, ID_WS, ID_IM))
748
749/* Check whether data-block type requires copy-on-evaluation from #ID_RECALC_PARAMETERS.
750 * Keep in sync with #BKE_id_eval_properties_copy. */
751#define ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW(id_type) ELEM(id_type, ID_ME)
752
753/* This used to be ELEM(id_type, ID_IP), currently there is no deprecated ID
754 * type. ID_IP was removed in Blender 5.0. */
755#define ID_TYPE_IS_DEPRECATED(id_type) false
756
757#define ID_NEW_SET(_id, _idn) \
758 (((id_cast<ID *>)(_id))->newid = (id_cast<ID *>)(_idn), \
759 ((id_cast<ID *>)(_id))->newid->tag |= ID_TAG_NEW, \
760 ((id_cast<ID *>)(_id))->newid)
761#define ID_NEW_REMAP(a) \
762 if ((a) && (a)->id.newid) { \
763 *(void **)&(a) = (a)->id.newid; \
764 } \
765 ((void)0)
766
809
810
827enum eID_Tag : int {
833
852
863
871
888
910
914
922 ID_TAG_NEW = 1 << 12,
930
958
959 /* ------------------------------------------------------------------------------------------- */
965
981 ID_TAG_NO_MAIN = 1 << 21,
1001
1005
1019
1020 /* ------------------------------------------------------------------------------------------- */
1021
1029 ID_TAG_DOIT = int(1u << 31),
1030};
1032
1033
1044#define ID_TAG_KEEP_ON_UNDO \
1045 (ID_TAG_EXTRAUSER | ID_TAG_MISSING | ID_TAG_RUNTIME | ID_TAG_LOCAL | ID_TAG_EXTERN | \
1046 ID_TAG_INDIRECT)
1047
1048/* Tag given ID for an update in all the dependency graphs. */
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 /* Strips in the sequencer changed.
1121 * Use this tag with a scene ID which owns the strips. */
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 /* The scene has changed in a way that affects the compositor. */
1162
1163 /* Provisioned flags.
1164 *
1165 * Not for actual use. The idea of them is to have all bits of the `IDRecalcFlag` defined to a
1166 * known value, silencing sanitizer warnings when checking bits of the ID_RECALC_ALL. */
1171
1172 /***************************************************************************
1173 * Pseudonyms, to have more semantic meaning in the actual code without
1174 * using too much low-level and implementation specific tags. */
1175
1176 /* Update animation data-block itself, without doing full re-evaluation of
1177 * all dependent objects. */
1179
1180 /* Ensure geometry of object and edit modes are both up-to-date in the evaluated data-block.
1181 * Example usage is when mesh validation modifies the non-edit-mode data,
1182 * which we want to be copied over to the evaluated data-block. */
1184
1185 /***************************************************************************
1186 * Aggregate flags, use only for checks on runtime.
1187 * Do NOT use those for tagging. */
1188
1189 /* Identifies that SOMETHING has been changed in this ID. */
1190 ID_RECALC_ALL = (0xffffffff),
1191
1192 /* Identifies that something in particle system did change. */
1195
1196};
1197
1198/* To filter ID types (filter_id). 64 bit to fit all types. */
1199#define FILTER_ID_AC (1ULL << 0)
1200#define FILTER_ID_AR (1ULL << 1)
1201#define FILTER_ID_BR (1ULL << 2)
1202#define FILTER_ID_CA (1ULL << 3)
1203#define FILTER_ID_CU_LEGACY (1ULL << 4)
1204#define FILTER_ID_GD_LEGACY (1ULL << 5)
1205#define FILTER_ID_GR (1ULL << 6)
1206#define FILTER_ID_IM (1ULL << 7)
1207#define FILTER_ID_LA (1ULL << 8)
1208#define FILTER_ID_LS (1ULL << 9)
1209#define FILTER_ID_LT (1ULL << 10)
1210#define FILTER_ID_MA (1ULL << 11)
1211#define FILTER_ID_MB (1ULL << 12)
1212#define FILTER_ID_MC (1ULL << 13)
1213#define FILTER_ID_ME (1ULL << 14)
1214#define FILTER_ID_MSK (1ULL << 15)
1215#define FILTER_ID_NT (1ULL << 16)
1216#define FILTER_ID_OB (1ULL << 17)
1217#define FILTER_ID_PAL (1ULL << 18)
1218#define FILTER_ID_PC (1ULL << 19)
1219#define FILTER_ID_SCE (1ULL << 20)
1220#define FILTER_ID_SPK (1ULL << 21)
1221#define FILTER_ID_SO (1ULL << 22)
1222#define FILTER_ID_TE (1ULL << 23)
1223#define FILTER_ID_TXT (1ULL << 24)
1224#define FILTER_ID_VF (1ULL << 25)
1225#define FILTER_ID_WO (1ULL << 26)
1226#define FILTER_ID_PA (1ULL << 27)
1227#define FILTER_ID_CF (1ULL << 28)
1228#define FILTER_ID_WS (1ULL << 29)
1229#define FILTER_ID_LP (1ULL << 31)
1230#define FILTER_ID_CV (1ULL << 32)
1231#define FILTER_ID_PT (1ULL << 33)
1232#define FILTER_ID_VO (1ULL << 34)
1233#define FILTER_ID_SIM (1ULL << 35)
1234#define FILTER_ID_KE (1ULL << 36)
1235#define FILTER_ID_SCR (1ULL << 37)
1236#define FILTER_ID_WM (1ULL << 38)
1237#define FILTER_ID_LI (1ULL << 39)
1238#define FILTER_ID_GP (1ULL << 40)
1239#define FILTER_ID_IP (1ULL << 41)
1240
1241#define FILTER_ID_ALL \
1242 (FILTER_ID_AC | FILTER_ID_AR | FILTER_ID_BR | FILTER_ID_CA | FILTER_ID_CU_LEGACY | \
1243 FILTER_ID_GD_LEGACY | FILTER_ID_GR | FILTER_ID_IM | FILTER_ID_LA | FILTER_ID_LS | \
1244 FILTER_ID_LT | FILTER_ID_MA | FILTER_ID_MB | FILTER_ID_MC | FILTER_ID_ME | FILTER_ID_MSK | \
1245 FILTER_ID_NT | FILTER_ID_OB | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_SCE | \
1246 FILTER_ID_SPK | FILTER_ID_SO | FILTER_ID_TE | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_WO | \
1247 FILTER_ID_CF | FILTER_ID_WS | FILTER_ID_LP | FILTER_ID_CV | FILTER_ID_PT | FILTER_ID_VO | \
1248 FILTER_ID_SIM | FILTER_ID_KE | FILTER_ID_SCR | FILTER_ID_WM | FILTER_ID_LI | FILTER_ID_GP | \
1249 FILTER_ID_IP)
1250
1282 /* Special case: Library, should never ever depend on any other type. */
1284
1285 /* Animation types, might be used by almost all other types. */
1287
1288 /* Grease Pencil, special case, should be with the other obdata, but it can also be used by many
1289 * other ID types, including node trees e.g.
1290 * So there is no proper place for those, for now keep close to the lower end of the processing
1291 * hierarchy, but we may want to re-evaluate that at some point. */
1293
1294 /* Node trees, abstraction for procedural data, potentially used by many other ID types.
1295 *
1296 * NOTE: While node trees can also use many other ID types, they should not /own/ any of those,
1297 * while they are being owned by many other ID types. This is why they are placed here. */
1299
1300 /* File-wrapper types, those usually 'embed' external files in Blender, with no dependencies to
1301 * other ID types. */
1305
1306 /* Image/movie types, can be used by shading ID types, but also directly by Objects, Scenes, etc.
1307 */
1311
1312 /* Shading types. */
1317
1318 /* Simulation-related types. */
1321
1322 /* Shape Keys snow-flake, can be used by several obdata types. */
1324
1325 /* Object data types. */
1339
1340 /* Collection and object types. */
1343
1344 /* Preset-like, not-really-data types, can use many other ID types but should never be used by
1345 * any actual data type (besides Scene, due to tool settings). */
1349
1350 /* Scene, after preset-like ID types because of tool settings. */
1352
1353 /* UI-related types, should never be used by any other data type. */
1357
1358 /* Special values, keep last. */
1360};
1361
1362#define INDEX_ID_MAX (INDEX_ID_NULL + 1)
1363
1364#ifdef __cplusplus
1365namespace dna {
1366namespace detail {
1367template<typename, typename = void> struct has_ID_member : std::false_type {};
1368template<typename T> struct has_ID_member<T, std::void_t<decltype(&T::id)>> : std::true_type {};
1369template<typename T> constexpr bool has_ID_as_first_member()
1370{
1371 if constexpr (std::is_standard_layout_v<T> && has_ID_member<T>::value) {
1372 return offsetof(T, id) == 0 && std::is_same_v<decltype(T::id), ID>;
1373 }
1374 else {
1375 return false;
1376 }
1377}
1378} // namespace detail
1379
1384template<typename T>
1385constexpr bool is_ID_v = detail::has_ID_as_first_member<T>() || std::is_same_v<T, ID>;
1386
1387} // namespace dna
1388
1389namespace dna::detail {
1390template<typename Dst, typename Src, typename SrcRuntime>
1391constexpr void id_cast_assert([[maybe_unused]] SrcRuntime *src)
1392{
1393 static_assert(dna::is_ID_v<Src>);
1394 static_assert(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#endif
1435
1436} // namespace blender
#define ENUM_OPERATORS(_enum_type)
Enumerations for DNA_ID.h.
#define DNA_DEFINE_CXX_METHODS(class_name)
Definition DNA_defs.h:104
These structs are the foundation for all linked lists in the library system.
#define BLI_assert(a)
#define offsetof(t, d)
#define T
bool operator==(const Error &left, const Error &right)
BMesh Iterators.
unsigned __int64 uint64_t
Definition BKE_text.h:91
ePreviewImage_Tag
Definition DNA_ID.h:626
@ PRV_TAG_DEFERRED_INVALID
Definition DNA_ID.h:632
@ PRV_TAG_DEFERRED_RENDERING
Definition DNA_ID.h:628
@ PRV_TAG_RESTART_RENDERING
Definition DNA_ID.h:634
@ PRV_TAG_DEFERRED_DELETE
Definition DNA_ID.h:630
bool operator!=(const CPPType &a, const CPPType &b)
eID_OverrideLib_PropTag
Definition DNA_ID.h:237
@ LIBOVERRIDE_PROP_TAG_NEEDS_RETORE
Definition DNA_ID.h:242
@ LIBOVERRIDE_PROP_OP_TAG_UNUSED
Definition DNA_ID.h:239
eID_OverrideLib_Op
Definition DNA_ID.h:182
@ LIBOVERRIDE_OP_ADD
Definition DNA_ID.h:192
@ LIBOVERRIDE_OP_INSERT_AFTER
Definition DNA_ID.h:200
@ LIBOVERRIDE_OP_SUBTRACT
Definition DNA_ID.h:194
@ LIBOVERRIDE_OP_MULTIPLY
Definition DNA_ID.h:196
@ LIBOVERRIDE_OP_NOOP
Definition DNA_ID.h:185
@ LIBOVERRIDE_OP_CUSTOM
Definition DNA_ID.h:212
@ LIBOVERRIDE_OP_REPLACE
Definition DNA_ID.h:188
@ LIBOVERRIDE_OP_INSERT_BEFORE
Definition DNA_ID.h:202
eID_OverrideLib_Flag
Definition DNA_ID.h:298
@ LIBOVERRIDE_FLAG_NO_HIERARCHY
Definition DNA_ID.h:303
@ LIBOVERRIDE_FLAG_SYSTEM_DEFINED
Definition DNA_ID.h:308
unsigned short uint16_t
Definition BKE_text.h:80
unsigned int uint32_t
Definition BKE_text.h:81
eID_RemapStatus
Definition DNA_ID.h:370
@ ID_REMAP_IS_USER_ONE_SKIPPED
Definition DNA_ID.h:374
@ ID_REMAP_IS_LINKED_DIRECT
Definition DNA_ID.h:372
@ INDEX_ID_KE
Definition DNA_ID.h:1323
@ INDEX_ID_CV
Definition DNA_ID.h:1330
@ INDEX_ID_TE
Definition DNA_ID.h:1313
@ INDEX_ID_PC
Definition DNA_ID.h:1347
@ INDEX_ID_CU_LEGACY
Definition DNA_ID.h:1328
@ INDEX_ID_WS
Definition DNA_ID.h:1355
@ INDEX_ID_VF
Definition DNA_ID.h:1302
@ INDEX_ID_MC
Definition DNA_ID.h:1310
@ INDEX_ID_SCR
Definition DNA_ID.h:1354
@ INDEX_ID_MA
Definition DNA_ID.h:1314
@ INDEX_ID_TXT
Definition DNA_ID.h:1303
@ INDEX_ID_ME
Definition DNA_ID.h:1327
@ INDEX_ID_GD_LEGACY
Definition DNA_ID.h:1292
@ INDEX_ID_VO
Definition DNA_ID.h:1332
@ INDEX_ID_SO
Definition DNA_ID.h:1304
@ INDEX_ID_LS
Definition DNA_ID.h:1315
@ INDEX_ID_CA
Definition DNA_ID.h:1335
@ INDEX_ID_WM
Definition DNA_ID.h:1356
@ INDEX_ID_LI
Definition DNA_ID.h:1283
@ INDEX_ID_WO
Definition DNA_ID.h:1316
@ INDEX_ID_MB
Definition DNA_ID.h:1329
@ INDEX_ID_AC
Definition DNA_ID.h:1286
@ INDEX_ID_AR
Definition DNA_ID.h:1326
@ INDEX_ID_SPK
Definition DNA_ID.h:1336
@ INDEX_ID_CF
Definition DNA_ID.h:1319
@ INDEX_ID_PAL
Definition DNA_ID.h:1346
@ INDEX_ID_GR
Definition DNA_ID.h:1342
@ INDEX_ID_OB
Definition DNA_ID.h:1341
@ INDEX_ID_LT
Definition DNA_ID.h:1333
@ INDEX_ID_GP
Definition DNA_ID.h:1338
@ INDEX_ID_MSK
Definition DNA_ID.h:1308
@ INDEX_ID_LP
Definition DNA_ID.h:1337
@ INDEX_ID_PA
Definition DNA_ID.h:1320
@ INDEX_ID_SCE
Definition DNA_ID.h:1351
@ INDEX_ID_LA
Definition DNA_ID.h:1334
@ INDEX_ID_NT
Definition DNA_ID.h:1298
@ INDEX_ID_PT
Definition DNA_ID.h:1331
@ INDEX_ID_NULL
Definition DNA_ID.h:1359
@ INDEX_ID_IM
Definition DNA_ID.h:1309
@ INDEX_ID_BR
Definition DNA_ID.h:1348
IDRecalcFlag
Definition DNA_ID.h:1049
@ ID_RECALC_PSYS_PHYS
Definition DNA_ID.h:1087
@ ID_RECALC_PROVISION_28
Definition DNA_ID.h:1167
@ ID_RECALC_SOURCE
Definition DNA_ID.h:1143
@ ID_RECALC_PARAMETERS
Definition DNA_ID.h:1138
@ ID_RECALC_ALL
Definition DNA_ID.h:1190
@ ID_RECALC_SELECT
Definition DNA_ID.h:1101
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1077
@ ID_RECALC_AUDIO_LISTENER
Definition DNA_ID.h:1130
@ ID_RECALC_PSYS_RESET
Definition DNA_ID.h:1083
@ ID_RECALC_GEOMETRY_ALL_MODES
Definition DNA_ID.h:1183
@ ID_RECALC_AUDIO_FPS
Definition DNA_ID.h:1127
@ ID_RECALC_PSYS_CHILD
Definition DNA_ID.h:1085
@ ID_RECALC_PSYS_REDO
Definition DNA_ID.h:1081
@ ID_RECALC_HIERARCHY
Definition DNA_ID.h:1158
@ ID_RECALC_AUDIO
Definition DNA_ID.h:1132
@ ID_RECALC_TAG_FOR_UNDO
Definition DNA_ID.h:1152
@ ID_RECALC_SHADING
Definition DNA_ID.h:1094
@ ID_RECALC_PROVISION_30
Definition DNA_ID.h:1169
@ ID_RECALC_ANIMATION_NO_FLUSH
Definition DNA_ID.h:1178
@ ID_RECALC_PROVISION_29
Definition DNA_ID.h:1168
@ ID_RECALC_TRANSFORM
Definition DNA_ID.h:1054
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ ID_RECALC_FRAME_CHANGE
Definition DNA_ID.h:1125
@ ID_RECALC_SEQUENCER_STRIPS
Definition DNA_ID.h:1122
@ ID_RECALC_COMPOSITOR
Definition DNA_ID.h:1161
@ ID_RECALC_AUDIO_MUTE
Definition DNA_ID.h:1129
@ ID_RECALC_EDITORS
Definition DNA_ID.h:1111
@ ID_RECALC_NTREE_OUTPUT
Definition DNA_ID.h:1155
@ ID_RECALC_POINT_CACHE
Definition DNA_ID.h:1105
@ ID_RECALC_PROVISION_31
Definition DNA_ID.h:1170
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ ID_RECALC_BASE_FLAGS
Definition DNA_ID.h:1104
@ ID_RECALC_AUDIO_VOLUME
Definition DNA_ID.h:1128
@ ID_RECALC_PSYS_ALL
Definition DNA_ID.h:1193
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ ID_TAG_LIBOVERRIDE_NEED_RESYNC
Definition DNA_ID.h:909
@ ID_TAG_NO_MAIN
Definition DNA_ID.h:981
@ ID_TAG_MISSING
Definition DNA_ID.h:870
@ ID_TAG_INDIRECT
Definition DNA_ID.h:851
@ ID_TAG_EXTRAUSER_SET
Definition DNA_ID.h:887
@ ID_TAG_NO_USER_REFCOUNT
Definition DNA_ID.h:1011
@ ID_TAG_TEMP_MAIN
Definition DNA_ID.h:974
@ ID_TAG_RUNTIME
Definition DNA_ID.h:862
@ ID_TAG_UNDO_OLD_ID_REREAD_IN_PLACE
Definition DNA_ID.h:957
@ ID_TAG_UNDO_OLD_ID_REUSED_NOUNDO
Definition DNA_ID.h:950
@ ID_TAG_LIBOVERRIDE_REFOK
Definition DNA_ID.h:894
@ ID_TAG_LOCAL
Definition DNA_ID.h:839
@ ID_TAG_COPIED_ON_EVAL
Definition DNA_ID.h:1000
@ ID_TAG_LOCALIZED
Definition DNA_ID.h:990
@ ID_TAG_LIBOVERRIDE_AUTOREFRESH
Definition DNA_ID.h:900
@ ID_TAG_PRE_EXISTING
Definition DNA_ID.h:929
@ ID_TAG_EXTRAUSER
Definition DNA_ID.h:881
@ ID_TAG_EXTERN
Definition DNA_ID.h:845
@ ID_TAG_NOT_ALLOCATED
Definition DNA_ID.h:1018
@ ID_TAG_DOIT
Definition DNA_ID.h:1029
@ ID_TAG_UNDO_OLD_ID_REUSED_UNCHANGED
Definition DNA_ID.h:939
@ ID_TAG_NEW
Definition DNA_ID.h:922
@ ID_FLAG_INDIRECT_WEAK_LINK
Definition DNA_ID.h:781
@ ID_FLAG_FAKEUSER
Definition DNA_ID.h:770
@ ID_FLAG_EMBEDDED_DATA
Definition DNA_ID.h:775
@ ID_FLAG_LINKED_AND_PACKED
Definition DNA_ID.h:806
@ ID_FLAG_CLIPBOARD_MARK
Definition DNA_ID.h:801
@ ID_FLAG_LIB_OVERRIDE_RESYNC_LEFTOVER
Definition DNA_ID.h:791
@ ID_FLAG_EMBEDDED_DATA_LIB_OVERRIDE
Definition DNA_ID.h:786
ePreviewImage_Flag
Definition DNA_ID.h:617
@ PRV_USER_EDITED
Definition DNA_ID.h:620
@ PRV_RENDERING
Definition DNA_ID.h:622
@ PRV_CHANGED
Definition DNA_ID.h:618
eID_OverrideLib_OpFlag
Definition DNA_ID.h:216
@ LIBOVERRIDE_OP_FLAG_IDPOINTER_ITEM_USE_ID
Definition DNA_ID.h:232
@ LIBOVERRIDE_OP_FLAG_MANDATORY
Definition DNA_ID.h:218
@ LIBOVERRIDE_OP_FLAG_LOCKED
Definition DNA_ID.h:220
@ LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE
Definition DNA_ID.h:226
signed char int8_t
Definition BKE_text.h:76
#define hash
Definition noise_c.cc:156
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:379
struct IDOverrideLibraryPropertyOperation * next
Definition DNA_ID.h:247
struct IDOverrideLibraryPropertyOperation * prev
Definition DNA_ID.h:247
struct IDOverrideLibraryProperty * prev
Definition DNA_ID.h:314
ListBaseT< IDOverrideLibraryPropertyOperation > operations
Definition DNA_ID.h:326
eID_OverrideLib_PropTag tag
Definition DNA_ID.h:331
struct IDOverrideLibraryProperty * next
Definition DNA_ID.h:314
ListBaseT< IDOverrideLibraryProperty > properties
Definition DNA_ID.h:344
eID_OverrideLib_Flag flag
Definition DNA_ID.h:356
struct ID * hierarchy_root
Definition DNA_ID.h:352
IDOverrideLibraryRuntime * runtime
Definition DNA_ID.h:354
bke::idprop::IDPropertyGroupChildrenSet * children_map
Definition DNA_ID.h:138
ListBaseT< struct IDProperty > group
Definition DNA_ID.h:133
IDPropertyUIData base
Definition DNA_ID.h:86
IDPropertyUIData base
Definition DNA_ID.h:96
IDPropertyUIData base
Definition DNA_ID.h:119
IDPropertyUIData base
Definition DNA_ID.h:69
IDPropertyUIDataEnumItem * enum_items
Definition DNA_ID.h:81
eIDPropertyFlag flag
Definition DNA_ID.h:151
IDPropertyUIData * ui_data
Definition DNA_ID.h:171
eIDPropertyType type
Definition DNA_ID.h:145
struct IDProperty * prev
Definition DNA_ID.h:144
struct IDProperty * next
Definition DNA_ID.h:144
IDPropertyData data
Definition DNA_ID.h:157
char name[258]
Definition DNA_ID.h:433
unsigned int session_uid
Definition DNA_ID.h:463
bke::id::ID_Runtime * runtime
Definition DNA_ID.h:541
struct ID * newid
Definition DNA_ID.h:419
unsigned int recalc_up_to_undo_push
Definition DNA_ID.h:456
struct LibraryWeakReference * library_weak_reference
Definition DNA_ID.h:529
struct Library * lib
Definition DNA_ID.h:421
IDProperty * system_properties
Definition DNA_ID.h:490
void * prev
Definition DNA_ID.h:418
short flag
Definition DNA_ID.h:439
struct AssetMetaData * asset_data
Definition DNA_ID.h:424
void * next
Definition DNA_ID.h:418
void * _pad1
Definition DNA_ID.h:492
int icon_id
Definition DNA_ID.h:445
unsigned int recalc_after_undo_push
Definition DNA_ID.h:457
IDOverrideLibrary * override_library
Definition DNA_ID.h:495
IDProperty * properties
Definition DNA_ID.h:481
unsigned int recalc
Definition DNA_ID.h:446
struct ID * orig_id
Definition DNA_ID.h:502
void * py_instance
Definition DNA_ID.h:519
IDHash deep_hash
Definition DNA_ID.h:475
uint16_t undo_runtime_tag
Definition DNA_ID.h:567
char _pad[4]
Definition DNA_ID.h:568
struct Library * archive_parent_library
Definition DNA_ID.h:575
struct PackedFile * packedfile
Definition DNA_ID.h:584
char filepath[1024]
Definition DNA_ID.h:562
bke::library::LibraryRuntime * runtime
Definition DNA_ID.h:591
uint16_t flag
Definition DNA_ID.h:565
unsigned int w[2]
Definition DNA_ID.h:645
bke::PreviewImageRuntime * runtime
Definition DNA_ID.h:651
unsigned int * rect[2]
Definition DNA_ID.h:649
unsigned int h[2]
Definition DNA_ID.h:646
short changed_timestamp[2]
Definition DNA_ID.h:648