GPv3: Time offset modifier #118371

Merged
Lukas Tönne merged 34 commits from LukasTonne/blender:gp3-time-offset-modifier into main 2024-02-27 14:17:30 +01:00
Member

Port of the Time Offset modifier from GPv2.

Changed behavior

The GPv2 version of this modifier handles many edge cases incorrectly:

  1. The difference in scene frame range and the modifier frame range (matches scene range by default) should be added to the offset. But the modifier always uses 1 for the scene frame range.
  2. In Reverse mode, if there is an input keyframe on frame 1 (start of the range more generally) both the last frame and the second-to-last show the first frame. If the first input frame is empty the last two are empty and the output starts with the 2nd keyframe. This is clearly a bug and is corrected in the GPv3 implementation.
    image
    image
  3. Scaling affects frames unevenly, e.g. a scale of 0.5 should make every frame last 2 frames. But the result is that frame 1 lasts 3 frames and every subsequent frame lasts 2.
Port of the Time Offset modifier from GPv2. ## Changed behavior The GPv2 version of this modifier handles many edge cases incorrectly: 1. The difference in scene frame range and the modifier frame range (matches scene range by default) should be added to the offset. But the modifier always uses 1 for the scene frame range. 2. In _Reverse_ mode, if there is an input keyframe on frame 1 (start of the range more generally) both the last frame and the second-to-last show the first frame. If the first input frame is empty the last two are empty and the output starts with the 2nd keyframe. This is clearly a bug and is corrected in the GPv3 implementation. ![image](/attachments/9bd9e0bf-2e8c-410a-b358-2b126008da71) ![image](/attachments/fe61dc78-714d-469a-836e-b6ab36651f5a) 3. Scaling affects frames unevenly, e.g. a scale of `0.5` should make every frame last 2 frames. But the result is that frame 1 lasts _3_ frames and every subsequent frame lasts 2.
Lukas Tönne added 4 commits 2024-02-16 12:30:11 +01:00
Lukas Tönne added 1 commit 2024-02-16 15:07:14 +01:00
Lukas Tönne force-pushed gp3-time-offset-modifier from 85b1e701d4 to 39ab85138e 2024-02-17 10:07:21 +01:00 Compare
Lukas Tönne added 1 commit 2024-02-19 09:16:10 +01:00
Lukas Tönne added 1 commit 2024-02-19 23:38:17 +01:00
Lukas Tönne added 1 commit 2024-02-20 00:33:06 +01:00
Lukas Tönne added 1 commit 2024-02-20 09:23:48 +01:00
Lukas Tönne added 2 commits 2024-02-20 15:14:18 +01:00
Lukas Tönne added 1 commit 2024-02-22 14:13:56 +01:00
Lukas Tönne added 1 commit 2024-02-22 15:01:04 +01:00
Lukas Tönne added 1 commit 2024-02-22 16:48:43 +01:00
Lukas Tönne added 1 commit 2024-02-23 14:48:34 +01:00
Lukas Tönne added 1 commit 2024-02-23 16:29:22 +01:00
Lukas Tönne added 2 commits 2024-02-24 10:41:11 +01:00
Lukas Tönne added 1 commit 2024-02-24 11:11:47 +01:00
Lukas Tönne added 1 commit 2024-02-24 14:50:08 +01:00
Lukas Tönne added 1 commit 2024-02-24 16:07:24 +01:00
Lukas Tönne changed title from WIP: GPv3: Time offset modifier to GPv3: Time offset modifier 2024-02-24 16:07:54 +01:00
Lukas Tönne added this to the Grease Pencil project 2024-02-24 16:08:00 +01:00
Lukas Tönne added 1 commit 2024-02-26 11:11:34 +01:00
Lukas Tönne added 1 commit 2024-02-26 11:32:55 +01:00
6209b2f548 Fix memory leak when converting time offset and dash modifiers.
These modifiers create an initial segments array that must be freed
before replacing it with the converted segments array.
Falk David reviewed 2024-02-26 11:33:24 +01:00
Falk David left a comment
Member

I see that there is commented out code and a few #if 0s. Should this PR still be WIP ?

I see that there is commented out code and a few `#if 0`s. Should this PR still be `WIP` ?
Lukas Tönne added 3 commits 2024-02-26 12:01:34 +01:00
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
d85c4c739e
Implemented frame range limit function.
Falk David requested changes 2024-02-26 12:20:56 +01:00
Dismissed
Falk David left a comment
Member

Good job on making the code very readable 👍 I left a few cleanup comments.

Good job on making the code very readable 👍 I left a few cleanup comments.
@ -0,0 +134,4 @@
* reversing the direction. */
static const IndexRange find_key_range(const Span<int> sorted_keys, const FrameRange &frame_range)
{
IndexRange result = sorted_keys.index_range();
Member

Can be const

Can be `const`
Author
Member

Is modified below (after function was cleaned up), the function snips off the head and tail keys that don't affect the frame range, and then returns result.

Is modified below (after function was cleaned up), the function snips off the head and tail keys that don't affect the frame range, and then returns `result`.
LukasTonne marked this conversation as resolved
@ -0,0 +449,4 @@
const auto mode = GreasePencilTimeModifierMode(tmd.mode);
const bool use_custom_range = tmd.flag & MOD_GREASE_PENCIL_TIME_CUSTOM_RANGE;
const Scene *scene = DEG_get_evaluated_scene(ctx.depsgraph);
Member

I think fill_scene_timeline should just get a const Scene &eval_scene (instead of const ModifierEvalContext &ctx). Then DEG_get_evaluated_scene can just be called once before the loop over the layers in modify_geometry_set.

I think `fill_scene_timeline` should just get a `const Scene &eval_scene` (instead of `const ModifierEvalContext &ctx`). Then `DEG_get_evaluated_scene` can just be called once before the loop over the layers in `modify_geometry_set`.
LukasTonne marked this conversation as resolved
@ -0,0 +497,4 @@
const IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask(
grease_pencil, tmd->influence, mask_memory);
for (const int64_t i : layer_mask.index_range()) {
Member

Would be a bit better to use the foreach_index API here:

const Span<Layer *> layers_for_write = grease_pencil.layers_for_write();
layer_mask.foreach_index([&] (const int64_t layer_i) {
   Layer &layer = *layers_for_write[layer_i];
   ...
});
Would be a bit better to use the `foreach_index` API here: ``` const Span<Layer *> layers_for_write = grease_pencil.layers_for_write(); layer_mask.foreach_index([&] (const int64_t layer_i) { Layer &layer = *layers_for_write[layer_i]; ... }); ```
LukasTonne marked this conversation as resolved
Member

@blender-bot build

@blender-bot build
Lukas Tönne added 1 commit 2024-02-26 12:28:51 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
79e3c23baa
Use correct source frame range in chain mode if scene start is not 1.
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne added 2 commits 2024-02-26 12:36:34 +01:00
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne added 1 commit 2024-02-26 17:01:15 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
6870416a65
Merge branch 'main' into gp3-time-offset-modifier
Author
Member

@blender-bot build

@blender-bot build
Falk David approved these changes 2024-02-26 17:04:06 +01:00
Falk David left a comment
Member

Thanks, looks good.

Thanks, looks good.
Lukas Tönne added 1 commit 2024-02-26 18:13:46 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
81e6c0e681
Fix invalid frame data access in case the key gets clamped.
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne added 1 commit 2024-02-27 12:50:38 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
b85cd52dfb
Merge branch 'main' into gp3-time-offset-modifier
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne added 1 commit 2024-02-27 13:50:02 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
efd9c5aa99
Merge branch 'main' into gp3-time-offset-modifier
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne merged commit c6e5e62f45 into main 2024-02-27 14:17:30 +01:00
Lukas Tönne deleted branch gp3-time-offset-modifier 2024-02-27 14:17:33 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#118371
No description provided.