[Bf-extensions-cvs] [d1dafb1] rigify_fixes: Paw Limb Code Review and Fix.
Lucio Rossi
noreply at git.blender.org
Fri Jul 29 13:27:29 CEST 2016
Commit: d1dafb1ec7fe5444360d575186f9e1bc31eff90b
Author: Lucio Rossi
Date: Thu Jul 28 17:45:23 2016 +0200
Branches: rigify_fixes
https://developer.blender.org/rBAd1dafb1ec7fe5444360d575186f9e1bc31eff90b
Paw Limb Code Review and Fix.
===================================================================
M rigify/rigs/pitchipoy/limbs/paw.py
M rigify/rigs/pitchipoy/limbs/super_limb.py
M rigify/rigs/pitchipoy/limbs/ui.py
===================================================================
diff --git a/rigify/rigs/pitchipoy/limbs/paw.py b/rigify/rigs/pitchipoy/limbs/paw.py
index 50b313f..32e39a3 100644
--- a/rigify/rigs/pitchipoy/limbs/paw.py
+++ b/rigify/rigs/pitchipoy/limbs/paw.py
@@ -30,21 +30,20 @@ def create_paw( cls, bones ):
[cls.org_bones[0]] + connected_children_names(cls.obj, cls.org_bones[0])
)
- bones['ik']['ctrl'] = []
+
+ bones['ik']['ctrl']['terminal'] = []
bpy.ops.object.mode_set(mode='EDIT')
eb = cls.obj.data.edit_bones
- # Create toes def bone
- toes_def = get_bone_name( org_bones[-1], 'def' )
- toes_def = copy_bone( cls.obj, org_bones[-1], toes_def )
+ # Create IK paw control
+ ctrl = get_bone_name( org_bones[2], 'ctrl', 'ik' )
+ ctrl = copy_bone( cls.obj, org_bones[2], ctrl )
- eb[ toes_def ].use_connect = False
- eb[ toes_def ].parent = eb[ bones['def'][-1] ]
- eb[ toes_def ].use_connect = True
+ # clear parent (so that rigify will parent to root)
+ eb[ ctrl ].parent = None
+ eb[ ctrl ].use_connect = False
- bones['def'] += [ toes_def ]
-
# Create heel control bone
heel = get_bone_name( org_bones[2], 'ctrl', 'heel_ik' )
heel = copy_bone( cls.obj, org_bones[2], heel )
@@ -53,15 +52,7 @@ def create_paw( cls, bones ):
eb[ heel ].parent = None
eb[ heel ].use_connect = False
- # Create IK paw control
- ctrl = get_bone_name( org_bones[2], 'ctrl', 'ik' )
- ctrl = copy_bone( cls.obj, org_bones[2], ctrl )
-
- # clear parent (so that rigify will parent to root)
- eb[ ctrl ].parent = None
- eb[ ctrl ].use_connect = False
-
- # Parent
+ # Parent
eb[ heel ].parent = eb[ ctrl ]
eb[ heel ].use_connect = False
@@ -170,20 +161,19 @@ def create_paw( cls, bones ):
})
# Constrain toes def bones
- make_constraint( cls, bones['def'][-2], {
+
+ make_constraint( cls, bones['def'][-1], {
'constraint' : 'DAMPED_TRACK',
- 'subtarget' : toes
+ 'subtarget' : toes,
+ 'head_tail' : 1
})
- make_constraint( cls, bones['def'][-2], {
- 'constraint' : 'STRETCH_TO',
- 'subtarget' : toes
- })
-
make_constraint( cls, bones['def'][-1], {
- 'constraint' : 'COPY_TRANSFORMS',
- 'subtarget' : toes
+ 'constraint' : 'STRETCH_TO',
+ 'subtarget' : toes,
+ 'head_tail' : 1
})
+
# Find IK/FK switch property
pb = cls.obj.pose.bones
prop = rna_idprop_ui_prop_get( pb[ bones['parent'] ], 'IK/FK' )
diff --git a/rigify/rigs/pitchipoy/limbs/super_limb.py b/rigify/rigs/pitchipoy/limbs/super_limb.py
index 28e9b70..4044709 100644
--- a/rigify/rigs/pitchipoy/limbs/super_limb.py
+++ b/rigify/rigs/pitchipoy/limbs/super_limb.py
@@ -19,9 +19,15 @@ class Rig:
""" Initialize torso rig and key rig properties """
self.obj = obj
self.params = params
- self.org_bones = list(
- [bone_name] + connected_children_names(obj, bone_name)
- )[:3] # The basic limb is the first 3 bones
+
+ if params.limb_type != 'paw':
+ self.org_bones = list(
+ [bone_name] + connected_children_names(obj, bone_name)
+ )[:3] # The basic limb is the first 3 bones
+ else:
+ self.org_bones = list(
+ [bone_name] + connected_children_names(obj, bone_name)
+ )[:4] # The basic limb is the first 4 bones for a paw
self.segments = params.segments
self.bbones = params.bbones
@@ -158,43 +164,90 @@ class Rig:
eb[ ctrl ].length /= 2
# Contraints
- for i,b in enumerate( tweaks['mch'] ):
- first = 0
- middle = trunc( len( tweaks['mch'] ) / 2 )
- last = len( tweaks['mch'] ) - 1
-
- if i == first or i == middle:
- make_constraint( self, b, {
- 'constraint' : 'COPY_SCALE',
- 'subtarget' : 'root'
- })
- elif i != last:
- targets = []
- dt_target_idx = middle
- factor = 0
- if i < middle:
- targets = [first,middle]
- else:
- targets = [middle,last]
- factor = self.segments
- dt_target_idx = last
-
- # Use copy transforms constraints to position each bone
- # exactly in the location respective to its index (between
- # the two edges)
- make_constraint( self, b, {
- 'constraint' : 'COPY_TRANSFORMS',
- 'subtarget' : tweaks['ctrl'][targets[0]]
- })
- make_constraint( self, b, {
- 'constraint' : 'COPY_TRANSFORMS',
- 'subtarget' : tweaks['ctrl'][targets[1]],
- 'influence' : (i - factor) / self.segments
- })
- make_constraint( self, b, {
- 'constraint' : 'DAMPED_TRACK',
- 'subtarget' : tweaks['ctrl'][ dt_target_idx ],
- })
+ if self.limb_type == 'paw':
+
+ for i,b in enumerate( tweaks['mch'] ):
+ first = 0
+ middle = trunc( len( tweaks['mch'] ) / 3 )
+ middle1 = middle + self.segments
+ last = len( tweaks['mch'] ) - 1
+
+ if i == first or i == middle or i == middle1:
+ make_constraint( self, b, {
+ 'constraint' : 'COPY_SCALE',
+ 'subtarget' : 'root'
+ })
+ elif i != last:
+ targets = []
+ factor = 0
+ if i < middle:
+ dt_target_idx = middle
+ targets = [first,middle]
+ elif i > middle and i < middle1:
+ targets = [middle,middle1]
+ factor = self.segments
+ dt_target_idx = middle1
+ else:
+ targets = [middle1,last]
+ factor = self.segments * 2
+ dt_target_idx = last
+
+
+ # Use copy transforms constraints to position each bone
+ # exactly in the location respective to its index (between
+ # the two edges)
+ make_constraint( self, b, {
+ 'constraint' : 'COPY_TRANSFORMS',
+ 'subtarget' : tweaks['ctrl'][targets[0]],
+ })
+ make_constraint( self, b, {
+ 'constraint' : 'COPY_TRANSFORMS',
+ 'subtarget' : tweaks['ctrl'][targets[1]],
+ 'influence' : (i - factor) / self.segments
+ })
+ make_constraint( self, b, {
+ 'constraint' : 'DAMPED_TRACK',
+ 'subtarget' : tweaks['ctrl'][ dt_target_idx ],
+ })
+
+ else:
+ for i,b in enumerate( tweaks['mch'] ):
+ first = 0
+ middle = trunc( len( tweaks['mch'] ) / 2 )
+ last = len( tweaks['mch'] ) - 1
+
+ if i == first or i == middle:
+ make_constraint( self, b, {
+ 'constraint' : 'COPY_SCALE',
+ 'subtarget' : 'root'
+ })
+ elif i != last:
+ targets = []
+ dt_target_idx = middle
+ factor = 0
+ if i < middle:
+ targets = [first,middle]
+ else:
+ targets = [middle,last]
+ factor = self.segments
+ dt_target_idx = last
+
+ # Use copy transforms constraints to position each bone
+ # exactly in the location respective to its index (between
+ # the two edges)
+ make_constraint( self, b, {
+ 'constraint' : 'COPY_TRANSFORMS',
+ 'subtarget' : tweaks['ctrl'][targets[0]],
+ })
+ make_constraint( self, b, {
+ 'constraint' : 'COPY_TRANSFORMS',
+ 'subtarget' : tweaks['ctrl'][targets[1]],
+ 'influence' : (i - factor) / self.segments
+ })
+ make_constraint( self, b, {
+ 'constraint' : 'DAMPED_TRACK',
+ 'subtarget' : tweaks['ctrl'][ dt_target_idx ],
+ })
# Ctrl bones Locks and Widgets
pb = self.obj.pose.bones
@@ -333,13 +386,16 @@ class Rig:
eb[ bone ].length /= 4
# Create MCH Stretch
- mch_str = copy_bone(
+ mch_str = copy_bone(
self.obj,
org_bones[0],
get_bone_name( org_bones[0], 'mch', 'ik_stretch' )
)
- eb[ mch_str ].tail = eb[ org_bones[-1] ].head
+ if self.limb_type != 'paw':
+ eb[ mch_str ].tail = eb[ org_bones[-1] ].head
+ else:
+ eb[ mch_str ].tail = eb[ org_bones[-2] ].head
# Parenting
eb[ ctrl ].parent = eb[ parent ]
@@ -374,8 +430,11 @@ class Rig:
def create_fk( self, parent ):
- org_bones = self.org_bones
-
+ org_bones = self.org_bones.copy()
+
+ if self.limb_type == 'paw': # Paw base chain is one bone longer
+ org_bones.pop()
+
bpy.ops.object.mode_set(mode ='EDIT')
eb = self.obj.data.edit_bones
@@ -429,7 +488,7 @@ class Rig:
for i,o in enumerate(org):
if i > 0
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list