Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-09-11 12:57:54 +0300
committerJacques Lucke <jacques@blender.org>2020-09-11 12:57:54 +0300
commitc27d00cde08ab32718af326f6b72ccfdf3ef073a (patch)
tree5088b2052e326fcab21e740ae0e61ea22d967a10 /source/blender
parentf8ef7f045c289a86a141b2fc952e3e070f7679f1 (diff)
Refactor: move CacheFile .blend I/O to IDTypeInfo callbacks
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/cachefile.c38
-rw-r--r--source/blender/blenloader/intern/readfile.c37
-rw-r--r--source/blender/blenloader/intern/writefile.c21
3 files changed, 39 insertions, 57 deletions
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index f3386df03c8..9475ba7efcf 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -39,6 +39,7 @@
#include "BLT_translation.h"
+#include "BKE_anim_data.h"
#include "BKE_cachefile.h"
#include "BKE_idtype.h"
#include "BKE_lib_id.h"
@@ -48,6 +49,8 @@
#include "DEG_depsgraph_query.h"
+#include "BLO_read_write.h"
+
#ifdef WITH_ALEMBIC
# include "ABC_alembic.h"
#endif
@@ -85,6 +88,37 @@ static void cache_file_free_data(ID *id)
BLI_freelistN(&cache_file->object_paths);
}
+static void cache_file_blend_write(BlendWriter *writer, ID *id, const void *id_address)
+{
+ CacheFile *cache_file = (CacheFile *)id;
+ if (cache_file->id.us > 0 || BLO_write_is_undo(writer)) {
+ /* Clean up, important in undo case to reduce false detection of changed datablocks. */
+ BLI_listbase_clear(&cache_file->object_paths);
+ cache_file->handle = NULL;
+ memset(cache_file->handle_filepath, 0, sizeof(cache_file->handle_filepath));
+ cache_file->handle_readers = NULL;
+
+ BLO_write_id_struct(writer, CacheFile, id_address, &cache_file->id);
+
+ if (cache_file->adt) {
+ BKE_animdata_blend_write(writer, cache_file->adt);
+ }
+ }
+}
+
+static void cache_file_blend_read_data(BlendDataReader *reader, ID *id)
+{
+ CacheFile *cache_file = (CacheFile *)id;
+ BLI_listbase_clear(&cache_file->object_paths);
+ cache_file->handle = NULL;
+ cache_file->handle_filepath[0] = '\0';
+ cache_file->handle_readers = NULL;
+
+ /* relink animdata */
+ BLO_read_data_address(reader, &cache_file->adt);
+ BKE_animdata_blend_read_data(reader, cache_file->adt);
+}
+
IDTypeInfo IDType_ID_CF = {
.id_code = ID_CF,
.id_filter = FILTER_ID_CF,
@@ -102,8 +136,8 @@ IDTypeInfo IDType_ID_CF = {
.foreach_id = NULL,
.foreach_cache = NULL,
- .blend_write = NULL,
- .blend_read_data = NULL,
+ .blend_write = cache_file_blend_write,
+ .blend_read_data = cache_file_blend_read_data,
.blend_read_lib = NULL,
.blend_read_expand = NULL,
};
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index d1dfee0e779..b0f0a08651c 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2538,28 +2538,6 @@ static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBas
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Read ID: CacheFiles
- * \{ */
-
-static void lib_link_cachefiles(BlendLibReader *UNUSED(reader), CacheFile *UNUSED(cache_file))
-{
-}
-
-static void direct_link_cachefile(BlendDataReader *reader, CacheFile *cache_file)
-{
- BLI_listbase_clear(&cache_file->object_paths);
- cache_file->handle = NULL;
- cache_file->handle_filepath[0] = '\0';
- cache_file->handle_readers = NULL;
-
- /* relink animdata */
- BLO_read_data_address(reader, &cache_file->adt);
- BKE_animdata_blend_read_data(reader, cache_file->adt);
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name Read ID: WorkSpace
* \{ */
@@ -6371,9 +6349,6 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
case ID_PA:
direct_link_particlesettings(&reader, (ParticleSettings *)id);
break;
- case ID_CF:
- direct_link_cachefile(&reader, (CacheFile *)id);
- break;
case ID_WS:
direct_link_workspace(&reader, (WorkSpace *)id, main);
break;
@@ -6407,6 +6382,7 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
case ID_VO:
case ID_SIM:
case ID_SO:
+ case ID_CF:
/* Do nothing. Handled by IDTypeInfo callback. */
break;
}
@@ -7036,9 +7012,6 @@ static void lib_link_all(FileData *fd, Main *bmain)
case ID_GR:
lib_link_collection(&reader, (Collection *)id);
break;
- case ID_CF:
- lib_link_cachefiles(&reader, (CacheFile *)id);
- break;
case ID_IP:
/* XXX deprecated... still needs to be maintained for version patches still. */
lib_link_ipo(&reader, (Ipo *)id);
@@ -7076,6 +7049,7 @@ static void lib_link_all(FileData *fd, Main *bmain)
case ID_VO:
case ID_SIM:
case ID_SO:
+ case ID_CF:
/* Do nothing. Handled by IDTypeInfo callback. */
break;
}
@@ -8003,10 +7977,6 @@ static void expand_scene(BlendExpander *expander, Scene *sce)
}
}
-static void expand_cachefile(BlendExpander *UNUSED(expander), CacheFile *UNUSED(cache_file))
-{
-}
-
static void expand_workspace(BlendExpander *expander, WorkSpace *workspace)
{
LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) {
@@ -8072,9 +8042,6 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
case ID_PA:
expand_particlesettings(&expander, (ParticleSettings *)id);
break;
- case ID_CF:
- expand_cachefile(&expander, (CacheFile *)id);
- break;
case ID_WS:
expand_workspace(&expander, (WorkSpace *)id);
break;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 70d68ef5262..171d111b94d 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2055,23 +2055,6 @@ static void write_screen(BlendWriter *writer, bScreen *screen, const void *id_ad
}
}
-static void write_cachefile(BlendWriter *writer, CacheFile *cache_file, const void *id_address)
-{
- if (cache_file->id.us > 0 || BLO_write_is_undo(writer)) {
- /* Clean up, important in undo case to reduce false detection of changed datablocks. */
- BLI_listbase_clear(&cache_file->object_paths);
- cache_file->handle = NULL;
- memset(cache_file->handle_filepath, 0, sizeof(cache_file->handle_filepath));
- cache_file->handle_readers = NULL;
-
- BLO_write_id_struct(writer, CacheFile, id_address, &cache_file->id);
-
- if (cache_file->adt) {
- BKE_animdata_blend_write(writer, cache_file->adt);
- }
- }
-}
-
static void write_workspace(BlendWriter *writer, WorkSpace *workspace, const void *id_address)
{
BLO_write_id_struct(writer, WorkSpace, id_address, &workspace->id);
@@ -2366,9 +2349,6 @@ static bool write_file_handle(Main *mainvar,
case ID_PA:
write_particlesettings(&writer, (ParticleSettings *)id_buffer, id);
break;
- case ID_CF:
- write_cachefile(&writer, (CacheFile *)id_buffer, id);
- break;
case ID_ME:
case ID_LT:
case ID_AC:
@@ -2399,6 +2379,7 @@ static bool write_file_handle(Main *mainvar,
case ID_VO:
case ID_SIM:
case ID_SO:
+ case ID_CF:
/* Do nothing, handled in IDTypeInfo callback. */
break;
case ID_LI: