Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
| Show All 38 Lines | |||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "BKE_colortools.h" | #include "BKE_colortools.h" | ||||
| #include "BKE_deform.h" | #include "BKE_deform.h" | ||||
| #include "BKE_gpencil.h" | #include "BKE_gpencil.h" | ||||
| #include "BKE_gpencil_geom.h" | #include "BKE_gpencil_geom.h" | ||||
| #include "BKE_gpencil_modifier.h" | #include "BKE_gpencil_modifier.h" | ||||
| #include "BKE_lib_query.h" | |||||
| #include "BKE_modifier.h" | |||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "MOD_gpencil_modifiertypes.h" | #include "MOD_gpencil_modifiertypes.h" | ||||
| #include "MOD_gpencil_util.h" | #include "MOD_gpencil_util.h" | ||||
| static void initData(GpencilModifierData *md) | static void initData(GpencilModifierData *md) | ||||
| { | { | ||||
| NoiseGpencilModifierData *gpmd = (NoiseGpencilModifierData *)md; | NoiseGpencilModifierData *gpmd = (NoiseGpencilModifierData *)md; | ||||
| gpmd->pass_index = 0; | gpmd->pass_index = 0; | ||||
| gpmd->flag |= GP_NOISE_FULL_STROKE; | gpmd->flag |= GP_NOISE_FULL_STROKE; | ||||
| gpmd->flag |= GP_NOISE_USE_RANDOM; | gpmd->flag |= GP_NOISE_USE_RANDOM; | ||||
| gpmd->factor = 0.5f; | gpmd->factor = 0.5f; | ||||
| gpmd->layername[0] = '\0'; | gpmd->layername[0] = '\0'; | ||||
| gpmd->materialname[0] = '\0'; | gpmd->material = NULL; | ||||
| gpmd->vgname[0] = '\0'; | gpmd->vgname[0] = '\0'; | ||||
| gpmd->step = 4; | gpmd->step = 4; | ||||
| gpmd->seed = 1; | gpmd->seed = 1; | ||||
| gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); | gpmd->curve_intensity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); | ||||
| if (gpmd->curve_intensity) { | if (gpmd->curve_intensity) { | ||||
| CurveMapping *curve = gpmd->curve_intensity; | CurveMapping *curve = gpmd->curve_intensity; | ||||
| BKE_curvemap_reset(curve->cm, &curve->clipr, CURVE_PRESET_BELL, CURVEMAP_SLOPE_POSITIVE); | BKE_curvemap_reset(curve->cm, &curve->clipr, CURVE_PRESET_BELL, CURVEMAP_SLOPE_POSITIVE); | ||||
| BKE_curvemapping_initialize(curve); | BKE_curvemapping_initialize(curve); | ||||
| ▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | static void deformStroke(GpencilModifierData *md, | ||||
| float normal[3]; | float normal[3]; | ||||
| float vec1[3], vec2[3]; | float vec1[3], vec2[3]; | ||||
| const int def_nr = BKE_object_defgroup_name_index(ob, mmd->vgname); | const int def_nr = BKE_object_defgroup_name_index(ob, mmd->vgname); | ||||
| const bool invert_group = (mmd->flag & GP_NOISE_INVERT_VGROUP) != 0; | const bool invert_group = (mmd->flag & GP_NOISE_INVERT_VGROUP) != 0; | ||||
| const bool use_curve = (mmd->flag & GP_NOISE_CUSTOM_CURVE) != 0 && mmd->curve_intensity; | const bool use_curve = (mmd->flag & GP_NOISE_CUSTOM_CURVE) != 0 && mmd->curve_intensity; | ||||
| if (!is_stroke_affected_by_modifier(ob, | if (!is_stroke_affected_by_modifier(ob, | ||||
| mmd->layername, | mmd->layername, | ||||
| mmd->materialname, | mmd->material, | ||||
| mmd->pass_index, | mmd->pass_index, | ||||
| mmd->layer_pass, | mmd->layer_pass, | ||||
| 1, | 1, | ||||
| gpl, | gpl, | ||||
| gps, | gps, | ||||
| mmd->flag & GP_NOISE_INVERT_LAYER, | mmd->flag & GP_NOISE_INVERT_LAYER, | ||||
| mmd->flag & GP_NOISE_INVERT_PASS, | mmd->flag & GP_NOISE_INVERT_PASS, | ||||
| mmd->flag & GP_NOISE_INVERT_LAYERPASS, | mmd->flag & GP_NOISE_INVERT_LAYERPASS, | ||||
| ▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { | ||||
| LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) { | LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) { | ||||
| LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { | LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { | ||||
| deformStroke(md, depsgraph, ob, gpl, gpf, gps); | deformStroke(md, depsgraph, ob, gpl, gpf, gps); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) | |||||
| { | |||||
| NoiseGpencilModifierData *mmd = (NoiseGpencilModifierData *)md; | |||||
| walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_NOP); | |||||
| } | |||||
| GpencilModifierTypeInfo modifierType_Gpencil_Noise = { | GpencilModifierTypeInfo modifierType_Gpencil_Noise = { | ||||
| /* name */ "Noise", | /* name */ "Noise", | ||||
| /* structName */ "NoiseGpencilModifierData", | /* structName */ "NoiseGpencilModifierData", | ||||
| /* structSize */ sizeof(NoiseGpencilModifierData), | /* structSize */ sizeof(NoiseGpencilModifierData), | ||||
| /* type */ eGpencilModifierTypeType_Gpencil, | /* type */ eGpencilModifierTypeType_Gpencil, | ||||
| /* flags */ eGpencilModifierTypeFlag_SupportsEditmode, | /* flags */ eGpencilModifierTypeFlag_SupportsEditmode, | ||||
| /* copyData */ copyData, | /* copyData */ copyData, | ||||
| /* deformStroke */ deformStroke, | /* deformStroke */ deformStroke, | ||||
| /* generateStrokes */ NULL, | /* generateStrokes */ NULL, | ||||
| /* bakeModifier */ bakeModifier, | /* bakeModifier */ bakeModifier, | ||||
| /* remapTime */ NULL, | /* remapTime */ NULL, | ||||
| /* initData */ initData, | /* initData */ initData, | ||||
| /* freeData */ freeData, | /* freeData */ freeData, | ||||
| /* isDisabled */ NULL, | /* isDisabled */ NULL, | ||||
| /* updateDepsgraph */ NULL, | /* updateDepsgraph */ NULL, | ||||
| /* dependsOnTime */ dependsOnTime, | /* dependsOnTime */ dependsOnTime, | ||||
| /* foreachObjectLink */ NULL, | /* foreachObjectLink */ NULL, | ||||
| /* foreachIDLink */ NULL, | /* foreachIDLink */ foreachIDLink, | ||||
| /* foreachTexLink */ NULL, | /* foreachTexLink */ NULL, | ||||
| }; | }; | ||||