Rigify Apply Toggle Pole to Keyframes clears out IK keyframes #105301

Closed
opened 2024-04-29 22:37:51 +02:00 by Raymond-Luc · 18 comments

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2060 SUPER/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 552.22

Blender Version
Broken: version: 4.1.1, branch: blender-v4.1-release, commit date: 2024-04-15 15:11, hash: e1743a0317bc
Worked: Blender 2.91.2 with Rigify 0.6.1

Addon Information
Name: Rigify (0, 6, 10)
Author: Nathan Vegdahl, Lucio Rossi, Ivan Cappiello, Alexander Gavrilov

Short description of error
The Apply Toggle Pole to Keyframes button in rigify is currently broken. Right now if the operator is run, it zeros out all the animation on the IK foot controller and applies no keyframe information to the actual Pole vector.

Exact steps for others to reproduce the error

  1. enable rigify
  2. Shift A -> add human meta rig
  3. Go to the Rig data tab and generate the rig
  4. In pose mode, set keyframes on the foot.ik.L and thigh_ik.L controls while moving them around.
  5. In the rig main properties N panel, click the arrow beside the ``Off``` button beside Toggle Pole
    image
  6. Enable Use Pole Vector And hit OK
    image

I've attached a blendfile with a Rigify rig, with keyframes on the IK foot control and knee target.

**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 2060 SUPER/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 552.22 **Blender Version** Broken: version: 4.1.1, branch: blender-v4.1-release, commit date: 2024-04-15 15:11, hash: `e1743a0317bc` Worked: Blender 2.91.2 with Rigify 0.6.1 **Addon Information** Name: Rigify (0, 6, 10) Author: Nathan Vegdahl, Lucio Rossi, Ivan Cappiello, Alexander Gavrilov **Short description of error** The ``Apply Toggle Pole to Keyframes`` button in rigify is currently broken. Right now if the operator is run, it zeros out all the animation on the IK foot controller and applies no keyframe information to the actual Pole vector. **Exact steps for others to reproduce the error** 1) enable rigify 2) Shift A -> add human meta rig 3) Go to the Rig data tab and generate the rig 4) In pose mode, set keyframes on the foot.ik.L and thigh_ik.L controls while moving them around. 5) In the rig main properties N panel, click the arrow beside the ``Off``` button beside Toggle Pole ![image](/attachments/4374699e-376e-4b25-bf7f-ac753f23b97f) 6) Enable ``Use Pole Vector`` And hit OK ![image](/attachments/5f3a00a2-96c7-4da1-b21d-2a8f79d967ba) I've attached a blendfile with a Rigify rig, with keyframes on the IK foot control and knee target.
Raymond-Luc added the
Status
Needs Triage
Priority
Normal
Type
Report
labels 2024-04-29 22:37:51 +02:00
Member

@Raymond-Luc issue confirmed.
the pole vector conversion seems to clear the ik keyframes

@Raymond-Luc issue confirmed. the pole vector conversion seems to clear the ik keyframes
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2024-04-30 09:12:10 +02:00
Ivan Cappiello added
Status
Confirmed
and removed
Status
Archived
labels 2024-04-30 09:19:06 +02:00
Ivan Cappiello changed title from Rigify Apply Toggle Pole to Keyframes broken in 4.1 to Rigify Apply Toggle Pole to Keyframes clears out IK keyframes 2024-04-30 09:25:17 +02:00
Member

@angavrilov would you mind having a look at this? I marked as high priority since the issue may lead to data loss.
@dr.sybren

@angavrilov would you mind having a look at this? I marked as high priority since the issue may lead to data loss. @dr.sybren
Ivan Cappiello added
Priority
High
and removed
Priority
Normal
labels 2024-05-02 09:42:29 +02:00

Unrelated to this, the button with the same icon, two rows higher, gives me this error:

Traceback (most recent call last):
  File "tracker/105301-Rigify_PV_Bug.blend/rig_ui.py", line 690, in execute
  File "tracker/105301-Rigify_PV_Bug.blend/rig_ui.py", line 651, in bake_apply_state
  File "tracker/105301-Rigify_PV_Bug.blend/rig_ui.py", line 1099, in apply_frame_state
  File "tracker/105301-Rigify_PV_Bug.blend/rig_ui.py", line 1288, in assign_extra_controls
