Commit: b380d25053801670502d3d1a7f9e9ff4eeb44811
Author: Campbell Barton
Date:   Wed Jan 18 14:16:36 2023 +1100
Branches: master
https://developer.blender.org/rBb380d25053801670502d3d1a7f9e9ff4eeb44811

Cleanup: define COLLECTION_FLAG_ALL_RUNTIME, use in file read/write

===================================================================

M       source/blender/blenkernel/intern/collection.c
M       source/blender/makesdna/DNA_collection_types.h

===================================================================

diff --git a/source/blender/blenkernel/intern/collection.c 
b/source/blender/blenkernel/intern/collection.c
index 621d8e5df8e..de785ddd38d 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -112,8 +112,7 @@ static void collection_copy_data(Main *bmain, ID *id_dst, 
const ID *id_src, cons
     collection_dst->preview = NULL;
   }
 
-  collection_dst->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
-  collection_dst->flag &= ~COLLECTION_HAS_OBJECT_CACHE_INSTANCED;
+  collection_dst->flag &= ~(COLLECTION_HAS_OBJECT_CACHE | 
COLLECTION_HAS_OBJECT_CACHE_INSTANCED);
   BLI_listbase_clear(&collection_dst->runtime.object_cache);
   BLI_listbase_clear(&collection_dst->runtime.object_cache_instanced);
 
@@ -206,11 +205,9 @@ static void collection_blend_write(BlendWriter *writer, ID 
*id, const void *id_a
 {
   Collection *collection = (Collection *)id;
 
-  /* 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;
-
   memset(&collection->runtime, 0, sizeof(collection->runtime));
+  /* Clean up, important in undo case to reduce false detection of changed 
data-blocks. */
+  collection->flag &= ~COLLECTION_FLAG_ALL_RUNTIME;
 
   /* write LibData */
   BLO_write_id_struct(writer, Collection, id_address, &collection->id);
@@ -259,6 +256,8 @@ void BKE_collection_blend_read_data(BlendDataReader 
*reader, Collection *collect
   }
 
   memset(&collection->runtime, 0, sizeof(collection->runtime));
+  collection->flag &= ~COLLECTION_FLAG_ALL_RUNTIME;
+
   collection->runtime.owner_id = owner_id;
 
   BLO_read_list(reader, &collection->gobject);
@@ -267,9 +266,6 @@ void BKE_collection_blend_read_data(BlendDataReader 
*reader, Collection *collect
   BLO_read_data_address(reader, &collection->preview);
   BKE_previewimg_blend_read(reader, collection->preview);
 
-  collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
-  collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE_INSTANCED;
-
 #ifdef USE_COLLECTION_COMPAT_28
   /* This runs before the very first doversion. */
   BLO_read_data_address(reader, &collection->collection);
@@ -842,8 +838,7 @@ ListBase 
BKE_collection_object_cache_instanced_get(Collection *collection)
 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;
+  collection->flag &= ~(COLLECTION_HAS_OBJECT_CACHE | 
COLLECTION_HAS_OBJECT_CACHE_INSTANCED);
   BLI_freelistN(&collection->runtime.object_cache);
   BLI_freelistN(&collection->runtime.object_cache_instanced);
 
diff --git a/source/blender/makesdna/DNA_collection_types.h 
b/source/blender/makesdna/DNA_collection_types.h
index d97d3d17182..8ec6626f4b3 100644
--- a/source/blender/makesdna/DNA_collection_types.h
+++ b/source/blender/makesdna/DNA_collection_types.h
@@ -113,6 +113,9 @@ enum {
   COLLECTION_HAS_OBJECT_CACHE_INSTANCED = (1 << 6),
 };
 
+#define COLLECTION_FLAG_ALL_RUNTIME \
+  (COLLECTION_HAS_OBJECT_CACHE | COLLECTION_HAS_OBJECT_CACHE_INSTANCED)
+
 /** #Collection_Runtime.tag */
 enum {
   /**

_______________________________________________
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

Reply via email to