diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-01-30 23:00:07 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-01-31 00:33:20 +0300 |
commit | 4443bad30a3926a33c3ead60f509f637ad29d6c5 (patch) | |
tree | f13a29ff0d122353bceabb3d5248de0a290b4999 /source/blender/blenkernel/BKE_main.h | |
parent | 997a210b086f93a881b10cb1c3ba6bedcb33676a (diff) |
Add optional, free-after-use usages mapping of IDs to Main.
The new MainIDRelations stores two mappings, one from ID users to ID
used, the other vice-versa.
That data is assumed to be short-living runtime, code creating it is
responsible to clear it asap. It will be much useful in places where we
handle relations between IDs for a lot of them at once.
Note: This commit is not fully functional, that is, the infamous, ugly,
PoS non-ID nodetrees will not be handled correctly when building relations.
Fix needed here is a bit noisy, so will be done in next own commit.
Diffstat (limited to 'source/blender/blenkernel/BKE_main.h')
-rw-r--r-- | source/blender/blenkernel/BKE_main.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index a4f5c425282..387045878f3 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -51,6 +51,8 @@ extern "C" { struct EvaluationContext; struct Library; struct MainLock; +struct GHash; +struct BLI_mempool; /* Blender thumbnail, as written on file (width, height, and data as char RGBA). */ /* We pack pixel data after that struct. */ @@ -59,6 +61,22 @@ typedef struct BlendThumbnail { char rect[0]; } BlendThumbnail; +/* Structs caching relations between data-blocks in a given Main. */ +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_library_query.h */ +} MainIDRelationsEntry; + +typedef struct MainIDRelations { + struct GHash *id_user_to_used; + struct GHash *id_used_to_user; + + /* Private... */ + struct BLI_mempool *entry_pool; +} MainIDRelations; + typedef struct Main { struct Main *next, *prev; char name[1024]; /* 1024 = FILE_MAX */ @@ -111,6 +129,11 @@ typedef struct Main { /* Evaluation context used by viewport */ struct EvaluationContext *eval_ctx; + /* Must be generated, used and freed by same code - never assume this is valid data unless you know + * when, who and how it was created. + * Used by code doing a lot of remapping etc. at once to speed things up. */ + struct MainIDRelations *relations; + struct MainLock *lock; } Main; |