Refactor: Move brush foreach_id to new IDTypeInfo structure.
This commit is contained in:
parent
e4890fa564
commit
4da3044abc
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue