diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2022-05-02 18:28:24 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2022-05-02 18:36:58 +0300 |
commit | 0d9e22d43ca18d8326aed33fabe3177dcf0663b8 (patch) | |
tree | c8a7e49048142f2d15657cf0b4d9062f57f71338 /source/blender/gpencil_modifiers/intern | |
parent | b1e0be0d2553742fcceda9cfe29ebb70f26b06a1 (diff) |
GPencil: New Noise modifier random in Keyframes only
This is for some animation styles that usually copy and paste keyframes and they want avoid that both frames look equal, but they don't want noise randomness changes in the inbetween frames.
The patch adds a new random `Mode` option to select when the noise change.
Reviewed By: pepeland
Maniphest Tasks: T97099
Differential Revision: https://developer.blender.org/D14566
Diffstat (limited to 'source/blender/gpencil_modifiers/intern')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c index fcf1e28c6da..259e62a249c 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c @@ -122,6 +122,8 @@ static void deformStroke(GpencilModifierData *md, 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 use_curve = (mmd->flag & GP_NOISE_CUSTOM_CURVE) != 0 && mmd->curve_intensity; + const int cfra = (int)DEG_get_ctime(depsgraph); + const bool is_keyframe = (mmd->noise_mode == GP_NOISE_RANDOM_KEYFRAME); if (!is_stroke_affected_by_modifier(ob, mmd->layername, @@ -148,7 +150,13 @@ static void deformStroke(GpencilModifierData *md, seed += BLI_hash_string(md->name); if (mmd->flag & GP_NOISE_USE_RANDOM) { - seed += ((int)DEG_get_ctime(depsgraph)) / mmd->step; + if (!is_keyframe) { + seed += cfra / mmd->step; + } + else { + /* If change every keyframe, use the last keyframe. */ + seed += gpf->framenum; + } } /* Sanitize as it can create out of bound reads. */ @@ -302,7 +310,12 @@ static void random_panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetActive(layout, RNA_boolean_get(ptr, "use_random")); - uiItemR(layout, ptr, "step", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "random_mode", 0, NULL, ICON_NONE); + + const int mode = RNA_enum_get(ptr, "random_mode"); + if (mode != GP_NOISE_RANDOM_KEYFRAME) { + uiItemR(layout, ptr, "step", 0, NULL, ICON_NONE); + } } static void mask_panel_draw(const bContext *UNUSED(C), Panel *panel) |