diff options
Diffstat (limited to 'source/blender/gpencil_modifiers')
22 files changed, 388 insertions, 106 deletions
diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index 87743911add..d3c85b891c6 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -56,6 +56,7 @@ set(SRC intern/MOD_gpencilsimplify.c intern/MOD_gpencilsmooth.c intern/MOD_gpencilsubdiv.c + intern/MOD_gpenciltexture.c intern/MOD_gpencilthick.c intern/MOD_gpenciltime.c intern/MOD_gpenciltint.c diff --git a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h index f5c064c1c07..a7a4333d82e 100644 --- a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h +++ b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h @@ -43,6 +43,7 @@ extern GpencilModifierTypeInfo modifierType_Gpencil_Offset; extern GpencilModifierTypeInfo modifierType_Gpencil_Armature; extern GpencilModifierTypeInfo modifierType_Gpencil_Time; extern GpencilModifierTypeInfo modifierType_Gpencil_Multiply; +extern GpencilModifierTypeInfo modifierType_Gpencil_Texture; /* MOD_gpencil_util.c */ void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[]); diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c index 7df0440aa85..f7929b58650 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c @@ -72,13 +72,14 @@ void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[]) INIT_GP_TYPE(Armature); INIT_GP_TYPE(Time); INIT_GP_TYPE(Multiply); + INIT_GP_TYPE(Texture); #undef INIT_GP_TYPE } /* verify if valid layer, material and pass index */ bool is_stroke_affected_by_modifier(Object *ob, char *mlayername, - char *mmaterialname, + Material *material, const int mpassindex, const int gpl_passindex, const int minpoints, @@ -105,15 +106,15 @@ bool is_stroke_affected_by_modifier(Object *ob, } } } - /* omit if filter by material */ - if (mmaterialname[0] != '\0') { + /* Omit if filter by material. */ + if (material != NULL) { if (inv4 == false) { - if (!STREQ(mmaterialname, ma->id.name + 2)) { + if (material != ma) { return false; } } else { - if (STREQ(mmaterialname, ma->id.name + 2)) { + if (material == ma) { return false; } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h index fc4522bc028..5cc3750639b 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h @@ -34,7 +34,7 @@ struct bGPDstroke; bool is_stroke_affected_by_modifier(struct Object *ob, char *mlayername, - char *mmaterialname, + struct Material *material, const int mpassindex, const int gpl_passindex, const int minpoints, diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c index 59a41901a48..2d5e01ced94 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2018, Blender Foundation @@ -63,7 +63,7 @@ static void initData(GpencilModifierData *md) static void copyData(const GpencilModifierData *md, GpencilModifierData *target) { - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); } static void gpencil_deform_verts(ArmatureGpencilModifierData *mmd, Object *target, bGPDstroke *gps) @@ -127,7 +127,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData Scene *scene = DEG_get_evaluated_scene(depsgraph); Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)md; - GpencilModifierData *md_eval = BKE_gpencil_modifiers_findByName(object_eval, md->name); + GpencilModifierData *md_eval = BKE_gpencil_modifiers_findby_name(object_eval, md->name); bGPdata *gpd = (bGPdata *)ob->data; int oldframe = (int)DEG_get_ctime(depsgraph); diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c index 314879927ff..da4c1f71f44 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2017, Blender Foundation @@ -77,11 +77,12 @@ static void initData(GpencilModifierData *md) gpmd->object = NULL; gpmd->flag |= GP_ARRAY_USE_RELATIVE; gpmd->seed = 1; + gpmd->material = NULL; } static void copyData(const GpencilModifierData *md, GpencilModifierData *target) { - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); } /* -------------------------------- */ @@ -163,7 +164,7 @@ static void generate_geometry(GpencilModifierData *md, LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { if (is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, 1, @@ -320,6 +321,15 @@ static void foreachObjectLink(GpencilModifierData *md, walk(userData, ob, &mmd->object, IDWALK_CB_NOP); } +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + ArrayGpencilModifierData *mmd = (ArrayGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); + + foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData); +} + GpencilModifierTypeInfo modifierType_Gpencil_Array = { /* name */ "Array", /* structName */ "ArrayGpencilModifierData", @@ -340,6 +350,6 @@ GpencilModifierTypeInfo modifierType_Gpencil_Array = { /* updateDepsgraph */ updateDepsgraph, /* dependsOnTime */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c index 435559f4881..71a051629d8 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2017, Blender Foundation @@ -63,7 +63,7 @@ static void initData(GpencilModifierData *md) static void copyData(const GpencilModifierData *md, GpencilModifierData *target) { - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); } static bool dependsOnTime(GpencilModifierData *UNUSED(md)) @@ -406,6 +406,7 @@ static void generate_geometry(GpencilModifierData *md, { BuildGpencilModifierData *mmd = (BuildGpencilModifierData *)md; const bool reverse = (mmd->transition != GP_BUILD_TRANSITION_GROW); + const bool is_percentage = (mmd->flag & GP_BUILD_PERCENTAGE); const float ctime = DEG_get_ctime(depsgraph); @@ -462,8 +463,8 @@ static void generate_geometry(GpencilModifierData *md, } /* Early exit if current frame is outside start/end bounds */ - /* NOTE: If we're beyond the next/prev frames (if existent), then we wouldn't have this problem - * anyway... */ + /* NOTE: If we're beyond the next/previous frames (if existent), + * then we wouldn't have this problem anyway... */ if (ctime < start_frame) { /* Before Start - Animation hasn't started. Display initial state. */ if (reverse) { @@ -500,7 +501,8 @@ static void generate_geometry(GpencilModifierData *md, } /* Determine how far along we are between the keyframes */ - float fac = (ctime - start_frame) / (end_frame - start_frame); + float fac = is_percentage ? mmd->percentage_fac : + (ctime - start_frame) / (end_frame - start_frame); /* Time management mode */ switch (mmd->mode) { diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c index d311e77b9e3..14125d5c8d4 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2017, Blender Foundation @@ -37,8 +37,10 @@ #include "BKE_colortools.h" #include "BKE_gpencil.h" #include "BKE_gpencil_modifier.h" +#include "BKE_lib_query.h" #include "BKE_main.h" #include "BKE_material.h" +#include "BKE_modifier.h" #include "DEG_depsgraph.h" @@ -50,8 +52,7 @@ static void initData(GpencilModifierData *md) ColorGpencilModifierData *gpmd = (ColorGpencilModifierData *)md; gpmd->pass_index = 0; ARRAY_SET_ITEMS(gpmd->hsv, 0.5f, 1.0f, 1.0f); - gpmd->layername[0] = '\0'; - gpmd->materialname[0] = '\0'; + gpmd->material = NULL; gpmd->modify_color = GP_MODIFY_COLOR_BOTH; gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); @@ -71,7 +72,7 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target) tgmd->curve_intensity = NULL; } - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); tgmd->curve_intensity = BKE_curvemapping_copy(gmd->curve_intensity); } @@ -91,7 +92,7 @@ static void deformStroke(GpencilModifierData *md, if (!is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, 1, @@ -178,6 +179,13 @@ static void freeData(GpencilModifierData *md) } } +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + ColorGpencilModifierData *mmd = (ColorGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); +} + GpencilModifierTypeInfo modifierType_Gpencil_Color = { /* name */ "Hue/Saturation", /* structName */ "ColorGpencilModifierData", @@ -198,6 +206,6 @@ GpencilModifierTypeInfo modifierType_Gpencil_Color = { /* updateDepsgraph */ NULL, /* dependsOnTime */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c index 76f22fc9a36..d39c94e06d5 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2017, Blender Foundation @@ -77,9 +77,7 @@ static void initData(GpencilModifierData *md) { HookGpencilModifierData *gpmd = (HookGpencilModifierData *)md; gpmd->pass_index = 0; - gpmd->layername[0] = '\0'; - gpmd->materialname[0] = '\0'; - gpmd->vgname[0] = '\0'; + gpmd->material = NULL; gpmd->object = NULL; gpmd->force = 0.5f; gpmd->falloff_type = eGPHook_Falloff_Smooth; @@ -99,7 +97,7 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target) tgmd->curfalloff = NULL; } - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); tgmd->curfalloff = BKE_curvemapping_copy(gmd->curfalloff); } @@ -208,7 +206,7 @@ static void deformStroke(GpencilModifierData *md, if (!is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, 1, @@ -338,6 +336,15 @@ static void foreachObjectLink(GpencilModifierData *md, walk(userData, ob, &mmd->object, IDWALK_CB_NOP); } +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + HookGpencilModifierData *mmd = (HookGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); + + foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData); +} + GpencilModifierTypeInfo modifierType_Gpencil_Hook = { /* name */ "Hook", /* structName */ "HookGpencilModifierData", @@ -358,6 +365,6 @@ GpencilModifierTypeInfo modifierType_Gpencil_Hook = { /* updateDepsgraph */ updateDepsgraph, /* dependsOnTime */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c index 73b3c332a2e..5d5d673ca55 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2017, Blender Foundation @@ -55,9 +55,7 @@ static void initData(GpencilModifierData *md) { LatticeGpencilModifierData *gpmd = (LatticeGpencilModifierData *)md; gpmd->pass_index = 0; - gpmd->layername[0] = '\0'; - gpmd->materialname[0] = '\0'; - gpmd->vgname[0] = '\0'; + gpmd->material = NULL; gpmd->object = NULL; gpmd->cache_data = NULL; gpmd->strength = 1.0f; @@ -65,7 +63,7 @@ static void initData(GpencilModifierData *md) static void copyData(const GpencilModifierData *md, GpencilModifierData *target) { - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); } static void deformStroke(GpencilModifierData *md, @@ -80,7 +78,7 @@ static void deformStroke(GpencilModifierData *md, if (!is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, 1, @@ -200,6 +198,15 @@ static void foreachObjectLink(GpencilModifierData *md, walk(userData, ob, &mmd->object, IDWALK_CB_NOP); } +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + LatticeGpencilModifierData *mmd = (LatticeGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); + + foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData); +} + GpencilModifierTypeInfo modifierType_Gpencil_Lattice = { /* name */ "Lattice", /* structName */ "LatticeGpencilModifierData", @@ -220,6 +227,6 @@ GpencilModifierTypeInfo modifierType_Gpencil_Lattice = { /* updateDepsgraph */ updateDepsgraph, /* dependsOnTime */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c index 09c0697eca5..10f0dd763b1 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2018, Blender Foundation @@ -57,15 +57,14 @@ static void initData(GpencilModifierData *md) { MirrorGpencilModifierData *gpmd = (MirrorGpencilModifierData *)md; gpmd->pass_index = 0; - gpmd->layername[0] = '\0'; - gpmd->materialname[0] = '\0'; + gpmd->material = NULL; gpmd->object = NULL; gpmd->flag |= GP_MIRROR_AXIS_X; } static void copyData(const GpencilModifierData *md, GpencilModifierData *target) { - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); } /* Mirror is using current object as origin. */ @@ -163,7 +162,7 @@ static void generate_geometry(GpencilModifierData *md, Object *ob, bGPDlayer *gp for (i = 0, gps = gpf->strokes.first; i < tot_strokes; i++, gps = gps->next) { if (is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, 1, @@ -246,6 +245,15 @@ static void foreachObjectLink(GpencilModifierData *md, walk(userData, ob, &mmd->object, IDWALK_CB_NOP); } +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + MirrorGpencilModifierData *mmd = (MirrorGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); + + foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData); +} + GpencilModifierTypeInfo modifierType_Gpencil_Mirror = { /* name */ "Mirror", /* structName */ "MirrorGpencilModifierData", @@ -266,6 +274,6 @@ GpencilModifierTypeInfo modifierType_Gpencil_Mirror = { /* updateDepsgraph */ updateDepsgraph, /* dependsOnTime */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c index 2552f527a5e..22e46626a13 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2017, Blender Foundation @@ -71,11 +71,12 @@ static void initData(GpencilModifierData *md) mmd->fading_center = 0.5f; mmd->fading_thickness = 0.5f; mmd->fading_opacity = 0.5f; + mmd->material = NULL; } static void copyData(const GpencilModifierData *md, GpencilModifierData *target) { - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); } static void minter_v3_v3v3v3_ref( @@ -211,7 +212,7 @@ static void bakeModifier(Main *UNUSED(bmain), for (gps = gpf->strokes.first; gps; gps = gps->next) { if (!is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, 1, @@ -252,7 +253,7 @@ static void generate_geometry(GpencilModifierData *md, Object *ob, bGPDlayer *gp for (gps = gpf->strokes.first; gps; gps = gps->next) { if (!is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, 1, @@ -297,6 +298,13 @@ static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, Objec } } +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + MultiplyGpencilModifierData *mmd = (MultiplyGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); +} + GpencilModifierTypeInfo modifierType_Gpencil_Multiply = { /* name */ "Multiple Strokes", /* structName */ "MultiplyGpencilModifierData", @@ -317,6 +325,6 @@ GpencilModifierTypeInfo modifierType_Gpencil_Multiply = { /* updateDepsgraph */ NULL, /* dependsOnTime */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c index 5ed08e39197..82f9d9a323d 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2017, Blender Foundation @@ -44,6 +44,8 @@ #include "BKE_gpencil.h" #include "BKE_gpencil_geom.h" #include "BKE_gpencil_modifier.h" +#include "BKE_lib_query.h" +#include "BKE_modifier.h" #include "BKE_object.h" #include "DEG_depsgraph.h" @@ -59,9 +61,7 @@ static void initData(GpencilModifierData *md) gpmd->flag |= GP_NOISE_FULL_STROKE; gpmd->flag |= GP_NOISE_USE_RANDOM; gpmd->factor = 0.5f; - gpmd->layername[0] = '\0'; - gpmd->materialname[0] = '\0'; - gpmd->vgname[0] = '\0'; + gpmd->material = NULL; gpmd->step = 4; gpmd->seed = 1; gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); @@ -91,7 +91,7 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target) tgmd->curve_intensity = NULL; } - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); tgmd->curve_intensity = BKE_curvemapping_copy(gmd->curve_intensity); } @@ -135,7 +135,7 @@ static void deformStroke(GpencilModifierData *md, if (!is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, 1, @@ -259,6 +259,13 @@ static void bakeModifier(struct Main *UNUSED(bmain), } } +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + NoiseGpencilModifierData *mmd = (NoiseGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); +} + GpencilModifierTypeInfo modifierType_Gpencil_Noise = { /* name */ "Noise", /* structName */ "NoiseGpencilModifierData", @@ -279,6 +286,6 @@ GpencilModifierTypeInfo modifierType_Gpencil_Noise = { /* updateDepsgraph */ NULL, /* dependsOnTime */ dependsOnTime, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c index a78de314c21..686f589ffe9 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2017, Blender Foundation @@ -38,6 +38,8 @@ #include "BKE_deform.h" #include "BKE_gpencil_geom.h" #include "BKE_gpencil_modifier.h" +#include "BKE_lib_query.h" +#include "BKE_modifier.h" #include "DEG_depsgraph.h" @@ -48,9 +50,7 @@ static void initData(GpencilModifierData *md) { OffsetGpencilModifierData *gpmd = (OffsetGpencilModifierData *)md; gpmd->pass_index = 0; - gpmd->layername[0] = '\0'; - gpmd->materialname[0] = '\0'; - gpmd->vgname[0] = '\0'; + gpmd->material = NULL; ARRAY_SET_ITEMS(gpmd->loc, 0.0f, 0.0f, 0.0f); ARRAY_SET_ITEMS(gpmd->rot, 0.0f, 0.0f, 0.0f); ARRAY_SET_ITEMS(gpmd->scale, 0.0f, 0.0f, 0.0f); @@ -58,7 +58,7 @@ static void initData(GpencilModifierData *md) static void copyData(const GpencilModifierData *md, GpencilModifierData *target) { - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); } /* change stroke offsetness */ @@ -77,7 +77,7 @@ static void deformStroke(GpencilModifierData *md, if (!is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, 1, @@ -129,6 +129,13 @@ static void bakeModifier(struct Main *UNUSED(bmain), } } +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + OffsetGpencilModifierData *mmd = (OffsetGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); +} + GpencilModifierTypeInfo modifierType_Gpencil_Offset = { /* name */ "Offset", /* structName */ "OffsetGpencilModifierData", @@ -149,6 +156,6 @@ GpencilModifierTypeInfo modifierType_Gpencil_Offset = { /* updateDepsgraph */ NULL, /* dependsOnTime */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c index 5ca99be0dff..92b2621d211 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2017, Blender Foundation @@ -38,8 +38,10 @@ #include "BKE_deform.h" #include "BKE_gpencil.h" #include "BKE_gpencil_modifier.h" +#include "BKE_lib_query.h" #include "BKE_main.h" #include "BKE_material.h" +#include "BKE_modifier.h" #include "DEG_depsgraph.h" @@ -52,9 +54,7 @@ static void initData(GpencilModifierData *md) gpmd->pass_index = 0; gpmd->factor = 1.0f; gpmd->hardeness = 1.0f; - gpmd->layername[0] = '\0'; - gpmd->materialname[0] = '\0'; - gpmd->vgname[0] = '\0'; + gpmd->material = NULL; gpmd->modify_color = GP_MODIFY_COLOR_BOTH; gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (gpmd->curve_intensity) { @@ -73,7 +73,7 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target) tgmd->curve_intensity = NULL; } - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); tgmd->curve_intensity = BKE_curvemapping_copy(gmd->curve_intensity); } @@ -92,7 +92,7 @@ static void deformStroke(GpencilModifierData *md, if (!is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, 1, @@ -189,6 +189,13 @@ static void freeData(GpencilModifierData *md) } } +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + OpacityGpencilModifierData *mmd = (OpacityGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); +} + GpencilModifierTypeInfo modifierType_Gpencil_Opacity = { /* name */ "Opacity", /* structName */ "OpacityGpencilModifierData", @@ -209,6 +216,6 @@ GpencilModifierTypeInfo modifierType_Gpencil_Opacity = { /* updateDepsgraph */ NULL, /* dependsOnTime */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c index 7b914b2a3b0..2cda108682e 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2017, Blender Foundation @@ -34,6 +34,8 @@ #include "BKE_gpencil_geom.h" #include "BKE_gpencil_modifier.h" +#include "BKE_lib_query.h" +#include "BKE_modifier.h" #include "DEG_depsgraph.h" @@ -48,13 +50,12 @@ static void initData(GpencilModifierData *md) gpmd->factor = 0.0f; gpmd->length = 0.1f; gpmd->distance = 0.1f; - gpmd->layername[0] = '\0'; - gpmd->materialname[0] = '\0'; + gpmd->material = NULL; } static void copyData(const GpencilModifierData *md, GpencilModifierData *target) { - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); } static void deformStroke(GpencilModifierData *md, @@ -68,7 +69,7 @@ static void deformStroke(GpencilModifierData *md, if (!is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, mmd->mode == GP_SIMPLIFY_SAMPLE ? 3 : 4, @@ -123,6 +124,13 @@ static void bakeModifier(struct Main *UNUSED(bmain), } } +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + SimplifyGpencilModifierData *mmd = (SimplifyGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); +} + GpencilModifierTypeInfo modifierType_Gpencil_Simplify = { /* name */ "Simplify", /* structName */ "SimplifyGpencilModifierData", @@ -143,6 +151,6 @@ GpencilModifierTypeInfo modifierType_Gpencil_Simplify = { /* updateDepsgraph */ NULL, /* dependsOnTime */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c index fb9089ea6cb..e2e13b736e4 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2017, Blender Foundation @@ -35,6 +35,8 @@ #include "BKE_deform.h" #include "BKE_gpencil_geom.h" #include "BKE_gpencil_modifier.h" +#include "BKE_lib_query.h" +#include "BKE_modifier.h" #include "DEG_depsgraph.h" @@ -47,9 +49,7 @@ static void initData(GpencilModifierData *md) gpmd->pass_index = 0; gpmd->flag |= GP_SMOOTH_MOD_LOCATION; gpmd->factor = 0.5f; - gpmd->layername[0] = '\0'; - gpmd->materialname[0] = '\0'; - gpmd->vgname[0] = '\0'; + gpmd->material = NULL; gpmd->step = 1; gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); @@ -69,7 +69,7 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target) tgmd->curve_intensity = NULL; } - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); tgmd->curve_intensity = BKE_curvemapping_copy(gmd->curve_intensity); } @@ -88,7 +88,7 @@ static void deformStroke(GpencilModifierData *md, if (!is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, 3, @@ -167,6 +167,13 @@ static void freeData(GpencilModifierData *md) } } +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + SmoothGpencilModifierData *mmd = (SmoothGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); +} + GpencilModifierTypeInfo modifierType_Gpencil_Smooth = { /* name */ "Smooth", /* structName */ "SmoothGpencilModifierData", @@ -187,6 +194,6 @@ GpencilModifierTypeInfo modifierType_Gpencil_Smooth = { /* updateDepsgraph */ NULL, /* dependsOnTime */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c index 0fdc3694af2..072159136ce 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2017, Blender Foundation @@ -36,6 +36,8 @@ #include "BKE_gpencil_geom.h" #include "BKE_gpencil_modifier.h" +#include "BKE_lib_query.h" +#include "BKE_modifier.h" #include "DEG_depsgraph.h" @@ -47,13 +49,12 @@ static void initData(GpencilModifierData *md) SubdivGpencilModifierData *gpmd = (SubdivGpencilModifierData *)md; gpmd->pass_index = 0; gpmd->level = 1; - gpmd->layername[0] = '\0'; - gpmd->materialname[0] = '\0'; + gpmd->material = NULL; } static void copyData(const GpencilModifierData *md, GpencilModifierData *target) { - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); } /* subdivide stroke to get more control points */ @@ -72,7 +73,7 @@ static void deformStroke(GpencilModifierData *md, if (!is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, minimum_vert, @@ -104,6 +105,13 @@ static void bakeModifier(struct Main *UNUSED(bmain), } } +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + SubdivGpencilModifierData *mmd = (SubdivGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); +} + GpencilModifierTypeInfo modifierType_Gpencil_Subdiv = { /* name */ "Subdivide", /* structName */ "SubdivGpencilModifierData", @@ -124,6 +132,6 @@ GpencilModifierTypeInfo modifierType_Gpencil_Subdiv = { /* updateDepsgraph */ NULL, /* dependsOnTime */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c new file mode 100644 index 00000000000..a5adf12b617 --- /dev/null +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c @@ -0,0 +1,172 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2017, Blender Foundation + * This is a new part of Blender + */ + +/** \file + * \ingroup modifiers + */ + +#include <stdio.h> + +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "DNA_gpencil_modifier_types.h" +#include "DNA_gpencil_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BKE_colortools.h" +#include "BKE_deform.h" +#include "BKE_gpencil.h" +#include "BKE_gpencil_geom.h" +#include "BKE_gpencil_modifier.h" +#include "BKE_lib_query.h" +#include "BKE_modifier.h" + +#include "DEG_depsgraph.h" + +#include "MOD_gpencil_modifiertypes.h" +#include "MOD_gpencil_util.h" + +static void initData(GpencilModifierData *md) +{ + TextureGpencilModifierData *gpmd = (TextureGpencilModifierData *)md; + gpmd->fit_method = GP_TEX_CONSTANT_LENGTH; + gpmd->fill_rotation = 0.0f; + gpmd->fill_scale = 1.0f; + gpmd->fill_offset[0] = 0.0f; + gpmd->fill_offset[1] = 0.0f; + gpmd->uv_offset = 0.0f; + gpmd->uv_scale = 1.0f; + gpmd->pass_index = 0; + gpmd->material = NULL; +} + +static void copyData(const GpencilModifierData *md, GpencilModifierData *target) +{ + BKE_gpencil_modifier_copydata_generic(md, target); +} + +/* change stroke uv texture values */ +static void deformStroke(GpencilModifierData *md, + Depsgraph *UNUSED(depsgraph), + Object *ob, + bGPDlayer *gpl, + bGPDframe *UNUSED(gpf), + bGPDstroke *gps) +{ + TextureGpencilModifierData *mmd = (TextureGpencilModifierData *)md; + const int def_nr = BKE_object_defgroup_name_index(ob, mmd->vgname); + + if (!is_stroke_affected_by_modifier(ob, + mmd->layername, + mmd->material, + mmd->pass_index, + mmd->layer_pass, + 1, + gpl, + gps, + mmd->flag & GP_TEX_INVERT_LAYER, + mmd->flag & GP_TEX_INVERT_PASS, + mmd->flag & GP_TEX_INVERT_LAYERPASS, + mmd->flag & GP_TEX_INVERT_MATERIAL)) { + return; + } + if ((mmd->mode == FILL) || (mmd->mode == STROKE_AND_FILL)) { + gps->uv_rotation += mmd->fill_rotation; + gps->uv_translation[0] += mmd->fill_offset[0]; + gps->uv_translation[1] += mmd->fill_offset[1]; + gps->uv_scale *= mmd->fill_scale; + BKE_gpencil_stroke_geometry_update(gps); + } + + if ((mmd->mode == STROKE) || (mmd->mode == STROKE_AND_FILL)) { + float totlen = 1.0f; + if (mmd->fit_method == GP_TEX_FIT_STROKE) { + totlen = 0.0f; + for (int i = 1; i < gps->totpoints; i++) { + totlen += len_v3v3(&gps->points[i - 1].x, &gps->points[i].x); + } + } + + for (int i = 0; i < gps->totpoints; i++) { + bGPDspoint *pt = &gps->points[i]; + MDeformVert *dvert = gps->dvert != NULL ? &gps->dvert[i] : NULL; + /* Verify point is part of vertex group. */ + float weight = get_modifier_point_weight( + dvert, (mmd->flag & GP_TEX_INVERT_VGROUP) != 0, def_nr); + if (weight < 0.0f) { + continue; + } + + pt->uv_fac /= totlen; + pt->uv_fac *= mmd->uv_scale; + pt->uv_fac += mmd->uv_offset; + } + } +} + +static void bakeModifier(struct Main *UNUSED(bmain), + Depsgraph *depsgraph, + GpencilModifierData *md, + Object *ob) +{ + bGPdata *gpd = ob->data; + + LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { + LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) { + LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { + deformStroke(md, depsgraph, ob, gpl, gpf, gps); + } + } + } +} + +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + TextureGpencilModifierData *mmd = (TextureGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); +} + +GpencilModifierTypeInfo modifierType_Gpencil_Texture = { + /* name */ "Texture Mapping", + /* structName */ "TextureGpencilModifierData", + /* structSize */ sizeof(TextureGpencilModifierData), + /* type */ eGpencilModifierTypeType_Gpencil, + /* flags */ eGpencilModifierTypeFlag_SupportsEditmode, + + /* copyData */ copyData, + + /* deformStroke */ deformStroke, + /* generateStrokes */ NULL, + /* bakeModifier */ bakeModifier, + /* remapTime */ NULL, + + /* initData */ initData, + /* freeData */ NULL, + /* isDisabled */ NULL, + /* updateDepsgraph */ NULL, + /* dependsOnTime */ NULL, + /* foreachObjectLink */ NULL, + /* foreachIDLink */ foreachIDLink, + /* foreachTexLink */ NULL, +}; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c index 4d985652a1e..b9fadea7fd0 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2017, Blender Foundation @@ -37,6 +37,8 @@ #include "BKE_deform.h" #include "BKE_gpencil.h" #include "BKE_gpencil_modifier.h" +#include "BKE_lib_query.h" +#include "BKE_modifier.h" #include "DEG_depsgraph.h" @@ -49,9 +51,7 @@ static void initData(GpencilModifierData *md) gpmd->pass_index = 0; gpmd->thickness_fac = 1.0f; gpmd->thickness = 30; - gpmd->layername[0] = '\0'; - gpmd->materialname[0] = '\0'; - gpmd->vgname[0] = '\0'; + gpmd->material = NULL; gpmd->curve_thickness = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (gpmd->curve_thickness) { BKE_curvemapping_initialize(gpmd->curve_thickness); @@ -77,7 +77,7 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target) tgmd->curve_thickness = NULL; } - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); tgmd->curve_thickness = BKE_curvemapping_copy(gmd->curve_thickness); } @@ -95,7 +95,7 @@ static void deformStroke(GpencilModifierData *md, if (!is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, 1, @@ -159,6 +159,13 @@ static void bakeModifier(struct Main *UNUSED(bmain), } } +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + ThickGpencilModifierData *mmd = (ThickGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); +} + GpencilModifierTypeInfo modifierType_Gpencil_Thick = { /* name */ "Thickness", /* structName */ "ThickGpencilModifierData", @@ -179,6 +186,6 @@ GpencilModifierTypeInfo modifierType_Gpencil_Thick = { /* updateDepsgraph */ NULL, /* dependsOnTime */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c index 10463f865e2..85400b56cad 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2018, Blender Foundation @@ -45,7 +45,6 @@ static void initData(GpencilModifierData *md) { TimeGpencilModifierData *gpmd = (TimeGpencilModifierData *)md; - gpmd->layername[0] = '\0'; gpmd->offset = 1; gpmd->frame_scale = 1.0f; gpmd->flag |= GP_TIME_KEEP_LOOP; @@ -55,7 +54,7 @@ static void initData(GpencilModifierData *md) static void copyData(const GpencilModifierData *md, GpencilModifierData *target) { - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); } static int remapTime(struct GpencilModifierData *md, diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c index 95a7fb53018..c35728bc8b3 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c @@ -10,7 +10,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2017, Blender Foundation @@ -61,9 +61,7 @@ static void initData(GpencilModifierData *md) { TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md; gpmd->pass_index = 0; - gpmd->layername[0] = '\0'; - gpmd->materialname[0] = '\0'; - gpmd->vgname[0] = '\0'; + gpmd->material = NULL; gpmd->object = NULL; gpmd->radius = 1.0f; gpmd->factor = 0.5f; @@ -103,7 +101,7 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target) tgmd->curve_intensity = NULL; } - BKE_gpencil_modifier_copyData_generic(md, target); + BKE_gpencil_modifier_copydata_generic(md, target); if (gmd->colorband) { tgmd->colorband = MEM_dupallocN(gmd->colorband); @@ -130,7 +128,7 @@ static void deformStroke(GpencilModifierData *md, if (!is_stroke_affected_by_modifier(ob, mmd->layername, - mmd->materialname, + mmd->material, mmd->pass_index, mmd->layer_pass, 1, @@ -323,6 +321,15 @@ static void foreachObjectLink(GpencilModifierData *md, walk(userData, ob, &mmd->object, IDWALK_CB_NOP); } +static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) +{ + TintGpencilModifierData *mmd = (TintGpencilModifierData *)md; + + walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER); + + foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData); +} + GpencilModifierTypeInfo modifierType_Gpencil_Tint = { /* name */ "Tint", /* structName */ "TintGpencilModifierData", @@ -343,6 +350,6 @@ GpencilModifierTypeInfo modifierType_Gpencil_Tint = { /* updateDepsgraph */ updateDepsgraph, /* dependsOnTime */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, }; |