Skip to content

Commit e58d11c

Browse files
committed
fix: IK rot2pole toggle: ORG scan for connected children only
add: strip_mch
1 parent c25a429 commit e58d11c

File tree

6 files changed

+28
-31
lines changed

6 files changed

+28
-31
lines changed

rigs/limbs/arm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .limb_utils import *
55
from mathutils import Vector
66
from ...utils import copy_bone, flip_bone, put_bone, create_cube_widget
7-
from ...utils import strip_org, make_deformer_name, create_widget
7+
from ...utils import strip_org, strip_mch, make_deformer_name, create_widget
88
from ...utils import create_circle_widget, create_sphere_widget, create_line_widget
99
from ...utils import MetarigError, make_mechanism_name, org
1010
from ...utils import create_limb_widget, connected_children_names
@@ -990,9 +990,9 @@ def get_future_names(bones):
990990

991991
names = dict()
992992

993-
uarm = strip_org(bones[0].name)
994-
farm = strip_org(bones[1].name)
995-
hand = strip_org(bones[2].name)
993+
uarm = strip_mch(strip_org(bones[0].name))
994+
farm = strip_mch(strip_org(bones[1].name))
995+
hand = strip_mch(strip_org(bones[2].name))
996996

997997
suffix=''
998998
if uarm[-2:] == '.L' or uarm[-2:] == '.R':

rigs/limbs/leg.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from .limb_utils import *
66
from mathutils import Vector
77
from ...utils import copy_bone, flip_bone, put_bone, create_cube_widget
8-
from ...utils import strip_org, make_deformer_name, create_widget
8+
from ...utils import strip_org, strip_mch, make_deformer_name, create_widget
99
from ...utils import create_circle_widget, create_sphere_widget, create_line_widget
1010
from ...utils import MetarigError, make_mechanism_name, org
1111
from ...utils import create_limb_widget, connected_children_names
@@ -1294,25 +1294,15 @@ def create_drivers(self, bones):
12941294
@staticmethod
12951295
def get_future_names(bones):
12961296

1297-
if len(bones) != 5:
1297+
if len(bones) != 4:
12981298
return
12991299

13001300
names = dict()
13011301

1302-
thigh = strip_org(bones[0].name)
1303-
shin = strip_org(bones[1].name)
1304-
1305-
foot = strip_org(bones[2].name)
1306-
1307-
bone3 = strip_org(bones[3].name)
1308-
bone4 = strip_org(bones[4].name)
1309-
1310-
if bones[3].bone.use_connect:
1311-
toe = bone3
1312-
heel = bone4
1313-
else:
1314-
toe = bone4
1315-
heel = bone3
1302+
thigh = strip_mch(strip_org(bones[0].name))
1303+
shin = strip_mch(strip_org(bones[1].name))
1304+
foot = strip_mch(strip_org(bones[2].name))
1305+
toe = strip_mch(strip_org(bones[3].name))
13161306

13171307
suffix = ''
13181308
if thigh[-2:] == '.L' or thigh[-2:] == '.R':
@@ -1321,7 +1311,6 @@ def get_future_names(bones):
13211311
shin = shin.rstrip(suffix)
13221312
foot = foot.rstrip(suffix)
13231313
toe = toe.rstrip(suffix)
1324-
heel = heel.rstrip(suffix)
13251314

13261315
# the following is declared in rig_ui
13271316
# controls = ['thigh_ik.R', 'thigh_fk.R', 'shin_fk.R', 'foot_fk.R', 'toe.R', 'foot_heel_ik.R', 'foot_ik.R',

rigs/limbs/paw.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .limb_utils import *
44
from mathutils import Vector
55
from ...utils import copy_bone, flip_bone, put_bone, create_cube_widget
6-
from ...utils import strip_org, make_deformer_name, create_widget
6+
from ...utils import strip_org, strip_mch, make_deformer_name, create_widget
77
from ...utils import create_circle_widget, create_sphere_widget, create_line_widget
88
from ...utils import MetarigError, make_mechanism_name, org
99
from ...utils import create_limb_widget, connected_children_names
@@ -1127,12 +1127,10 @@ def get_future_names(bones):
11271127

11281128
names = dict()
11291129

1130-
thigh = strip_org(bones[0].name)
1131-
shin = strip_org(bones[1].name)
1132-
1133-
foot = strip_org(bones[2].name)
1134-
1135-
toe = strip_org(bones[3].name)
1130+
thigh = strip_mch(strip_org(bones[0].name))
1131+
shin = strip_mch(strip_org(bones[1].name))
1132+
foot = strip_mch(strip_org(bones[2].name))
1133+
toe = strip_mch(strip_org(bones[3].name))
11361134

11371135
suffix = ''
11381136
if thigh[-2:] == '.L' or thigh[-2:] == '.R':

rigs/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .limbs.super_limb import Rig as LimbRig
2+
from ..utils import connected_children_names
23
import re
34

45

@@ -11,10 +12,10 @@ def get_limb_generated_names(rig):
1112
super_limb_orgs = []
1213
if re.match('^ORG', b.name) and b.rigify_type == 'limbs.super_limb':
1314
super_limb_orgs.append(b)
14-
children = b.children_recursive
15+
children = connected_children_names(rig, b.name)
1516
for child in children:
16-
if re.match('^ORG', child.name):
17-
super_limb_orgs.append(child)
17+
if re.match('^ORG', child) or re.match('^MCH', child):
18+
super_limb_orgs.append(pbones[child])
1819
names[b.name] = LimbRig.get_future_names(super_limb_orgs)
1920

2021
return names

ui.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,7 @@ def rotPoleToggle(rig, window='ALL', value=False, toggle=False, bake=False):
11051105
bpy.ops.anim.keyframe_insert_menu(type='Scaling')
11061106
limb_generated_names.pop(group)
11071107
break
1108+
scn.frame_set(0)
11081109

11091110

11101111
class OBJECT_OT_IK2FK(bpy.types.Operator):

utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ def strip_org(name):
107107
org_name = strip_org
108108

109109

110+
def strip_mch(name):
111+
""" Returns the name with ORG_PREFIX stripped from it.
112+
"""
113+
if name.startswith(MCH_PREFIX):
114+
return name[len(MCH_PREFIX):]
115+
else:
116+
return name
117+
110118
def org(name):
111119
""" Prepends the ORG_PREFIX to a name if it doesn't already have
112120
it, and returns it.

0 commit comments

Comments
 (0)