[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25297] trunk/blender: * rename 'rna_path' --> 'data_path', rna and dna are for internal use and are not descriptive.

Campbell Barton ideasman42 at gmail.com
Thu Dec 10 23:23:09 CET 2009


Revision: 25297
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25297
Author:   campbellbarton
Date:     2009-12-10 23:23:09 +0100 (Thu, 10 Dec 2009)

Log Message:
-----------
* 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

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/graphviz_export.py
    trunk/blender/release/scripts/modules/rigify/__init__.py
    trunk/blender/release/scripts/modules/rigify/arm_biped_generic.py
    trunk/blender/release/scripts/modules/rigify/delta.py
    trunk/blender/release/scripts/modules/rigify/finger_curl.py
    trunk/blender/release/scripts/modules/rigify/leg_biped_generic.py
    trunk/blender/release/scripts/modules/rigify/neck_flex.py
    trunk/blender/release/scripts/modules/rigify/palm_curl.py
    trunk/blender/release/scripts/modules/rigify/spine_pivot_flex.py
    trunk/blender/release/scripts/modules/rigify_utils.py
    trunk/blender/release/scripts/ui/properties_scene.py
    trunk/blender/source/blender/makesrna/intern/rna_animation.c
    trunk/blender/source/blender/makesrna/intern/rna_animation_api.c
    trunk/blender/source/blender/makesrna/intern/rna_armature.c
    trunk/blender/source/blender/makesrna/intern/rna_fcurve.c

Modified: trunk/blender/release/scripts/modules/graphviz_export.py
===================================================================
--- trunk/blender/release/scripts/modules/graphviz_export.py	2009-12-10 22:07:33 UTC (rev 25296)
+++ trunk/blender/release/scripts/modules/graphviz_export.py	2009-12-10 22:23:09 UTC (rev 25297)
@@ -150,16 +150,16 @@
         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", "")

Modified: trunk/blender/release/scripts/modules/rigify/__init__.py
===================================================================
--- trunk/blender/release/scripts/modules/rigify/__init__.py	2009-12-10 22:07:33 UTC (rev 25296)
+++ trunk/blender/release/scripts/modules/rigify/__init__.py	2009-12-10 22:23:09 UTC (rev 25297)
@@ -49,6 +49,8 @@
     
 
 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 @@
             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 @@
     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 @@
                 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
 
 

Modified: trunk/blender/release/scripts/modules/rigify/arm_biped_generic.py
===================================================================
--- trunk/blender/release/scripts/modules/rigify/arm_biped_generic.py	2009-12-10 22:07:33 UTC (rev 25296)
+++ trunk/blender/release/scripts/modules/rigify/arm_biped_generic.py	2009-12-10 22:23:09 UTC (rev 25297)
@@ -240,7 +240,7 @@
         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

Modified: trunk/blender/release/scripts/modules/rigify/delta.py
===================================================================
--- trunk/blender/release/scripts/modules/rigify/delta.py	2009-12-10 22:07:33 UTC (rev 25296)
+++ trunk/blender/release/scripts/modules/rigify/delta.py	2009-12-10 22:23:09 UTC (rev 25297)
@@ -67,6 +67,9 @@
     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

Modified: trunk/blender/release/scripts/modules/rigify/finger_curl.py
===================================================================
--- trunk/blender/release/scripts/modules/rigify/finger_curl.py	2009-12-10 22:07:33 UTC (rev 25296)
+++ trunk/blender/release/scripts/modules/rigify/finger_curl.py	2009-12-10 22:23:09 UTC (rev 25297)
@@ -201,14 +201,14 @@
         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:

Modified: trunk/blender/release/scripts/modules/rigify/leg_biped_generic.py
===================================================================
--- trunk/blender/release/scripts/modules/rigify/leg_biped_generic.py	2009-12-10 22:07:33 UTC (rev 25296)
+++ trunk/blender/release/scripts/modules/rigify/leg_biped_generic.py	2009-12-10 22:23:09 UTC (rev 25297)
@@ -341,7 +341,7 @@
     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

Modified: trunk/blender/release/scripts/modules/rigify/neck_flex.py
===================================================================
--- trunk/blender/release/scripts/modules/rigify/neck_flex.py	2009-12-10 22:07:33 UTC (rev 25296)
+++ trunk/blender/release/scripts/modules/rigify/neck_flex.py	2009-12-10 22:23:09 UTC (rev 25297)
@@ -121,11 +121,15 @@
     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)
     ex.head_e.connected = False
@@ -142,10 +146,6 @@
     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 @@
     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(ex_chain.attr_names):
+        neck_e = getattr(ex_chain, attr + "_e")
 
-    for i, attr in enumerate(mt_chain.attr_names):
-        neck_e = getattr(mt_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 @@
 
     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 @@
     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 @@
     tar.name = "var"
     tar.id_type = 'OBJECT'
     tar.id = obj

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list