diff options
author | Lucio Rossi <lucio.rossi75@gmail.com> | 2017-07-24 19:14:16 +0300 |
---|---|---|
committer | Lucio Rossi <lucio.rossi75@gmail.com> | 2017-07-24 19:14:30 +0300 |
commit | 33b0e2e9025965133656dd85506bbef62ca3183d (patch) | |
tree | 52f2368a79623272cadf64a9c1ca3ac209176231 /rigify/rigs | |
parent | 49230a4c122013bf851ab37b029e7d4f624d68ad (diff) |
Rigify 0.5: new features, Animation Tools and Quat/Euler converter
small fixes & UI improvements
Diffstat (limited to 'rigify/rigs')
-rw-r--r-- | rigify/rigs/experimental/super_chain.py | 22 | ||||
-rw-r--r-- | rigify/rigs/faces/super_face.py | 60 | ||||
-rw-r--r-- | rigify/rigs/limbs/arm.py | 80 | ||||
-rw-r--r-- | rigify/rigs/limbs/leg.py | 104 | ||||
-rw-r--r-- | rigify/rigs/limbs/paw.py | 92 | ||||
-rw-r--r-- | rigify/rigs/limbs/simple_tentacle.py | 32 | ||||
-rw-r--r-- | rigify/rigs/limbs/super_limb.py | 33 | ||||
-rw-r--r-- | rigify/rigs/limbs/super_palm.py | 2 | ||||
-rw-r--r-- | rigify/rigs/limbs/ui.py | 10 | ||||
-rw-r--r-- | rigify/rigs/misc/__init__.py | 0 | ||||
-rw-r--r-- | rigify/rigs/misc/delta.py | 165 | ||||
-rw-r--r-- | rigify/rigs/spines/super_spine.py | 28 | ||||
-rw-r--r-- | rigify/rigs/utils.py | 21 |
13 files changed, 401 insertions, 248 deletions
diff --git a/rigify/rigs/experimental/super_chain.py b/rigify/rigs/experimental/super_chain.py index cff25f2a..32c1b925 100644 --- a/rigify/rigs/experimental/super_chain.py +++ b/rigify/rigs/experimental/super_chain.py @@ -1310,24 +1310,38 @@ def parameters_ui(layout, params): col = r.column(align=True) row = col.row(align=True) + bone_layers = bpy.context.active_pose_bone.bone.layers[:] + for i in range(8): - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) row = col.row(align=True) for i in range(16,24): - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) col = r.column(align=True) row = col.row(align=True) for i in range(8,16): - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) row = col.row(align=True) for i in range(24,32): - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) def create_sample(obj): diff --git a/rigify/rigs/faces/super_face.py b/rigify/rigs/faces/super_face.py index f5121f90..dcdb1093 100644 --- a/rigify/rigs/faces/super_face.py +++ b/rigify/rigs/faces/super_face.py @@ -1031,26 +1031,26 @@ def add_parameters(params): RigifyParameters PropertyGroup """ - #Setting up extra layers for the tweak bones + # Setting up extra layers for the tweak bones params.primary_layers_extra = bpy.props.BoolProperty( - name = "primary_layers_extra", - default = True, - description = "" + name="primary_layers_extra", + default=True, + description="" ) params.primary_layers = bpy.props.BoolVectorProperty( - size = 32, - description = "Layers for the 1st tweak controls to be on", - default = tuple( [ i == 1 for i in range(0, 32) ] ) + size=32, + description="Layers for the 1st tweak controls to be on", + default=tuple([i == 1 for i in range(0, 32)]) ) params.secondary_layers_extra = bpy.props.BoolProperty( - name = "secondary_layers_extra", - default = True, - description = "" + name="secondary_layers_extra", + default=True, + description="" ) params.secondary_layers = bpy.props.BoolVectorProperty( - size = 32, - description = "Layers for the 2nd tweak controls to be on", - default = tuple( [ i == 1 for i in range(0, 32) ] ) + size=32, + description="Layers for the 2nd tweak controls to be on", + default=tuple([i == 1 for i in range(0, 32)]) ) @@ -1058,29 +1058,43 @@ def parameters_ui(layout, params): """ Create the ui for the rig parameters.""" layers = ["primary_layers", "secondary_layers"] + bone_layers = bpy.context.active_pose_bone.bone.layers[:] + for layer in layers: r = layout.row() r.prop( params, layer + "_extra" ) r.active = getattr( params, layer + "_extra" ) - + col = r.column(align=True) row = col.row(align=True) for i in range(8): - row.prop(params, layer, index=i, toggle=True, text="") + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer, index=i, toggle=True, text="", icon=icon) row = col.row(align=True) - for i in range(16,24): - row.prop(params, layer, index=i, toggle=True, text="") - + for i in range(16, 24): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer, index=i, toggle=True, text="", icon=icon) + col = r.column(align=True) row = col.row(align=True) - - for i in range(8,16): - row.prop(params, layer, index=i, toggle=True, text="") + + for i in range(8, 16): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer, index=i, toggle=True, text="", icon=icon) row = col.row(align=True) - for i in range(24,32): - row.prop(params, layer, index=i, toggle=True, text="") + for i in range(24, 32): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer, index=i, toggle=True, text="", icon=icon) def create_sample(obj): diff --git a/rigify/rigs/limbs/arm.py b/rigify/rigs/limbs/arm.py index b5c07569..193e2034 100644 --- a/rigify/rigs/limbs/arm.py +++ b/rigify/rigs/limbs/arm.py @@ -4,7 +4,7 @@ from .ui import create_script from .limb_utils import * from mathutils import Vector from ...utils import copy_bone, flip_bone, put_bone, create_cube_widget -from ...utils import strip_org, make_deformer_name, create_widget +from ...utils import strip_org, strip_mch, make_deformer_name, create_widget from ...utils import create_circle_widget, create_sphere_widget, create_line_widget from ...utils import MetarigError, make_mechanism_name, org from ...utils import create_limb_widget, connected_children_names @@ -982,6 +982,52 @@ class Rig: var.targets[0].data_path = \ owner.path_from_id() + '[' + '"' + prop + '"' + ']' + @staticmethod + def get_future_names(bones): + + if len(bones) != 3: + return + + names = dict() + + uarm = strip_mch(strip_org(bones[0].name)) + farm = strip_mch(strip_org(bones[1].name)) + hand = strip_mch(strip_org(bones[2].name)) + + suffix='' + if uarm[-2:] == '.L' or uarm[-2:] == '.R': + suffix = uarm[-2:] + uarm = uarm.rstrip(suffix) + farm = farm.rstrip(suffix) + hand = hand.rstrip(suffix) + + # the following is declared in rig_ui + # controls = ['upper_arm_ik.L', 'upper_arm_fk.L', 'forearm_fk.L', 'hand_fk.L', 'hand_ik.L', 'MCH-hand_fk.L', + # 'upper_arm_parent.L'] + # tweaks = ['upper_arm_tweak.L.001', 'forearm_tweak.L', 'forearm_tweak.L.001'] + # ik_ctrl = ['hand_ik.L', 'MCH-upper_arm_ik.L', 'MCH-upper_arm_ik_target.L'] + # fk_ctrl = 'upper_arm_fk.L' + # parent = 'upper_arm_parent.L' + # hand_fk = 'hand_fk.L' + # pole = 'upper_arm_ik_target.L' + + names['controls'] = [uarm + '_ik', uarm + '_fk', farm + '_fk', hand + '_fk', hand + '_ik', + make_mechanism_name(hand + '_fk'), uarm + '_parent'] + names['ik_ctrl'] = [hand + '_ik', make_mechanism_name(uarm) + '_ik', make_mechanism_name(uarm) + '_ik_target'] + names['fk_ctrl'] = uarm + '_fk' + suffix + names['parent'] = uarm + '_parent' + suffix + names['hand_fk'] = hand + '_fk' + suffix + names['pole'] = uarm + '_ik_target' + suffix + names['limb_type'] = 'arm' + + if suffix: + for i, name in enumerate(names['controls']): + names['controls'][i] = name + suffix + for i, name in enumerate(names['ik_ctrl']): + names['ik_ctrl'][i] = name + suffix + + return names + def generate(self): bpy.ops.object.mode_set(mode='EDIT') eb = self.obj.data.edit_bones @@ -1105,7 +1151,9 @@ def parameters_ui(layout, params): r = layout.row() r.prop(params, "bbones") - for layer in [ 'fk', 'tweak' ]: + bone_layers = bpy.context.active_pose_bone.bone.layers[:] + + for layer in ['fk', 'tweak']: r = layout.row() r.prop(params, layer + "_extra_layers") r.active = params.tweak_extra_layers @@ -1114,23 +1162,35 @@ def parameters_ui(layout, params): row = col.row(align=True) for i in range(8): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) row = col.row(align=True) - for i in range(16,24): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + for i in range(16, 24): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) col = r.column(align=True) row = col.row(align=True) - for i in range(8,16): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + for i in range(8, 16): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) row = col.row(align=True) - for i in range(24,32): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + for i in range(24, 32): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) def create_sample(obj): @@ -1341,7 +1401,7 @@ def create_sample(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone = obj.pose.bones[bones['palm.01.L']] - pbone.rigify_type = 'palm' + pbone.rigify_type = 'limbs.super_palm' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False diff --git a/rigify/rigs/limbs/leg.py b/rigify/rigs/limbs/leg.py index 021f641b..6c76dd9f 100644 --- a/rigify/rigs/limbs/leg.py +++ b/rigify/rigs/limbs/leg.py @@ -5,7 +5,7 @@ from .ui import create_script from .limb_utils import * from mathutils import Vector from ...utils import copy_bone, flip_bone, put_bone, create_cube_widget -from ...utils import strip_org, make_deformer_name, create_widget +from ...utils import strip_org, strip_mch, make_deformer_name, create_widget from ...utils import create_circle_widget, create_sphere_widget, create_line_widget from ...utils import MetarigError, make_mechanism_name, org from ...utils import create_limb_widget, connected_children_names @@ -363,7 +363,7 @@ class Rig: # Rubber hose drivers pb = self.obj.pose.bones - for i,t in enumerate( tweaks[1:-1] ): + for i, t in enumerate(tweaks[1:-1]): # Create custom property on tweak bone to control rubber hose name = 'rubber_tweak' @@ -406,18 +406,18 @@ class Rig: def create_ik(self, parent): org_bones = self.org_bones - bpy.ops.object.mode_set(mode ='EDIT') + bpy.ops.object.mode_set(mode='EDIT') eb = self.obj.data.edit_bones ctrl = get_bone_name(org_bones[0], 'ctrl', 'ik') mch_ik = get_bone_name(org_bones[0], 'mch', 'ik') mch_target = get_bone_name(org_bones[0], 'mch', 'ik_target') - for o, ik in zip( org_bones, [ ctrl, mch_ik, mch_target ] ): - bone = copy_bone( self.obj, o, ik ) + for o, ik in zip(org_bones, [ctrl, mch_ik, mch_target]): + bone = copy_bone(self.obj, o, ik) - if org_bones.index(o) == len( org_bones ) - 1: - eb[ bone ].length /= 4 + if org_bones.index(o) == len(org_bones) - 1: + eb[bone].length /= 4 # Create MCH Stretch mch_str = copy_bone( @@ -687,6 +687,13 @@ class Rig: else: leg_parent = None + mch_name = get_bone_name(strip_org(org_bones[0]), 'mch', 'parent_socket') + mch_main_parent = copy_bone(self.obj, org_bones[0], mch_name) + eb[mch_main_parent].length = eb[org_bones[0]].length / 12 + eb[mch_main_parent].parent = eb[bones['parent']] + eb[mch_main_parent].roll = 0.0 + eb[bones['main_parent']].parent = eb[mch_main_parent] + # Create heel ctrl bone heel = get_bone_name(org_bones[2], 'ctrl', 'heel_ik') heel = copy_bone(self.obj, org_bones[2], heel) @@ -948,6 +955,10 @@ class Rig: 'max_y' : 1.05, 'owner_space' : 'LOCAL' }) + make_constraint(self, mch_main_parent, { + 'constraint': 'COPY_ROTATION', + 'subtarget': org_bones[0] + }) # Create ik/fk switch property pb_parent = pb[bones['main_parent']] @@ -1291,6 +1302,55 @@ class Rig: var.targets[0].data_path = \ owner.path_from_id() + '[' + '"' + prop + '"' + ']' + @staticmethod + def get_future_names(bones): + + if len(bones) != 4: + return + + names = dict() + + thigh = strip_mch(strip_org(bones[0].name)) + shin = strip_mch(strip_org(bones[1].name)) + foot = strip_mch(strip_org(bones[2].name)) + toe = strip_mch(strip_org(bones[3].name)) + + suffix = '' + if thigh[-2:] == '.L' or thigh[-2:] == '.R': + suffix = thigh[-2:] + thigh = thigh.rstrip(suffix) + shin = shin.rstrip(suffix) + foot = foot.rstrip(suffix) + toe = toe.rstrip(suffix) + + # the following is declared in rig_ui + # controls = ['thigh_ik.R', 'thigh_fk.R', 'shin_fk.R', 'foot_fk.R', 'toe.R', 'foot_heel_ik.R', 'foot_ik.R', + # 'MCH-foot_fk.R', 'thigh_parent.R'] + # tweaks = ['thigh_tweak.R.001', 'shin_tweak.R', 'shin_tweak.R.001'] + # ik_ctrl = ['foot_ik.R', 'MCH-thigh_ik.R', 'MCH-thigh_ik_target.R'] + # fk_ctrl = 'thigh_fk.R' + # parent = 'thigh_parent.R' + # foot_fk = 'foot_fk.R' + # pole = 'thigh_ik_target.R' + + names['controls'] = [thigh + '_ik', thigh + '_fk', shin + '_fk', foot + '_fk', toe, foot + '_heel_ik', + foot + '_ik', make_mechanism_name(foot + '_fk'), thigh + '_parent'] + names['ik_ctrl'] = [foot + '_ik', make_mechanism_name(thigh) + '_ik', make_mechanism_name(thigh) + '_ik_target'] + names['fk_ctrl'] = thigh + '_fk' + suffix + names['parent'] = thigh + '_parent' + suffix + names['foot_fk'] = foot + '_fk' + suffix + names['pole'] = thigh + '_ik_target' + suffix + + names['limb_type'] = 'leg' + + if suffix: + for i, name in enumerate(names['controls']): + names['controls'][i] = name + suffix + for i, name in enumerate(names['ik_ctrl']): + names['ik_ctrl'][i] = name + suffix + + return names + def generate(self): bpy.ops.object.mode_set(mode='EDIT') eb = self.obj.data.edit_bones @@ -1414,7 +1474,9 @@ def parameters_ui(layout, params): r = layout.row() r.prop(params, "bbones") - for layer in [ 'fk', 'tweak' ]: + bone_layers = bpy.context.active_pose_bone.bone.layers[:] + + for layer in ['fk', 'tweak']: r = layout.row() r.prop(params, layer + "_extra_layers") r.active = params.tweak_extra_layers @@ -1423,23 +1485,35 @@ def parameters_ui(layout, params): row = col.row(align=True) for i in range(8): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) row = col.row(align=True) - for i in range(16,24): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + for i in range(16, 24): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) col = r.column(align=True) row = col.row(align=True) - for i in range(8,16): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + for i in range(8, 16): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) row = col.row(align=True) - for i in range(24,32): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + for i in range(24, 32): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) def create_sample(obj): diff --git a/rigify/rigs/limbs/paw.py b/rigify/rigs/limbs/paw.py index 8c9dab20..9c39d87b 100644 --- a/rigify/rigs/limbs/paw.py +++ b/rigify/rigs/limbs/paw.py @@ -3,7 +3,7 @@ from .ui import create_script from .limb_utils import * from mathutils import Vector from ...utils import copy_bone, flip_bone, put_bone, create_cube_widget -from ...utils import strip_org, make_deformer_name, create_widget +from ...utils import strip_org, strip_mch, make_deformer_name, create_widget from ...utils import create_circle_widget, create_sphere_widget, create_line_widget from ...utils import MetarigError, make_mechanism_name, org from ...utils import create_limb_widget, connected_children_names @@ -672,6 +672,13 @@ class Rig: else: paw_parent = None + mch_name = get_bone_name(strip_org(org_bones[0]), 'mch', 'parent_socket') + mch_main_parent = copy_bone(self.obj, org_bones[0], mch_name) + eb[mch_main_parent].length = eb[org_bones[0]].length / 12 + eb[mch_main_parent].parent = eb[bones['parent']] + eb[mch_main_parent].roll = 0.0 + eb[bones['main_parent']].parent = eb[mch_main_parent] + # Create heel ctrl bone heel = get_bone_name(org_bones[2], 'ctrl', 'heel_ik') heel = copy_bone(self.obj, org_bones[2], heel) @@ -776,6 +783,10 @@ class Rig: 'max_y' : 1.05, 'owner_space' : 'LOCAL' }) + make_constraint(self, mch_main_parent, { + 'constraint': 'COPY_ROTATION', + 'subtarget': org_bones[0] + }) pb = self.obj.pose.bones @@ -1119,6 +1130,55 @@ class Rig: var.targets[0].data_path = \ owner.path_from_id() + '[' + '"' + prop + '"' + ']' + @staticmethod + def get_future_names(bones): + + if len(bones) != 4: + return + + names = dict() + + thigh = strip_mch(strip_org(bones[0].name)) + shin = strip_mch(strip_org(bones[1].name)) + foot = strip_mch(strip_org(bones[2].name)) + toe = strip_mch(strip_org(bones[3].name)) + + suffix = '' + if thigh[-2:] == '.L' or thigh[-2:] == '.R': + suffix = thigh[-2:] + thigh = thigh.rstrip(suffix) + shin = shin.rstrip(suffix) + foot = foot.rstrip(suffix) + toe = toe.rstrip(suffix) + + # the following is declared in rig_ui + # controls = ['thigh_ik.R', 'thigh_fk.R', 'shin_fk.R', 'foot_fk.R', 'toe.R', 'foot_heel_ik.R', 'foot_ik.R', + # 'MCH-foot_fk.R', 'thigh_parent.R'] + # tweaks = ['thigh_tweak.R.001', 'shin_tweak.R', 'shin_tweak.R.001'] + # ik_ctrl = ['foot_ik.R', 'MCH-thigh_ik.R', 'MCH-thigh_ik_target.R'] + # fk_ctrl = 'thigh_fk.R' + # parent = 'thigh_parent.R' + # foot_fk = 'foot_fk.R' + # pole = 'thigh_ik_target.R' + + names['controls'] = [thigh + '_ik', thigh + '_fk', shin + '_fk', foot + '_fk', toe, foot + '_heel_ik', + foot + '_ik', make_mechanism_name(foot + '_fk'), thigh + '_parent'] + names['ik_ctrl'] = [foot + '_ik', make_mechanism_name(thigh) + '_ik', make_mechanism_name(thigh) + '_ik_target'] + names['fk_ctrl'] = thigh + '_fk' + suffix + names['parent'] = thigh + '_parent' + suffix + names['foot_fk'] = foot + '_fk' + suffix + names['pole'] = thigh + '_ik_target' + suffix + + names['limb_type'] = 'paw' + + if suffix: + for i, name in enumerate(names['controls']): + names['controls'][i] = name + suffix + for i, name in enumerate(names['ik_ctrl']): + names['ik_ctrl'][i] = name + suffix + + return names + def generate(self): bpy.ops.object.mode_set(mode='EDIT') eb = self.obj.data.edit_bones @@ -1242,7 +1302,9 @@ def parameters_ui(layout, params): r = layout.row() r.prop(params, "bbones") - for layer in [ 'fk', 'tweak' ]: + bone_layers = bpy.context.active_pose_bone.bone.layers[:] + + for layer in ['fk', 'tweak']: r = layout.row() r.prop(params, layer + "_extra_layers") r.active = params.tweak_extra_layers @@ -1251,23 +1313,35 @@ def parameters_ui(layout, params): row = col.row(align=True) for i in range(8): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) row = col.row(align=True) - for i in range(16,24): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + for i in range(16, 24): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) col = r.column(align=True) row = col.row(align=True) - for i in range(8,16): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + for i in range(8, 16): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) row = col.row(align=True) - for i in range(24,32): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + for i in range(24, 32): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) def create_sample(obj): diff --git a/rigify/rigs/limbs/simple_tentacle.py b/rigify/rigs/limbs/simple_tentacle.py index d8ca1bf9..310ed7ab 100644 --- a/rigify/rigs/limbs/simple_tentacle.py +++ b/rigify/rigs/limbs/simple_tentacle.py @@ -249,7 +249,7 @@ def parameters_ui(layout, params): r = layout.row() col = r.column(align=True) row = col.row(align=True) - for i,axis in enumerate( [ 'x', 'y', 'z' ] ): + for i, axis in enumerate(['x', 'y', 'z']): row.prop(params, "copy_rotation_axes", index=i, toggle=True, text=axis) r = layout.row() @@ -259,24 +259,38 @@ def parameters_ui(layout, params): col = r.column(align=True) row = col.row(align=True) - for i in range( 8 ): # Layers 0-7 - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + bone_layers = bpy.context.active_pose_bone.bone.layers[:] - row = col.row(align=True) + for i in range(8): # Layers 0-7 + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) - for i in range( 16, 24 ): # Layers 16-23 - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + row = col.row(align=True) + for i in range(16, 24): # Layers 16-23 + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) + col = r.column(align=True) row = col.row(align=True) - for i in range( 8, 16 ): # Layers 8-15 - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + for i in range(8, 16): # Layers 8-15 + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) row = col.row(align=True) for i in range( 24, 32 ): # Layers 24-31 - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) def create_sample(obj): diff --git a/rigify/rigs/limbs/super_limb.py b/rigify/rigs/limbs/super_limb.py index 8ce98a31..e5670829 100644 --- a/rigify/rigs/limbs/super_limb.py +++ b/rigify/rigs/limbs/super_limb.py @@ -23,6 +23,15 @@ class Rig: return self.limb.generate() + @staticmethod + def get_future_names(bones): + if bones[0].rigify_parameters.limb_type == 'arm': + return armRig.get_future_names(bones) + elif bones[0].rigify_parameters.limb_type == 'leg': + return legRig.get_future_names(bones) + elif bones[0].rigify_parameters.limb_type == 'paw': + return pawRig.get_future_names(bones) + def add_parameters(params): """ Add the parameters of this rig type to the @@ -121,7 +130,9 @@ def parameters_ui(layout, params): r = layout.row() r.prop(params, "bbones") - for layer in [ 'fk', 'tweak' ]: + bone_layers = bpy.context.active_pose_bone.bone.layers[:] + + for layer in ['fk', 'tweak']: r = layout.row() r.prop(params, layer + "_extra_layers") r.active = params.tweak_extra_layers @@ -130,23 +141,35 @@ def parameters_ui(layout, params): row = col.row(align=True) for i in range(8): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) row = col.row(align=True) for i in range(16,24): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) col = r.column(align=True) row = col.row(align=True) for i in range(8,16): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) row = col.row(align=True) for i in range(24,32): - row.prop(params, layer + "_layers", index=i, toggle=True, text="") + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) def create_sample(obj): diff --git a/rigify/rigs/limbs/super_palm.py b/rigify/rigs/limbs/super_palm.py index efcb5681..127d9d0c 100644 --- a/rigify/rigs/limbs/super_palm.py +++ b/rigify/rigs/limbs/super_palm.py @@ -308,7 +308,7 @@ def create_sample(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'YXZ' pbone = obj.pose.bones[bones['palm.01']] - pbone.rigify_type = 'palm' + pbone.rigify_type = 'limbs.super_palm' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, True, True) pbone.lock_rotation_w = False diff --git a/rigify/rigs/limbs/ui.py b/rigify/rigs/limbs/ui.py index 7783e06d..f04eb891 100644 --- a/rigify/rigs/limbs/ui.py +++ b/rigify/rigs/limbs/ui.py @@ -26,6 +26,11 @@ if is_selected( controls ): props.hand_ik = controls[4] props.pole = pole props.main_parent = parent + props = layout.operator("rigify.rotation_pole", text="Switch Rotation-Pole") + props.bone_name = controls[1] + props.window = "CURRENT" + props.toggle = True + props.bake = False # BBone rubber hose on each Respective Tweak @@ -76,6 +81,11 @@ if is_selected( controls ): props.footroll = controls[5] props.mfoot_ik = ik_ctrl[2] props.main_parent = parent + props = layout.operator("rigify.rotation_pole", text="Toggle Rotation and Pole") + props.bone_name = controls[1] + props.window = "CURRENT" + props.toggle = True + props.bake = False # BBone rubber hose on each Respective Tweak for t in tweaks: diff --git a/rigify/rigs/misc/__init__.py b/rigify/rigs/misc/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/rigify/rigs/misc/__init__.py +++ /dev/null diff --git a/rigify/rigs/misc/delta.py b/rigify/rigs/misc/delta.py deleted file mode 100644 index 84f3612b..00000000 --- a/rigify/rigs/misc/delta.py +++ /dev/null @@ -1,165 +0,0 @@ -#====================== BEGIN GPL LICENSE BLOCK ====================== -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -#======================= END GPL LICENSE BLOCK ======================== - -# <pep8 compliant> - -if False: - # This rig type is disabled due to its obscurity. - # However, some of the code may be useful in the future, so - # I'm leaving it here. - from math import acos - - import bpy - - from ...utils import MetarigError - from ...utils import copy_bone - from ...utils import org_name, make_mechanism_name - - - class Rig: - """ A delta rig. - Creates a setup that will place its child at its position in pose mode, - but will not modifying its child's position in edit mode. - This is a mechanism-only rig (no control or deformation bones). - - """ - def __init__(self, obj, bone, params): - """ Gather and validate data about the rig. - Store any data or references to data that will be needed later on. - In particular, store references to bones that will be needed. - Do NOT change any data in the scene. This is a gathering phase only. - - """ - bb = obj.data.bones - - if bb[bone].children is None: - raise MetarigError("RIGIFY ERROR: bone '%s': rig type requires one child" % org_name(bone.name)) - if bb[bone].use_connect is True: - raise MetarigError("RIGIFY ERROR: bone '%s': rig type cannot be connected to parent" % org_name(bone.name)) - - self.obj = obj - self.org_bones = {"delta": bone, "child": bb[bone].children[0].name} - self.org_names = [org_name(bone), org_name(bb[bone].children[0].name)] - - def generate(self): - """ Generate the rig. - Do NOT modify any of the original bones, except for adding constraints. - The main armature should be selected and active before this is called. - - """ - bpy.ops.object.mode_set(mode='EDIT') - eb = self.obj.data.edit_bones - - org_delta = self.org_bones["delta"] - org_delta_e = eb[self.org_bones["delta"]] - # org_child = self.org_bones["child"] # UNUSED - org_child_e = eb[self.org_bones["child"]] - - # Calculate the matrix for achieving the delta - child_mat = org_delta_e.matrix.invert() * org_child_e.matrix - mat = org_delta_e.matrix * child_mat.invert() - - # Create the delta bones. - delta_e = eb[copy_bone(self.obj, self.org_bones["delta"])] - delta_e.name = make_mechanism_name(self.org_names[0]) - delta = delta_e.name - - # Set the delta to the matrix's transforms - set_mat(self.obj, delta, mat) - - bpy.ops.object.mode_set(mode='OBJECT') - - # Constrain org_delta to delta - con = self.obj.pose.bones[org_delta].constraints.new('COPY_TRANSFORMS') - con.name = "delta" - con.target = self.obj - con.subtarget = delta - - def create_sample(obj): - # generated by rigify.utils.write_metarig - bpy.ops.object.mode_set(mode='EDIT') - arm = obj.data - - bones = {} - - bone = arm.edit_bones.new('delta') - bone.head[:] = 0.0000, -0.1198, 0.1253 - bone.tail[:] = -0.0000, -0.2483, 0.2785 - bone.roll = -0.0000 - bone.use_connect = False - bones['delta'] = bone.name - bone = arm.edit_bones.new('Bone') - bone.head[:] = -0.0000, 0.0000, 0.0000 - bone.tail[:] = -0.0000, 0.0000, 0.2000 - bone.roll = 0.0000 - bone.use_connect = False - bone.parent = arm.edit_bones[bones['delta']] - bones['Bone'] = bone.name - - bpy.ops.object.mode_set(mode='OBJECT') - pbone = obj.pose.bones[bones['delta']] - pbone.rigify_type = 'misc.delta' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - pbone = obj.pose.bones[bones['Bone']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - - bpy.ops.object.mode_set(mode='EDIT') - for bone in arm.edit_bones: - bone.select = False - bone.select_head = False - bone.select_tail = False - for b in bones: - bone = arm.edit_bones[bones[b]] - bone.select = True - bone.select_head = True - bone.select_tail = True - arm.edit_bones.active = bone - - def set_mat(obj, bone_name, matrix): - """ Sets the bone to have the given transform matrix. - """ - a = obj.data.edit_bones[bone_name] - - a.head = (0, 0, 0) - a.tail = (0, 1, 0) - - a.transform(matrix) - - d = acos(a.matrix.to_quaternion().dot(matrix.to_quaternion())) * 2.0 - - roll_1 = a.roll + d - roll_2 = a.roll - d - - a.roll = roll_1 - d1 = a.matrix.to_quaternion().dot(matrix.to_quaternion()) - a.roll = roll_2 - d2 = a.matrix.to_quaternion().dot(matrix.to_quaternion()) - - if d1 > d2: - a.roll = roll_1 - else: - a.roll = roll_2 diff --git a/rigify/rigs/spines/super_spine.py b/rigify/rigs/spines/super_spine.py index a1991afd..c96af461 100644 --- a/rigify/rigs/spines/super_spine.py +++ b/rigify/rigs/spines/super_spine.py @@ -1103,24 +1103,38 @@ def parameters_ui(layout, params): col = r.column(align=True) row = col.row(align=True) + bone_layers = bpy.context.active_pose_bone.bone.layers[:] + for i in range(8): - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) row = col.row(align=True) - for i in range(16,24): - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + for i in range(16, 24): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) col = r.column(align=True) row = col.row(align=True) - for i in range(8,16): - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + for i in range(8, 16): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) row = col.row(align=True) - for i in range(24,32): - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + for i in range(24, 32): + icon = "NONE" + if bone_layers[i]: + icon = "LAYER_ACTIVE" + row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) def create_sample(obj): diff --git a/rigify/rigs/utils.py b/rigify/rigs/utils.py new file mode 100644 index 00000000..c08cb8f9 --- /dev/null +++ b/rigify/rigs/utils.py @@ -0,0 +1,21 @@ +from .limbs.super_limb import Rig as LimbRig +from ..utils import connected_children_names +import re + + +def get_limb_generated_names(rig): + + pbones = rig.pose.bones + names = dict() + + for b in pbones: + super_limb_orgs = [] + if re.match('^ORG', b.name) and b.rigify_type == 'limbs.super_limb': + super_limb_orgs.append(b) + children = connected_children_names(rig, b.name) + for child in children: + if re.match('^ORG', child) or re.match('^MCH', child): + super_limb_orgs.append(pbones[child]) + names[b.name] = LimbRig.get_future_names(super_limb_orgs) + + return names |