diff options
author | Bastien Montagne <bastien@blender.org> | 2020-05-13 20:52:19 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-05-13 20:52:19 +0300 |
commit | 4da3044abccfb14153959832303325001ff2de1a (patch) | |
tree | 1e9189b1658c230e40bc4becc97041babb2b9c1a /source | |
parent | e4890fa564f2b798d48274b34a563e23f6f32bf5 (diff) |
Refactor: Move brush foreach_id to new IDTypeInfo structure.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_texture.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 15 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lib_query.c | 23 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 7 |
4 files changed, 29 insertions, 19 deletions
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index fb925565735..43ef2b1ba7f 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -31,6 +31,7 @@ struct Brush; struct ColorBand; struct FreestyleLineStyle; struct ImagePool; +struct LibraryForeachIDData; struct MTex; struct Main; struct ParticleSettings; @@ -42,6 +43,8 @@ struct TexResult; /** #ColorBand.data length. */ #define MAXCOLORBAND 32 +void BKE_texture_mtex_foreach_id(struct LibraryForeachIDData *data, struct MTex *mtex); + void BKE_texture_default(struct Tex *tex); struct Tex *BKE_texture_copy(struct Main *bmain, const struct Tex *tex); struct Tex *BKE_texture_add(struct Main *bmain, const char *name); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 0e6b9409404..c21dec16555 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -181,6 +181,20 @@ static void brush_make_local(Main *bmain, ID *id, const int flags) } } +static void brush_foreach_id(ID *id, LibraryForeachIDData *data) +{ + Brush *brush = (Brush *)id; + + BKE_LIB_FOREACHID_PROCESS(data, brush->toggle_brush, IDWALK_CB_NOP); + BKE_LIB_FOREACHID_PROCESS(data, brush->clone.image, IDWALK_CB_NOP); + BKE_LIB_FOREACHID_PROCESS(data, brush->paint_curve, IDWALK_CB_USER); + if (brush->gpencil_settings) { + BKE_LIB_FOREACHID_PROCESS(data, brush->gpencil_settings->material, IDWALK_CB_USER); + } + BKE_texture_mtex_foreach_id(data, &brush->mtex); + BKE_texture_mtex_foreach_id(data, &brush->mask_mtex); +} + IDTypeInfo IDType_ID_BR = { .id_code = ID_BR, .id_filter = FILTER_ID_BR, @@ -195,6 +209,7 @@ IDTypeInfo IDType_ID_BR = { .copy_data = brush_copy_data, .free_data = brush_free_data, .make_local = brush_make_local, + .foreach_id = brush_foreach_id, }; static RNG *brush_rng; diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index 71bf065d855..d922c5dd24c 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -81,6 +81,7 @@ #include "BKE_rigidbody.h" #include "BKE_sequencer.h" #include "BKE_shader_fx.h" +#include "BKE_texture.h" #include "BKE_workspace.h" #define FOREACH_FINALIZE _finalize @@ -318,14 +319,6 @@ static void library_foreach_animationData(LibraryForeachIDData *data, AnimData * FOREACH_FINALIZE_VOID; } -static void library_foreach_mtex(LibraryForeachIDData *data, MTex *mtex) -{ - FOREACH_CALLBACK_INVOKE(data, mtex->object, IDWALK_CB_NOP); - FOREACH_CALLBACK_INVOKE(data, mtex->tex, IDWALK_CB_USER); - - FOREACH_FINALIZE_VOID; -} - static void library_foreach_paint(LibraryForeachIDData *data, Paint *paint) { FOREACH_CALLBACK_INVOKE(data, paint->brush, IDWALK_CB_USER); @@ -964,15 +957,7 @@ static void library_foreach_ID_link(Main *bmain, } case ID_BR: { - Brush *brush = (Brush *)id; - CALLBACK_INVOKE(brush->toggle_brush, IDWALK_CB_NOP); - CALLBACK_INVOKE(brush->clone.image, IDWALK_CB_NOP); - CALLBACK_INVOKE(brush->paint_curve, IDWALK_CB_USER); - if (brush->gpencil_settings) { - CALLBACK_INVOKE(brush->gpencil_settings->material, IDWALK_CB_USER); - } - library_foreach_mtex(&data, &brush->mtex); - library_foreach_mtex(&data, &brush->mask_mtex); + BLI_assert(0); break; } @@ -985,7 +970,7 @@ static void library_foreach_ID_link(Main *bmain, for (i = 0; i < MAX_MTEX; i++) { if (psett->mtex[i]) { - library_foreach_mtex(&data, psett->mtex[i]); + BKE_texture_mtex_foreach_id(&data, psett->mtex[i]); } } @@ -1063,7 +1048,7 @@ static void library_foreach_ID_link(Main *bmain, for (i = 0; i < MAX_MTEX; i++) { if (linestyle->mtex[i]) { - library_foreach_mtex(&data, linestyle->mtex[i]); + BKE_texture_mtex_foreach_id(&data, linestyle->mtex[i]); } } if (linestyle->nodetree) { diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 49c5c073f49..e2c3c20e36e 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -151,6 +151,13 @@ IDTypeInfo IDType_ID_TE = { .foreach_id = texture_foreach_id, }; +/* Utils for all IDs using those texture slots. */ +void BKE_texture_mtex_foreach_id(LibraryForeachIDData *data, MTex *mtex) +{ + BKE_LIB_FOREACHID_PROCESS(data, mtex->object, IDWALK_CB_NOP); + BKE_LIB_FOREACHID_PROCESS(data, mtex->tex, IDWALK_CB_USER); +} + /* ****************** Mapping ******************* */ TexMapping *BKE_texture_mapping_add(int type) |