Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucio Rossi <lucio.rossi75@gmail.com>2016-07-28 18:45:23 +0300
committerLucio Rossi <lucio.rossi75@gmail.com>2016-07-28 18:45:23 +0300
commitd1dafb1ec7fe5444360d575186f9e1bc31eff90b (patch)
tree5209b212f758de3e36ed6de2c6c5c5638ecf7739
parent84b69e64ea67ae01b31a6831d11c339496a525bc (diff)
Paw Limb Code Review and Fix.
-rw-r--r--rigify/rigs/pitchipoy/limbs/paw.py44
-rw-r--r--rigify/rigs/pitchipoy/limbs/super_limb.py151
-rw-r--r--rigify/rigs/pitchipoy/limbs/ui.py6
3 files changed, 127 insertions, 74 deletions
diff --git a/rigify/rigs/pitchipoy/limbs/paw.py b/rigify/rigs/pitchipoy/limbs/paw.py
index 50b313f8..32e39a32 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 28e9b70e..40447097 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:
eb[o].parent = eb[ org[i-1] ]
- if i <= 2:
+ if i <= len(org)-1:
eb[o].use_connect = True
bpy.ops.object.mode_set(mode ='OBJECT')
@@ -504,7 +563,7 @@ class Rig:
bones = self.create_terminal( self.limb_type, bones )
- return [ create_script( bones ) ]
+ return [ create_script( bones, self.limb_type ) ]
def add_parameters( params ):
""" Add the parameters of this rig type to the
diff --git a/rigify/rigs/pitchipoy/limbs/ui.py b/rigify/rigs/pitchipoy/limbs/ui.py
index 118593ed..b086e666 100644
--- a/rigify/rigs/pitchipoy/limbs/ui.py
+++ b/rigify/rigs/pitchipoy/limbs/ui.py
@@ -23,7 +23,11 @@ if is_selected( fk_ctrl ):
layout.prop( pose_bones[ parent ], '["%s"]', slider = True )
"""
-def create_script( bones):
+def create_script( bones, limb_type=None): # limb_type arg is added for future fk/ik
+ # switch to add in UI scripts
+ # scripts are different between arms and
+ # legs and paws
+
# All ctrls have IK/FK switch
controls = [ bones['ik']['ctrl']['limb'] ] + bones['fk']['ctrl']
controls += bones['ik']['ctrl']['terminal']