diff options
author | Nathan Vegdahl <cessen@cessen.com> | 2013-02-15 19:14:24 +0400 |
---|---|---|
committer | Nathan Vegdahl <cessen@cessen.com> | 2013-02-15 19:14:24 +0400 |
commit | a2b35fb7cca524a9027db863f00fe90d7c15c04f (patch) | |
tree | fb73e9a3bc80d87dda7e95cafb593da3fa3c20a2 /rigify | |
parent | 3b3ee36a1d0bce6529b19af4510757b43ee0c846 (diff) |
Bunch of bug fixes.
The biggest fixes relate to keeping ID data modification out of
draw methods. This was breaking Rigify with the current API.
Secondary fix was to move widget meshes to match the bones, even
if the widget meshes already exist. It's nice for when the user
is progressively tweaking the metarig.
Diffstat (limited to 'rigify')
-rw-r--r-- | rigify/__init__.py | 2 | ||||
-rw-r--r-- | rigify/generate.py | 25 | ||||
-rw-r--r-- | rigify/metarigs/human.py | 79 | ||||
-rw-r--r-- | rigify/rigs/basic/copy.py | 9 | ||||
-rw-r--r-- | rigify/rigs/basic/copy_chain.py | 9 | ||||
-rw-r--r-- | rigify/rigs/biped/arm/__init__.py | 17 | ||||
-rw-r--r-- | rigify/rigs/biped/leg/__init__.py | 17 | ||||
-rw-r--r-- | rigify/rigs/finger.py | 13 | ||||
-rw-r--r-- | rigify/rigs/misc/delta.py | 1 | ||||
-rw-r--r-- | rigify/rigs/neck_short.py | 10 | ||||
-rw-r--r-- | rigify/rigs/palm.py | 7 | ||||
-rw-r--r-- | rigify/rigs/spine.py | 30 | ||||
-rw-r--r-- | rigify/ui.py | 3 | ||||
-rw-r--r-- | rigify/utils.py | 70 |
14 files changed, 131 insertions, 161 deletions
diff --git a/rigify/__init__.py b/rigify/__init__.py index ca99e31c..1ee7d8d8 100644 --- a/rigify/__init__.py +++ b/rigify/__init__.py @@ -131,7 +131,7 @@ def register(): bpy.utils.register_class(RigifyArmatureLayer) bpy.types.PoseBone.rigify_type = bpy.props.StringProperty(name="Rigify Type", description="Rig type for this bone") - bpy.types.PoseBone.rigify_parameters = bpy.props.CollectionProperty(type=RigifyParameters) + bpy.types.PoseBone.rigify_parameters = bpy.props.PointerProperty(type=RigifyParameters) bpy.types.Armature.rigify_layers = bpy.props.CollectionProperty(type=RigifyArmatureLayer) diff --git a/rigify/generate.py b/rigify/generate.py index 3d595b42..89f89b71 100644 --- a/rigify/generate.py +++ b/rigify/generate.py @@ -157,17 +157,15 @@ def generate_rig(context, metarig): # rigify_type and rigify_parameters bone_gen.rigify_type = bone.rigify_type - if len(bone.rigify_parameters) > 0: - bone_gen.rigify_parameters.add() - for prop in dir(bone_gen.rigify_parameters[0]): - if (not prop.startswith("_")) \ - and (not prop.startswith("bl_")) \ - and (prop != "rna_type"): - try: - setattr(bone_gen.rigify_parameters[0], prop, \ - getattr(bone.rigify_parameters[0], prop)) - except AttributeError: - print("FAILED TO COPY PARAMETER: " + str(prop)) + for prop in dir(bone_gen.rigify_parameters): + if (not prop.startswith("_")) \ + and (not prop.startswith("bl_")) \ + and (prop != "rna_type"): + try: + setattr(bone_gen.rigify_parameters, prop, \ + getattr(bone.rigify_parameters, prop)) + except AttributeError: + print("FAILED TO COPY PARAMETER: " + str(prop)) # Custom properties for prop in bone.keys(): @@ -412,10 +410,7 @@ def get_bone_rigs(obj, bone_name, halt_on_missing=False): pass else: # Gather parameters - try: - params = obj.pose.bones[bone_name].rigify_parameters[0] - except (KeyError, IndexError): - params = None + params = obj.pose.bones[bone_name].rigify_parameters # Get the rig try: diff --git a/rigify/metarigs/human.py b/rigify/metarigs/human.py index 23ec2483..6cc92f3b 100644 --- a/rigify/metarigs/human.py +++ b/rigify/metarigs/human.py @@ -500,8 +500,7 @@ def create(obj): bpy.ops.object.mode_set(mode='OBJECT') pbone = obj.pose.bones[bones['hips']] pbone.rigify_type = 'spine' - pbone.rigify_parameters.add() - pbone.rigify_parameters[0].chain_bone_controls = "1, 2, 3" + pbone.rigify_parameters.chain_bone_controls = "1, 2, 3" pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False @@ -524,13 +523,12 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone.bone.layers = [False, False, False, False, False, 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] - pbone.rigify_parameters.add() try: - pbone.rigify_parameters[0].separate_ik_layers = True + pbone.rigify_parameters.separate_ik_layers = True except AttributeError: pass try: - pbone.rigify_parameters[0].ik_layers = [False, False, False, False, False, False, 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] + pbone.rigify_parameters.ik_layers = [False, False, False, False, False, False, 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] except AttributeError: pass pbone = obj.pose.bones[bones['thigh.R']] @@ -541,13 +539,12 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone.bone.layers = [False, False, False, False, False, False, False, 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] - pbone.rigify_parameters.add() try: - pbone.rigify_parameters[0].separate_ik_layers = True + pbone.rigify_parameters.separate_ik_layers = True except AttributeError: pass try: - pbone.rigify_parameters[0].ik_layers = [False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] + pbone.rigify_parameters.ik_layers = [False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] except AttributeError: pass pbone = obj.pose.bones[bones['ribs']] @@ -590,7 +587,6 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'YXZ' 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.rigify_parameters.add() pbone = obj.pose.bones[bones['shoulder.R']] pbone.rigify_type = 'basic.copy' pbone.lock_location = (True, True, True) @@ -599,7 +595,6 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'YXZ' 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.rigify_parameters.add() pbone = obj.pose.bones[bones['foot.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) @@ -664,13 +659,12 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone.bone.layers = [False, 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] - pbone.rigify_parameters.add() try: - pbone.rigify_parameters[0].separate_ik_layers = True + pbone.rigify_parameters.separate_ik_layers = True except AttributeError: pass try: - pbone.rigify_parameters[0].ik_layers = [False, False, 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] + pbone.rigify_parameters.ik_layers = [False, False, 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] except AttributeError: pass pbone = obj.pose.bones[bones['upper_arm.R']] @@ -681,13 +675,12 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone.bone.layers = [False, False, False, 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] - pbone.rigify_parameters.add() try: - pbone.rigify_parameters[0].separate_ik_layers = True + pbone.rigify_parameters.separate_ik_layers = True except AttributeError: pass try: - pbone.rigify_parameters[0].ik_layers = [False, False, False, False, 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] + pbone.rigify_parameters.ik_layers = [False, False, False, False, 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] except AttributeError: pass pbone = obj.pose.bones[bones['toe.L']] @@ -746,7 +739,6 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'YXZ' pbone.bone.layers = [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, False] - pbone.rigify_parameters.add() pbone = obj.pose.bones[bones['palm.02.L']] pbone.rigify_type = '' pbone.lock_location = (True, True, True) @@ -779,7 +771,6 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'YXZ' pbone.bone.layers = [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, False] - pbone.rigify_parameters.add() pbone = obj.pose.bones[bones['palm.02.R']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) @@ -812,13 +803,12 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone.bone.layers = [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, False] - pbone.rigify_parameters.add() try: - pbone.rigify_parameters[0].separate_extra_layers = True + pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass try: - pbone.rigify_parameters[0].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] + 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: pass pbone = obj.pose.bones[bones['thumb.01.L']] @@ -829,13 +819,12 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone.bone.layers = [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, False] - pbone.rigify_parameters.add() try: - pbone.rigify_parameters[0].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] + 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: pass try: - pbone.rigify_parameters[0].separate_extra_layers = True + pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass pbone = obj.pose.bones[bones['finger_middle.01.L']] @@ -846,13 +835,12 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone.bone.layers = [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, False] - pbone.rigify_parameters.add() try: - pbone.rigify_parameters[0].separate_extra_layers = True + pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass try: - pbone.rigify_parameters[0].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] + 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: pass pbone = obj.pose.bones[bones['finger_ring.01.L']] @@ -863,13 +851,13 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone.bone.layers = [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, False] - pbone.rigify_parameters.add() + try: - pbone.rigify_parameters[0].separate_extra_layers = True + pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass try: - pbone.rigify_parameters[0].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] + 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: pass pbone = obj.pose.bones[bones['finger_pinky.01.L']] @@ -880,13 +868,13 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone.bone.layers = [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, False] - pbone.rigify_parameters.add() + try: - pbone.rigify_parameters[0].separate_extra_layers = True + pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass try: - pbone.rigify_parameters[0].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] + 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: pass pbone = obj.pose.bones[bones['finger_index.01.R']] @@ -897,13 +885,12 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone.bone.layers = [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, False] - pbone.rigify_parameters.add() try: - pbone.rigify_parameters[0].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] + 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: pass try: - pbone.rigify_parameters[0].separate_extra_layers = True + pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass pbone = obj.pose.bones[bones['thumb.01.R']] @@ -914,13 +901,12 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone.bone.layers = [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, False] - pbone.rigify_parameters.add() try: - pbone.rigify_parameters[0].separate_extra_layers = True + pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass try: - pbone.rigify_parameters[0].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] + 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: pass pbone = obj.pose.bones[bones['finger_middle.01.R']] @@ -931,13 +917,12 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone.bone.layers = [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, False] - pbone.rigify_parameters.add() try: - pbone.rigify_parameters[0].separate_extra_layers = True + pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass try: - pbone.rigify_parameters[0].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] + 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: pass pbone = obj.pose.bones[bones['finger_ring.01.R']] @@ -948,13 +933,12 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone.bone.layers = [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, False] - pbone.rigify_parameters.add() try: - pbone.rigify_parameters[0].separate_extra_layers = True + pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass try: - pbone.rigify_parameters[0].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] + 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: pass pbone = obj.pose.bones[bones['finger_pinky.01.R']] @@ -965,13 +949,12 @@ def create(obj): pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone.bone.layers = [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, False] - pbone.rigify_parameters.add() try: - pbone.rigify_parameters[0].separate_extra_layers = True + pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass try: - pbone.rigify_parameters[0].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] + 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: pass pbone = obj.pose.bones[bones['finger_index.02.L']] diff --git a/rigify/rigs/basic/copy.py b/rigify/rigs/basic/copy.py index a961a71a..be04830b 100644 --- a/rigify/rigs/basic/copy.py +++ b/rigify/rigs/basic/copy.py @@ -83,18 +83,18 @@ class Rig: create_bone_widget(self.obj, bone) @classmethod - def add_parameters(self, group): + def add_parameters(self, params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ - group.make_control = bpy.props.BoolProperty(name="Control", default=True, description="Create a control bone for the copy") - group.make_deform = bpy.props.BoolProperty(name="Deform", default=True, description="Create a deform bone for the copy") + params.make_control = bpy.props.BoolProperty(name="Control", default=True, description="Create a control bone for the copy") + params.make_deform = bpy.props.BoolProperty(name="Deform", default=True, description="Create a deform bone for the copy") @classmethod def parameters_ui(self, layout, obj, bone): """ Create the ui for the rig parameters. """ - params = obj.pose.bones[bone].rigify_parameters[0] + params = obj.pose.bones[bone].rigify_parameters r = layout.row() r.prop(params, "make_control") @@ -127,7 +127,6 @@ class Rig: pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' - pbone.rigify_parameters.add() bpy.ops.object.mode_set(mode='EDIT') for bone in arm.edit_bones: diff --git a/rigify/rigs/basic/copy_chain.py b/rigify/rigs/basic/copy_chain.py index eaff060f..4b4f0c85 100644 --- a/rigify/rigs/basic/copy_chain.py +++ b/rigify/rigs/basic/copy_chain.py @@ -122,18 +122,18 @@ class Rig: create_bone_widget(self.obj, bone) @classmethod - def add_parameters(self, group): + def add_parameters(self, params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ - group.make_controls = bpy.props.BoolProperty(name="Controls", default=True, description="Create control bones for the copy") - group.make_deforms = bpy.props.BoolProperty(name="Deform", default=True, description="Create deform bones for the copy") + params.make_controls = bpy.props.BoolProperty(name="Controls", default=True, description="Create control bones for the copy") + params.make_deforms = bpy.props.BoolProperty(name="Deform", default=True, description="Create deform bones for the copy") @classmethod def parameters_ui(self, layout, obj, bone): """ Create the ui for the rig parameters. """ - params = obj.pose.bones[bone].rigify_parameters[0] + params = obj.pose.bones[bone].rigify_parameters r = layout.row() r.prop(params, "make_controls") @@ -180,7 +180,6 @@ class Rig: pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' - pbone.rigify_parameters.add() pbone = obj.pose.bones[bones['bone.02']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) diff --git a/rigify/rigs/biped/arm/__init__.py b/rigify/rigs/biped/arm/__init__.py index e6c426db..41fe1f71 100644 --- a/rigify/rigs/biped/arm/__init__.py +++ b/rigify/rigs/biped/arm/__init__.py @@ -89,28 +89,28 @@ class Rig: return [script % (fk_controls[0], fk_controls[1], fk_controls[2], ik_controls[0], ik_controls[1], ik_controls[2], ik_controls[3])] @classmethod - def add_parameters(self, group): + def add_parameters(self, params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ items = [('X', 'X', ''), ('Y', 'Y', ''), ('Z', 'Z', ''), ('-X', '-X', ''), ('-Y', '-Y', ''), ('-Z', '-Z', '')] - group.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='X') + params.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='X') - group.bend_hint = bpy.props.BoolProperty(name="Bend Hint", default=True, description="Give IK chain a hint about which way to bend. Useful for perfectly straight chains") + params.bend_hint = bpy.props.BoolProperty(name="Bend Hint", default=True, description="Give IK chain a hint about which way to bend. Useful for perfectly straight chains") - group.separate_ik_layers = bpy.props.BoolProperty(name="Separate IK Control Layers:", default=False, description="Enable putting the ik controls on a separate layer from the fk controls") - group.ik_layers = bpy.props.BoolVectorProperty(size=32, description="Layers for the ik controls to be on") + params.separate_ik_layers = bpy.props.BoolProperty(name="Separate IK Control Layers:", default=False, description="Enable putting the ik controls on a separate layer from the fk controls") + params.ik_layers = bpy.props.BoolVectorProperty(size=32, description="Layers for the ik controls to be on") - group.use_upper_arm_twist = bpy.props.BoolProperty(name="Upper Arm Twist", default=True, description="Generate the dual-bone twist setup for the upper arm") - group.use_forearm_twist = bpy.props.BoolProperty(name="Forearm Twist", default=True, description="Generate the dual-bone twist setup for the forearm") + params.use_upper_arm_twist = bpy.props.BoolProperty(name="Upper Arm Twist", default=True, description="Generate the dual-bone twist setup for the upper arm") + params.use_forearm_twist = bpy.props.BoolProperty(name="Forearm Twist", default=True, description="Generate the dual-bone twist setup for the forearm") @classmethod def parameters_ui(self, layout, obj, bone): """ Create the ui for the rig parameters. """ - params = obj.pose.bones[bone].rigify_parameters[0] + params = obj.pose.bones[bone].rigify_parameters r = layout.row() r.prop(params, "separate_ik_layers") @@ -206,7 +206,6 @@ class Rig: pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' - pbone.rigify_parameters.add() pbone = obj.pose.bones[bones['forearm']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) diff --git a/rigify/rigs/biped/leg/__init__.py b/rigify/rigs/biped/leg/__init__.py index 3827d7cc..dbeeb0ef 100644 --- a/rigify/rigs/biped/leg/__init__.py +++ b/rigify/rigs/biped/leg/__init__.py @@ -91,28 +91,28 @@ class Rig: return [script % (fk_controls[0], fk_controls[1], fk_controls[2], fk_controls[3], ik_controls[0], ik_controls[1], ik_controls[2], ik_controls[3], ik_controls[4], ik_controls[5])] @classmethod - def add_parameters(self, group): + def add_parameters(self, params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ items = [('X', 'X', ''), ('Y', 'Y', ''), ('Z', 'Z', ''), ('-X', '-X', ''), ('-Y', '-Y', ''), ('-Z', '-Z', '')] - group.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='X') + params.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='X') - group.bend_hint = bpy.props.BoolProperty(name="Bend Hint", default=True, description="Give IK chain a hint about which way to bend (useful for perfectly straight chains)") + params.bend_hint = bpy.props.BoolProperty(name="Bend Hint", default=True, description="Give IK chain a hint about which way to bend (useful for perfectly straight chains)") - group.separate_ik_layers = bpy.props.BoolProperty(name="Separate IK Control Layers:", default=False, description="Enable putting the ik controls on a separate layer from the fk controls") - group.ik_layers = bpy.props.BoolVectorProperty(size=32, description="Layers for the ik controls to be on") + params.separate_ik_layers = bpy.props.BoolProperty(name="Separate IK Control Layers:", default=False, description="Enable putting the ik controls on a separate layer from the fk controls") + params.ik_layers = bpy.props.BoolVectorProperty(size=32, description="Layers for the ik controls to be on") - group.use_thigh_twist = bpy.props.BoolProperty(name="Thigh Twist", default=True, description="Generate the dual-bone twist setup for the thigh") - group.use_shin_twist = bpy.props.BoolProperty(name="Shin Twist", default=True, description="Generate the dual-bone twist setup for the shin") + params.use_thigh_twist = bpy.props.BoolProperty(name="Thigh Twist", default=True, description="Generate the dual-bone twist setup for the thigh") + params.use_shin_twist = bpy.props.BoolProperty(name="Shin Twist", default=True, description="Generate the dual-bone twist setup for the shin") @classmethod def parameters_ui(self, layout, obj, bone): """ Create the ui for the rig parameters. """ - params = obj.pose.bones[bone].rigify_parameters[0] + params = obj.pose.bones[bone].rigify_parameters r = layout.row() r.prop(params, "separate_ik_layers") @@ -229,7 +229,6 @@ class Rig: pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' - pbone.rigify_parameters.add() pbone = obj.pose.bones[bones['shin']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) diff --git a/rigify/rigs/finger.py b/rigify/rigs/finger.py index 0dee1b0d..15e1bbac 100644 --- a/rigify/rigs/finger.py +++ b/rigify/rigs/finger.py @@ -275,23 +275,23 @@ class Rig: self.control() @classmethod - def add_parameters(self, group): + def add_parameters(self, params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ items = [('X', 'X', ''), ('Y', 'Y', ''), ('Z', 'Z', ''), ('-X', '-X', ''), ('-Y', '-Y', ''), ('-Z', '-Z', '')] - group.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='X') + params.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='X') - group.separate_extra_layers = bpy.props.BoolProperty(name="Separate Secondary Control Layers:", default=False, description="Enable putting the secondary controls on a separate layer from the primary controls") - group.extra_layers = bpy.props.BoolVectorProperty(size=32, description="Layers for the secondary controls to be on") + params.separate_extra_layers = bpy.props.BoolProperty(name="Separate Secondary Control Layers:", default=False, description="Enable putting the secondary controls on a separate layer from the primary controls") + params.extra_layers = bpy.props.BoolVectorProperty(size=32, description="Layers for the secondary controls to be on") - group.use_digit_twist = bpy.props.BoolProperty(name="Digit Twist", default=True, description="Generate the dual-bone twist setup for the first finger digit") + params.use_digit_twist = bpy.props.BoolProperty(name="Digit Twist", default=True, description="Generate the dual-bone twist setup for the first finger digit") @classmethod def parameters_ui(self, layout, obj, bone): """ Create the ui for the rig parameters. """ - params = obj.pose.bones[bone].rigify_parameters[0] + params = obj.pose.bones[bone].rigify_parameters r = layout.row() r.prop(params, "separate_extra_layers") @@ -383,7 +383,6 @@ class Rig: pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'YZX' - pbone.rigify_parameters.add() pbone = obj.pose.bones[bones['finger.02']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) diff --git a/rigify/rigs/misc/delta.py b/rigify/rigs/misc/delta.py index b32134ff..d13f7d4e 100644 --- a/rigify/rigs/misc/delta.py +++ b/rigify/rigs/misc/delta.py @@ -114,7 +114,6 @@ class Rig: pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' - pbone.rigify_parameters.add() pbone = obj.pose.bones[bones['Bone']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) diff --git a/rigify/rigs/neck_short.py b/rigify/rigs/neck_short.py index 07420875..a94b3cef 100644 --- a/rigify/rigs/neck_short.py +++ b/rigify/rigs/neck_short.py @@ -313,13 +313,8 @@ class Rig: i += 1 # Create control widgets - w1 = create_circle_widget(self.obj, neck_ctrl, radius=1.0, head_tail=0.5) - w2 = create_circle_widget(self.obj, head_ctrl, radius=1.0, head_tail=0.5) - - if w1 != None: - obj_to_bone(w1, self.obj, self.org_bones[(len(self.org_bones) - 1) // 2]) - if w2 != None: - obj_to_bone(w2, self.obj, self.org_bones[-1]) + w1 = create_circle_widget(self.obj, neck_ctrl, radius=1.0, head_tail=0.5, bone_transform_name=self.org_bones[(len(self.org_bones) - 1) // 2]) + w2 = create_circle_widget(self.obj, head_ctrl, radius=1.0, head_tail=0.5, bone_transform_name=self.org_bones[-1]) # Return control bones return (head_ctrl, neck_ctrl) @@ -370,7 +365,6 @@ class Rig: pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' - pbone.rigify_parameters.add() pbone = obj.pose.bones[bones['head']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) diff --git a/rigify/rigs/palm.py b/rigify/rigs/palm.py index 1d25050a..f055dffb 100644 --- a/rigify/rigs/palm.py +++ b/rigify/rigs/palm.py @@ -161,20 +161,20 @@ class Rig: mod.levels = 2 @classmethod - def add_parameters(self, group): + def add_parameters(self, params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ items = [('X', 'X', ''), ('Z', 'Z', '')] - group.palm_rotation_axis = bpy.props.EnumProperty(items=items, name="Palm Rotation Axis", default='X') + params.palm_rotation_axis = bpy.props.EnumProperty(items=items, name="Palm Rotation Axis", default='X') @classmethod def parameters_ui(self, layout, obj, bone): """ Create the ui for the rig parameters. """ - params = obj.pose.bones[bone].rigify_parameters[0] + params = obj.pose.bones[bone].rigify_parameters r = layout.row() r.label(text="Primary rotation axis:") @@ -259,7 +259,6 @@ class Rig: pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'YXZ' - pbone.rigify_parameters.add() bpy.ops.object.mode_set(mode='EDIT') for bone in arm.edit_bones: diff --git a/rigify/rigs/spine.py b/rigify/rigs/spine.py index cee08615..56888c8a 100644 --- a/rigify/rigs/spine.py +++ b/rigify/rigs/spine.py @@ -483,30 +483,23 @@ class Rig: # Control appearance # Main pb[main_control].custom_shape_transform = pb[main_wgt2] - w = create_compass_widget(self.obj, main_control) - if w != None: - obj_to_bone(w, self.obj, main_wgt2) + w = create_compass_widget(self.obj, main_control, bone_transform_name=main_wgt2) # Spines for name, i in zip(controls[1:-1], self.control_indices[1:-1]): pb[name].custom_shape_transform = pb[self.org_bones[i]] # Create control widgets - w = create_circle_widget(self.obj, name, radius=1.0, head_tail=0.5, with_line=True) - if w != None: - obj_to_bone(w, self.obj, self.org_bones[i]) + w = create_circle_widget(self.obj, name, radius=1.0, head_tail=0.5, with_line=True, bone_transform_name=self.org_bones[i]) + # Hips pb[controls[0]].custom_shape_transform = pb[self.org_bones[0]] # Create control widgets - w = create_circle_widget(self.obj, controls[0], radius=1.0, head_tail=0.5, with_line=True) - if w != None: - obj_to_bone(w, self.obj, self.org_bones[0]) + w = create_circle_widget(self.obj, controls[0], radius=1.0, head_tail=0.5, with_line=True, bone_transform_name=self.org_bones[0]) # Ribs pb[controls[-1]].custom_shape_transform = pb[self.org_bones[-1]] # Create control widgets - w = create_circle_widget(self.obj, controls[-1], radius=1.0, head_tail=0.5, with_line=True) - if w != None: - obj_to_bone(w, self.obj, self.org_bones[-1]) + w = create_circle_widget(self.obj, controls[-1], radius=1.0, head_tail=0.5, with_line=True, bone_transform_name=self.org_bones[-1]) # Layers pb[main_control].bone.layers = pb[self.org_bones[0]].bone.layers @@ -526,19 +519,19 @@ class Rig: return [script % (controls[0], controls_string)] @classmethod - def add_parameters(self, group): + def add_parameters(self, params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ - group.spine_main_control_name = bpy.props.StringProperty(name="Main control name", default="torso", description="Name that the main control bone should be given") - group.rest_pivot_slide = bpy.props.FloatProperty(name="Rest Pivot Slide", default=0.0, min=0.0, max=1.0, soft_min=0.0, soft_max=1.0, description="The pivot slide value in the rest pose") - group.chain_bone_controls = bpy.props.StringProperty(name="Control bone list", default="", description="Define which bones have controls") + params.spine_main_control_name = bpy.props.StringProperty(name="Main control name", default="torso", description="Name that the main control bone should be given") + params.rest_pivot_slide = bpy.props.FloatProperty(name="Rest Pivot Slide", default=0.0, min=0.0, max=1.0, soft_min=0.0, soft_max=1.0, description="The pivot slide value in the rest pose") + params.chain_bone_controls = bpy.props.StringProperty(name="Control bone list", default="", description="Define which bones have controls") @classmethod def parameters_ui(self, layout, obj, bone): """ Create the ui for the rig parameters. """ - params = obj.pose.bones[bone].rigify_parameters[0] + params = obj.pose.bones[bone].rigify_parameters r = layout.row() r.prop(params, "spine_main_control_name") @@ -602,8 +595,7 @@ class Rig: pbone.rotation_mode = 'QUATERNION' pbone = obj.pose.bones[bones['hips']] pbone['rigify_type'] = 'spine' - pbone.rigify_parameters.add() - pbone.rigify_parameters[0].chain_bone_controls = "1, 2, 3" + pbone.rigify_parameters.chain_bone_controls = "1, 2, 3" bpy.ops.object.mode_set(mode='EDIT') for bone in arm.edit_bones: diff --git a/rigify/ui.py b/rigify/ui.py index 136ff172..946b1e70 100644 --- a/rigify/ui.py +++ b/rigify/ui.py @@ -177,9 +177,6 @@ class BONE_PT_rigify_buttons(bpy.types.Panel): # Rig type parameters / Rig type non-exist alert if rig_name != "": - if len(bone.rigify_parameters) < 1: - bone.rigify_parameters.add() - try: rig = get_rig_type(rig_name) rig.Rig diff --git a/rigify/utils.py b/rigify/utils.py index bcb13a66..db66da63 100644 --- a/rigify/utils.py +++ b/rigify/utils.py @@ -260,20 +260,36 @@ def obj_to_bone(obj, rig, bone_name): obj.scale = (bone.length * scl_avg), (bone.length * scl_avg), (bone.length * scl_avg) -def create_widget(rig, bone_name): +def create_widget(rig, bone_name, bone_transform_name=None): """ Creates an empty widget object for a bone, and returns the object. """ + if bone_transform_name == None: + bone_transform_name = bone_name + obj_name = WGT_PREFIX + bone_name scene = bpy.context.scene - # Check if it already exists + + # Check if it already exists in the scene if obj_name in scene.objects: + # Move object to bone position, in case it changed + obj = scene.objects[obj_name] + obj_to_bone(obj, rig, bone_transform_name) + return None else: + # Delete object if it exists in blend data but not scene data. + # This is necessary so we can then create the object without + # name conflicts. + if obj_name in bpy.data.objects: + bpy.data.objects.remove(bpy.data.objects[obj_name]) + + # Create mesh object mesh = bpy.data.meshes.new(obj_name) obj = bpy.data.objects.new(obj_name, mesh) scene.objects.link(obj) - obj_to_bone(obj, rig, bone_name) + # Move object to bone position and set layers + obj_to_bone(obj, rig, bone_transform_name) obj.layers = WGT_LAYERS return obj @@ -281,22 +297,22 @@ def create_widget(rig, bone_name): # Common Widgets -def create_line_widget(rig, bone_name): +def create_line_widget(rig, bone_name, bone_transform_name=None): """ Creates a basic line widget, a line that spans the length of the bone. """ - obj = create_widget(rig, bone_name) + obj = create_widget(rig, bone_name, bone_transform_name) if obj != None: mesh = obj.data mesh.from_pydata([(0, 0, 0), (0, 1, 0)], [(0, 1)], []) mesh.update() -def create_circle_widget(rig, bone_name, radius=1.0, head_tail=0.0, with_line=False): +def create_circle_widget(rig, bone_name, radius=1.0, head_tail=0.0, with_line=False, bone_transform_name=None): """ Creates a basic circle widget, a circle around the y-axis. radius: the radius of the circle head_tail: where along the length of the bone the circle is (0.0=head, 1.0=tail) """ - obj = create_widget(rig, bone_name) + obj = create_widget(rig, bone_name, bone_transform_name) if obj != None: v = [(0.7071068286895752, 2.980232238769531e-07, -0.7071065306663513), (0.8314696550369263, 2.980232238769531e-07, -0.5555699467658997), (0.9238795042037964, 2.682209014892578e-07, -0.3826831877231598), (0.9807852506637573, 2.5331974029541016e-07, -0.19509011507034302), (1.0, 2.365559055306221e-07, 1.6105803979371558e-07), (0.9807853698730469, 2.2351741790771484e-07, 0.19509044289588928), (0.9238796234130859, 2.086162567138672e-07, 0.38268351554870605), (0.8314696550369263, 1.7881393432617188e-07, 0.5555704236030579), (0.7071068286895752, 1.7881393432617188e-07, 0.7071070075035095), (0.5555702447891235, 1.7881393432617188e-07, 0.8314698934555054), (0.38268327713012695, 1.7881393432617188e-07, 0.923879861831665), (0.19509008526802063, 1.7881393432617188e-07, 0.9807855486869812), (-3.2584136988589307e-07, 1.1920928955078125e-07, 1.000000238418579), (-0.19509072601795197, 1.7881393432617188e-07, 0.9807854294776917), (-0.3826838731765747, 1.7881393432617188e-07, 0.9238795638084412), (-0.5555707216262817, 1.7881393432617188e-07, 0.8314695358276367), (-0.7071071863174438, 1.7881393432617188e-07, 0.7071065902709961), (-0.8314700126647949, 1.7881393432617188e-07, 0.5555698871612549), (-0.923879861831665, 2.086162567138672e-07, 0.3826829195022583), (-0.9807853698730469, 2.2351741790771484e-07, 0.1950896978378296), (-1.0, 2.365559907957504e-07, -7.290432222362142e-07), (-0.9807850122451782, 2.5331974029541016e-07, -0.195091113448143), (-0.9238790273666382, 2.682209014892578e-07, -0.38268423080444336), (-0.831468939781189, 2.980232238769531e-07, -0.5555710196495056), (-0.7071058750152588, 2.980232238769531e-07, -0.707107424736023), (-0.555569052696228, 2.980232238769531e-07, -0.8314701318740845), (-0.38268208503723145, 2.980232238769531e-07, -0.923879861831665), (-0.19508881866931915, 2.980232238769531e-07, -0.9807853102684021), (1.6053570561780361e-06, 2.980232238769531e-07, -0.9999997615814209), (0.19509197771549225, 2.980232238769531e-07, -0.9807847142219543), (0.3826850652694702, 2.980232238769531e-07, -0.9238786101341248), (0.5555717945098877, 2.980232238769531e-07, -0.8314683437347412)] verts = [(a[0] * radius, head_tail, a[2] * radius) for a in v] @@ -312,10 +328,10 @@ def create_circle_widget(rig, bone_name, radius=1.0, head_tail=0.0, with_line=Fa return None -def create_sphere_widget(rig, bone_name): +def create_sphere_widget(rig, bone_name, bone_transform_name=None): """ Creates a basic sphere widget, three pependicular overlapping circles. """ - obj = create_widget(rig, bone_name) + obj = create_widget(rig, bone_name, bone_transform_name) if obj != None: verts = [(0.3535533845424652, 0.3535533845424652, 0.0), (0.4619397521018982, 0.19134171307086945, 0.0), (0.5, -2.1855694143368964e-08, 0.0), (0.4619397521018982, -0.19134175777435303, 0.0), (0.3535533845424652, -0.3535533845424652, 0.0), (0.19134174287319183, -0.4619397521018982, 0.0), (7.549790126404332e-08, -0.5, 0.0), (-0.1913416087627411, -0.46193981170654297, 0.0), (-0.35355329513549805, -0.35355350375175476, 0.0), (-0.4619397521018982, -0.19134178757667542, 0.0), (-0.5, 5.962440319251527e-09, 0.0), (-0.4619397222995758, 0.1913418024778366, 0.0), (-0.35355326533317566, 0.35355350375175476, 0.0), (-0.19134148955345154, 0.46193987131118774, 0.0), (3.2584136988589307e-07, 0.5, 0.0), (0.1913420855998993, 0.46193960309028625, 0.0), (7.450580596923828e-08, 0.46193960309028625, 0.19134199619293213), (5.9254205098113744e-08, 0.5, 2.323586443253589e-07), (4.470348358154297e-08, 0.46193987131118774, -0.1913415789604187), (2.9802322387695312e-08, 0.35355350375175476, -0.3535533547401428), (2.9802322387695312e-08, 0.19134178757667542, -0.46193981170654297), (5.960464477539063e-08, -1.1151834122813398e-08, -0.5000000596046448), (5.960464477539063e-08, -0.1913418024778366, -0.46193984150886536), (5.960464477539063e-08, -0.35355350375175476, -0.3535533845424652), (7.450580596923828e-08, -0.46193981170654297, -0.19134166836738586), (9.348272556053416e-08, -0.5, 1.624372103492533e-08), (1.043081283569336e-07, -0.4619397521018982, 0.19134168326854706), (1.1920928955078125e-07, -0.3535533845424652, 0.35355329513549805), (1.1920928955078125e-07, -0.19134174287319183, 0.46193966269493103), (1.1920928955078125e-07, -4.7414250303745575e-09, 0.49999991059303284), (1.1920928955078125e-07, 0.19134172797203064, 0.46193966269493103), (8.940696716308594e-08, 0.3535533845424652, 0.35355329513549805), (0.3535534739494324, 0.0, 0.35355329513549805), (0.1913418173789978, -2.9802322387695312e-08, 0.46193966269493103), (8.303572940349113e-08, -5.005858838558197e-08, 0.49999991059303284), (-0.19134165346622467, -5.960464477539063e-08, 0.46193966269493103), (-0.35355329513549805, -8.940696716308594e-08, 0.35355329513549805), (-0.46193963289260864, -5.960464477539063e-08, 0.19134168326854706), (-0.49999991059303284, -5.960464477539063e-08, 1.624372103492533e-08), (-0.4619397521018982, -2.9802322387695312e-08, -0.19134166836738586), (-0.3535534143447876, -2.9802322387695312e-08, -0.3535533845424652), (-0.19134171307086945, 0.0, -0.46193984150886536), (7.662531942287387e-08, 9.546055501630235e-09, -0.5000000596046448), (0.19134187698364258, 5.960464477539063e-08, -0.46193981170654297), (0.3535535931587219, 5.960464477539063e-08, -0.3535533547401428), (0.4619399905204773, 5.960464477539063e-08, -0.1913415789604187), (0.5000000596046448, 5.960464477539063e-08, 2.323586443253589e-07), (0.4619396924972534, 2.9802322387695312e-08, 0.19134199619293213)] edges = [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10), (10, 11), (11, 12), (12, 13), (13, 14), (14, 15), (0, 15), (16, 31), (16, 17), (17, 18), (18, 19), (19, 20), (20, 21), (21, 22), (22, 23), (23, 24), (24, 25), (25, 26), (26, 27), (27, 28), (28, 29), (29, 30), (30, 31), (32, 33), (33, 34), (34, 35), (35, 36), (36, 37), (37, 38), (38, 39), (39, 40), (40, 41), (41, 42), (42, 43), (43, 44), (44, 45), (45, 46), (46, 47), (32, 47)] @@ -324,11 +340,11 @@ def create_sphere_widget(rig, bone_name): mesh.update() -def create_limb_widget(rig, bone_name): +def create_limb_widget(rig, bone_name, bone_transform_name=None): """ Creates a basic limb widget, a line that spans the length of the bone, with a circle around the center. """ - obj = create_widget(rig, bone_name) + obj = create_widget(rig, bone_name, bone_transform_name) if obj != None: verts = [(-1.1920928955078125e-07, 1.7881393432617188e-07, 0.0), (3.5762786865234375e-07, 1.0000004768371582, 0.0), (0.1767769455909729, 0.5000001192092896, 0.17677664756774902), (0.20786768198013306, 0.5000001192092896, 0.1388925313949585), (0.23097014427185059, 0.5000001192092896, 0.09567084908485413), (0.24519658088684082, 0.5000001192092896, 0.048772573471069336), (0.2500002384185791, 0.5000001192092896, -2.545945676502015e-09), (0.24519658088684082, 0.5000001192092896, -0.048772573471069336), (0.23097014427185059, 0.5000001192092896, -0.09567084908485413), (0.20786768198013306, 0.5000001192092896, -0.13889259099960327), (0.1767769455909729, 0.5000001192092896, -0.1767767071723938), (0.13889282941818237, 0.5000001192092896, -0.20786744356155396), (0.09567105770111084, 0.5000001192092896, -0.23096990585327148), (0.04877278208732605, 0.5000001192092896, -0.24519634246826172), (1.7279069197684294e-07, 0.5000000596046448, -0.25), (-0.0487724244594574, 0.5000001192092896, -0.24519634246826172), (-0.09567070007324219, 0.5000001192092896, -0.2309698462486267), (-0.13889241218566895, 0.5000001192092896, -0.20786738395690918), (-0.17677652835845947, 0.5000001192092896, -0.17677664756774902), (-0.20786726474761963, 0.5000001192092896, -0.13889244198799133), (-0.23096972703933716, 0.5000001192092896, -0.09567070007324219), (-0.24519610404968262, 0.5000001192092896, -0.04877239465713501), (-0.2499997615814209, 0.5000001192092896, 2.1997936983098043e-07), (-0.24519598484039307, 0.5000001192092896, 0.04877282679080963), (-0.23096948862075806, 0.5000001192092896, 0.09567108750343323), (-0.20786696672439575, 0.5000001192092896, 0.1388927698135376), (-0.1767762303352356, 0.5000001192092896, 0.17677688598632812), (-0.13889199495315552, 0.5000001192092896, 0.2078675627708435), (-0.09567028284072876, 0.5000001192092896, 0.23097002506256104), (-0.048771947622299194, 0.5000001192092896, 0.24519634246826172), (6.555903269145347e-07, 0.5000001192092896, 0.25), (0.04877324402332306, 0.5000001192092896, 0.24519622325897217), (0.09567153453826904, 0.5000001192092896, 0.23096966743469238), (0.13889318704605103, 0.5000001192092896, 0.20786714553833008)] edges = [(0, 1), (2, 3), (4, 3), (5, 4), (5, 6), (6, 7), (8, 7), (8, 9), (10, 9), (10, 11), (11, 12), (13, 12), (14, 13), (14, 15), (16, 15), (16, 17), (17, 18), (19, 18), (19, 20), (21, 20), (21, 22), (22, 23), (24, 23), (25, 24), (25, 26), (27, 26), (27, 28), (29, 28), (29, 30), (30, 31), (32, 31), (32, 33), (2, 33)] @@ -337,10 +353,10 @@ def create_limb_widget(rig, bone_name): mesh.update() -def create_bone_widget(rig, bone_name): +def create_bone_widget(rig, bone_name, bone_transform_name=None): """ Creates a basic bone widget, a simple obolisk-esk shape. """ - obj = create_widget(rig, bone_name) + obj = create_widget(rig, bone_name, bone_transform_name) if obj != None: verts = [(0.04, 1.0, -0.04), (0.1, 0.0, -0.1), (-0.1, 0.0, -0.1), (-0.04, 1.0, -0.04), (0.04, 1.0, 0.04), (0.1, 0.0, 0.1), (-0.1, 0.0, 0.1), (-0.04, 1.0, 0.04)] edges = [(1, 2), (0, 1), (0, 3), (2, 3), (4, 5), (5, 6), (6, 7), (4, 7), (1, 5), (0, 4), (2, 6), (3, 7)] @@ -349,10 +365,10 @@ def create_bone_widget(rig, bone_name): mesh.update() -def create_compass_widget(rig, bone_name): +def create_compass_widget(rig, bone_name, bone_transform_name=None): """ Creates a compass-shaped widget. """ - obj = create_widget(rig, bone_name) + obj = create_widget(rig, bone_name, bone_transform_name) if obj != None: verts = [(0.0, 1.2000000476837158, 0.0), (0.19509032368659973, 0.9807852506637573, 0.0), (0.3826834559440613, 0.9238795042037964, 0.0), (0.5555702447891235, 0.8314695954322815, 0.0), (0.7071067690849304, 0.7071067690849304, 0.0), (0.8314696550369263, 0.5555701851844788, 0.0), (0.9238795042037964, 0.3826834261417389, 0.0), (0.9807852506637573, 0.19509035348892212, 0.0), (1.2000000476837158, 7.549790126404332e-08, 0.0), (0.9807853102684021, -0.19509020447731018, 0.0), (0.9238795638084412, -0.38268327713012695, 0.0), (0.8314696550369263, -0.5555701851844788, 0.0), (0.7071067690849304, -0.7071067690849304, 0.0), (0.5555701851844788, -0.8314696550369263, 0.0), (0.38268327713012695, -0.9238796234130859, 0.0), (0.19509008526802063, -0.9807853102684021, 0.0), (-3.2584136988589307e-07, -1.2999999523162842, 0.0), (-0.19509072601795197, -0.9807851910591125, 0.0), (-0.3826838731765747, -0.9238793253898621, 0.0), (-0.5555707216262817, -0.8314692974090576, 0.0), (-0.7071072459220886, -0.707106351852417, 0.0), (-0.8314700126647949, -0.5555696487426758, 0.0), (-0.923879861831665, -0.3826826810836792, 0.0), (-0.9807854294776917, -0.1950894594192505, 0.0), (-1.2000000476837158, 9.655991561885457e-07, 0.0), (-0.980785071849823, 0.1950913518667221, 0.0), (-0.923879086971283, 0.38268446922302246, 0.0), (-0.831468939781189, 0.5555712580680847, 0.0), (-0.7071058750152588, 0.707107663154602, 0.0), (-0.5555691123008728, 0.8314703702926636, 0.0), (-0.38268208503723145, 0.9238801002502441, 0.0), (-0.19508881866931915, 0.9807855486869812, 0.0)] edges = [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10), (10, 11), (11, 12), (12, 13), (13, 14), (14, 15), (15, 16), (16, 17), (17, 18), (18, 19), (19, 20), (20, 21), (21, 22), (22, 23), (23, 24), (24, 25), (25, 26), (26, 27), (27, 28), (28, 29), (29, 30), (30, 31), (0, 31)] @@ -361,10 +377,10 @@ def create_compass_widget(rig, bone_name): mesh.update() -def create_root_widget(rig, bone_name): +def create_root_widget(rig, bone_name, bone_transform_name=None): """ Creates a widget for the root bone. """ - obj = create_widget(rig, bone_name) + obj = create_widget(rig, bone_name, bone_transform_name) if obj != None: verts = [(0.7071067690849304, 0.7071067690849304, 0.0), (0.7071067690849304, -0.7071067690849304, 0.0), (-0.7071067690849304, 0.7071067690849304, 0.0), (-0.7071067690849304, -0.7071067690849304, 0.0), (0.8314696550369263, 0.5555701851844788, 0.0), (0.8314696550369263, -0.5555701851844788, 0.0), (-0.8314696550369263, 0.5555701851844788, 0.0), (-0.8314696550369263, -0.5555701851844788, 0.0), (0.9238795042037964, 0.3826834261417389, 0.0), (0.9238795042037964, -0.3826834261417389, 0.0), (-0.9238795042037964, 0.3826834261417389, 0.0), (-0.9238795042037964, -0.3826834261417389, 0.0), (0.9807852506637573, 0.19509035348892212, 0.0), (0.9807852506637573, -0.19509035348892212, 0.0), (-0.9807852506637573, 0.19509035348892212, 0.0), (-0.9807852506637573, -0.19509035348892212, 0.0), (0.19509197771549225, 0.9807849526405334, 0.0), (0.19509197771549225, -0.9807849526405334, 0.0), (-0.19509197771549225, 0.9807849526405334, 0.0), (-0.19509197771549225, -0.9807849526405334, 0.0), (0.3826850652694702, 0.9238788485527039, 0.0), (0.3826850652694702, -0.9238788485527039, 0.0), (-0.3826850652694702, 0.9238788485527039, 0.0), (-0.3826850652694702, -0.9238788485527039, 0.0), (0.5555717945098877, 0.8314685821533203, 0.0), (0.5555717945098877, -0.8314685821533203, 0.0), (-0.5555717945098877, 0.8314685821533203, 0.0), (-0.5555717945098877, -0.8314685821533203, 0.0), (0.19509197771549225, 1.2807848453521729, 0.0), (0.19509197771549225, -1.2807848453521729, 0.0), (-0.19509197771549225, 1.2807848453521729, 0.0), (-0.19509197771549225, -1.2807848453521729, 0.0), (1.280785322189331, 0.19509035348892212, 0.0), (1.280785322189331, -0.19509035348892212, 0.0), (-1.280785322189331, 0.19509035348892212, 0.0), (-1.280785322189331, -0.19509035348892212, 0.0), (0.3950919806957245, 1.2807848453521729, 0.0), (0.3950919806957245, -1.2807848453521729, 0.0), (-0.3950919806957245, 1.2807848453521729, 0.0), (-0.3950919806957245, -1.2807848453521729, 0.0), (1.280785322189331, 0.39509034156799316, 0.0), (1.280785322189331, -0.39509034156799316, 0.0), (-1.280785322189331, 0.39509034156799316, 0.0), (-1.280785322189331, -0.39509034156799316, 0.0), (0.0, 1.5807849168777466, 0.0), (0.0, -1.5807849168777466, 0.0), (1.5807852745056152, 0.0, 0.0), (-1.5807852745056152, 0.0, 0.0)] edges = [(0, 4), (1, 5), (2, 6), (3, 7), (4, 8), (5, 9), (6, 10), (7, 11), (8, 12), (9, 13), (10, 14), (11, 15), (16, 20), (17, 21), (18, 22), (19, 23), (20, 24), (21, 25), (22, 26), (23, 27), (0, 24), (1, 25), (2, 26), (3, 27), (16, 28), (17, 29), (18, 30), (19, 31), (12, 32), (13, 33), (14, 34), (15, 35), (28, 36), (29, 37), (30, 38), (31, 39), (32, 40), (33, 41), (34, 42), (35, 43), (36, 44), (37, 45), (38, 44), (39, 45), (40, 46), (41, 46), (42, 47), (43, 47)] @@ -515,16 +531,16 @@ def write_metarig(obj, layers=False, func_name="create_sample"): if layers: code.append(" pbone.bone.layers = %s" % str(list(pbone.bone.layers))) # Rig type parameters - if len(pbone.rigify_parameters) > 0: - code.append(" pbone.rigify_parameters.add()") - for param_name in pbone.rigify_parameters[0].keys(): - param = getattr(pbone.rigify_parameters[0], param_name) - if str(type(param)) == "<class 'bpy_prop_array'>": - param = list(param) - code.append(" try:") - code.append(" pbone.rigify_parameters[0].%s = %s" % (param_name, str(param))) - code.append(" except AttributeError:") - code.append(" pass") + for param_name in pbone.rigify_parameters.keys(): + param = getattr(pbone.rigify_parameters, param_name) + if str(type(param)) == "<class 'bpy_prop_array'>": + param = list(param) + if type(param) == str: + param = '"' + param + '"' + code.append(" try:") + code.append(" pbone.rigify_parameters.%s = %s" % (param_name, str(param))) + code.append(" except AttributeError:") + code.append(" pass") code.append("\n bpy.ops.object.mode_set(mode='EDIT')") code.append(" for bone in arm.edit_bones:") |