Skip to content

Commit 98d0ee9

Browse files
committed
mod: switch rot/pole, overwrite pole_vector prop
fix: switch FK/IK action: force select of ik/fk chains
1 parent e58d11c commit 98d0ee9

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

rigs/limbs/ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
props.hand_ik = controls[4]
2727
props.pole = pole
2828
props.main_parent = parent
29-
props = layout.operator("rigify.rotation_pole", text="Toggle Rotation and Pole")
29+
props = layout.operator("rigify.rotation_pole", text="Switch Rotation-Pole")
3030
props.bone_name = controls[1]
3131
props.window = "CURRENT"
3232
props.toggle = True

ui.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from .utils import unique_name
2828
from .utils import upgradeMetarigTypes, outdated_types
2929
from .utils import get_keyed_frames
30+
from .utils import overwrite_prop_animation
3031
from .rigs.utils import get_limb_generated_names
3132
from . import rig_lists
3233
from . import generate
@@ -651,8 +652,14 @@ def draw(self, context):
651652
row.operator("rigify.clear_animation", text="Clear FK Action", icon='CANCEL').type = "FK"
652653

653654
row = self.layout.row(align=True)
654-
row.operator("rigify.rotation_pole", icon='NONE', text='Toggle IK rotation-pole')
655-
655+
op = row.operator("rigify.rotation_pole", icon='SCRIPTWIN', text='Switch to pole')
656+
op.value = True
657+
op.toggle = False
658+
op.bake = True
659+
op = row.operator("rigify.rotation_pole", icon='SCRIPTWIN', text='Switch to rotation')
660+
op.value = False
661+
op.toggle = False
662+
op.bake = True
656663
row = self.layout.row(align=True)
657664
row.prop(id_store, 'rigify_transfer_start_frame')
658665
row.prop(id_store, 'rigify_transfer_end_frame')
@@ -902,6 +909,10 @@ def FktoIk(rig, window='ALL'):
902909
fk_ctrl = names['fk_ctrl']
903910
parent = names['parent']
904911
pole = names['pole']
912+
rig.pose.bones[controls[0]].bone.select = True
913+
rig.pose.bones[ik_ctrl[1]].bone.select = True
914+
rig.pose.bones[controls[4]].bone.select = True
915+
rig.pose.bones[pole].bone.select = True
905916
kwargs = {'uarm_fk': controls[1], 'farm_fk': controls[2], 'hand_fk': controls[3],
906917
'uarm_ik': controls[0], 'farm_ik': ik_ctrl[1], 'hand_ik': controls[4],
907918
'pole': pole, 'main_parent': parent}
@@ -912,7 +923,11 @@ def FktoIk(rig, window='ALL'):
912923
fk_ctrl = names['fk_ctrl']
913924
parent = names['parent']
914925
pole = names['pole']
915-
926+
rig.pose.bones[controls[0]].bone.select = True
927+
rig.pose.bones[ik_ctrl[1]].bone.select = True
928+
rig.pose.bones[controls[6]].bone.select = True
929+
rig.pose.bones[controls[5]].bone.select = True
930+
rig.pose.bones[pole].bone.select = True
916931
kwargs = {'thigh_fk': controls[1], 'shin_fk': controls[2], 'foot_fk': controls[3],
917932
'mfoot_fk': controls[7], 'thigh_ik': controls[0], 'shin_ik': ik_ctrl[1],
918933
'foot_ik': controls[6], 'pole': pole, 'footroll': controls[5], 'mfoot_ik': ik_ctrl[2],
@@ -964,6 +979,9 @@ def IktoFk(rig, window='ALL'):
964979
fk_ctrl = names['fk_ctrl']
965980
parent = names['parent']
966981
pole = names['pole']
982+
rig.pose.bones[controls[1]].bone.select = True
983+
rig.pose.bones[controls[2]].bone.select = True
984+
rig.pose.bones[controls[3]].bone.select = True
967985
kwargs = {'uarm_fk': controls[1], 'farm_fk': controls[2], 'hand_fk': controls[3],
968986
'uarm_ik': controls[0], 'farm_ik': ik_ctrl[1],
969987
'hand_ik': controls[4]}
@@ -974,6 +992,9 @@ def IktoFk(rig, window='ALL'):
974992
fk_ctrl = names['fk_ctrl']
975993
parent = names['parent']
976994
pole = names['pole']
995+
rig.pose.bones[controls[1]].bone.select = True
996+
rig.pose.bones[controls[2]].bone.select = True
997+
rig.pose.bones[controls[3]].bone.select = True
977998
kwargs = {'thigh_fk': controls[1], 'shin_fk': controls[2], 'foot_fk': controls[3],
978999
'mfoot_fk': controls[7], 'thigh_ik': controls[0], 'shin_ik': ik_ctrl[1],
9791000
'foot_ik': ik_ctrl[2], 'mfoot_ik': ik_ctrl[2]}
@@ -1103,6 +1124,8 @@ def rotPoleToggle(rig, window='ALL', value=False, toggle=False, bake=False):
11031124
if bake:
11041125
bpy.ops.anim.keyframe_insert_menu(type='BUILTIN_KSI_VisualLocRot')
11051126
bpy.ops.anim.keyframe_insert_menu(type='Scaling')
1127+
overwrite_prop_animation(rig, rig.pose.bones[parent], 'pole_vector', new_pole_vector_value,
1128+
[f])
11061129
limb_generated_names.pop(group)
11071130
break
11081131
scn.frame_set(0)

utils.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,3 +1199,25 @@ def get_keyed_frames(rig):
11991199
frames.sort()
12001200

12011201
return frames
1202+
1203+
1204+
def overwrite_prop_animation(rig, bone, prop_name, value, frames):
1205+
act = rig.animation_data.action
1206+
if not act:
1207+
return
1208+
1209+
bone_name = bone.name
1210+
curve = None
1211+
1212+
for fcu in act.fcurves:
1213+
words = fcu.data_path.split('"')
1214+
if words[0] == "pose.bones[" and words[1] == bone_name and words[-2] == prop_name:
1215+
curve = fcu
1216+
break
1217+
1218+
if not curve:
1219+
return
1220+
1221+
for kp in curve.keyframe_points:
1222+
if kp.co[0] in frames:
1223+
kp.co[1] = value

0 commit comments

Comments
 (0)