diff options
author | Bastien Montagne <bastien@blender.org> | 2021-02-02 19:26:30 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-02-02 19:26:59 +0300 |
commit | 4ff5051ffc523d0227dddda6e072befb430743d8 (patch) | |
tree | 67565cfc5770bc68186a07e3bda96652a889cce0 /source/blender | |
parent | 2262e18269bf93a5b93ad0f36020cef69b728f43 (diff) |
BKE BMain relations: add utils to (re)set tags of the entries.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_main.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/main.c | 21 |
2 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 0768423fc5f..b6116b32ca5 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -202,6 +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_tag_set(struct Main *bmain, + const MainIDRelationsEntryTags tag, + const bool value); struct GSet *BKE_main_gset_create(struct Main *bmain, struct GSet *gset); diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c index 4a7636926e6..d5cbcb62af2 100644 --- a/source/blender/blenkernel/intern/main.c +++ b/source/blender/blenkernel/intern/main.c @@ -309,6 +309,27 @@ void BKE_main_relations_free(Main *bmain) } } +/** Set or clear given `tag` in all relation entries of given `bmain`. */ +void BKE_main_relations_tag_set(struct Main *bmain, + const MainIDRelationsEntryTags tag, + const bool value) +{ + if (bmain->relations == NULL) { + return; + } + for (GHashIterator *gh_iter = BLI_ghashIterator_new(bmain->relations->relations_from_pointers); + !BLI_ghashIterator_done(gh_iter); + BLI_ghashIterator_step(gh_iter)) { + MainIDRelationsEntry *entry = BLI_ghashIterator_getValue(gh_iter); + if (value) { + entry->tags |= tag; + } + else { + entry->tags &= ~tag; + } + } +} + /** * Create a GSet storing all IDs present in given \a bmain, by their pointers. * |