Refactor: use insert_key_rna() for button keyframing #121491

Open
Nathan Vegdahl wants to merge 3 commits from nathanvegdahl/blender:button_keying_uniformity into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

This commit does two things:

  • Switches manual (not auto) keyframing of buttons to use
    insert_key_rna() instead of insert_keyframe().
  • Modifies insert_key_rna() to accept and understand rna paths that
    specify an array element (for array properties), in order to make
    the above possible.

This is part of a progressive refactor that is unifying the keyframing
code to use the same keyframing functions (in particular converging
on insert_key_rna()), rather than many different functions with
subtly different behavior.

Notes for reviewers:

  • @ChrisLend and I already discussed that we want insert_key_rna() to be able to take paths with fully qualified array indices. However, I'm not 100% sold on appending "[##]" to the path string to accomplish that. An alternative is for insert_key_rna() to take a span of string + int pairs rather than just a span strings like it does now.
  • This refactor is also partially in preparation for enabling button keyframing for Baklava, because insert_key_rna() will already handle Baklava keying after #120428 lands.
This commit does two things: - Switches manual (not auto) keyframing of buttons to use `insert_key_rna()` instead of `insert_keyframe()`. - Modifies `insert_key_rna()` to accept and understand rna paths that specify an array element (for array properties), in order to make the above possible. This is part of a progressive refactor that is unifying the keyframing code to use the same keyframing functions (in particular converging on `insert_key_rna()`), rather than many different functions with subtly different behavior. **Notes for reviewers:** - @ChrisLend and I already discussed that we want `insert_key_rna()` to be able to take paths with fully qualified array indices. However, I'm not 100% sold on appending "[##]" to the path string to accomplish that. An alternative is for `insert_key_rna()` to take a span of string + int pairs rather than just a span strings like it does now. - This refactor is also partially in preparation for enabling button keyframing for Baklava, because `insert_key_rna()` will already handle Baklava keying after #120428 lands.
Nathan Vegdahl added the
Module
Animation & Rigging
label 2024-05-06 17:55:36 +02:00
Nathan Vegdahl added 1 commit 2024-05-06 17:55:46 +02:00
362380fe46 Refactor: use `insert_key_rna()` for button keyframing
This commit does two things:
- Modifies `insert_key_rna()` to accept and understand rna paths that
  specify a specific array element of an array property.
- Switches manual (not auto) keyframing of property buttons to use
  `insert_key_rna()` instead of `insert_keyframe()` like it was before.

This is part of a progressive refactor that is trying to unify the
keyframing code to use the same keyframing functions, rather than many
different functions with subtley different behavior.
Nathan Vegdahl requested review from Christoph Lendenfeld 2024-05-06 17:56:10 +02:00
Nathan Vegdahl requested review from Sybren A. Stüvel 2024-05-06 17:56:44 +02:00
Christoph Lendenfeld approved these changes 2024-05-07 10:00:19 +02:00
Christoph Lendenfeld left a comment
Member

Curious what sybren thinks of this, but I like this solution.
It keeps the function interface of insert_key_rna really simple.

The only thing that is slightly annoying is having to hardcode the [] into the string.

Curious what sybren thinks of this, but I like this solution. It keeps the function interface of `insert_key_rna` really simple. The only thing that is slightly annoying is having to hardcode the `[]` into the string.
Author
Member

Yeah, I think this is a perfectly reasonable solution. And I agree that it keeps the interface for insert_key_rna() simpler when looking at just insert_key_rna().

However, I suspect that in practice it will make insert_key_rna() more complicated to call from most places: you usually have the index as an integer, not already embedded in the path string, so this way you have to take the time and code space to append that index to the string before you can call insert_key_rna(). Whereas if it's passed as an integer alongside the path, you can just do that directly without any real prep work.

Having said that, I think it would be a pretty straightforward refactor going from one to the other, so I don't think it's critical that we get it "right" straight away.

Yeah, I think this is a perfectly reasonable solution. And I agree that it keeps the interface for `insert_key_rna()` simpler when looking at just `insert_key_rna()`. However, I suspect that in practice it will make `insert_key_rna()` more complicated to call from most places: you usually have the index as an integer, not already embedded in the path string, so this way you have to take the time and code space to append that index to the string before you can call `insert_key_rna()`. Whereas if it's passed as an integer alongside the path, you can just do that directly without any real prep work. Having said that, I think it would be a pretty straightforward refactor going from one to the other, so I don't think it's critical that we get it "right" straight away.
Nathan Vegdahl added 1 commit 2024-05-10 15:13:17 +02:00
1c2501d7d0 Remove unnecessary temporary Vector
It turns out that you can just create a temporary Span with initializer
lists, and it works fine.  (Confirmed with Jacques Lucke, who wrote
Span.)
Nathan Vegdahl added 1 commit 2024-05-10 15:13:31 +02:00
Author
Member

After some discussion about a related refactor with @ChrisLend, I think I'm going to split off the Modifies insert_key_rna() to accept and understand rna paths that specify an array element part of this into a separate PR.

Edit: here's that PR: #121879

After some discussion about a related refactor with @ChrisLend, I think I'm going to split off the `Modifies insert_key_rna() to accept and understand rna paths that specify an array element` part of this into a separate PR. Edit: here's that PR: #121879
This pull request has changes conflicting with the target branch.
  • source/blender/animrig/intern/keyframing.cc
  • source/blender/editors/animation/keyframing.cc

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u button_keying_uniformity:nathanvegdahl-button_keying_uniformity
git checkout nathanvegdahl-button_keying_uniformity
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser Project (Legacy)
Interest
Asset System
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#121491
No description provided.