[Bf-blender-cvs] [3a59c184b98] master: Move Scene's cache management during undo to new system.

Bastien Montagne noreply at git.blender.org
Fri Jul 3 16:10:38 CEST 2020


Commit: 3a59c184b98a729ccaa1261d1252e084167f7a32
Author: Bastien Montagne
Date:   Fri Jul 3 16:09:58 2020 +0200
Branches: master
https://developer.blender.org/rB3a59c184b98a729ccaa1261d1252e084167f7a32

Move Scene's cache management during undo to new system.

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

M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/readblenentry.c
M	source/blender/blenloader/intern/readfile.c

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

diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index b0faa555f29..7f3d6eb0372 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -570,6 +570,20 @@ static void scene_foreach_id(ID *id, LibraryForeachIDData *data)
   }
 }
 
+static void scene_foreach_cache(ID *id,
+                                IDTypeForeachCacheFunctionCallback function_callback,
+                                void *user_data)
+{
+  Scene *scene = (Scene *)id;
+  IDCacheKey key = {
+      .id_session_uuid = id->session_uuid,
+      .offset_in_ID = offsetof(Scene, eevee.light_cache_data),
+      .cache_v = scene->eevee.light_cache_data,
+  };
+
+  function_callback(id, &key, (void **)&scene->eevee.light_cache_data, user_data);
+}
+
 IDTypeInfo IDType_ID_SCE = {
     .id_code = ID_SCE,
     .id_filter = FILTER_ID_SCE,
@@ -587,6 +601,7 @@ IDTypeInfo IDType_ID_SCE = {
      * support all possible corner cases. */
     .make_local = NULL,
     .foreach_id = scene_foreach_id,
+    .foreach_cache = scene_foreach_cache,
 };
 
 const char *RE_engine_id_BLENDER_EEVEE = "BLENDER_EEVEE";
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index e1350f9de66..914eb6c4690 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -390,29 +390,26 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain,
       blo_make_old_idmap_from_main(fd, old_mainlist.first);
     }
 
+    /* TODO: Move handling of nodetree caches to new system as well... */
     /* makes lookup of existing images in old main */
     blo_make_image_pointer_map(fd, oldmain);
-
-    /* makes lookup of existing light caches in old main */
-    blo_make_scene_pointer_map(fd, oldmain);
-
     /* makes lookup of existing video clips in old main */
     blo_make_movieclip_pointer_map(fd, oldmain);
 
     /* removed packed data from this trick - it's internal data that needs saves */
 
+    /* Store all existing ID caches pointers into a mapping, to allow restoring them into newly
+     * read IDs whenever possible. */
     blo_cache_storage_init(fd, oldmain);
 
     bfd = blo_read_file_internal(fd, filename);
 
+    /* Ensure relinked caches are not freed together with their old IDs. */
     blo_cache_storage_old_bmain_clear(fd, oldmain);
 
-    /* ensures relinked light caches are not freed */
-    blo_end_scene_pointer_map(fd, oldmain);
-
+    /* TODO: Move handling of nodetree caches to new system as well... */
     /* ensures relinked images are not freed */
     blo_end_image_pointer_map(fd, oldmain);
-
     /* ensures relinked movie clips are not freed */
     blo_end_movieclip_pointer_map(fd, oldmain);
 
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 4d411225be3..880a854acfc 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6942,13 +6942,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
   }
 
   if (reader->fd->memfile) {
-    /* If it's undo try to recover the cache. */
-    if (reader->fd->scenemap) {
-      sce->eevee.light_cache_data = newsceadr(reader->fd, sce->eevee.light_cache_data);
-    }
-    else {
-      sce->eevee.light_cache_data = NULL;
-    }
+    /* If it's undo do nothing here, caches are handled by higher-level generic calling code. */
   }
   else {
     /* else try to read the cache from file. */



More information about the Bf-blender-cvs mailing list