diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-02-08 20:44:37 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-02-08 20:53:09 +0300 |
commit | 6ba8e71fa2890ec36de6f5012414ff40e5e4b23a (patch) | |
tree | a958ad168dcacb91caed9af10b13d7fcd36068f9 /source/blender/blenkernel/intern | |
parent | 4b4a231250248dc144dc80eefc3b7517ad2d24dc (diff) |
BKE_main: add a util to generate/extend a GSet with all ID pointers of a Main database.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/main.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c index d5b9147b34f..37d812adfa2 100644 --- a/source/blender/blenkernel/intern/main.c +++ b/source/blender/blenkernel/intern/main.c @@ -209,6 +209,27 @@ void BKE_main_relations_free(Main *bmain) } } +static bool main_gset_create(Main *UNUSED(bmain), ID *id, void *user_data) +{ + GSet *gset = user_data; + BLI_gset_add(gset, id); + return true; +} + +/** + * Create a GSet storing all IDs present in given \a bmain, by their pointers. + * + * \param gset If not NULL, given GSet will be extended with IDs from given \a bmain, instead of creating a new one. + */ +GSet *BKE_main_gset_create(Main *bmain, GSet *gset) +{ + if (gset == NULL) { + gset = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); + } + BKE_main_foreach_id(bmain, false, main_gset_create, gset); + return gset; +} + /** * Call given callback over every IDs of given \a lb listbase (assumed to be part of given \a bmain). * |