Animation: Paste Keys in Graph Editor with value offset #104512

Merged
Christoph Lendenfeld merged 12 commits from ChrisLend/blender:copy_paste_frame_range into main 2023-02-23 09:47:00 +01:00

Extend the GRAPH_OT_paste operator with an enum to define the value offset.

Options are:

Option Effect
No Offset use the same key values as the copied keys
Cursor Value align the leftmost key with the cursor value
Current Frame Value Evaluate the curve under the cursor align the leftmost key with it
Right Key Align the rightmost key with the first key that is to the right of the cursor
Left Key Align the leftmost key with the first key that is to the left of the cursor
Extend the `GRAPH_OT_paste` operator with an enum to define the value offset. Options are: | Option | Effect | | ------------------- | ----------------------------------------------------------------------------- | | No Offset | use the same key values as the copied keys | | Cursor Value | align the leftmost key with the cursor value | | Current Frame Value | Evaluate the curve under the cursor align the leftmost key with it | | Right Key | Align the rightmost key with the first key that is to the right of the cursor | | Left Key | Align the leftmost key with the first key that is to the left of the cursor |
Christoph Lendenfeld added the
Module
Animation & Rigging
label 2023-02-09 13:11:16 +01:00
Christoph Lendenfeld added 2 commits 2023-02-09 13:11:18 +01:00
Christoph Lendenfeld requested review from Sybren A. Stüvel 2023-02-09 13:11:31 +01:00
Author
Member

video demo
paste_keys_2023-01-27 13-47-04.mp4

video demo ![paste_keys_2023-01-27 13-47-04.mp4](/attachments/bc50c9ac-3c7d-4253-a347-23f2ba80a636)
Brecht Van Lommel added this to the Animation & Rigging project 2023-02-13 09:14:10 +01:00
Sybren A. Stüvel requested changes 2023-02-14 17:33:40 +01:00
Sybren A. Stüvel left a comment
Member

Nice work as always :)
Just a few minor things.

Nice work as always :) Just a few minor things.
@ -1138,0 +1140,4 @@
bezt->vec[0][1] += offset[1];
bezt->vec[1][1] += offset[1];
bezt->vec[2][1] += offset[1];

I think this would be clearer as:

add_v2_v2(bezt->vec[0], offset);
add_v2_v2(bezt->vec[1], offset);
add_v2_v2(bezt->vec[2], offset);

Same below with sub_v2_v2()

I think this would be clearer as: ```c add_v2_v2(bezt->vec[0], offset); add_v2_v2(bezt->vec[1], offset); add_v2_v2(bezt->vec[2], offset); ``` Same below with `sub_v2_v2()`
ChrisLend marked this conversation as resolved
@ -1191,0 +1231,4 @@
bAnimListElem *ale,
const eKeyPasteValueOffset value_offset_mode)
{
float offset;

Instead of having a variable offset, and having to track how it's changed in the code below, IMO it's better to just replace this

offset = ...;
break;

with

return ...;
Instead of having a variable `offset`, and having to track how it's changed in the code below, IMO it's better to just replace this ```c offset = ...; break; ``` with ```c return ...; ```

With this change, you don't even need the top-level variable float offset any more. If you want to keep a variable between the calculation and the return (can aid in debugging the code), use a const float offset = ... constant scoped to the case statement instead. Or just return sipo->cursorVal - aci->bezt[0].vec[1][1]; if you don't need the extra variable.

With this change, you don't even need the top-level variable `float offset` any more. If you want to keep a variable between the calculation and the `return` (can aid in debugging the code), use a `const float offset = ...` constant scoped to the `case` statement instead. Or just `return sipo->cursorVal - aci->bezt[0].vec[1][1];` if you don't need the extra variable.
dr.sybren marked this conversation as resolved
Christoph Lendenfeld added 2 commits 2023-02-16 17:16:30 +01:00
Christoph Lendenfeld requested review from Sybren A. Stüvel 2023-02-16 17:17:17 +01:00
Sybren A. Stüvel reviewed 2023-02-17 15:13:35 +01:00
@ -1191,0 +1257,4 @@
}
case KEYFRAME_PASTE_VALUE_OFFSET_NONE:
default:

You can remove the default:, that way the compiler can complain when a new value was added to the enum, but not handled here.

You can remove the `default:`, that way the compiler can complain when a new value was added to the enum, but not handled here.
ChrisLend marked this conversation as resolved
Christoph Lendenfeld added 2 commits 2023-02-17 15:38:14 +01:00
Sybren A. Stüvel requested changes 2023-02-17 15:53:48 +01:00
Sybren A. Stüvel left a comment
Member

Just two tiny things

Just two tiny things

Oh and some submodule changes snuck back in, be sure to revert them.

Oh and some submodule changes snuck back in, be sure to revert them.
Christoph Lendenfeld added 1 commit 2023-02-17 16:23:59 +01:00
Christoph Lendenfeld added 1 commit 2023-02-17 16:25:10 +01:00
Christoph Lendenfeld added 1 commit 2023-02-17 16:25:24 +01:00
Christoph Lendenfeld added 1 commit 2023-02-17 16:25:51 +01:00
Christoph Lendenfeld requested review from Sybren A. Stüvel 2023-02-17 16:27:15 +01:00
Sybren A. Stüvel approved these changes 2023-02-17 16:30:02 +01:00
Sybren A. Stüvel left a comment
Member

👍

:+1:
Christoph Lendenfeld added 1 commit 2023-02-17 18:09:02 +01:00
Christoph Lendenfeld added 1 commit 2023-02-23 09:30:13 +01:00
Christoph Lendenfeld merged commit 7267682017 into main 2023-02-23 09:47:00 +01:00
Christoph Lendenfeld deleted branch copy_paste_frame_range 2023-02-23 09:47:00 +01:00
Sybren A. Stüvel removed this from the Animation & Rigging project 2023-03-02 17:00:32 +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#104512
No description provided.