From 12693b807ec0f3daf16f05ae621c7aec98ce2c61 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 11 Sep 2020 11:39:06 +0200 Subject: Refactor: move Volume .blend I/O to IDTypeInfo callbacks --- source/blender/blenloader/BLO_read_write.h | 2 +- source/blender/blenloader/intern/readfile.c | 48 ++-------------------------- source/blender/blenloader/intern/writefile.c | 24 +------------- 3 files changed, 4 insertions(+), 70 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/BLO_read_write.h b/source/blender/blenloader/BLO_read_write.h index e05c1046b95..8a6811444af 100644 --- a/source/blender/blenloader/BLO_read_write.h +++ b/source/blender/blenloader/BLO_read_write.h @@ -210,7 +210,7 @@ bool BLO_read_data_is_undo(BlendDataReader *reader); ID *BLO_read_get_new_id_address(BlendLibReader *reader, struct Library *lib, struct ID *id); #define BLO_read_id_address(reader, lib, id_ptr_p) \ - *(id_ptr_p) = (void *)BLO_read_get_new_id_address((reader), (lib), (ID *)*(id_ptr_p)) + *((void **)id_ptr_p) = (void *)BLO_read_get_new_id_address((reader), (lib), (ID *)*(id_ptr_p)) /* Misc. */ bool BLO_read_lib_is_undo(BlendLibReader *reader); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index f72568ed11f..f32168092eb 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6238,36 +6238,6 @@ static void lib_link_sound(BlendLibReader *reader, bSound *sound) /** \} */ -/* -------------------------------------------------------------------- */ -/** \name Read ID: Volume - * \{ */ - -static void lib_link_volume(BlendLibReader *reader, Volume *volume) -{ - /* Needs to be done *after* cache pointers are restored (call to - * `foreach_cache`/`blo_cache_storage_entry_restore_in_new`), easier for now to do it in - * lib_link... */ - BKE_volume_init_grids(volume); - - for (int a = 0; a < volume->totcol; a++) { - BLO_read_id_address(reader, volume->id.lib, &volume->mat[a]); - } -} - -static void direct_link_volume(BlendDataReader *reader, Volume *volume) -{ - BLO_read_data_address(reader, &volume->adt); - BKE_animdata_blend_read_data(reader, volume->adt); - - BKE_packedfile_blend_read(reader, &volume->packedfile); - volume->runtime.frame = 0; - - /* materials */ - BLO_read_pointer_array(reader, (void **)&volume->mat); -} - -/** \} */ - /* -------------------------------------------------------------------- */ /** \name Read ID: Simulation * \{ */ @@ -6479,9 +6449,6 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID * case ID_WS: direct_link_workspace(&reader, (WorkSpace *)id, main); break; - case ID_VO: - direct_link_volume(&reader, (Volume *)id); - break; case ID_SIM: direct_link_simulation(&reader, (Simulation *)id); break; @@ -6512,6 +6479,7 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID * case ID_GD: case ID_HA: case ID_PT: + case ID_VO: /* Do nothing. Handled by IDTypeInfo callback. */ break; } @@ -7147,9 +7115,6 @@ static void lib_link_all(FileData *fd, Main *bmain) case ID_CF: lib_link_cachefiles(&reader, (CacheFile *)id); break; - case ID_VO: - lib_link_volume(&reader, (Volume *)id); - break; case ID_SIM: lib_link_simulation(&reader, (Simulation *)id); break; @@ -7187,6 +7152,7 @@ static void lib_link_all(FileData *fd, Main *bmain) case ID_GD: case ID_HA: case ID_PT: + case ID_VO: /* Do nothing. Handled by IDTypeInfo callback. */ break; } @@ -8130,13 +8096,6 @@ static void expand_workspace(BlendExpander *expander, WorkSpace *workspace) } } -static void expand_volume(BlendExpander *expander, Volume *volume) -{ - for (int a = 0; a < volume->totcol; a++) { - BLO_expand(expander, volume->mat[a]); - } -} - static void expand_simulation(BlendExpander *expander, Simulation *simulation) { LISTBASE_FOREACH (SimulationDependency *, dependency, &simulation->dependencies) { @@ -8211,9 +8170,6 @@ void BLO_expand_main(void *fdhandle, Main *mainvar) case ID_WS: expand_workspace(&expander, (WorkSpace *)id); break; - case ID_VO: - expand_volume(&expander, (Volume *)id); - break; case ID_SIM: expand_simulation(&expander, (Simulation *)id); break; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 386cdfc50eb..8390838163d 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2104,26 +2104,6 @@ static void write_workspace(BlendWriter *writer, WorkSpace *workspace, const voi } } -static void write_volume(BlendWriter *writer, Volume *volume, const void *id_address) -{ - if (volume->id.us > 0 || BLO_write_is_undo(writer)) { - /* Clean up, important in undo case to reduce false detection of changed datablocks. */ - volume->runtime.grids = 0; - - /* write LibData */ - BLO_write_id_struct(writer, Volume, id_address, &volume->id); - BKE_id_blend_write(writer, &volume->id); - - /* direct data */ - BLO_write_pointer_array(writer, volume->totcol, volume->mat); - if (volume->adt) { - BKE_animdata_blend_write(writer, volume->adt); - } - - BKE_packedfile_blend_write(writer, volume->packedfile); - } -} - static void write_simulation(BlendWriter *writer, Simulation *simulation, const void *id_address) { if (simulation->id.us > 0 || BLO_write_is_undo(writer)) { @@ -2461,9 +2441,6 @@ static bool write_file_handle(Main *mainvar, case ID_CF: write_cachefile(&writer, (CacheFile *)id_buffer, id); break; - case ID_VO: - write_volume(&writer, (Volume *)id_buffer, id); - break; case ID_SIM: write_simulation(&writer, (Simulation *)id_buffer, id); break; @@ -2494,6 +2471,7 @@ static bool write_file_handle(Main *mainvar, case ID_GD: case ID_HA: case ID_PT: + case ID_VO: /* Do nothing, handled in IDTypeInfo callback. */ break; case ID_LI: -- cgit v1.2.3