[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1812] trunk/py/scripts/addons/rigify: Rigify: fixed broken ik/fk snapping (api changes).

Nathan Vegdahl cessen at cessen.com
Mon Apr 11 08:10:08 CEST 2011


Revision: 1812
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1812
Author:   cessen
Date:     2011-04-11 06:10:07 +0000 (Mon, 11 Apr 2011)
Log Message:
-----------
Rigify: fixed broken ik/fk snapping (api changes).

Modified Paths:
--------------
    trunk/py/scripts/addons/rigify/generate.py
    trunk/py/scripts/addons/rigify/rig_ui_template.py
    trunk/py/scripts/addons/rigify/utils.py

Modified: trunk/py/scripts/addons/rigify/generate.py
===================================================================
--- trunk/py/scripts/addons/rigify/generate.py	2011-04-11 03:03:09 UTC (rev 1811)
+++ trunk/py/scripts/addons/rigify/generate.py	2011-04-11 06:10:07 UTC (rev 1812)
@@ -25,7 +25,7 @@
 from rigify.utils import ORG_PREFIX, MCH_PREFIX, DEF_PREFIX, WGT_PREFIX, ROOT_NAME, make_original_name
 from rigify.utils import RIG_DIR
 from rigify.utils import create_root_widget
-from rigify.utils import random_string
+from rigify.utils import random_id
 from rigify.rig_ui_template import UI_SLIDERS, layers_ui, UI_REGISTER
 from rigify import rigs
 
@@ -55,7 +55,7 @@
 
     # Random string with time appended so that
     # different rigs don't collide id's
-    rig_id = random_string(8) + str(hex(int(time.time())))[2:][-8:].rjust(8, '0')
+    rig_id = random_id(16)
 
     # Initial configuration
     mode_orig = context.mode

Modified: trunk/py/scripts/addons/rigify/rig_ui_template.py
===================================================================
--- trunk/py/scripts/addons/rigify/rig_ui_template.py	2011-04-11 03:03:09 UTC (rev 1811)
+++ trunk/py/scripts/addons/rigify/rig_ui_template.py	2011-04-11 06:10:07 UTC (rev 1812)
@@ -49,42 +49,12 @@
     # Get matrix in bone's current transform space
     smat = rest_inv * (par_rest * (par_inv * mat))
 
-    # Compensate for non-inherited rotation/scale
-    if not pose_bone.bone.use_inherit_rotation:
-        loc = mat.to_translation()
-        loc -= (par_mat*(par_rest.inverted() * rest)).to_translation()
-        loc *= rest.inverted().to_quaternion()
-        if pose_bone.bone.use_inherit_scale:
-            t = par_mat.to_scale()
-            par_scale = Matrix.Scale(t[0], 4, Vector((1,0,0)))
-            par_scale *= Matrix.Scale(t[1], 4, Vector((0,1,0)))
-            par_scale *= Matrix.Scale(t[2], 4, Vector((0,0,1)))
-        else:
-            par_scale = Matrix()
-
-        smat = rest_inv * mat * par_scale.inverted()
-        smat[3][0] = loc[0]
-        smat[3][1] = loc[1]
-        smat[3][2] = loc[2]
-    elif not pose_bone.bone.use_inherit_scale:
-        loc = smat.to_translation()
-        rot = smat.to_quaternion()
-        scl = mat.to_scale()
-
-        smat = Matrix.Scale(scl[0], 4, Vector((1,0,0)))
-        smat *= Matrix.Scale(scl[1], 4, Vector((0,1,0)))
-        smat *= Matrix.Scale(scl[2], 4, Vector((0,0,1)))
-        smat *= Matrix.Rotation(rot.angle, 4, rot.axis)
-        smat[3][0] = loc[0]
-        smat[3][1] = loc[1]
-        smat[3][2] = loc[2]
-
     # Compensate for non-local location
-    if not pose_bone.bone.use_local_location:
-        loc = smat.to_translation() * (par_rest.inverted() * rest).to_quaternion()
-        smat[3][0] = loc[0]
-        smat[3][1] = loc[1]
-        smat[3][2] = loc[2]
+    #if not pose_bone.bone.use_local_location:
+    #    loc = smat.to_translation() * (par_rest.inverted() * rest).to_quaternion()
+    #    smat[3][0] = loc[0]
+    #    smat[3][1] = loc[1]
+    #    smat[3][2] = loc[2]
 
     return smat
 

Modified: trunk/py/scripts/addons/rigify/utils.py
===================================================================
--- trunk/py/scripts/addons/rigify/utils.py	2011-04-11 03:03:09 UTC (rev 1811)
+++ trunk/py/scripts/addons/rigify/utils.py	2011-04-11 06:10:07 UTC (rev 1812)
@@ -18,7 +18,8 @@
 
 import bpy
 import imp
-from random import randint
+import random
+import time
 from mathutils import Vector
 from math import ceil, floor
 from rna_prop_ui import rna_idprop_ui_prop_get
@@ -497,10 +498,16 @@
     return "\n".join(code)
 
 
-def random_string(length):
+def random_id(length = 8):
+    """ Generates a random alphanumeric id string.
+    """
+    tlength = int(length / 2)
+    rlength = int(length / 2) + int(length % 2)
+
     chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
     text = ""
-    for i in range(0, length):
-        text += chars[randint(0, 35)]
+    for i in range(0, rlength):
+        text += random.choice(chars)
+    text += str(hex(int(time.time())))[2:][-tlength:].rjust(tlength, '0')[::-1]
     return text
 



More information about the Bf-extensions-cvs mailing list