Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

Commit

Permalink
parentConstraints with 2 targets set to noFlip
Browse files Browse the repository at this point in the history
In the lips and eye riggers, any parentConstraints with 2 or more targets is now set to noFlip. Set to Average, sometimes these controls would flip.
  • Loading branch information
chris-lesage committed Sep 6, 2020
1 parent 64efce7 commit f791d53
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
8 changes: 6 additions & 2 deletions scripts/mgear/rigbits/eye_rigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,12 @@ def setName(name, ind=None):
# adding parent average contrains to odd controls
for i, ctl in enumerate(upControls):
if utils.is_odd(i):
pm.parentConstraint(upControls[i - 1],
cns_node = pm.parentConstraint(upControls[i - 1],
upControls[i + 1],
ctl.getParent(),
mo=True)
# Make the constraint "noFlip"
cns_node.interpType.set(0)

# lower eyelid controls
lowControls = [upControls[0]]
Expand Down Expand Up @@ -480,10 +482,12 @@ def setName(name, ind=None):
# adding parent average contrains to odd controls
for i, ctl in enumerate(lowControls):
if utils.is_odd(i):
pm.parentConstraint(lowControls[i - 1],
cns_node = pm.parentConstraint(lowControls[i - 1],
lowControls[i + 1],
ctl.getParent(),
mo=True)
# Make the constraint "noFlip"
cns_node.interpType.set(0)

# Connecting control crvs with controls
applyop.gear_curvecns_op(upCrv_ctl, upControls)
Expand Down
12 changes: 8 additions & 4 deletions scripts/mgear/rigbits/facial_rigger/eye_rigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,15 @@ def setName(name, ind=None):
npoBase.attr("ry").set(180)
npoBase.attr("sz").set(-1)

# adding parent average contrains to odd controls
# adding parent constraints to odd controls
for i, ctl in enumerate(upControls):
if utils.is_odd(i):
pm.parentConstraint(upControls[i - 1],
cns_node = pm.parentConstraint(upControls[i - 1],
upControls[i + 1],
ctl.getParent(),
mo=True)
# Make the constraint "noFlip"
cns_node.interpType.set(0)

# lower eyelid controls
lowControls = [upControls[0]]
Expand Down Expand Up @@ -518,13 +520,15 @@ def setName(name, ind=None):
node.add_controller_tag(lctl, over_ctl)
lowControls.append(upControls[-1])

# adding parent average contrains to odd controls
# adding parent constraints to odd controls
for i, ctl in enumerate(lowControls):
if utils.is_odd(i):
pm.parentConstraint(lowControls[i - 1],
cns_node = pm.parentConstraint(lowControls[i - 1],
lowControls[i + 1],
ctl.getParent(),
mo=True)
# Make the constraint "noFlip"
cns_node.interpType.set(0)

# Connecting control crvs with controls
applyop.gear_curvecns_op(upCrv_ctl, upControls)
Expand Down
19 changes: 15 additions & 4 deletions scripts/mgear/rigbits/facial_rigger/lips_rigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(upControls[0].name() + "W0").set(.75)
cns_node.attr(upControls[3].name() + "W1").set(.25)
cns_node.interpType.set(0) # noFlip

cns_node = pm.parentConstraint(upControls[0],
upControls[3],
Expand All @@ -598,6 +599,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(upControls[0].name() + "W0").set(.25)
cns_node.attr(upControls[3].name() + "W1").set(.75)
cns_node.interpType.set(0) # noFlip

cns_node = pm.parentConstraint(upControls[3],
upControls[6],
Expand All @@ -606,6 +608,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(upControls[3].name() + "W0").set(.75)
cns_node.attr(upControls[6].name() + "W1").set(.25)
cns_node.interpType.set(0) # noFlip

cns_node = pm.parentConstraint(upControls[3],
upControls[6],
Expand All @@ -614,6 +617,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(upControls[3].name() + "W0").set(.25)
cns_node.attr(upControls[6].name() + "W1").set(.75)
cns_node.interpType.set(0) # noFlip

# low
cns_node = pm.parentConstraint(upControls[0],
Expand All @@ -623,6 +627,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(upControls[0].name() + "W0").set(.75)
cns_node.attr(lowControls[2].name() + "W1").set(.25)
cns_node.interpType.set(0) # noFlip

cns_node = pm.parentConstraint(upControls[0],
lowControls[2],
Expand All @@ -631,6 +636,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(upControls[0].name() + "W0").set(.25)
cns_node.attr(lowControls[2].name() + "W1").set(.75)
cns_node.interpType.set(0) # noFlip

cns_node = pm.parentConstraint(lowControls[2],
upControls[6],
Expand All @@ -639,6 +645,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(lowControls[2].name() + "W0").set(.75)
cns_node.attr(upControls[6].name() + "W1").set(.25)
cns_node.interpType.set(0) # noFlip

cns_node = pm.parentConstraint(lowControls[2],
upControls[6],
Expand All @@ -647,6 +654,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(lowControls[2].name() + "W0").set(.25)
cns_node.attr(upControls[6].name() + "W1").set(.75)
cns_node.interpType.set(0) # noFlip

###########################################
# Connecting rig
Expand Down Expand Up @@ -676,6 +684,7 @@ def setName(name, side="C", idx=None):
return

# in order to avoid flips lets create a reference transform
# also to avoid flips, set any multi target parentConstraint to noFlip
ref_cns_list = []
for cns_ref in [head_joint, jaw_joint]:

Expand All @@ -688,21 +697,23 @@ def setName(name, side="C", idx=None):
ref.setMatrix(t, worldSpace=True)
ref_cns_list.append(ref)
# right corner connection
pm.parentConstraint(ref_cns_list[0],
cns_node = pm.parentConstraint(ref_cns_list[0],
ref_cns_list[1],
upControls[0].getParent(),
mo=True)
cns_node.interpType.set(0) # noFlip
# left corner connection
pm.parentConstraint(ref_cns_list[0],
cns_node = pm.parentConstraint(ref_cns_list[0],
ref_cns_list[1],
upControls[-1].getParent(),
mo=True)
cns_node.interpType.set(0) # noFlip
# up control connection
pm.parentConstraint(head_joint,
cns_node = pm.parentConstraint(head_joint,
upControls[3].getParent(),
mo=True)
# low control connection
pm.parentConstraint(jaw_joint,
cns_node = pm.parentConstraint(jaw_joint,
lowControls[2].getParent(),
mo=True)

Expand Down
19 changes: 15 additions & 4 deletions scripts/mgear/rigbits/lips_rigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(upControls[0].name() + "W0").set(.75)
cns_node.attr(upControls[3].name() + "W1").set(.25)
cns_node.interpType.set(0) # noFlip

cns_node = pm.parentConstraint(upControls[0],
upControls[3],
Expand All @@ -427,6 +428,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(upControls[0].name() + "W0").set(.25)
cns_node.attr(upControls[3].name() + "W1").set(.75)
cns_node.interpType.set(0) # noFlip

cns_node = pm.parentConstraint(upControls[3],
upControls[6],
Expand All @@ -435,6 +437,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(upControls[3].name() + "W0").set(.75)
cns_node.attr(upControls[6].name() + "W1").set(.25)
cns_node.interpType.set(0) # noFlip

cns_node = pm.parentConstraint(upControls[3],
upControls[6],
Expand All @@ -443,6 +446,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(upControls[3].name() + "W0").set(.25)
cns_node.attr(upControls[6].name() + "W1").set(.75)
cns_node.interpType.set(0) # noFlip

# low
cns_node = pm.parentConstraint(upControls[0],
Expand All @@ -452,6 +456,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(upControls[0].name() + "W0").set(.75)
cns_node.attr(lowControls[2].name() + "W1").set(.25)
cns_node.interpType.set(0) # noFlip

cns_node = pm.parentConstraint(upControls[0],
lowControls[2],
Expand All @@ -460,6 +465,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(upControls[0].name() + "W0").set(.25)
cns_node.attr(lowControls[2].name() + "W1").set(.75)
cns_node.interpType.set(0) # noFlip

cns_node = pm.parentConstraint(lowControls[2],
upControls[6],
Expand All @@ -468,6 +474,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(lowControls[2].name() + "W0").set(.75)
cns_node.attr(upControls[6].name() + "W1").set(.25)
cns_node.interpType.set(0) # noFlip

cns_node = pm.parentConstraint(lowControls[2],
upControls[6],
Expand All @@ -476,6 +483,7 @@ def setName(name, side="C", idx=None):
skipRotate=["x", "y", "z"])
cns_node.attr(lowControls[2].name() + "W0").set(.25)
cns_node.attr(upControls[6].name() + "W1").set(.75)
cns_node.interpType.set(0) # noFlip

##################
# Joints
Expand Down Expand Up @@ -621,6 +629,7 @@ def setName(name, side="C", idx=None):
return

# in order to avoid flips lets create a reference transform
# also to avoid flips, set any multi target parentConstraint to noFlip
ref_cns_list = []
for cns_ref in [headJnt, jawJnt]:

Expand All @@ -633,21 +642,23 @@ def setName(name, side="C", idx=None):
ref.setMatrix(t, worldSpace=True)
ref_cns_list.append(ref)
# right corner connection
pm.parentConstraint(ref_cns_list[0],
cns_node = pm.parentConstraint(ref_cns_list[0],
ref_cns_list[1],
upControls[0].getParent(),
mo=True)
cns_node.interpType.set(0) # noFlip
# left corner connection
pm.parentConstraint(ref_cns_list[0],
cns_node = pm.parentConstraint(ref_cns_list[0],
ref_cns_list[1],
upControls[-1].getParent(),
mo=True)
cns_node.interpType.set(0) # noFlip
# up control connection
pm.parentConstraint(headJnt,
cns_node = pm.parentConstraint(headJnt,
upControls[3].getParent(),
mo=True)
# low control connection
pm.parentConstraint(jawJnt,
cns_node = pm.parentConstraint(jawJnt,
lowControls[2].getParent(),
mo=True)

Expand Down

0 comments on commit f791d53

Please sign in to comment.