diff options
Diffstat (limited to 'source/blender/blenkernel/BKE_main.h')
-rw-r--r-- | source/blender/blenkernel/BKE_main.h | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 8106607572b..b6116b32ca5 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -60,22 +60,52 @@ typedef struct BlendThumbnail { } BlendThumbnail; /* Structs caching relations between data-blocks in a given Main. */ +typedef struct MainIDRelationsEntryItem { + struct MainIDRelationsEntryItem *next; + + union { + /* For `from_ids` list, a user of the hashed ID. */ + struct ID *from; + /* For `to_ids` list, an ID used by the hashed ID. */ + struct ID **to; + } id_pointer; + /* Session uuid of the `id_pointer`. */ + uint session_uuid; + + int usage_flag; /* Using IDWALK_ enums, defined in BKE_lib_query.h */ +} MainIDRelationsEntryItem; + typedef struct MainIDRelationsEntry { - struct MainIDRelationsEntry *next; - /* WARNING! for user_to_used, - * that pointer is really an ID** one, but for used_to_user, it’s only an ID* one! */ - struct ID **id_pointer; - int usage_flag; /* Using IDWALK_ enums, in BKE_lib_query.h */ + /* Linked list of IDs using that ID. */ + struct MainIDRelationsEntryItem *from_ids; + /* Linked list of IDs used by that ID. */ + struct MainIDRelationsEntryItem *to_ids; + + /* Session uuid of the ID matching that entry. */ + uint session_uuid; + + /* Runtime tags, users should ensure those are reset after usage. */ + uint tags; } MainIDRelationsEntry; +/* MainIDRelationsEntry.tags */ +typedef enum MainIDRelationsEntryTags { + /* Generic tag marking the entry as to be processed. */ + MAINIDRELATIONS_ENTRY_TAGS_DOIT = 1 << 0, + /* Generic tag marking the entry as processed. */ + MAINIDRELATIONS_ENTRY_TAGS_PROCESSED = 1 << 1, +} MainIDRelationsEntryTags; + typedef struct MainIDRelations { - struct GHash *id_user_to_used; - struct GHash *id_used_to_user; + /* Mapping from an ID pointer to all of its parents (IDs using it) and children (IDs it uses). + * Values are `MainIDRelationsEntry` pointers. */ + struct GHash *relations_from_pointers; + /* Note: we could add more mappings when needed (e.g. from session uuid?). */ short flag; /* Private... */ - struct BLI_mempool *entry_pool; + struct BLI_mempool *entry_items_pool; } MainIDRelations; enum { @@ -172,7 +202,9 @@ void BKE_main_unlock(struct Main *bmain); void BKE_main_relations_create(struct Main *bmain, const short flag); void BKE_main_relations_free(struct Main *bmain); -void BKE_main_relations_ID_remove(struct Main *bmain, struct ID *id); +void BKE_main_relations_tag_set(struct Main *bmain, + const MainIDRelationsEntryTags tag, + const bool value); struct GSet *BKE_main_gset_create(struct Main *bmain, struct GSet *gset); |