diff options
author | Aleš Jelovčan <frogstomp> | 2022-05-23 16:54:35 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2022-05-23 17:03:04 +0300 |
commit | 82d7234ed97f3ec1c0d4b7f8d752e69de2101d05 (patch) | |
tree | b15f273dc0c4ce817fd4acd82499094401a8f8de /source/blender/gpencil_modifiers/intern | |
parent | 698e394e7ef78eab38f0389fd013889ae0a425e7 (diff) |
GPencil: A Ping Pong effect to Time modifier
This patch adds 4th option to Time offset modifier Modes.
It loops from start frame to end frame and then back to start in reverse direction.
In other words it is a combination of Normal and Reverse mode.
Especially with offset control it adds the ability to create easy looping animations such as cheering crowds, flowers opening and closing at different offsets.
Reviewed By: #grease_pencil, antoniov, pepeland, mendio
Differential Revision: https://developer.blender.org/D14965
Diffstat (limited to 'source/blender/gpencil_modifiers/intern')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c index c576cfbe525..414231fcae5 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c @@ -122,6 +122,30 @@ static int remapTime(struct GpencilModifierData *md, nfra = (efra + 1 - (cfra + offset - 1) % (efra - sfra + 1)) - 1; } } + + if (mmd->mode == GP_TIME_MODE_PINGPONG) { + if ((mmd->flag & GP_TIME_KEEP_LOOP) == 0) { + if (((int)(cfra + offset - 1) / (efra - sfra)) % (2)) { + nfra = efra - (cfra + offset - 1) % (efra - sfra); + } + else { + nfra = sfra + (cfra + offset - 1) % (efra - sfra); + } + if (cfra > (efra - sfra) * 2) { + nfra = sfra + offset; + } + } + else { + + if (((int)(cfra + offset - 1) / (efra - sfra)) % (2)) { + nfra = efra - (cfra + offset - 1) % (efra - sfra); + } + else { + nfra = sfra + (cfra + offset - 1) % (efra - sfra); + } + } + } + return nfra; } |