Move Scene's cache management during undo to new system.
This commit is contained in:
parent
a33756d783
commit
3a59c184b9
Notes:
blender-bot
2023-06-07 10:31:13 +02:00
Referenced by issue #78608, Memory leak in Material properties: "Data from SCE" Referenced by issue #78588, Material preview not visible in selection list
|
@ -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";
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
Loading…
Reference in New Issue