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-08-28 14:05:48 +0300
committerJacques Lucke <jacques@blender.org>2020-08-28 14:05:48 +0300
commita443287908248d0b83f490f0993d857fb1d73fec (patch)
tree10cbbdfd907bceee6b4c09702da1b7e4bd91b30f /source/blender/blenloader
parent346023b457d3da7056210a8dae78e881e1e8820b (diff)
IDTypeInfo: add .blend file io callbacks
This is part of T76372. It adds the `blend_write`, `blend_read_data`, `blend_read_lib` and `blend_read_expand` which correspond to the various steps when reading and writing .blend files. Having these callbacks allows us to decentralize the blenloader code a lot more. This has the affect that code related to any specific ID type is less scattered. Reviewers: mont29 Differential Revision: https://developer.blender.org/D8670
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c13
-rw-r--r--source/blender/blenloader/intern/writefile.c5
2 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 304ba87402c..b35ad3d34c6 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -8240,6 +8240,9 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
}
const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
+ if (id_type->blend_read_data != NULL) {
+ id_type->blend_read_data(&reader, id);
+ }
/* XXX Very weakly handled currently, see comment in read_libblock() before trying to
* use it for anything new. */
@@ -8959,6 +8962,11 @@ static void lib_link_all(FileData *fd, Main *bmain)
lib_link_id(&reader, id);
+ const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
+ if (id_type->blend_read_lib != NULL) {
+ id_type->blend_read_lib(&reader, id);
+ }
+
/* Note: ID types are processed in reverse order as defined by INDEX_ID_XXX enums in DNA_ID.h.
* This ensures handling of most dependencies in proper order, as elsewhere in code.
* Please keep order of entries in that switch matching that order, it's easier to quickly see
@@ -10372,6 +10380,11 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
if (id->tag & LIB_TAG_NEED_EXPAND) {
expand_id(&expander, id);
+ const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
+ if (id_type->blend_read_expand != NULL) {
+ id_type->blend_read_expand(&expander, id);
+ }
+
switch (GS(id->name)) {
case ID_OB:
expand_object(&expander, (Object *)id);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index a9f9685bf75..6ce822a09c1 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -3865,6 +3865,11 @@ static bool write_file_handle(Main *mainvar,
((ID *)id_buffer)->prev = NULL;
((ID *)id_buffer)->next = NULL;
+ const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
+ if (id_type->blend_write != NULL) {
+ id_type->blend_write(&writer, (ID *)id_buffer, id);
+ }
+
switch ((ID_Type)GS(id->name)) {
case ID_WM:
write_windowmanager(&writer, (wmWindowManager *)id_buffer, id);