rigify
* optional default blend argument, use for better leg & arm defaults * way to define arbitrary options for bones that can then be passed to the generator function, only used to set elbow target parent at the moment.
This commit is contained in:
@@ -96,7 +96,7 @@ def metarig_definition(obj, orig_bone_name):
|
||||
return [palm_parent.name] + bone_definition
|
||||
|
||||
|
||||
def main(obj, bone_definition, base_names):
|
||||
def main(obj, bone_definition, base_names, options):
|
||||
arm = obj.data
|
||||
|
||||
children = bone_definition[1:]
|
||||
@@ -163,22 +163,6 @@ def main(obj, bone_definition, base_names):
|
||||
driver = driver_fcurves[2].driver
|
||||
driver.expression = "(1.0-cos(x))-s"
|
||||
|
||||
def x_direction():
|
||||
# NOTE: the direction of the Z rotation depends on which side the palm is on.
|
||||
# we could do a simple side-of-x test but better to work out the direction
|
||||
# the hand is facing.
|
||||
from Mathutils import Vector, AngleBetweenVecs
|
||||
from math import degrees
|
||||
child_pbone_01 = obj.pose.bones[children[0]]
|
||||
child_pbone_02 = obj.pose.bones[children[1]]
|
||||
|
||||
rel_vec = child_pbone_01.head - child_pbone_02.head
|
||||
x_vec = child_pbone_01.matrix.rotationPart() * Vector(1.0, 0.0, 0.0)
|
||||
return degrees(AngleBetweenVecs(rel_vec, x_vec)) > 90.0
|
||||
|
||||
if x_direction(): # flip
|
||||
driver.expression = "-(%s)" % driver.expression
|
||||
|
||||
for fcurve in driver_fcurves:
|
||||
fcurve.modifiers.remove(0) # grr dont need a modifier
|
||||
|
||||
@@ -229,5 +213,23 @@ def main(obj, bone_definition, base_names):
|
||||
child_pbone = obj.pose.bones[children[-1]]
|
||||
child_pbone.rotation_mode = 'QUATERNION'
|
||||
|
||||
# fix at the end since there is some trouble with tx info not being updated otherwise
|
||||
def x_direction():
|
||||
# NOTE: the direction of the Z rotation depends on which side the palm is on.
|
||||
# we could do a simple side-of-x test but better to work out the direction
|
||||
# the hand is facing.
|
||||
from Mathutils import Vector, AngleBetweenVecs
|
||||
from math import degrees
|
||||
child_pbone_01 = obj.pose.bones[children[0]].bone
|
||||
child_pbone_02 = obj.pose.bones[children[1]].bone
|
||||
|
||||
rel_vec = child_pbone_01.head - child_pbone_02.head
|
||||
x_vec = child_pbone_01.matrix.rotationPart() * Vector(1.0, 0.0, 0.0)
|
||||
print(rel_vec, x_vec)
|
||||
return degrees(AngleBetweenVecs(rel_vec, x_vec)) > 90.0
|
||||
|
||||
if x_direction(): # flip
|
||||
driver.expression = "-(%s)" % driver.expression
|
||||
|
||||
# no blending the result of this
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user