BKE BMain relations: add utils to (re)set tags of the entries.

This commit is contained in:
Bastien Montagne
2021-02-02 17:26:30 +01:00
parent 2262e18269
commit 4ff5051ffc
2 changed files with 24 additions and 0 deletions

View File

@@ -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);

View File

@@ -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.
*