Commit: 44dd3308a5b66fbd9bc4dc39304690f64da8d971 Author: Campbell Barton Date: Wed Jan 18 13:47:00 2023 +1100 Branches: master https://developer.blender.org/rB44dd3308a5b66fbd9bc4dc39304690f64da8d971
DNA: move Collection members into their own Runtime struct Also add static assert that COLLECTION_COLOR_TOT has the correct number of items in the enum. =================================================================== M source/blender/blenkernel/intern/blendfile_link_append.c M source/blender/blenkernel/intern/collection.c M source/blender/blenkernel/intern/layer.cc M source/blender/blenkernel/intern/scene.cc M source/blender/editors/interface/interface_templates.cc M source/blender/editors/object/object_relations.c M source/blender/editors/space_outliner/outliner_collections.cc M source/blender/editors/space_outliner/outliner_dragdrop.cc M source/blender/editors/space_outliner/outliner_draw.cc M source/blender/editors/space_outliner/tree/tree_display_libraries.cc M source/blender/makesdna/DNA_collection_types.h M source/blender/makesrna/intern/rna_collection.c =================================================================== diff --git a/source/blender/blenkernel/intern/blendfile_link_append.c b/source/blender/blenkernel/intern/blendfile_link_append.c index 3f3c1028d10..49b480fcb64 100644 --- a/source/blender/blenkernel/intern/blendfile_link_append.c +++ b/source/blender/blenkernel/intern/blendfile_link_append.c @@ -574,7 +574,8 @@ static void loose_data_instantiate_obdata_preprocess( * (return false). */ static bool loose_data_instantiate_collection_parents_check_recursive(Collection *collection) { - for (CollectionParent *parent_collection = collection->parents.first; parent_collection != NULL; + for (CollectionParent *parent_collection = collection->runtime.parents.first; + parent_collection != NULL; parent_collection = parent_collection->next) { if ((parent_collection->collection->id.tag & LIB_TAG_DOIT) != 0) { return true; diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 53ef78525c2..1ca870bd397 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -114,12 +114,12 @@ static void collection_copy_data(Main *bmain, ID *id_dst, const ID *id_src, cons collection_dst->flag &= ~COLLECTION_HAS_OBJECT_CACHE; collection_dst->flag &= ~COLLECTION_HAS_OBJECT_CACHE_INSTANCED; - BLI_listbase_clear(&collection_dst->object_cache); - BLI_listbase_clear(&collection_dst->object_cache_instanced); + BLI_listbase_clear(&collection_dst->runtime.object_cache); + BLI_listbase_clear(&collection_dst->runtime.object_cache_instanced); BLI_listbase_clear(&collection_dst->gobject); BLI_listbase_clear(&collection_dst->children); - BLI_listbase_clear(&collection_dst->parents); + BLI_listbase_clear(&collection_dst->runtime.parents); LISTBASE_FOREACH (CollectionChild *, child, &collection_src->children) { collection_child_add(collection_dst, child->collection, flag, false); @@ -138,7 +138,7 @@ static void collection_free_data(ID *id) BLI_freelistN(&collection->gobject); BLI_freelistN(&collection->children); - BLI_freelistN(&collection->parents); + BLI_freelistN(&collection->runtime.parents); BKE_collection_object_cache_free(collection); } @@ -148,7 +148,7 @@ static void collection_foreach_id(ID *id, LibraryForeachIDData *data) Collection *collection = (Collection *)id; BKE_LIB_FOREACHID_PROCESS_ID( - data, collection->owner_id, IDWALK_CB_LOOPBACK | IDWALK_CB_NEVER_SELF); + data, collection->runtime.owner_id, IDWALK_CB_LOOPBACK | IDWALK_CB_NEVER_SELF); LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, cob->ob, IDWALK_CB_USER); @@ -157,7 +157,7 @@ static void collection_foreach_id(ID *id, LibraryForeachIDData *data) BKE_LIB_FOREACHID_PROCESS_IDSUPER( data, child->collection, IDWALK_CB_NEVER_SELF | IDWALK_CB_USER); } - LISTBASE_FOREACH (CollectionParent *, parent, &collection->parents) { + LISTBASE_FOREACH (CollectionParent *, parent, &collection->runtime.parents) { /* XXX This is very weak. The whole idea of keeping pointers to private IDs is very bad * anyway... */ const int cb_flag = ((parent->collection != NULL && @@ -178,11 +178,12 @@ static ID **collection_owner_pointer_get(ID *id) Collection *master_collection = (Collection *)id; BLI_assert((master_collection->flag & COLLECTION_IS_MASTER) != 0); - BLI_assert(master_collection->owner_id != NULL); - BLI_assert(GS(master_collection->owner_id->name) == ID_SCE); - BLI_assert(((Scene *)master_collection->owner_id)->master_collection == master_collection); + BLI_assert(master_collection->runtime.owner_id != NULL); + BLI_assert(GS(master_collection->runtime.owner_id->name) == ID_SCE); + BLI_assert(((Scene *)master_collection->runtime.owner_id)->master_collection == + master_collection); - return &master_collection->owner_id; + return &master_collection->runtime.owner_id; } void BKE_collection_blend_write_nolib(BlendWriter *writer, Collection *collection) @@ -208,10 +209,10 @@ static void collection_blend_write(BlendWriter *writer, ID *id, const void *id_a /* Clean up, important in undo case to reduce false detection of changed data-blocks. */ collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE; collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE_INSTANCED; - collection->tag = 0; - BLI_listbase_clear(&collection->object_cache); - BLI_listbase_clear(&collection->object_cache_instanced); - BLI_listbase_clear(&collection->parents); + collection->runtime.tag = 0; + BLI_listbase_clear(&collection->runtime.object_cache); + BLI_listbase_clear(&collection->runtime.object_cache_instanced); + BLI_listbase_clear(&collection->runtime.parents); /* write LibData */ BLO_write_id_struct(writer, Collection, id_address, &collection->id); @@ -258,7 +259,7 @@ void BKE_collection_blend_read_data(BlendDataReader *reader, Collection *collect } collection->id.flag |= LIB_EMBEDDED_DATA; } - collection->owner_id = owner_id; + collection->runtime.owner_id = owner_id; BLO_read_list(reader, &collection->gobject); BLO_read_list(reader, &collection->children); @@ -268,10 +269,10 @@ void BKE_collection_blend_read_data(BlendDataReader *reader, Collection *collect collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE; collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE_INSTANCED; - collection->tag = 0; - BLI_listbase_clear(&collection->object_cache); - BLI_listbase_clear(&collection->object_cache_instanced); - BLI_listbase_clear(&collection->parents); + collection->runtime.tag = 0; + BLI_listbase_clear(&collection->runtime.object_cache); + BLI_listbase_clear(&collection->runtime.object_cache_instanced); + BLI_listbase_clear(&collection->runtime.parents); #ifdef USE_COLLECTION_COMPAT_28 /* This runs before the very first doversion. */ @@ -543,7 +544,7 @@ bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy) else { /* Link child collections into parent collection. */ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { - LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) { + LISTBASE_FOREACH (CollectionParent *, cparent, &collection->runtime.parents) { Collection *parent = cparent->collection; collection_child_add(parent, child->collection, 0, true); } @@ -552,7 +553,7 @@ bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy) CollectionObject *cob = collection->gobject.first; while (cob != NULL) { /* Link child object into parent collections. */ - LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) { + LISTBASE_FOREACH (CollectionParent *, cparent, &collection->runtime.parents) { Collection *parent = cparent->collection; collection_object_add(bmain, parent, cob->ob, 0, true); } @@ -816,13 +817,13 @@ ListBase BKE_collection_object_cache_get(Collection *collection) BLI_mutex_lock(&cache_lock); if (!(collection->flag & COLLECTION_HAS_OBJECT_CACHE)) { - collection_object_cache_fill(&collection->object_cache, collection, 0, false); + collection_object_cache_fill(&collection->runtime.object_cache, collection, 0, false); collection->flag |= COLLECTION_HAS_OBJECT_CACHE; } BLI_mutex_unlock(&cache_lock); } - return collection->object_cache; + return collection->runtime.object_cache; } ListBase BKE_collection_object_cache_instanced_get(Collection *collection) @@ -832,13 +833,14 @@ ListBase BKE_collection_object_cache_instanced_get(Collection *collection) BLI_mutex_lock(&cache_lock); if (!(collection->flag & COLLECTION_HAS_OBJECT_CACHE_INSTANCED)) { - collection_object_cache_fill(&collection->object_cache_instanced, collection, 0, true); + collection_object_cache_fill( + &collection->runtime.object_cache_instanced, collection, 0, true); collection->flag |= COLLECTION_HAS_OBJECT_CACHE_INSTANCED; } BLI_mutex_unlock(&cache_lock); } - return collection->object_cache_instanced; + return collection->runtime.object_cache_instanced; } static void collection_object_cache_free(Collection *collection) @@ -846,10 +848,10 @@ static void collection_object_cache_free(Collection *collection) /* Clear own cache an for all parents, since those are affected by changes as well. */ collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE; collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE_INSTANCED; - BLI_freelistN(&collection->object_cache); - BLI_freelistN(&collection->object_cache_instanced); + BLI_freelistN(&collection->runtime.object_cache); + BLI_freelistN(&collection->runtime.object_cache_instanced); - LISTBASE_FOREACH (CollectionParent *, parent, &collection->parents) { + LISTBASE_FOREACH (CollectionParent *, parent, &collection->runtime.parents) { collection_object_cache_free(parent->collection); } } @@ -884,7 +886,7 @@ Collection *BKE_collection_master_add(Scene *scene) Collection *master_collection = BKE_libblock_alloc( NULL, ID_GR, BKE_SCENE_COLLECTION_NAME, LIB_ID_CREATE_NO_MAIN); master_collection->id.flag |= LIB_EMBEDDED_DATA; - master_collection->owner_id = &scene->id; + master_collection->runtime.owner_id = &scene->id; master_collection->flag |= COLLECTION_IS_MASTER; master_collection->color_tag = COLLECTION_COLOR_NONE; @@ -1024,7 +1026,7 @@ static void collection_tag_update_parent_recursive(Main *bmain, DEG_id_tag_update_ex(bmain, &collection->id, flag); - LISTBASE_FOREACH (CollectionParent *, collection_parent, &collection->parents) { + LISTBASE_FOREACH (CollectionParent *, collection_parent, &collection->runtime.parents) { if (collection_parent->collection->flag & COLLECTION_IS_MASTER) { /* We don't care about scene/master collection here. */ continue; @@ -1045,7 +1047,7 @@ static Collection *collection_parent_editable_find_recursive(const ViewLayer *vi return NULL; } - LISTBASE_FOREACH (CollectionParent *, collection_parent, &collection->parents) { + LISTBASE_FOREACH (CollectionParent *, collection_parent, &c @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs