Commit: e628e8821e7c81b912968c28e1972afe7078343a Author: Jacques Lucke Date: Thu Sep 10 17:47:04 2020 +0200 Branches: master https://developer.blender.org/rBe628e8821e7c81b912968c28e1972afe7078343a
Refactor: move LightProbe .blend I/O to IDTypeInfo callbacks =================================================================== M source/blender/blenkernel/intern/lightprobe.c M source/blender/blenloader/intern/readfile.c M source/blender/blenloader/intern/writefile.c =================================================================== 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, }; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e30df56c2ec..9b8564cf817 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6372,23 +6372,6 @@ static void fix_relpaths_library(const char *basepath, Main *main) /** \} */ -/* -------------------------------------------------------------------- */ -/** \name Read ID: Light Probe - * \{ */ - -static void lib_link_lightprobe(BlendLibReader *reader, LightProbe *prb) -{ - BLO_read_id_address(reader, prb->id.lib, &prb->visibility_grp); -} - -static void direct_link_lightprobe(BlendDataReader *reader, LightProbe *prb) -{ - BLO_read_data_address(reader, &prb->adt); - BKE_animdata_blend_read_data(reader, prb->adt); -} - -/** \} */ - /* -------------------------------------------------------------------- */ /** \name Read ID: Sound * \{ */ @@ -6715,9 +6698,6 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID * case ID_SO: direct_link_sound(&reader, (bSound *)id); break; - case ID_LP: - direct_link_lightprobe(&reader, (LightProbe *)id); - break; case ID_GR: direct_link_collection(&reader, (Collection *)id); break; @@ -6766,6 +6746,7 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID * case ID_MSK: case ID_SPK: case ID_AR: + case ID_LP: /* Do nothing. Handled by IDTypeInfo callback. */ break; } @@ -7389,9 +7370,6 @@ static void lib_link_all(FileData *fd, Main *bmain) * 3D viewport may contains pointers to other ID data (like bgpic)! See T41411. */ lib_link_screen(&reader, (bScreen *)id); break; - case ID_LP: - lib_link_lightprobe(&reader, (LightProbe *)id); - break; case ID_PA: lib_link_particlesettings(&reader, (ParticleSettings *)id); break; @@ -7453,6 +7431,7 @@ static void lib_link_all(FileData *fd, Main *bmain) case ID_MSK: case ID_SPK: case ID_AR: + case ID_LP: /* Do nothing. Handled by IDTypeInfo callback. */ break; } @@ -8400,10 +8379,6 @@ static void expand_sound(BlendExpander *expander, bSound *snd) BLO_expand(expander, snd->ipo); // XXX deprecated - old animation system } -static void expand_lightprobe(BlendExpander *UNUSED(expander), LightProbe *UNUSED(prb)) -{ -} - static void expand_gpencil(BlendExpander *expander, bGPdata *gpd) { LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { @@ -8508,9 +8483,6 @@ void BLO_expand_main(void *fdhandle, Main *mainvar) case ID_SO: expand_sound(&expander, (bSound *)id); break; - case ID_LP: - expand_lightprobe(&expander, (LightProbe *)id); - break; case ID_GR: expand_collection(&expander, (Collection *)id); break; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 9fc8fb75ea0..cae6990fbb0 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2160,19 +2160,6 @@ static void write_sound(BlendWriter *writer, bSound *sound, const void *id_addre } } -static void write_probe(BlendWriter *writer, LightProbe *prb, const void *id_address) -{ - 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 write_cachefile(BlendWriter *writer, CacheFile *cache_file, const void *id_address) { if (cache_file->id.us > 0 || BLO_write_is_undo(writer)) { @@ -2608,9 +2595,6 @@ static bool write_file_handle(Main *mainvar, case ID_KE: write_key(&writer, (Key *)id_buffer, id); break; - case ID_LP: - write_probe(&writer, (LightProbe *)id_buffer, id); - break; case ID_SO: write_sound(&writer, (bSound *)id_buffer, id); break; @@ -2665,6 +2649,7 @@ static bool write_file_handle(Main *mainvar, case ID_MSK: case ID_SPK: case ID_AR: + case ID_LP: /* Do nothing, handled in IDTypeInfo callback. */ break; case ID_LI: _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs