diff options
author | Jacques Lucke <jacques@blender.org> | 2020-09-10 18:47:04 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-09-10 18:47:04 +0300 |
commit | e628e8821e7c81b912968c28e1972afe7078343a (patch) | |
tree | 4456a22454b92ab9d2f1c52cea440207ff307e12 /source/blender/blenkernel/intern/lightprobe.c | |
parent | 133b7c34dd1c457ee921302e88594654ac64ba9f (diff) |
Refactor: move LightProbe .blend I/O to IDTypeInfo callbacks
Diffstat (limited to 'source/blender/blenkernel/intern/lightprobe.c')
-rw-r--r-- | source/blender/blenkernel/intern/lightprobe.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c index b4b13306112..cf680641a7b 100644 --- a/source/blender/blenkernel/intern/lightprobe.c +++ b/source/blender/blenkernel/intern/lightprobe.c @@ -30,6 +30,7 @@ #include "BLI_utildefines.h" +#include "BKE_anim_data.h" #include "BKE_idtype.h" #include "BKE_lib_id.h" #include "BKE_lib_query.h" @@ -38,6 +39,8 @@ #include "BLT_translation.h" +#include "BLO_read_write.h" + static void lightprobe_init_data(ID *id) { LightProbe *probe = (LightProbe *)id; @@ -54,6 +57,33 @@ static void lightprobe_foreach_id(ID *id, LibraryForeachIDData *data) BKE_LIB_FOREACHID_PROCESS(data, probe->visibility_grp, IDWALK_CB_NOP); } +static void lightprobe_blend_write(BlendWriter *writer, ID *id, const void *id_address) +{ + LightProbe *prb = (LightProbe *)id; + if (prb->id.us > 0 || BLO_write_is_undo(writer)) { + /* write LibData */ + BLO_write_id_struct(writer, LightProbe, id_address, &prb->id); + BKE_id_blend_write(writer, &prb->id); + + if (prb->adt) { + BKE_animdata_blend_write(writer, prb->adt); + } + } +} + +static void lightprobe_blend_read_data(BlendDataReader *reader, ID *id) +{ + LightProbe *prb = (LightProbe *)id; + BLO_read_data_address(reader, &prb->adt); + BKE_animdata_blend_read_data(reader, prb->adt); +} + +static void lightprobe_blend_read_lib(BlendLibReader *reader, ID *id) +{ + LightProbe *prb = (LightProbe *)id; + BLO_read_id_address(reader, prb->id.lib, &prb->visibility_grp); +} + IDTypeInfo IDType_ID_LP = { .id_code = ID_LP, .id_filter = FILTER_ID_LP, @@ -71,9 +101,9 @@ IDTypeInfo IDType_ID_LP = { .foreach_id = lightprobe_foreach_id, .foreach_cache = NULL, - .blend_write = NULL, - .blend_read_data = NULL, - .blend_read_lib = NULL, + .blend_write = lightprobe_blend_write, + .blend_read_data = lightprobe_blend_read_data, + .blend_read_lib = lightprobe_blend_read_lib, .blend_read_expand = NULL, }; |