WIP: Animation: operators to update the pose library #104673

Draft
Sybren A. Stüvel wants to merge 10 commits from dr.sybren/blender-addons:pr/poselib-replace-pose into main

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

This adds two operators to the pose library context menu:

Replace Pose

  • Completely replaces the selected pose asset with a new one.
  • Unselected bones will effectively be removed from the asset. They are not be part of the new asset, just like they wouldn't be when you'd use Create Pose.
  • The pose asset is keyed on the current frame, regardless of where the original asset was keyed.
  • Asset data (description, copyright, tags, assigned catalog, etc.) are copied from the original pose asset.

Update Pose

  • Updates an existing pose asset to the new pose of selected bones.
  • Bones that were not part of the original pose asset are added to it.
  • Keys of unselected bones will remain as they are in the pose asset.
  • All keys are placed on the original keyframe.

For reference, the frame on which the pose asset is keyed influences which frame is used for rendering its preview image. This could influence choice in camera, backdrop color, etc. when those are animated in the scene.

The operators work in both the asset browser and the asset view (i.e. in the 3D viewport side-panel).

This patch requires blender/blender#108547 for the Replace Pose operator. Since blender/blender#108547 has landed on main, there are no futher dependencies for this PR.

Limitations

This patch does not work around the limitation that Blender is only allowed to write to the currently-open blend file. As such, editing the pose library still requires you to open the blend file that contains the pose asset.

Future Work

Once this patch is in, people have used it a bit for actual work & the feature got polished, it might be a good idea to follow this up with "Update from Clipboard" and/or "Replace from Clipboard" operators. That could be used in conjunction with the "Copy Pose as Asset" operator.

This adds two operators to the pose library context menu: #### Replace Pose - Completely replaces the selected pose asset with a new one. - **Unselected bones will effectively be removed** from the asset. They are not be part of the new asset, just like they wouldn't be when you'd use _Create Pose_. - The pose asset is keyed on the current frame, regardless of where the original asset was keyed. - Asset data (description, copyright, tags, assigned catalog, etc.) are copied from the original pose asset. #### Update Pose - Updates an existing pose asset to the new pose of selected bones. - Bones that were not part of the original pose asset are added to it. - Keys of **unselected bones will remain as they** are in the pose asset. - All keys are placed on the original keyframe. For reference, the frame on which the pose asset is keyed influences which frame is used for rendering its preview image. This could influence choice in camera, backdrop color, etc. when those are animated in the scene. The operators work in both the asset browser and the asset view (i.e. in the 3D viewport side-panel). ~~This patch requires https://projects.blender.org/blender/blender/pulls/108547 for the _Replace Pose_ operator.~~ Since blender/blender#108547 has landed on `main`, there are no futher dependencies for this PR. #### Limitations This patch does _not_ work around the limitation that Blender is only allowed to write to the currently-open blend file. As such, editing the pose library still requires you to open the blend file that contains the pose asset. #### Future Work Once this patch is in, people have used it a bit for actual work & the feature got polished, it might be a good idea to follow this up with "Update from Clipboard" and/or "Replace from Clipboard" operators. That could be used in conjunction with the "Copy Pose as Asset" operator.
Sybren A. Stüvel added 1 commit 2023-06-05 18:11:52 +02:00
9f89730744 Animation: pose library, add 'Replace Pose' operator
Add a 'Replace Pose' operator that completely replaces the selected
pose asset. It creates a new pose asset just like 'Create Pose', copies
the asset metadata from the selected asset to the newly created one, then
removes the selected asset.

This requires blender/blender#108547
Sybren A. Stüvel added the
Interest
Animation & Rigging
label 2023-06-05 18:12:03 +02:00
Sybren A. Stüvel added 2 commits 2023-06-06 14:49:00 +02:00
Sybren A. Stüvel changed title from WIP: Animation: pose library, add 'Replace Pose' operator to WIP: Animation: operators to update the pose library 2023-06-06 14:49:29 +02:00
Sybren A. Stüvel added 3 commits 2023-06-06 15:14:00 +02:00
Sybren A. Stüvel changed title from WIP: Animation: operators to update the pose library to Animation: operators to update the pose library 2023-06-06 15:14:35 +02:00
Sybren A. Stüvel added 1 commit 2023-06-06 17:39:43 +02:00
Sybren A. Stüvel requested review from Nathan Vegdahl 2023-06-08 10:17:15 +02:00
Sybren A. Stüvel added 1 commit 2023-06-08 10:21:40 +02:00
Nathan Vegdahl approved these changes 2023-06-08 14:42:41 +02:00
Nathan Vegdahl left a comment
Member

Looks good to me. I left a couple of comments that you may or may not want to address. But neither are critical.

Looks good to me. I left a couple of comments that you may or may not want to address. But neither are critical.
@ -142,0 +330,4 @@
# Update the exsting FCurve. This assumes that it is a valid
# pose asset, i.e. that the FCurve has a single key.
kp = fcu_existing.keyframe_points[0]
old_value = kp.co.y
Member

Unimportant nit: it doesn't seem like the old_value temporary is necessary.

(fcu_value, by contrast, I think aids readability, since it's short-handing something that's rather long to read.)

Not a big deal either way, though.

Unimportant nit: it doesn't seem like the `old_value` temporary is necessary. (`fcu_value`, by contrast, I think aids readability, since it's short-handing something that's rather long to read.) Not a big deal either way, though.
Author
Member

It's indeed not really necessary, but to me it makes the if old_value == fcu_value: read nicer. That can be resolved by renaming kp to keyframe and it overall being less cryptic.

It's indeed not really necessary, but to me it makes the `if old_value == fcu_value:` read nicer. That can be resolved by renaming `kp` to `keyframe` and it overall being less cryptic.
dr.sybren marked this conversation as resolved
@ -142,0 +334,4 @@
# Don't bother updating the FCurve if the value was unchanged.
fcu_value = fcu_to_read.keyframe_points[0].co.y
if abs(old_value - fcu_value) < 0.0001:
Member

Do we expect there to be floating point error involved here? I wouldn't think so, but I could very well be missing something.

But if not, I think it makes more sense to just do a straight == comparison, rather than having an arbitrary epsilon.

Do we expect there to be floating point error involved here? I wouldn't think so, but I could very well be missing something. But if not, I think it makes more sense to just do a straight `==` comparison, rather than having an arbitrary epsilon.
dr.sybren marked this conversation as resolved
Sybren A. Stüvel added 1 commit 2023-06-08 15:24:15 +02:00
Sybren A. Stüvel added 1 commit 2023-06-09 12:22:29 +02:00
Sybren A. Stüvel changed title from Animation: operators to update the pose library to WIP: Animation: operators to update the pose library 2023-06-09 12:22:42 +02:00
Author
Member

Marked as WIP, as I want to include the suggestions from yesterday's module meeting as well.

Marked as WIP, as I want to include the suggestions from [yesterday's module meeting](https://devtalk.blender.org/t/2023-06-08-animation-rigging-module-meeting/29793) as well.
This pull request has changes conflicting with the target branch.
  • pose_library/operators.py

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u pr/poselib-replace-pose:dr.sybren-pr/poselib-replace-pose
git checkout dr.sybren-pr/poselib-replace-pose
Sign in to join this conversation.
No reviewers
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-addons#104673
No description provided.