NameError: name 'bone_name' is not defined

It would seem there's more broken in Rigify 😿

Unrelated to this, the button with the same icon, two rows higher, gives me this error: ``` Traceback (most recent call last): File "tracker/105301-Rigify_PV_Bug.blend/rig_ui.py", line 690, in execute File "tracker/105301-Rigify_PV_Bug.blend/rig_ui.py", line 651, in bake_apply_state File "tracker/105301-Rigify_PV_Bug.blend/rig_ui.py", line 1099, in apply_frame_state File "tracker/105301-Rigify_PV_Bug.blend/rig_ui.py", line 1288, in assign_extra_controls NameError: name 'bone_name' is not defined ``` It would seem there's more broken in Rigify 😿
Member

@dr.sybren i guess you are talking about ik>fk with roll which i never actually used. So i never noticed.

In this case having an error is better than delete user data.

Probably we have to build some test units. For simple operators like those should be pretty easy and very useful.

@dr.sybren i guess you are talking about `ik>fk with roll` which i never actually used. So i never noticed. In this case having an error is better than delete user data. Probably we have to build some test units. For simple operators like those should be pretty easy and very useful.

Probably we have to build some test units.

Yeah, I think that's pretty much a necessity.

@nathanvegdahl and I did some digging, and we can reproduce this in:

Blender version Rigify version OK?
3.5 0.6.7
3.0 0.6.4
2.93 0.6.3
2.92 0.6.2
2.91 0.6.1
2.90 0.6.1
2.81 0.6.0
2.79 0.5

Given how long it's been broken (2.92 was released in Feb 2021) and gone unreported, I don't think this is a frequently-used feature. I'll drop the priority to 'normal'.

Git-bisecting the Rigify add-on showed the culprit as 46590bb780 (review). It was a change by @Mets and reviewed by @icappiello . Would you guys like to dig into this?

