Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-09-11 11:35:36 +0300
committerJacques Lucke <jacques@blender.org>2020-09-11 11:35:36 +0300
commit16fecdf9944b96c5ed40c5f08b19f4b57f3c903a (patch)
tree0c6d3ef01d04a2b9261f66d0f257671f5ac858e4 /source
parentb2fc0678542a2496e834b68f10519310cd79e851 (diff)
Refactor: move Texture .blend I/O to IDTypeInfo callbacks
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/texture.c70
-rw-r--r--source/blender/blenloader/intern/readfile.c43
-rw-r--r--source/blender/blenloader/intern/writefile.c30
3 files changed, 69 insertions, 74 deletions
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 9e176f355d3..698f6b8cffd 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -36,6 +36,9 @@
#include "BLT_translation.h"
+/* Allow using deprecated functionality for .blend file I/O. */
+#define DNA_DEPRECATED_ALLOW
+
#include "DNA_brush_types.h"
#include "DNA_color_types.h"
#include "DNA_defaults.h"
@@ -50,6 +53,7 @@
#include "BKE_main.h"
+#include "BKE_anim_data.h"
#include "BKE_colorband.h"
#include "BKE_colortools.h"
#include "BKE_icons.h"
@@ -65,6 +69,8 @@
#include "RE_shader_ext.h"
+#include "BLO_read_write.h"
+
static void texture_init_data(ID *id)
{
Tex *texture = (Tex *)id;
@@ -134,6 +140,62 @@ static void texture_foreach_id(ID *id, LibraryForeachIDData *data)
BKE_LIB_FOREACHID_PROCESS(data, texture->ima, IDWALK_CB_USER);
}
+static void texture_blend_write(BlendWriter *writer, ID *id, const void *id_address)
+{
+ Tex *tex = (Tex *)id;
+ 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 texture_blend_read_data(BlendDataReader *reader, ID *id)
+{
+ Tex *tex = (Tex *)id;
+ 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;
+}
+
+static void texture_blend_read_lib(BlendLibReader *reader, ID *id)
+{
+ Tex *tex = (Tex *)id;
+ 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 texture_blend_read_expand(BlendExpander *expander, ID *id)
+{
+ Tex *tex = (Tex *)id;
+ BLO_expand(expander, tex->ima);
+ BLO_expand(expander, tex->ipo); // XXX deprecated - old animation system
+}
+
IDTypeInfo IDType_ID_TE = {
.id_code = ID_TE,
.id_filter = FILTER_ID_TE,
@@ -151,10 +213,10 @@ IDTypeInfo IDType_ID_TE = {
.foreach_id = texture_foreach_id,
.foreach_cache = NULL,
- .blend_write = NULL,
- .blend_read_data = NULL,
- .blend_read_lib = NULL,
- .blend_read_expand = NULL,
+ .blend_write = texture_blend_write,
+ .blend_read_data = texture_blend_read_data,
+ .blend_read_lib = texture_blend_read_lib,
+ .blend_read_expand = texture_blend_read_expand,
};
/* Utils for all IDs using those texture slots. */
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
@@ -2804,32 +2804,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: