Skip to content

Commit

Permalink
Rigify: switch the human metarig from simple_tentacle to super_finger.
Browse files Browse the repository at this point in the history
For better compatibility, support the Tweak layer assignment
in super_finger for the detail controls, and allow changing
the B-Bone resolution.
  • Loading branch information
angavrilov committed Nov 2, 2019
1 parent af18f8d commit b9a821b
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 40 deletions.
24 changes: 12 additions & 12 deletions rigify/metarigs/human.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ def create(obj):
arm.rigify_layers[5].row = 5
arm.rigify_layers[5].selset = False
arm.rigify_layers[5].group = 6
arm.rigify_layers[6].name = "Fingers (Tweak)"
arm.rigify_layers[6].name = "Fingers (Detail)"
arm.rigify_layers[6].row = 6
arm.rigify_layers[6].selset = False
arm.rigify_layers[6].group = 4
arm.rigify_layers[6].group = 5
arm.rigify_layers[7].name = "Arm.L (IK)"
arm.rigify_layers[7].row = 7
arm.rigify_layers[7].selset = False
Expand Down Expand Up @@ -1964,7 +1964,7 @@ def create(obj):
pbone.rotation_mode = 'QUATERNION'
pbone.bone.layers = [True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False]
pbone = obj.pose.bones[bones['f_index.01.L']]
pbone.rigify_type = 'limbs.simple_tentacle'
pbone.rigify_type = 'limbs.super_finger'
pbone.lock_location = (False, False, False)
pbone.lock_rotation = (False, False, False)
pbone.lock_rotation_w = False
Expand All @@ -1980,7 +1980,7 @@ def create(obj):
except AttributeError:
pass
pbone = obj.pose.bones[bones['thumb.01.L']]
pbone.rigify_type = 'limbs.simple_tentacle'
pbone.rigify_type = 'limbs.super_finger'
pbone.lock_location = (False, False, False)
pbone.lock_rotation = (False, False, False)
pbone.lock_rotation_w = False
Expand All @@ -1996,7 +1996,7 @@ def create(obj):
except AttributeError:
pass
pbone = obj.pose.bones[bones['f_middle.01.L']]
pbone.rigify_type = 'limbs.simple_tentacle'
pbone.rigify_type = 'limbs.super_finger'
pbone.lock_location = (False, False, False)
pbone.lock_rotation = (False, False, False)
pbone.lock_rotation_w = False
Expand All @@ -2012,7 +2012,7 @@ def create(obj):
except AttributeError:
pass
pbone = obj.pose.bones[bones['f_ring.01.L']]
pbone.rigify_type = 'limbs.simple_tentacle'
pbone.rigify_type = 'limbs.super_finger'
pbone.lock_location = (False, False, False)
pbone.lock_rotation = (False, False, False)
pbone.lock_rotation_w = False
Expand All @@ -2028,7 +2028,7 @@ def create(obj):
except AttributeError:
pass
pbone = obj.pose.bones[bones['f_pinky.01.L']]
pbone.rigify_type = 'limbs.simple_tentacle'
pbone.rigify_type = 'limbs.super_finger'
pbone.lock_location = (False, False, False)
pbone.lock_rotation = (False, False, False)
pbone.lock_rotation_w = False
Expand All @@ -2044,7 +2044,7 @@ def create(obj):
except AttributeError:
pass
pbone = obj.pose.bones[bones['f_index.01.R']]
pbone.rigify_type = 'limbs.simple_tentacle'
pbone.rigify_type = 'limbs.super_finger'
pbone.lock_location = (False, False, False)
pbone.lock_rotation = (False, False, False)
pbone.lock_rotation_w = False
Expand All @@ -2060,7 +2060,7 @@ def create(obj):
except AttributeError:
pass
pbone = obj.pose.bones[bones['thumb.01.R']]
pbone.rigify_type = 'limbs.simple_tentacle'
pbone.rigify_type = 'limbs.super_finger'
pbone.lock_location = (False, False, False)
pbone.lock_rotation = (False, False, False)
pbone.lock_rotation_w = False
Expand All @@ -2076,7 +2076,7 @@ def create(obj):
except AttributeError:
pass
pbone = obj.pose.bones[bones['f_middle.01.R']]
pbone.rigify_type = 'limbs.simple_tentacle'
pbone.rigify_type = 'limbs.super_finger'
pbone.lock_location = (False, False, False)
pbone.lock_rotation = (False, False, False)
pbone.lock_rotation_w = False
Expand All @@ -2092,7 +2092,7 @@ def create(obj):
except AttributeError:
pass
pbone = obj.pose.bones[bones['f_ring.01.R']]
pbone.rigify_type = 'limbs.simple_tentacle'
pbone.rigify_type = 'limbs.super_finger'
pbone.lock_location = (False, False, False)
pbone.lock_rotation = (False, False, False)
pbone.lock_rotation_w = False
Expand All @@ -2108,7 +2108,7 @@ def create(obj):
except AttributeError:
pass
pbone = obj.pose.bones[bones['f_pinky.01.R']]
pbone.rigify_type = 'limbs.simple_tentacle'
pbone.rigify_type = 'limbs.super_finger'
pbone.lock_location = (False, False, False)
pbone.lock_rotation = (False, False, False)
pbone.lock_rotation_w = False
Expand Down
4 changes: 2 additions & 2 deletions rigify/rigs/basic/pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ def add_parameters(self, params):
params.make_extra_control = bpy.props.BoolProperty(
name = "Extra Control",
default = False,
description = "Create an extended control"
description = "Create an optional control"
)

params.make_extra_deform = bpy.props.BoolProperty(
name = "Extra Deform",
default = False,
description = "Create an extra deform bone"
description = "Create an optional deform bone"
)


Expand Down
6 changes: 3 additions & 3 deletions rigify/rigs/chain_rigs.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ def configure_control_bone(self, i, ctrl, org):

@stage.generate_widgets
def make_control_widgets(self):
for ctrl in self.bones.ctrl.fk:
self.make_control_widget(ctrl)
for args in zip(count(0), self.bones.ctrl.fk):
self.make_control_widget(*args)

def make_control_widget(self, ctrl):
def make_control_widget(self, i, ctrl):
create_bone_widget(self.obj, ctrl)

##############################
Expand Down
8 changes: 4 additions & 4 deletions rigify/rigs/experimental/super_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,10 @@ def add_parameters(params):
)

params.bbones = bpy.props.IntProperty(
name='bbone segments',
default=10,
min=1,
description='Number of segments'
name = 'B-Bone Segments',
default = 10,
min = 1,
description = 'Number of B-Bone segments'
)

params.wgt_offset = bpy.props.FloatProperty(
Expand Down
8 changes: 4 additions & 4 deletions rigify/rigs/limbs/limb_rigs.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,17 +809,17 @@ def add_parameters(self, params):
)

params.segments = bpy.props.IntProperty(
name = 'limb segments',
name = 'Limb Segments',
default = 2,
min = 1,
description = 'Number of segments'
description = 'Number of limb segments'
)

params.bbones = bpy.props.IntProperty(
name = 'bbone segments',
name = 'B-Bone Segments',
default = 10,
min = 1,
description = 'Number of segments'
description = 'Number of B-Bone segments'
)

params.make_custom_pivot = bpy.props.BoolProperty(
Expand Down
2 changes: 1 addition & 1 deletion rigify/rigs/limbs/simple_tentacle.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def rig_control_bone(self, i, ctrl, prev_ctrl):
)

# Widgets
def make_control_widget(self, ctrl):
def make_control_widget(self, i, ctrl):
create_circle_widget(self.obj, ctrl, radius=0.3, head_tail=0.5)


Expand Down
42 changes: 29 additions & 13 deletions rigify/rigs/limbs/super_finger.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
from itertools import count

from ...utils.errors import MetarigError
from ...utils.bones import flip_bone, align_chain_x_axis
from ...utils.bones import put_bone, flip_bone, align_chain_x_axis, set_bone_widget_transform
from ...utils.naming import make_derived_name
from ...utils.widgets import create_widget
from ...utils.widgets_basic import create_circle_widget
from ...utils.misc import map_list
from ...utils.layers import ControlLayersOption

from ...base_rig import stage

Expand All @@ -40,7 +41,7 @@ class Rig(SimpleChainRig):
def initialize(self):
super().initialize()

self.bbone_segments = 8
self.bbone_segments = self.params.bbones
self.first_parent = self.get_bone_parent(self.bones.org[0])

def prepare_bones(self):
Expand Down Expand Up @@ -116,6 +117,8 @@ def configure_control_chain(self):
for args in zip(count(0), self.bones.ctrl.fk, self.bones.org + [None]):
self.configure_control_bone(*args)

ControlLayersOption.TWEAK.assign(self.params, self.obj, self.bones.ctrl.fk)

def configure_control_bone(self, i, ctrl, org):
if org:
self.copy_bone_properties(org, ctrl)
Expand All @@ -125,11 +128,13 @@ def configure_control_bone(self, i, ctrl, org):
bone.lock_rotation = (True, True, True)
bone.lock_scale = (True, True, True)

def make_control_widget(self, ctrl):
def make_control_widget(self, i, ctrl):
if ctrl == self.bones.ctrl.fk[-1]:
# Tip control
create_circle_widget(self.obj, ctrl, radius=0.3, head_tail=0.0)
else:
set_bone_widget_transform(self.obj, ctrl, self.bones.org[i])

create_circle_widget(self.obj, ctrl, radius=0.3, head_tail=0.5)

##############################
Expand Down Expand Up @@ -234,20 +239,22 @@ def rig_org_chain(self):
def configure_master_properties(self):
master = self.bones.ctrl.master

self.make_property(master, 'finger_curve', 0.0, description="Rubber hose finger cartoon effect")
if self.bbone_segments > 1:
self.make_property(master, 'finger_curve', 0.0, description="Rubber hose finger cartoon effect")

# Create UI
panel = self.script.panel_with_selected_check(self, self.bones.ctrl.flatten())
panel.custom_prop(master, 'finger_curve', text="Curvature", slider=True)
# Create UI
panel = self.script.panel_with_selected_check(self, self.bones.ctrl.flatten())
panel.custom_prop(master, 'finger_curve', text="Curvature", slider=True)

def rig_deform_bone(self, i, deform, org):
master = self.bones.ctrl.master
bone = self.get_bone(deform)

self.make_constraint(deform, 'COPY_TRANSFORMS', org)

self.make_driver(bone.bone, 'bbone_easein', variables=[(master, 'finger_curve')])
self.make_driver(bone.bone, 'bbone_easeout', variables=[(master, 'finger_curve')])
if self.bbone_segments > 1:
self.make_driver(bone.bone, 'bbone_easein', variables=[(master, 'finger_curve')])
self.make_driver(bone.bone, 'bbone_easeout', variables=[(master, 'finger_curve')])

###############
# OPTIONS
Expand All @@ -261,6 +268,15 @@ def add_parameters(self, params):
('-X', '-X manual', ''), ('-Y', '-Y manual', ''), ('-Z', '-Z manual', '')]
params.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='automatic')

params.bbones = bpy.props.IntProperty(
name = 'B-Bone Segments',
default = 10,
min = 1,
description = 'Number of B-Bone segments'
)

ControlLayersOption.TWEAK.add_parameters(params)

@classmethod
def parameters_ui(self, layout, params):
""" Create the ui for the rig parameters.
Expand All @@ -269,6 +285,10 @@ def parameters_ui(self, layout, params):
r.label(text="Bend rotation axis:")
r.prop(params, "primary_rotation_axis", text="")

layout.prop(params, 'bbones')

ControlLayersOption.TWEAK.parameters_ui(layout, params)


def create_sample(obj):
# generated by rigify.utils.write_metarig
Expand Down Expand Up @@ -320,10 +340,6 @@ def create_sample(obj):
pbone.lock_rotation_w = False
pbone.lock_scale = (False, False, False)
pbone.rotation_mode = 'QUATERNION'
try:
pbone.rigify_parameters.separate_extra_layers = True
except AttributeError:
pass
try:
pbone.rigify_parameters.extra_layers = [False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False]
except AttributeError:
Expand Down
2 changes: 1 addition & 1 deletion rigify/rigs/spines/basic_tail.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def rig_control_bone(self, i, ctrl, prev_ctrl):
)

# Widgets
def make_control_widget(self, ctrl):
def make_control_widget(self, i, ctrl):
create_circle_widget(self.obj, ctrl, radius=0.5, head_tail=0.75)

####################################################
Expand Down

0 comments on commit b9a821b

Please sign in to comment.