diff options
author | Jacques Lucke <jacques@blender.org> | 2020-08-28 14:05:48 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-08-28 14:05:48 +0300 |
commit | a443287908248d0b83f490f0993d857fb1d73fec (patch) | |
tree | 10cbbdfd907bceee6b4c09702da1b7e4bd91b30f /source/blender/blenloader/intern/readfile.c | |
parent | 346023b457d3da7056210a8dae78e881e1e8820b (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/intern/readfile.c')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 13 |
1 files changed, 13 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); |