diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-12-11 01:23:09 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-12-11 01:23:09 +0300 |
commit | 97abf6ad96932ae5d1a3e6b6d89e271f11e9cd8a (patch) | |
tree | 7337e06f4d54e8e9a455f4710d60459758efd9ab /release/scripts | |
parent | 2a785e8fae8d160f7ce11565705be4d71e2d676b (diff) |
* rename 'rna_path' --> 'data_path', rna and dna are for internal use and are not descriptive.
* armature.pose_position: POSE_POSITION, REST_POSITION --> POSE, REST
* rigify now forces rest pose mode
* updated neck_flex to keep original bones unchanged
Diffstat (limited to 'release/scripts')
-rw-r--r-- | release/scripts/modules/graphviz_export.py | 8 | ||||
-rw-r--r-- | release/scripts/modules/rigify/__init__.py | 23 | ||||
-rw-r--r-- | release/scripts/modules/rigify/arm_biped_generic.py | 2 | ||||
-rw-r--r-- | release/scripts/modules/rigify/delta.py | 3 | ||||
-rw-r--r-- | release/scripts/modules/rigify/finger_curl.py | 4 | ||||
-rw-r--r-- | release/scripts/modules/rigify/leg_biped_generic.py | 2 | ||||
-rw-r--r-- | release/scripts/modules/rigify/neck_flex.py | 67 | ||||
-rw-r--r-- | release/scripts/modules/rigify/palm_curl.py | 8 | ||||
-rw-r--r-- | release/scripts/modules/rigify/spine_pivot_flex.py | 10 | ||||
-rw-r--r-- | release/scripts/modules/rigify_utils.py | 2 | ||||
-rw-r--r-- | release/scripts/ui/properties_scene.py | 2 |
11 files changed, 80 insertions, 51 deletions
diff --git a/release/scripts/modules/graphviz_export.py b/release/scripts/modules/graphviz_export.py index e4bce9a85a9..f39095b9eba 100644 --- a/release/scripts/modules/graphviz_export.py +++ b/release/scripts/modules/graphviz_export.py @@ -150,16 +150,16 @@ def graph_armature(obj, path, FAKE_PARENT=True, CONSTRAINTS=True, DRIVERS=True, if animation_data: fcurve_drivers = [fcurve_driver for fcurve_driver in animation_data.drivers] - fcurve_drivers.sort(key=lambda fcurve_driver: fcurve_driver.rna_path) + fcurve_drivers.sort(key=lambda fcurve_driver: fcurve_driver.data_path) for fcurve_driver in fcurve_drivers: - rna_path = fcurve_driver.rna_path + rna_path = fcurve_driver.data_path pbone = rna_path_as_pbone(rna_path) if pbone: for target in fcurve_driver.driver.targets: - pbone_target = rna_path_as_pbone(target.rna_path) - rna_path_target = target.rna_path + pbone_target = rna_path_as_pbone(target.data_path) + rna_path_target = target.data_path if pbone_target: opts = ['dir=forward', "weight=1", "arrowhead=normal", "arrowtail=none", "constraint=false", 'color="blue"', "labelfontsize=4"] # , display_source = rna_path.replace("pose.bones", "") diff --git a/release/scripts/modules/rigify/__init__.py b/release/scripts/modules/rigify/__init__.py index ff0c1421f55..f4922f80040 100644 --- a/release/scripts/modules/rigify/__init__.py +++ b/release/scripts/modules/rigify/__init__.py @@ -49,6 +49,8 @@ def submodule_func_from_type(bone_type): def validate_rig(context, obj): + type_found = False + for pbone in obj.pose.bones: bone_name = pbone.name bone_type = pbone.get("type", "") @@ -62,19 +64,29 @@ def validate_rig(context, obj): submod, type_func = submodule_func_from_type(bone_type) reload(submod) submod.metarig_definition(obj, bone_name) + type_found = True # missing, - check for duplicate root bone. + + if not type_found: + raise RigifyError("This rig has no 'type' properties defined on any pose bones, nothing to do") def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): from collections import OrderedDict import rigify_utils reload(rigify_utils) + + # Not needed but catches any errors before duplicating + # validate_rig(context, obj_orig) global_undo = context.user_preferences.edit.global_undo context.user_preferences.edit.global_undo = False mode_orig = context.mode - + rest_backup = obj_orig.data.pose_position + obj_orig.data.pose_position = 'REST' + + bpy.ops.object.mode_set(mode='OBJECT') scene = context.scene @@ -86,7 +98,7 @@ def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): scene.objects.link(obj) scene.objects.active = obj obj.selected = True - + if META_DEF: obj_def = obj_orig.copy() obj_def.data = obj_orig.data.copy() @@ -254,15 +266,20 @@ def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): con.target = obj con.subtarget = bone_name + # would be 'REST' from when copied + obj_def.data.pose_position = 'POSE' + # Only for demo'ing # obj.restrict_view = True obj.data.draw_axes = False bpy.ops.object.mode_set(mode=mode_orig) - + obj_orig.data.pose_position = rest_backup + obj.data.pose_position = 'POSE' context.user_preferences.edit.global_undo = global_undo + return obj diff --git a/release/scripts/modules/rigify/arm_biped_generic.py b/release/scripts/modules/rigify/arm_biped_generic.py index dfae94875b7..e22857852ee 100644 --- a/release/scripts/modules/rigify/arm_biped_generic.py +++ b/release/scripts/modules/rigify/arm_biped_generic.py @@ -240,7 +240,7 @@ def fk(obj, definitions, base_names): tar.name = "hinge" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = controller_path + '["hinge"]' + tar.data_path = controller_path + '["hinge"]' mod = driver_fcurve.modifiers[0] mod.poly_order = 1 diff --git a/release/scripts/modules/rigify/delta.py b/release/scripts/modules/rigify/delta.py index a83b45307dd..4f1e56b7bb1 100644 --- a/release/scripts/modules/rigify/delta.py +++ b/release/scripts/modules/rigify/delta.py @@ -67,6 +67,9 @@ def metarig_definition(obj, orig_bone_name): if len(children) != 1: raise RigifyError("only 1 child supported for delta on bone '%s'" % delta.name) + if delta.connected: + raise RigifyError("bone cannot be connected to its parent '%s'" % delta.name) + bone_definition = [delta.name, children[0].name] return bone_definition diff --git a/release/scripts/modules/rigify/finger_curl.py b/release/scripts/modules/rigify/finger_curl.py index 15bdd803500..7f21eecd7d3 100644 --- a/release/scripts/modules/rigify/finger_curl.py +++ b/release/scripts/modules/rigify/finger_curl.py @@ -201,14 +201,14 @@ def main(obj, bone_definition, base_names): tar.name = "scale" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = controller_path + '.scale[1]' + tar.data_path = controller_path + '.scale[1]' # bend target tar = driver.targets.new() tar.name = "br" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = controller_path + '["bend_ratio"]' + tar.data_path = controller_path + '["bend_ratio"]' # XXX - todo, any number if i == 0: diff --git a/release/scripts/modules/rigify/leg_biped_generic.py b/release/scripts/modules/rigify/leg_biped_generic.py index d08d0e99f43..af103a08265 100644 --- a/release/scripts/modules/rigify/leg_biped_generic.py +++ b/release/scripts/modules/rigify/leg_biped_generic.py @@ -341,7 +341,7 @@ def fk(obj, bone_definition, base_names): tar.name = "var" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = hinge_driver_path + tar.data_path = hinge_driver_path mod = fcurve.modifiers[0] mod.poly_order = 1 diff --git a/release/scripts/modules/rigify/neck_flex.py b/release/scripts/modules/rigify/neck_flex.py index 31763518f09..9bb852b25b5 100644 --- a/release/scripts/modules/rigify/neck_flex.py +++ b/release/scripts/modules/rigify/neck_flex.py @@ -121,10 +121,14 @@ def main(obj, bone_definition, base_names): neck_chain_basename = base_names[mt_chain.neck_01_e.name].split(".")[0] neck_chain_segment_length = mt_chain.neck_01_e.length - ex = bone_class_instance(obj, ["body", "head", "head_hinge", "neck_socket"]) # hinge & extras + ex = bone_class_instance(obj, ["body", "head", "head_hinge", "neck_socket", "head_ctrl"]) # hinge & extras # Add the head hinge at the bodys location, becomes the parent of the original head + # apply everything to this copy of the chain + ex_chain = mt_chain.copy(base_names=base_names) + ex_chain.neck_01_e.parent = mt_chain.neck_01_e.parent + # Copy the head bone and offset ex.head_e = copy_bone_simple(arm, mt.head, "MCH_%s" % base_names[mt.head], parent=True) @@ -142,10 +146,6 @@ def main(obj, bone_definition, base_names): ex.head_hinge_e.head.y += head_length / 4.0 ex.head_hinge_e.tail.y += head_length / 4.0 - # reparent the head, assume its not connected - mt.head_e.connected = False - mt.head_e.parent = ex.head_hinge_e - # Insert the neck socket, the head copys this loation ex.neck_socket_e = arm.edit_bones.new("MCH-%s_socked" % neck_chain_basename) ex.neck_socket = ex.neck_socket_e.name @@ -154,20 +154,21 @@ def main(obj, bone_definition, base_names): ex.neck_socket_e.head = mt.head_e.head ex.neck_socket_e.tail = mt.head_e.head - Vector(0.0, neck_chain_segment_length / 2.0, 0.0) ex.neck_socket_e.roll = 0.0 + + + # copy of the head for controling + ex.head_ctrl_e = copy_bone_simple(arm, mt.head, base_names[mt.head]) + ex.head_ctrl = ex.head_ctrl_e.name + ex.head_ctrl_e.parent = ex.head_hinge_e - # offset the head, not really needed since it has a copyloc constraint - mt.head_e.head.y += head_length / 4.0 - mt.head_e.tail.y += head_length / 4.0 - - for i, attr in enumerate(mt_chain.attr_names): - neck_e = getattr(mt_chain, attr + "_e") + for i, attr in enumerate(ex_chain.attr_names): + neck_e = getattr(ex_chain, attr + "_e") # dont store parent names, re-reference as each chain bones parent. - neck_e_parent = arm.edit_bones.new("MCH-rot_%s" % base_names[neck_e.name]) + neck_e_parent = arm.edit_bones.new("MCH-rot_%s" % base_names[getattr(mt_chain, attr)]) neck_e_parent.head = neck_e.head neck_e_parent.tail = neck_e.head + ((mt.head_e.tail - mt.head_e.head).normalize() * neck_chain_segment_length / 2.0) neck_e_parent.roll = mt.head_e.roll - orig_parent = neck_e.parent neck_e.connected = False @@ -184,20 +185,21 @@ def main(obj, bone_definition, base_names): mt.update() mt_chain.update() + ex_chain.update() ex.update() # Simple one off constraints, no drivers - con = mt.head_p.constraints.new('COPY_LOCATION') + con = ex.head_ctrl_p.constraints.new('COPY_LOCATION') con.target = obj con.subtarget = ex.neck_socket con = ex.head_p.constraints.new('COPY_ROTATION') con.target = obj - con.subtarget = mt.head + con.subtarget = ex.head_ctrl # driven hinge - prop = rna_idprop_ui_prop_get(mt.head_p, "hinge", create=True) - mt.head_p["hinge"] = 0.0 + prop = rna_idprop_ui_prop_get(ex.head_ctrl_p, "hinge", create=True) + ex.head_ctrl_p["hinge"] = 0.0 prop["soft_min"] = 0.0 prop["soft_max"] = 1.0 @@ -207,7 +209,7 @@ def main(obj, bone_definition, base_names): con.subtarget = mt.body # add driver - hinge_driver_path = mt.head_p.path_to_id() + '["hinge"]' + hinge_driver_path = ex.head_ctrl_p.path_to_id() + '["hinge"]' fcurve = con.driver_add("influence", 0) driver = fcurve.driver @@ -216,7 +218,7 @@ def main(obj, bone_definition, base_names): tar.name = "var" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = hinge_driver_path + tar.data_path = hinge_driver_path #mod = fcurve_driver.modifiers.new('GENERATOR') mod = fcurve.modifiers[0] @@ -224,12 +226,12 @@ def main(obj, bone_definition, base_names): mod.coefficients[0] = 1.0 mod.coefficients[1] = -1.0 - head_driver_path = mt.head_p.path_to_id() + head_driver_path = ex.head_ctrl_p.path_to_id() target_names = [("b%.2d" % (i + 1)) for i in range(len(neck_chain))] - mt.head_p["bend_tot"] = 0.0 - fcurve = mt.head_p.driver_add('["bend_tot"]', 0) + ex.head_ctrl_p["bend_tot"] = 0.0 + fcurve = ex.head_ctrl_p.driver_add('["bend_tot"]', 0) driver = fcurve.driver driver.type = 'SUM' fcurve.modifiers.remove(0) # grr dont need a modifier @@ -239,19 +241,19 @@ def main(obj, bone_definition, base_names): tar.name = target_names[i] tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = head_driver_path + ('["bend_%.2d"]' % (i + 1)) + tar.data_path = head_driver_path + ('["bend_%.2d"]' % (i + 1)) - for i, attr in enumerate(mt_chain.attr_names): - neck_p = getattr(mt_chain, attr + "_p") + for i, attr in enumerate(ex_chain.attr_names): + neck_p = getattr(ex_chain, attr + "_p") neck_p.lock_location = True, True, True neck_p.lock_location = True, True, True neck_p.lock_rotations_4d = True # Add bend prop prop_name = "bend_%.2d" % (i + 1) - prop = rna_idprop_ui_prop_get(mt.head_p, prop_name, create=True) - mt.head_p[prop_name] = 1.0 + prop = rna_idprop_ui_prop_get(ex.head_ctrl_p, prop_name, create=True) + ex.head_ctrl_p[prop_name] = 1.0 prop["soft_min"] = 0.0 prop["soft_max"] = 1.0 @@ -279,13 +281,20 @@ def main(obj, bone_definition, base_names): tar.name = "bend_tot" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = head_driver_path + ('["bend_tot"]') + tar.data_path = head_driver_path + ('["bend_tot"]') tar = driver.targets.new() tar.name = "bend" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = head_driver_path + ('["%s"]' % prop_name) + tar.data_path = head_driver_path + ('["%s"]' % prop_name) + + + # finally constrain the original bone to this one + orig_neck_p = getattr(mt_chain, attr + "_p") + con = orig_neck_p.constraints.new('COPY_ROTATION') + con.target = obj + con.subtarget = neck_p.name # no blending the result of this return None diff --git a/release/scripts/modules/rigify/palm_curl.py b/release/scripts/modules/rigify/palm_curl.py index cc40503703c..6c9ff516c49 100644 --- a/release/scripts/modules/rigify/palm_curl.py +++ b/release/scripts/modules/rigify/palm_curl.py @@ -145,7 +145,7 @@ def main(obj, bone_definition, base_names): tar.name = "x" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = controller_path + ".rotation_euler[0]" + tar.data_path = controller_path + ".rotation_euler[0]" # ***** @@ -156,7 +156,7 @@ def main(obj, bone_definition, base_names): tar.name = "x" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = controller_path + ".rotation_euler[0]" + tar.data_path = controller_path + ".rotation_euler[0]" # ***** @@ -166,13 +166,13 @@ def main(obj, bone_definition, base_names): tar.name = "x" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = controller_path + ".rotation_euler[0]" + tar.data_path = controller_path + ".rotation_euler[0]" tar = driver.targets.new() tar.name = "s" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = controller_path + '["spread"]' + tar.data_path = controller_path + '["spread"]' for i, child_name in enumerate(children): diff --git a/release/scripts/modules/rigify/spine_pivot_flex.py b/release/scripts/modules/rigify/spine_pivot_flex.py index f9a5aceb4d6..beeb5c68b7c 100644 --- a/release/scripts/modules/rigify/spine_pivot_flex.py +++ b/release/scripts/modules/rigify/spine_pivot_flex.py @@ -322,7 +322,7 @@ def main(obj, bone_definition, base_names): tar.name = "var" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = ex.ribcage_copy_p.path_to_id() + '["hinge"]' + tar.data_path = ex.ribcage_copy_p.path_to_id() + '["hinge"]' mod = fcurve.modifiers[0] mod.poly_order = 1 @@ -406,7 +406,7 @@ def main(obj, bone_definition, base_names): tar.name = target_names[i] tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = rib_driver_path + ('["bend_%.2d"]' % (i + 1)) + tar.data_path = rib_driver_path + ('["bend_%.2d"]' % (i + 1)) for i in range(1, spine_chain_len): @@ -441,13 +441,13 @@ def main(obj, bone_definition, base_names): tar.name = "bend_tot" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = rib_driver_path + ('["bend_tot"]') + tar.data_path = rib_driver_path + ('["bend_tot"]') tar = driver.targets.new() tar.name = "bend" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = rib_driver_path + ('["%s"]' % prop_name) + tar.data_path = rib_driver_path + ('["%s"]' % prop_name) @@ -490,7 +490,7 @@ def main(obj, bone_definition, base_names): tar.name = "var" tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = rib_driver_path + '["pivot_slide"]' + tar.data_path = rib_driver_path + '["pivot_slide"]' mod = fcurve.modifiers[0] mod.poly_order = 1 diff --git a/release/scripts/modules/rigify_utils.py b/release/scripts/modules/rigify_utils.py index 5061248c35d..a1fc54cb5bb 100644 --- a/release/scripts/modules/rigify_utils.py +++ b/release/scripts/modules/rigify_utils.py @@ -141,7 +141,7 @@ def blend_bone_list(obj, apply_bones, from_bones, to_bones, target_bone=None, ta tar.name = target_bone tar.id_type = 'OBJECT' tar.id = obj - tar.rna_path = driver_path + tar.data_path = driver_path def blend_location(new_pbone, from_bone_name, to_bone_name): con = new_pbone.constraints.new('COPY_LOCATION') diff --git a/release/scripts/ui/properties_scene.py b/release/scripts/ui/properties_scene.py index 857b6bfff02..622ce06c567 100644 --- a/release/scripts/ui/properties_scene.py +++ b/release/scripts/ui/properties_scene.py @@ -134,7 +134,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel): col = layout.column() col.label(text="Target:") col.template_any_ID(ksp, "id", "id_type") - col.template_path_builder(ksp, "rna_path", ksp.id) + col.template_path_builder(ksp, "data_path", ksp.id) row = layout.row() |