diff options
Diffstat (limited to 'rigify/rigs')
-rw-r--r-- | rigify/rigs/experimental/super_chain.py | 64 | ||||
-rw-r--r-- | rigify/rigs/faces/super_face.py | 4 | ||||
-rw-r--r-- | rigify/rigs/limbs/arm.py | 102 | ||||
-rw-r--r-- | rigify/rigs/limbs/leg.py | 102 | ||||
-rw-r--r-- | rigify/rigs/limbs/paw.py | 103 | ||||
-rw-r--r-- | rigify/rigs/limbs/simple_tentacle.py | 62 | ||||
-rw-r--r-- | rigify/rigs/limbs/super_limb.py | 69 | ||||
-rw-r--r-- | rigify/rigs/spines/super_spine.py | 62 |
8 files changed, 73 insertions, 495 deletions
diff --git a/rigify/rigs/experimental/super_chain.py b/rigify/rigs/experimental/super_chain.py index 565e5bdc..e833d256 100644 --- a/rigify/rigs/experimental/super_chain.py +++ b/rigify/rigs/experimental/super_chain.py @@ -4,6 +4,7 @@ from ...utils import copy_bone, put_bone, org, align_bone_y_axis, align_bone_x_a from ...utils import strip_org, make_deformer_name, connected_children_names from ...utils import create_chain_widget from ...utils import make_mechanism_name, create_cube_widget +from ...utils import ControlLayersOption from rna_prop_ui import rna_idprop_ui_prop_get from ..limbs.limb_utils import get_bone_name @@ -22,12 +23,6 @@ class Rig: self.bbones = params.bbones self.SINGLE_BONE = (len(self.org_bones) == 1) - # Assign values to tweak layers props if opted by user - if params.tweak_extra_layers: - self.tweak_layers = list(params.tweak_layers) - else: - self.tweak_layers = None - def orient_bone(self, eb, axis, scale, reverse=False): v = Vector((0, 0, 0)) @@ -563,9 +558,7 @@ class Rig: ) # Assigning layers to tweaks and ctrls - for bone in bones['chain']['tweak']: - if self.tweak_layers: - pb[bone].bone.layers = self.tweak_layers + ControlLayersOption.TWEAK.assign(self.params, pb, bones['chain']['tweak']) return @@ -626,18 +619,7 @@ def add_parameters(params): description='Number of segments' ) - # Setting up extra layers for the FK and tweak - params.tweak_extra_layers = bpy.props.BoolProperty( - name="tweak_extra_layers", - default=True, - description="" - ) - - params.tweak_layers = bpy.props.BoolVectorProperty( - size=32, - description="Layers for the tweak controls to be on", - default=tuple([i == 1 for i in range(0, 32)]) - ) + ControlLayersOption.TWEAK.add_parameters(params) def parameters_ui(layout, params): @@ -656,45 +638,7 @@ def parameters_ui(layout, params): r = layout.row() r.prop_search(params, 'conv_bone', pb, "bones", text="Convergence Bone") - r = layout.row() - r.prop(params, "tweak_extra_layers") - r.active = params.tweak_extra_layers - - col = r.column(align=True) - row = col.row(align=True) - - bone_layers = bpy.context.active_pose_bone.bone.layers[:] - - for i in range(8): - 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): - 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): - 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): - icon = "NONE" - if bone_layers[i]: - icon = "LAYER_ACTIVE" - row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) + ControlLayersOption.TWEAK.parameters_ui(layout, params) def create_sample(obj): diff --git a/rigify/rigs/faces/super_face.py b/rigify/rigs/faces/super_face.py index c097cbb9..8248c38b 100644 --- a/rigify/rigs/faces/super_face.py +++ b/rigify/rigs/faces/super_face.py @@ -1042,7 +1042,7 @@ def add_parameters(params): ) params.primary_layers = bpy.props.BoolVectorProperty( size=32, - description="Layers for the 1st tweak controls to be on", + description="Layers for the primary controls to be on", default=tuple([i == 1 for i in range(0, 32)]) ) params.secondary_layers_extra = bpy.props.BoolProperty( @@ -1052,7 +1052,7 @@ def add_parameters(params): ) params.secondary_layers = bpy.props.BoolVectorProperty( size=32, - description="Layers for the 2nd tweak controls to be on", + description="Layers for the secondary controls to be on", default=tuple([i == 1 for i in range(0, 32)]) ) diff --git a/rigify/rigs/limbs/arm.py b/rigify/rigs/limbs/arm.py index f9174e92..1f964dc0 100644 --- a/rigify/rigs/limbs/arm.py +++ b/rigify/rigs/limbs/arm.py @@ -3,12 +3,14 @@ from ..widgets import create_hand_widget, create_gear_widget 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, strip_mch, make_deformer_name, create_widget +from ...utils import copy_bone, put_bone +from ...utils import strip_org, strip_mch from ...utils import create_circle_widget, create_sphere_widget, create_line_widget -from ...utils import MetarigError, make_mechanism_name, org +from ...utils import make_mechanism_name from ...utils import create_limb_widget, connected_children_names -from ...utils import align_bone_y_axis, align_bone_x_axis, align_bone_z_axis +from ...utils import align_bone_x_axis, align_bone_z_axis +from ...rig_ui_template import UTILITIES_RIG_ARM, REGISTER_RIG_ARM +from ...utils import ControlLayersOption from rna_prop_ui import rna_idprop_ui_prop_get from ..widgets import create_ikarrow_widget from math import trunc, pi @@ -46,16 +48,6 @@ class Rig: self.rot_axis = params.rotation_axis self.auto_align_extremity = params.auto_align_extremity - # Assign values to tweak/FK layers props if opted by user - if params.tweak_extra_layers: - self.tweak_layers = list(params.tweak_layers) - else: - self.tweak_layers = None - - if params.fk_extra_layers: - self.fk_layers = list(params.fk_layers) - else: - self.fk_layers = None def orient_org_bones(self): @@ -266,8 +258,7 @@ class Rig: create_sphere_widget(self.obj, t, bone_transform_name=None) - if self.tweak_layers: - pb[t].bone.layers = self.tweak_layers + ControlLayersOption.TWEAK.assign(self.params, pb, tweaks['ctrl']) return tweaks @@ -547,9 +538,7 @@ class Rig: create_circle_widget(self.obj, ctrls[2], radius=0.4, head_tail=0.0) - for c in ctrls: - if self.fk_layers: - pb[c].bone.layers = self.fk_layers + ControlLayersOption.FK.assign(self.params, pb, ctrls) return {'ctrl': ctrls, 'mch': mch} @@ -1067,7 +1056,12 @@ class Rig: script += extra_script % (controls_string, bones['main_parent'], 'IK_follow', 'pole_follow', 'pole_follow', 'root/parent', 'root/parent') - return [script] + return { + 'script': [script], + 'utilities': UTILITIES_RIG_ARM, + 'register': REGISTER_RIG_ARM, + 'noparent_bones': [bones['ik']['mch_hand'][i] for i in [0,1]], + } def add_parameters(params): @@ -1108,30 +1102,8 @@ def add_parameters(params): ) # Setting up extra layers for the FK and tweak - params.tweak_extra_layers = bpy.props.BoolProperty( - name = "tweak_extra_layers", - default = True, - description = "" - ) - - params.tweak_layers = bpy.props.BoolVectorProperty( - size = 32, - description = "Layers for the tweak controls to be on", - default = tuple( [ i == 1 for i in range(0, 32) ] ) - ) - - # Setting up extra layers for the FK and tweak - params.fk_extra_layers = bpy.props.BoolProperty( - name = "fk_extra_layers", - default = True, - description = "" - ) - - params.fk_layers = bpy.props.BoolVectorProperty( - size = 32, - description = "Layers for the FK controls to be on", - default = tuple( [ i == 1 for i in range(0, 32) ] ) - ) + ControlLayersOption.FK.add_parameters(params) + ControlLayersOption.TWEAK.add_parameters(params) def parameters_ui(layout, params): @@ -1151,46 +1123,8 @@ def parameters_ui(layout, params): r = layout.row() r.prop(params, "bbones") - 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 - - col = r.column(align=True) - row = col.row(align=True) - - for i in range(8): - 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): - 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): - 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): - icon = "NONE" - if bone_layers[i]: - icon = "LAYER_ACTIVE" - row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) + ControlLayersOption.FK.parameters_ui(layout, params) + ControlLayersOption.TWEAK.parameters_ui(layout, params) def create_sample(obj): diff --git a/rigify/rigs/limbs/leg.py b/rigify/rigs/limbs/leg.py index 4f53fb89..743e5703 100644 --- a/rigify/rigs/limbs/leg.py +++ b/rigify/rigs/limbs/leg.py @@ -1,15 +1,17 @@ -import bpy, re, math +import bpy, math from ..widgets import create_foot_widget, create_ballsocket_widget, create_gear_widget 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, strip_mch, make_deformer_name, create_widget +from ...utils import copy_bone, flip_bone, put_bone +from ...utils import strip_org, strip_mch from ...utils import create_circle_widget, create_sphere_widget, create_line_widget -from ...utils import MetarigError, make_mechanism_name, org +from ...utils import MetarigError, make_mechanism_name from ...utils import create_limb_widget, connected_children_names from ...utils import align_bone_y_axis, align_bone_x_axis, align_bone_z_axis +from ...rig_ui_template import UTILITIES_RIG_LEG, REGISTER_RIG_LEG +from ...utils import ControlLayersOption from rna_prop_ui import rna_idprop_ui_prop_get from ..widgets import create_ikarrow_widget from math import trunc, pi @@ -47,16 +49,6 @@ class Rig: self.rot_axis = params.rotation_axis self.auto_align_extremity = params.auto_align_extremity - # Assign values to tweak/FK layers props if opted by user - if params.tweak_extra_layers: - self.tweak_layers = list(params.tweak_layers) - else: - self.tweak_layers = None - - if params.fk_extra_layers: - self.fk_layers = list(params.fk_layers) - else: - self.fk_layers = None def orient_org_bones(self): @@ -293,8 +285,7 @@ class Rig: create_sphere_widget(self.obj, t, bone_transform_name=None) - if self.tweak_layers: - pb[t].bone.layers = self.tweak_layers + ControlLayersOption.TWEAK.assign(self.params, pb, tweaks['ctrl']) return tweaks @@ -574,9 +565,7 @@ class Rig: create_circle_widget(self.obj, ctrls[2], radius=0.4, head_tail=0.0) - for c in ctrls: - if self.fk_layers: - pb[c].bone.layers = self.fk_layers + ControlLayersOption.FK.assign(self.params, pb, ctrls) return {'ctrl': ctrls, 'mch': mch} @@ -1390,7 +1379,12 @@ class Rig: script += extra_script % (controls_string, bones['main_parent'], 'IK_follow', 'pole_follow', 'pole_follow', 'root/parent', 'root/parent') - return [script] + return { + 'script': [script], + 'utilities': UTILITIES_RIG_LEG, + 'register': REGISTER_RIG_LEG, + 'noparent_bones': [bones['ik']['mch_foot'][i] for i in [0,1]], + } def add_parameters(params): @@ -1431,30 +1425,8 @@ def add_parameters(params): ) # Setting up extra layers for the FK and tweak - params.tweak_extra_layers = bpy.props.BoolProperty( - name = "tweak_extra_layers", - default = True, - description = "" - ) - - params.tweak_layers = bpy.props.BoolVectorProperty( - size = 32, - description = "Layers for the tweak controls to be on", - default = tuple( [ i == 1 for i in range(0, 32) ] ) - ) - - # Setting up extra layers for the FK and tweak - params.fk_extra_layers = bpy.props.BoolProperty( - name = "fk_extra_layers", - default = True, - description = "" - ) - - params.fk_layers = bpy.props.BoolVectorProperty( - size = 32, - description = "Layers for the FK controls to be on", - default = tuple( [ i == 1 for i in range(0, 32) ] ) - ) + ControlLayersOption.FK.add_parameters(params) + ControlLayersOption.TWEAK.add_parameters(params) def parameters_ui(layout, params): @@ -1474,46 +1446,8 @@ def parameters_ui(layout, params): r = layout.row() r.prop(params, "bbones") - 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 - - col = r.column(align=True) - row = col.row(align=True) - - for i in range(8): - 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): - 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): - 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): - icon = "NONE" - if bone_layers[i]: - icon = "LAYER_ACTIVE" - row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) + ControlLayersOption.FK.parameters_ui(layout, params) + ControlLayersOption.TWEAK.parameters_ui(layout, params) def create_sample(obj): diff --git a/rigify/rigs/limbs/paw.py b/rigify/rigs/limbs/paw.py index cb1438bf..44851e3e 100644 --- a/rigify/rigs/limbs/paw.py +++ b/rigify/rigs/limbs/paw.py @@ -2,12 +2,14 @@ import bpy 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, strip_mch, make_deformer_name, create_widget +from ...utils import copy_bone, flip_bone, put_bone +from ...utils import strip_org, strip_mch from ...utils import create_circle_widget, create_sphere_widget, create_line_widget -from ...utils import MetarigError, make_mechanism_name, org +from ...utils import MetarigError, make_mechanism_name from ...utils import create_limb_widget, connected_children_names -from ...utils import align_bone_y_axis, align_bone_x_axis, align_bone_z_axis +from ...utils import align_bone_x_axis, align_bone_z_axis +from ...rig_ui_template import UTILITIES_RIG_LEG, REGISTER_RIG_LEG +from ...utils import ControlLayersOption from rna_prop_ui import rna_idprop_ui_prop_get from ..widgets import create_ikarrow_widget, create_gear_widget from ..widgets import create_foot_widget, create_ballsocket_widget @@ -46,17 +48,6 @@ class Rig: self.rot_axis = params.rotation_axis self.auto_align_extremity = params.auto_align_extremity - # Assign values to tweak/FK layers props if opted by user - if params.tweak_extra_layers: - self.tweak_layers = list(params.tweak_layers) - else: - self.tweak_layers = None - - if params.fk_extra_layers: - self.fk_layers = list(params.fk_layers) - else: - self.fk_layers = None - def orient_org_bones(self): bpy.ops.object.mode_set(mode='EDIT') @@ -285,8 +276,7 @@ class Rig: create_sphere_widget(self.obj, t, bone_transform_name=None) - if self.tweak_layers: - pb[t].bone.layers = self.tweak_layers + ControlLayersOption.TWEAK.assign(self.params, pb, tweaks['ctrl']) return tweaks @@ -569,9 +559,7 @@ class Rig: create_circle_widget(self.obj, ctrls[2], radius=0.4, head_tail=0.0) - for c in ctrls: - if self.fk_layers: - pb[c].bone.layers = self.fk_layers + ControlLayersOption.FK.assign(self.params, pb, ctrls) return {'ctrl': ctrls, 'mch': mch} @@ -1218,7 +1206,12 @@ class Rig: script += extra_script % (controls_string, bones['main_parent'], 'IK_follow', 'pole_follow', 'pole_follow', 'root/parent', 'root/parent') - return [script] + return { + 'script': [script], + 'utilities': UTILITIES_RIG_LEG, + 'register': REGISTER_RIG_LEG, + 'noparent_bones': [bones['ik']['mch_foot'][i] for i in [0,1]], + } def add_parameters(params): @@ -1259,30 +1252,8 @@ def add_parameters(params): ) # Setting up extra layers for the FK and tweak - params.tweak_extra_layers = bpy.props.BoolProperty( - name = "tweak_extra_layers", - default = True, - description = "" - ) - - params.tweak_layers = bpy.props.BoolVectorProperty( - size = 32, - description = "Layers for the tweak controls to be on", - default = tuple( [ i == 1 for i in range(0, 32) ] ) - ) - - # Setting up extra layers for the FK and tweak - params.fk_extra_layers = bpy.props.BoolProperty( - name = "fk_extra_layers", - default = True, - description = "" - ) - - params.fk_layers = bpy.props.BoolVectorProperty( - size = 32, - description = "Layers for the FK controls to be on", - default = tuple( [ i == 1 for i in range(0, 32) ] ) - ) + ControlLayersOption.FK.add_parameters(params) + ControlLayersOption.TWEAK.add_parameters(params) def parameters_ui(layout, params): @@ -1302,46 +1273,8 @@ def parameters_ui(layout, params): r = layout.row() r.prop(params, "bbones") - 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 - - col = r.column(align=True) - row = col.row(align=True) - - for i in range(8): - 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): - 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): - 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): - icon = "NONE" - if bone_layers[i]: - icon = "LAYER_ACTIVE" - row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) + ControlLayersOption.FK.parameters_ui(layout, params) + ControlLayersOption.TWEAK.parameters_ui(layout, params) def create_sample(obj): diff --git a/rigify/rigs/limbs/simple_tentacle.py b/rigify/rigs/limbs/simple_tentacle.py index 71a9eaa9..82fcafe8 100644 --- a/rigify/rigs/limbs/simple_tentacle.py +++ b/rigify/rigs/limbs/simple_tentacle.py @@ -4,6 +4,7 @@ from ...utils import strip_org, make_deformer_name, connected_children_names from ...utils import put_bone, create_sphere_widget from ...utils import create_circle_widget, align_bone_x_axis from ...utils import MetarigError +from ...utils import ControlLayersOption class Rig: @@ -15,11 +16,6 @@ class Rig: self.copy_rotation_axes = params.copy_rotation_axes - if params.tweak_extra_layers: - self.tweak_layers = list(params.tweak_layers) - else: - self.tweak_layers = None - if len(self.org_bones) <= 1: raise MetarigError( "RIGIFY ERROR: invalid rig structure on bone: %s" % (strip_org(bone_name)) @@ -118,9 +114,7 @@ class Rig: tweak_pb.lock_rotation = (True, True, True) tweak_pb.lock_scale = (True, True, True) - # Set up tweak bone layers - if self.tweak_layers: - tweak_pb.bone.layers = self.tweak_layers + ControlLayersOption.TWEAK.assign(self.params, self.obj.pose.bones, tweak_chain) return tweak_chain @@ -250,17 +244,7 @@ def add_parameters(params): ) # Setting up extra tweak layers - params.tweak_extra_layers = bpy.props.BoolProperty( - name="tweak_extra_layers", - default=True, - description="" - ) - - params.tweak_layers = bpy.props.BoolVectorProperty( - size=32, - description="Layers for the tweak controls to be on", - default=tuple([i == 1 for i in range(0, 32)]) - ) + ControlLayersOption.TWEAK.add_parameters(params) items = [('automatic', 'Automatic', ''), ('manual', 'Manual', '')] params.roll_alignment = bpy.props.EnumProperty(items=items, name="Bone roll alignment", default='automatic') @@ -277,45 +261,7 @@ def parameters_ui(layout, params): for i, axis in enumerate(['x', 'y', 'z']): row.prop(params, "copy_rotation_axes", index=i, toggle=True, text=axis) - r = layout.row() - r.prop(params, "tweak_extra_layers") - r.active = params.tweak_extra_layers - - col = r.column(align=True) - row = col.row(align=True) - - bone_layers = bpy.context.active_pose_bone.bone.layers[:] - - 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) - - 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 - 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 - icon = "NONE" - if bone_layers[i]: - icon = "LAYER_ACTIVE" - row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) + ControlLayersOption.TWEAK.parameters_ui(layout, params) def create_sample(obj): diff --git a/rigify/rigs/limbs/super_limb.py b/rigify/rigs/limbs/super_limb.py index e5670829..3d2bb8e2 100644 --- a/rigify/rigs/limbs/super_limb.py +++ b/rigify/rigs/limbs/super_limb.py @@ -4,6 +4,7 @@ from .arm import Rig as armRig from .leg import Rig as legRig from .paw import Rig as pawRig +from ...utils import ControlLayersOption class Rig: @@ -83,30 +84,8 @@ def add_parameters(params): ) # Setting up extra layers for the FK and tweak - params.tweak_extra_layers = bpy.props.BoolProperty( - name = "tweak_extra_layers", - default = True, - description = "" - ) - - params.tweak_layers = bpy.props.BoolVectorProperty( - size = 32, - description = "Layers for the tweak controls to be on", - default = tuple( [ i == 1 for i in range(0, 32) ] ) - ) - - # Setting up extra layers for the FK and tweak - params.fk_extra_layers = bpy.props.BoolProperty( - name = "fk_extra_layers", - default = True, - description = "" - ) - - params.fk_layers = bpy.props.BoolVectorProperty( - size = 32, - description = "Layers for the FK controls to be on", - default = tuple( [ i == 1 for i in range(0, 32) ] ) - ) + ControlLayersOption.FK.add_parameters(params) + ControlLayersOption.TWEAK.add_parameters(params) def parameters_ui(layout, params): @@ -130,46 +109,8 @@ def parameters_ui(layout, params): r = layout.row() r.prop(params, "bbones") - 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 - - col = r.column(align=True) - row = col.row(align=True) - - for i in range(8): - 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): - 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): - 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): - icon = "NONE" - if bone_layers[i]: - icon = "LAYER_ACTIVE" - row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon) + ControlLayersOption.FK.parameters_ui(layout, params) + ControlLayersOption.TWEAK.parameters_ui(layout, params) def create_sample(obj): diff --git a/rigify/rigs/spines/super_spine.py b/rigify/rigs/spines/super_spine.py index 6e46aa5c..d1b7593f 100644 --- a/rigify/rigs/spines/super_spine.py +++ b/rigify/rigs/spines/super_spine.py @@ -5,6 +5,7 @@ from ...utils import strip_org, make_deformer_name, connected_children_names from ...utils import create_circle_widget, create_sphere_widget, create_neck_bend_widget, create_neck_tweak_widget from ..widgets import create_ballsocket_widget from ...utils import MetarigError, make_mechanism_name, create_cube_widget +from ...utils import ControlLayersOption from rna_prop_ui import rna_idprop_ui_prop_get script = """ @@ -58,12 +59,6 @@ class Rig: if self.use_tail and self.pivot_pos - 2 > 0: self.tail_pos = params.tail_pos - # Assign values to tweak layers props if opted by user - if params.tweak_extra_layers: - self.tweak_layers = list(params.tweak_layers) - else: - self.tweak_layers = None - # Report error of user created less than the minimum of bones for rig min_bone_number = 3 if self.use_head: @@ -941,8 +936,7 @@ class Rig: continue create_sphere_widget(self.obj, bone, bone_transform_name=None) - if self.tweak_layers: - pb[bone].bone.layers = self.tweak_layers + ControlLayersOption.TWEAK.assign(self.params, pb, tweaks) def generate(self): # Torso Rig Anatomy: @@ -1058,17 +1052,7 @@ def add_parameters(params): ) # Setting up extra layers for the FK and tweak - params.tweak_extra_layers = bpy.props.BoolProperty( - name="tweak_extra_layers", - default=True, - description="" - ) - - params.tweak_layers = bpy.props.BoolVectorProperty( - size = 32, - description = "Layers for the tweak controls to be on", - default = tuple( [ i == 1 for i in range(0, 32) ] ) - ) + ControlLayersOption.TWEAK.add_parameters(params) def parameters_ui(layout, params): @@ -1096,45 +1080,7 @@ def parameters_ui(layout, params): row.prop(params, "copy_rotation_axes", index=i, toggle=True, text=axis) r.enabled = params.use_tail - r = layout.row() - r.prop(params, "tweak_extra_layers") - r.active = params.tweak_extra_layers - - col = r.column(align=True) - row = col.row(align=True) - - bone_layers = bpy.context.active_pose_bone.bone.layers[:] - - for i in range(8): - 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): - 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): - 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): - icon = "NONE" - if bone_layers[i]: - icon = "LAYER_ACTIVE" - row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon) + ControlLayersOption.TWEAK.parameters_ui(layout, params) def create_sample(obj): |