> Probably we have to build some test units. Yeah, I think that's pretty much a necessity. @nathanvegdahl and I did some digging, and we can reproduce this in: | Blender version | Rigify version | OK? | |-----------------|----------------|-----| | 3.5 | 0.6.7 | ❌ | | 3.0 | 0.6.4 | ❌ | | 2.93 | 0.6.3 | ❌ | | 2.92 | 0.6.2 | ❌ | | 2.91 | 0.6.1 | ✅ | | 2.90 | 0.6.1 | ✅ | | 2.81 | 0.6.0 | ✅ | | 2.79 | 0.5 | ✅ | Given how long it's been broken (2.92 was released in Feb 2021) and gone unreported, I don't think this is a frequently-used feature. I'll drop the priority to 'normal'. Git-bisecting the Rigify add-on showed the culprit as 46590bb7800eea5aa1826f6e9305d7e0320829be ([review](https://archive.blender.org/developer/D8496)). It was a change by @Mets and reviewed by @icappiello . Would you guys like to dig into this?
Sybren A. Stüvel added
Priority
Normal
Type
Bug
and removed
Priority
High
Type
Report
labels 2024-05-06 15:43:11 +02:00
Member

I only started that patch, it was finished by @angavrilov. My diff only affected the horse metarig and the paw rigs, so there's no way it could've affected the human metarig.

I looked into it briefly. I find Rigify's snapping code pretty intimidating, so I think if I went in there, I would definitely just break things further. My best guess is the issue might be at line 952 of rig_ui_template.py, maybe a wrong index is being requested from the ctrl_bones list. I definitely wouldn't feel comfortable touching this code, so I'm leaving this to Alexander.

I only started that patch, it was finished by @angavrilov. [My diff](https://archive.blender.org/developer/differential/0008/0008496/D8496.id29144.html) only affected the horse metarig and the paw rigs, so there's no way it could've affected the human metarig. I looked into it briefly. I find Rigify's snapping code pretty intimidating, so I think if I went in there, I would definitely just break things further. My best guess is the issue might be at line 952 of rig_ui_template.py, maybe a wrong index is being requested from the `ctrl_bones` list. I definitely wouldn't feel comfortable touching this code, so I'm leaving this to Alexander.
Member

Git-bisecting the Rigify add-on showed the culprit as 46590bb780 (review). It was a change by @Mets and reviewed by @icappiello . Would you guys like to dig into this?

@dr.sybren actually i see my comment in https://archive.blender.org/developer/D8496 was:

Since Design is done in my opinion, i am assigning the code part to @Mets unless @angavrilov can find some time to handle it before him.

and the actual review and commit was done by @angavrilov.

> Git-bisecting the Rigify add-on showed the culprit as 46590bb780 (review). It was a change by @Mets and reviewed by @icappiello . Would you guys like to dig into this? @dr.sybren actually i see my comment in https://archive.blender.org/developer/D8496 was: >Since Design is done in my opinion, i am assigning the code part to @Mets unless @angavrilov can find some time to handle it before him. and the actual review and commit was done by @angavrilov.

I looked into it briefly. I find Rigify's snapping code pretty intimidating

Yeah, same here.

My best guess is the issue might be at line 952 of rig_ui_template.py , maybe a wrong index is being requested from the ctrl_bones list.

Which version of that file? scripts/addons/rigify/rig_ui_template.py in current main doesn't mention ctrl_bones. Looking in other files for that name shows me things like:

        ctrl_bones = self.fk_limb.generate()
        thigh = ctrl_bones[0]
        shin = ctrl_bones[1]
        foot = ctrl_bones[2]
        foot_mch = ctrl_bones[3]

which IMO looks rather error prone.

> I looked into it briefly. I find Rigify's snapping code pretty intimidating Yeah, same here. > My best guess is the issue might be at line 952 of rig_ui_template.py , maybe a wrong index is being requested from the `ctrl_bones` list. Which version of that file? `scripts/addons/rigify/rig_ui_template.py` in current `main` doesn't mention `ctrl_bones`. Looking in other files for that name shows me things like: ```python ctrl_bones = self.fk_limb.generate() thigh = ctrl_bones[0] shin = ctrl_bones[1] foot = ctrl_bones[2] foot_mch = ctrl_bones[3] ``` which IMO looks rather error prone.
Member

Which version of that file?

I was referring to the line numbers of the patch, but I gave the wrong filename, sorry. Navigating the archived stuff is a bit iffy. The file name I meant was apparently limb_rigs.py, and the closest link I can provide is this:
https://archive.blender.org/developer/differential/0008/0008496/#change-DSwjrEKVEHMS
Even copy-pasting code from there is impossible, but there's a call to match_pole_target() where on line 952 the index got changed from 2 to 1. I doubt the issue is as simple as that though. But I'd really only spend time trying to untangle this if Alexander isn't available.

> Which version of that file? I was referring to the line numbers of the patch, but I gave the wrong filename, sorry. Navigating the archived stuff is a bit iffy. The file name I meant was apparently limb_rigs.py, and the closest link I can provide is this: https://archive.blender.org/developer/differential/0008/0008496/#change-DSwjrEKVEHMS Even copy-pasting code from there is impossible, but there's a call to `match_pole_target()` where on line 952 the index got changed from 2 to 1. I doubt the issue is as simple as that though. But I'd really only spend time trying to untangle this if Alexander isn't available.
Member

@angavrilov seems that your help is needed here since you are the one and only maintainer of the rigify code.
Answering, even just saying you have no time for that, would be nice.
Any help about where to look for the issue would be appreciated by people here that are willing to help.

@angavrilov seems that your help is needed here since you are the one and only maintainer of the rigify code. Answering, even just saying you have no time for that, would be nice. Any help about where to look for the issue would be appreciated by people here that are willing to help.

I'll try to have a look this week or weekend.

I'll try to have a look this week or weekend.

So I had a look. I think I'll postpone applying the fix to rigify until tomorrow to prevent making more mistakes in a hurry, but the following changes in the generated rig_ui script seem to fix the problem:

Change these lines:

            if self.use_pole:
                keyframe_transform_properties(
                    obj, self.ctrl_bone_list[2], self.keyflags,
        pole_curves = self.bake_get_all_bone_curves(self.ctrl_bone_list[2], TRANSFORM_PROPS_LOCATION)

To be like this:

            if self.use_pole:
                keyframe_transform_properties(
                    obj, self.ctrl_bone_list[1], self.keyflags,
        pole_curves = self.bake_get_all_bone_curves(self.ctrl_bone_list[1], TRANSFORM_PROPS_LOCATION)

Basically the problem was that in order to help introducing those paw rigs the order of bones in the list was changed, but these two locations in the operator were not updated. I must have forgot to test it with keyframed animations, since the bug is purely in keyframing code, so the current frame toggle button works fine. If you look through the changes in the commit you can actually find a similar change in the IK->FK snap operator, but not pole toggle.

So I had a look. I think I'll postpone applying the fix to rigify until tomorrow to prevent making more mistakes in a hurry, but the following changes in the generated rig_ui script seem to fix the problem: Change these lines: ``` if self.use_pole: keyframe_transform_properties( obj, self.ctrl_bone_list[2], self.keyflags, ``` ``` pole_curves = self.bake_get_all_bone_curves(self.ctrl_bone_list[2], TRANSFORM_PROPS_LOCATION) ``` To be like this: ``` if self.use_pole: keyframe_transform_properties( obj, self.ctrl_bone_list[1], self.keyflags, ``` ``` pole_curves = self.bake_get_all_bone_curves(self.ctrl_bone_list[1], TRANSFORM_PROPS_LOCATION) ``` Basically the problem was that in order to help introducing those paw rigs the order of bones in the list was changed, but these two locations in the operator were not updated. I must have forgot to test it with keyframed animations, since the bug is purely in keyframing code, so the current frame toggle button works fine. If you look through the changes in the commit you can actually find a similar change in the IK->FK snap operator, but not pole toggle.
Member

@angavrilov thanks for digging in. any update on this?

@angavrilov thanks for digging in. any update on this?

Alexander's proposed change seems to work, at least in a quick test that I did.

@icappiello @Raymond-Luc can you test with this Rigify extension? It does require Blender 4.2. Also please regenerate the rig before testing, as that's required to actually insert the corrected code into the rig scripts.

Alexander's proposed change seems to work, at least in a quick test that I did. @icappiello @Raymond-Luc can you test with this Rigify extension? It does require Blender 4.2. Also please regenerate the rig before testing, as that's required to actually insert the corrected code into the rig scripts.
302 KiB
Member

@dr.sybren seems to work quite fine (at least on human).
animation is correctly converted to pole vector and keyframes are retained,

since the issue seems to depend on bone lists, i'd suggest to test it further on other metarigs (i.e. animals) to double check if any other change on longer chain limbs are required

@dr.sybren seems to work quite fine (at least on human). animation is correctly converted to pole vector and keyframes are retained, since the issue seems to depend on bone lists, i'd suggest to test it further on other metarigs (i.e. animals) to double check if any other change on longer chain limbs are required

i'd suggest to test it further on other metarigs

Please do, because I don't have the experience with Rigify to test this in a way that convinces me that it's been adequately tested.

> i'd suggest to test it further on other metarigs Please do, because I don't have the experience with Rigify to test this in a way that convinces me that it's been adequately tested.
Member

@dr.sybren seems to work fine on both horse and dog too. Those are the two rigs that have the modified limbs from that commit. Animation is correctly converted to pole and back whilst animation is not cleared out on ik.

@dr.sybren seems to work fine on both horse and dog too. Those are the two rigs that have the modified limbs from that commit. Animation is correctly converted to pole and back whilst animation is not cleared out on ik.

Thanks, I'll land extensions/rigify#2 in the main branch then. It should then get picked up by @dfelinto 's script to auto-push to https://extensions.blender.org

Thanks, I'll land https://projects.blender.org/extensions/rigify/pulls/2 in the main branch then. It should then get picked up by @dfelinto 's script to auto-push to https://extensions.blender.org
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-06-06 10:15:07 +02:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
5 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#105301
No description provided.