Anim: Insert keyframes without keying sets #113504

Merged
Christoph Lendenfeld merged 59 commits from ChrisLend/blender:keying_sets_rework into main 2023-11-21 15:38:09 +01:00

Part of #113278: Anim: Keyframing Rework

When animators want to key something in the viewport, the code needs to know which properties should be keyed of that selected thing. So far that was done with keying sets, and a pop-up that let's you choose the keying set to use. You can get rid of the popup by choosing a keying set ahead of time. But that is also not always desirable.

That pop-up is quite confusing and gives way too many options. To simplify this process this PR adds a User Preference option to choose one or more of:

  • Location
  • Rotation
  • Scale
  • Rotation Mode
  • Custom Properties

Now whenever the I key is pressed in the viewport, and no keying set is enabled, it reads the preferences for which channels to insert.

User Facing changes

  • The popup will not be shown when pressing the hotkey, but you can still explicitly use keying sets by going to the menu
  • Which channels are keyed is defined by a User Preference setting under animation
  • when a keying set is used explicitly, the User Preference settings are ignored
    image

Code side changes

There is now a code path for inserting keyframes, that completely bypasses the keying set system.
In a nutshell, the flow looks like this: operator -> insert_key_action - > insert_vert_fcurve
The idea is that with the animation 2025 project, the operator would call insert_key_animation instead and the replacement would be quite seamless.
I had to remove the type enum property on the ANIM_OT_keyframe_insert operator. This is a breaking change of the python api, and I am not sure this is a good idea for 4.1
The reason why I did it anyway is that I don't think this enum was used much from python since the enum order can change if you have custom keying sets. I would love feedback on this though. Whatever we do, there needs to be a way to tell blender to ignore the enum which I am not sure how to do properly.

Future plans

Rework the keying sets to hook into this new code path instead of going their own ways. They both eventually call insert_vert_fcurve, but the functions used for keying sets have so many arguments it was not feasable to do it with this PR.

TODO

  • convert scene_frame to nla_frame
  • read active keyingset from scene instead of presenting a popup
  • make work for bones
  • correctly assign fcurve groups
  • make a meny entry "Insert key with keying set"
  • tag depsgraph for an update when an fcurve has been created
  • Cycle aware keying support when creating FCurves
  • properly pass keyframe flags
  • Unit tests
Part of [#113278: Anim: Keyframing Rework](https://projects.blender.org/blender/blender/issues/113278) When animators want to key something in the viewport, the code needs to know *which properties* should be keyed of that selected thing. So far that was done with keying sets, and a pop-up that let's you choose the keying set to use. You can get rid of the popup by choosing a keying set ahead of time. But that is also not always desirable. That pop-up is quite confusing and gives way too many options. To simplify this process this PR adds a User Preference option to choose one or more of: * Location * Rotation * Scale * Rotation Mode * Custom Properties Now whenever the `I` key is pressed in the viewport, and no keying set is enabled, it reads the preferences for which channels to insert. # User Facing changes * The popup will not be shown when pressing the hotkey, but you can still explicitly use keying sets by going to the menu * Which channels are keyed is defined by a User Preference setting under animation * when a keying set is used explicitly, the User Preference settings are ignored ![image](/attachments/1b653639-f66a-4b1f-ad44-0278ea6b7fbc) # Code side changes There is now a code path for inserting keyframes, that completely bypasses the keying set system. In a nutshell, the flow looks like this: `operator` -> `insert_key_action` - > `insert_vert_fcurve` The idea is that with the animation 2025 project, the operator would call `insert_key_animation` instead and the replacement would be quite seamless. I had to remove the `type` enum property on the `ANIM_OT_keyframe_insert` operator. This is a breaking change of the python api, and I am not sure this is a good idea for 4.1 The reason why I did it anyway is that I don't think this enum was used much from python since the enum order can change if you have custom keying sets. I would love feedback on this though. Whatever we do, there needs to be a way to tell blender to ignore the enum which I am not sure how to do properly. # Future plans Rework the keying sets to hook into this new code path instead of going their own ways. They both eventually call `insert_vert_fcurve`, but the functions used for keying sets have so many arguments it was not feasable to do it with this PR. # TODO * ~~convert `scene_frame` to `nla_frame`~~ * ~~read active keyingset from scene instead of presenting a popup~~ * ~~make work for bones~~ * ~~correctly assign fcurve groups~~ * ~~make a meny entry "Insert key with keying set"~~ * ~~tag depsgraph for an update when an fcurve has been created~~ * ~~Cycle aware keying support when creating FCurves~~ * ~~properly pass keyframe flags~~ * ~~Unit tests~~
Christoph Lendenfeld added 1 commit 2023-10-10 17:03:29 +02:00
Christoph Lendenfeld added the
Module
Animation & Rigging
label 2023-10-10 17:03:49 +02:00
Christoph Lendenfeld added this to the Animation & Rigging project 2023-10-10 17:03:55 +02:00
Christoph Lendenfeld added this to the 4.1 milestone 2023-10-10 17:03:59 +02:00
Hans Goudey changed title from WIP: ANIM: Insert keyframes without keying sets to WIP: Anim: Insert keyframes without keying sets 2023-10-10 18:26:37 +02:00
Christoph Lendenfeld added 6 commits 2023-10-13 15:45:46 +02:00
Christoph Lendenfeld added 1 commit 2023-10-13 16:45:31 +02:00
Christoph Lendenfeld added 4 commits 2023-10-17 13:42:37 +02:00
Christoph Lendenfeld added 1 commit 2023-10-17 17:42:16 +02:00
Christoph Lendenfeld added 8 commits 2023-10-19 17:41:37 +02:00
Christoph Lendenfeld added 1 commit 2023-10-19 17:50:01 +02:00
Christoph Lendenfeld added 5 commits 2023-10-20 15:29:44 +02:00
Christoph Lendenfeld added 1 commit 2023-10-20 16:30:23 +02:00
Christoph Lendenfeld added 1 commit 2023-10-20 17:02:09 +02:00
Christoph Lendenfeld added 5 commits 2023-11-02 16:48:38 +01:00
Christoph Lendenfeld added 1 commit 2023-11-02 16:49:49 +01:00
Christoph Lendenfeld added 6 commits 2023-11-10 09:30:40 +01:00
Christoph Lendenfeld added 2 commits 2023-11-10 11:36:55 +01:00
Christoph Lendenfeld added 2 commits 2023-11-10 12:26:07 +01:00
Christoph Lendenfeld added 1 commit 2023-11-10 12:29:49 +01:00
Christoph Lendenfeld added 1 commit 2023-11-10 14:40:36 +01:00
Christoph Lendenfeld added 1 commit 2023-11-10 15:07:59 +01:00
Christoph Lendenfeld added 2 commits 2023-11-10 16:12:50 +01:00
Christoph Lendenfeld added 2 commits 2023-11-10 16:29:10 +01:00
Christoph Lendenfeld added 2 commits 2023-11-10 16:50:32 +01:00
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR113504) when ready.
Christoph Lendenfeld added 2 commits 2023-11-14 16:01:22 +01:00
Christoph Lendenfeld changed title from WIP: Anim: Insert keyframes without keying sets to Anim: Insert keyframes without keying sets 2023-11-14 16:18:44 +01:00

