From 16fecdf9944b96c5ed40c5f08b19f4b57f3c903a Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 11 Sep 2020 10:35:36 +0200 Subject: Refactor: move Texture .blend I/O to IDTypeInfo callbacks --- source/blender/blenloader/intern/readfile.c | 43 ++-------------------------- source/blender/blenloader/intern/writefile.c | 30 +------------------ 2 files changed, 3 insertions(+), 70 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index b9f94b08558..8413fd94d2c 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2803,32 +2803,6 @@ void blo_do_versions_key_uidgen(Key *key) /** \} */ -/* -------------------------------------------------------------------- */ -/** \name Read ID: Texture - * \{ */ - -static void lib_link_texture(BlendLibReader *reader, Tex *tex) -{ - BLO_read_id_address(reader, tex->id.lib, &tex->ima); - BLO_read_id_address(reader, tex->id.lib, &tex->ipo); // XXX deprecated - old animation system -} - -static void direct_link_texture(BlendDataReader *reader, Tex *tex) -{ - BLO_read_data_address(reader, &tex->adt); - BKE_animdata_blend_read_data(reader, tex->adt); - - BLO_read_data_address(reader, &tex->coba); - - BLO_read_data_address(reader, &tex->preview); - BKE_previewimg_blend_read(reader, tex->preview); - - tex->iuser.ok = 1; - tex->iuser.scene = NULL; -} - -/** \} */ - /* -------------------------------------------------------------------- */ /** \name Read ID: Particle Settings * \{ */ @@ -6630,9 +6604,6 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID * case ID_OB: direct_link_object(&reader, (Object *)id); break; - case ID_TE: - direct_link_texture(&reader, (Tex *)id); - break; case ID_IP: direct_link_ipo(&reader, (Ipo *)id); break; @@ -6692,6 +6663,7 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID * case ID_AR: case ID_LP: case ID_KE: + case ID_TE: /* Do nothing. Handled by IDTypeInfo callback. */ break; } @@ -7336,9 +7308,6 @@ static void lib_link_all(FileData *fd, Main *bmain) case ID_VO: lib_link_volume(&reader, (Volume *)id); break; - case ID_TE: - lib_link_texture(&reader, (Tex *)id); - break; case ID_GD: lib_link_gpencil(&reader, (bGPdata *)id); break; @@ -7375,6 +7344,7 @@ static void lib_link_all(FileData *fd, Main *bmain) case ID_AR: case ID_LP: case ID_KE: + case ID_TE: /* Do nothing. Handled by IDTypeInfo callback. */ break; } @@ -8060,12 +8030,6 @@ static void expand_collection(BlendExpander *expander, Collection *collection) #endif } -static void expand_texture(BlendExpander *expander, Tex *tex) -{ - BLO_expand(expander, tex->ima); - BLO_expand(expander, tex->ipo); // XXX deprecated - old animation system -} - /* callback function used to expand constraint ID-links */ static void expand_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, @@ -8412,9 +8376,6 @@ void BLO_expand_main(void *fdhandle, Main *mainvar) case ID_SCE: expand_scene(&expander, (Scene *)id); break; - case ID_TE: - expand_texture(&expander, (Tex *)id); - break; case ID_SO: expand_sound(&expander, (bSound *)id); break; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index d4e3f4646d6..998bd0691ff 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1393,32 +1393,6 @@ static void write_object(BlendWriter *writer, Object *ob, const void *id_address } } -static void write_texture(BlendWriter *writer, Tex *tex, const void *id_address) -{ - if (tex->id.us > 0 || BLO_write_is_undo(writer)) { - /* write LibData */ - BLO_write_id_struct(writer, Tex, id_address, &tex->id); - BKE_id_blend_write(writer, &tex->id); - - if (tex->adt) { - BKE_animdata_blend_write(writer, tex->adt); - } - - /* direct data */ - if (tex->coba) { - BLO_write_struct(writer, ColorBand, tex->coba); - } - - /* nodetree is integral part of texture, no libdata */ - if (tex->nodetree) { - BLO_write_struct(writer, bNodeTree, tex->nodetree); - ntreeBlendWrite(writer, tex->nodetree); - } - - BKE_previewimg_blend_write(writer, tex->preview); - } -} - static void write_collection_nolib(BlendWriter *writer, Collection *collection) { /* Shared function for collection data-blocks and scene master collection. */ @@ -2580,9 +2554,6 @@ static bool write_file_handle(Main *mainvar, case ID_OB: write_object(&writer, (Object *)id_buffer, id); break; - case ID_TE: - write_texture(&writer, (Tex *)id_buffer, id); - break; case ID_PA: write_particlesettings(&writer, (ParticleSettings *)id_buffer, id); break; @@ -2627,6 +2598,7 @@ static bool write_file_handle(Main *mainvar, case ID_AR: case ID_LP: case ID_KE: + case ID_TE: /* Do nothing, handled in IDTypeInfo callback. */ break; case ID_LI: -- cgit v1.2.3