I tested it today and I already love it.

I tested it today and I already love it.
Nathan Vegdahl requested changes 2023-11-20 18:14:15 +01:00
Nathan Vegdahl left a comment
Member

Over-all looks good to me. Just some nits. I also haven't had a chance to test it yet, so still need to do that.

Over-all looks good to me. Just some nits. I also haven't had a chance to test it yet, so still need to do that.
@ -168,0 +171,4 @@
/**
* Insert keys for the given rna_path in the given action. The length of the values Span is
* expected to be the size of the property array.
* \param frame is expected to be in NLA space.
Member

Really glad this note on frame parameters is here. However, what does NLA space mean in this case? Local time of the action? Time on the NLA track? I think this could be rephrased or expanded on to be clearer.

Really glad this note on frame parameters is here. However, what does NLA space mean in this case? Local time of the action? Time on the NLA track? I think this could be rephrased or expanded on to be clearer.
nathanvegdahl marked this conversation as resolved
@ -168,0 +173,4 @@
* expected to be the size of the property array.
* \param frame is expected to be in NLA space.
*/
int insert_key_action(Main *bmain,
Member

What is the integer return value? Let's document that too, because at least to me (having not seen the function body yet as I work my way through the PR) it's not at all obvious.

What is the integer return value? Let's document that too, because at least to me (having not seen the function body yet as I work my way through the PR) it's not at all obvious.
nathanvegdahl marked this conversation as resolved
@ -341,0 +505,4 @@
Scene *scene = CTX_data_scene(C);
const float scene_frame = BKE_scene_frame_get(scene);
/* Passing autokey mode as true because that is needed to get the cycle aware keying flag. */
Member

Maybe add a TODO here to investigate why that's the case? Because that seems pretty odd, and is perhaps a sign of something else that also needs some spring cleaning.

Maybe add a TODO here to investigate why that's the case? Because that seems pretty odd, and is perhaps a sign of something else that also needs some spring cleaning.
Author
Member

would the TODO make more sense if I added it in the ANIM_get_keyframing_flags function itself?
by adding it below the current comment its a bit far away from where the actual issue is, and might get missed when the function is refactored/

would the TODO make more sense if I added it in the `ANIM_get_keyframing_flags` function itself? by adding it below the current comment its a bit far away from where the actual issue is, and might get missed when the function is refactored/
Member

Oh! Yeah, that would make a lot more sense. Good call.

Oh! Yeah, that would make a lot more sense. Good call.
nathanvegdahl marked this conversation as resolved
@ -343,3 +548,3 @@
ot->idname = "ANIM_OT_keyframe_insert";
ot->description =
"Insert keyframes on the current frame for all properties in the specified Keying Set";
"Insert keyframes on the current frame using the either the active keying set, or the user "
Member

Typo: "using the either the" -> "using either the"

Typo: "using the either the" -> "using either the"
nathanvegdahl marked this conversation as resolved
Christoph Lendenfeld requested review from Nathan Vegdahl 2023-11-21 11:35:41 +01:00
Christoph Lendenfeld added 2 commits 2023-11-21 11:35:49 +01:00
Member

Just tested it out, and it appears to work great!

Just tested it out, and it appears to work great!
Christoph Lendenfeld added 1 commit 2023-11-21 13:48:10 +01:00
Nathan Vegdahl approved these changes 2023-11-21 14:05:42 +01:00
Nathan Vegdahl left a comment
Member

Looks good to me!

Looks good to me!
Christoph Lendenfeld merged commit a99e419b6e into main 2023-11-21 15:38:09 +01:00
Christoph Lendenfeld deleted branch keying_sets_rework 2023-11-21 15:38:11 +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 Assignees
4 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#113504
No description provided.