[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25142] trunk/blender/release/scripts/ modules: fixes for automatic tests and some errors in last commit
Campbell Barton
ideasman42 at gmail.com
Sat Dec 5 21:45:52 CET 2009
Revision: 25142
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25142
Author: campbellbarton
Date: 2009-12-05 21:45:51 +0100 (Sat, 05 Dec 2009)
Log Message:
-----------
fixes for automatic tests and some errors in last commit
Modified Paths:
--------------
trunk/blender/release/scripts/modules/bpy/__init__.py
trunk/blender/release/scripts/modules/graphviz_export.py
trunk/blender/release/scripts/modules/rigify/__init__.py
trunk/blender/release/scripts/modules/rigify/arm.py
trunk/blender/release/scripts/modules/rigify/finger.py
trunk/blender/release/scripts/modules/rigify/leg.py
trunk/blender/release/scripts/modules/rigify/spine.py
Modified: trunk/blender/release/scripts/modules/bpy/__init__.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/__init__.py 2009-12-05 20:06:19 UTC (rev 25141)
+++ trunk/blender/release/scripts/modules/bpy/__init__.py 2009-12-05 20:45:51 UTC (rev 25142)
@@ -31,17 +31,26 @@
# fake operator module
ops = _ops_module.ops_fake_module
+import time
+
def load_scripts(reload_scripts=False):
import os
import sys
import traceback
+
+
+ tt = time.time()
def test_import(module_name):
try:
- return __import__(module_name)
+ t = time.time()
+ ret= __import__(module_name)
+ print("time %s %.4f" % (module_name, time.time() - t))
+ return ret
except:
traceback.print_exc()
return None
+
for base_path in utils.script_paths():
for path_subdir in ("ui", "op", "io"):
@@ -61,6 +70,8 @@
if reload_scripts and mod:
print("Reloading:", mod)
reload(mod)
+
+ print("Time %.4f" % (time.time() - tt))
def _main():
@@ -70,7 +81,7 @@
import sys
sys.stdin = None
- if "-d" in sys.argv and False: # Enable this to measure startup speed
+ if "-d" in sys.argv: # Enable this to measure startup speed
import cProfile
cProfile.run('import bpy; bpy.load_scripts()', 'blender.prof')
Modified: trunk/blender/release/scripts/modules/graphviz_export.py
===================================================================
--- trunk/blender/release/scripts/modules/graphviz_export.py 2009-12-05 20:06:19 UTC (rev 25141)
+++ trunk/blender/release/scripts/modules/graphviz_export.py 2009-12-05 20:45:51 UTC (rev 25142)
@@ -47,7 +47,8 @@
text = text.replace('"', '\\"')
return "* " + text
-def graph_armature(obj, path, FAKE_PARENT=True, CONSTRAINTS=True, DRIVERS=True):
+def graph_armature(obj, path, FAKE_PARENT=True, CONSTRAINTS=True, DRIVERS=True, XTRA_INFO=False):
+ CONSTRAINTS = DRIVERS = True
file = open(path, "w")
fw = file.write
@@ -76,7 +77,7 @@
label.append("%s = %s" % (key, value))
- opts = ["shape=box", "regular=1", "style=filled", 'width="2.33"', 'height="0.35"', "fixedsize=false", 'label="%s"' % compat_str('\n'.join(label))]
+ opts = ["shape=box", "regular=1", "style=filled", "fixedsize=false", 'label="%s"' % compat_str('\n'.join(label))]
if bone.name.startswith('ORG'):
opts.append("fillcolor=yellow")
@@ -123,8 +124,9 @@
if subtarget:
# TODO, not internal links
opts = ['dir=forward', "weight=1", "arrowhead=normal", "arrowtail=none", "constraint=false", 'color="red"', 'labelfontsize=4']
- label = "%s\n%s" % (constraint.type, constraint.name)
- opts.append('label="%s"' % compat_str(label))
+ if XTRA_INFO:
+ label = "%s\n%s" % (constraint.type, constraint.name)
+ opts.append('label="%s"' % compat_str(label))
fw('"%s" -> "%s" [%s] ;\n' % (subtarget, pbone.name, ','.join(opts)))
# Drivers
@@ -157,8 +159,9 @@
opts = ['dir=forward', "weight=1", "arrowhead=normal", "arrowtail=none", "constraint=false", 'color="blue"', "labelfontsize=4"] # ,
display_source = rna_path.replace("pose.bones", "")
display_target = rna_path_target.replace("pose.bones", "")
- label = "%s\\n%s" % (display_source, display_target)
- opts.append('label="%s"' % compat_str(label))
+ if XTRA_INFO:
+ label = "%s\\n%s" % (display_source, display_target)
+ opts.append('label="%s"' % compat_str(label))
fw('"%s" -> "%s" [%s] ;\n' % (pbone_target.name, pbone.name, ','.join(opts)))
fw(footer)
Modified: trunk/blender/release/scripts/modules/rigify/__init__.py
===================================================================
--- trunk/blender/release/scripts/modules/rigify/__init__.py 2009-12-05 20:06:19 UTC (rev 25141)
+++ trunk/blender/release/scripts/modules/rigify/__init__.py 2009-12-05 20:45:51 UTC (rev 25142)
@@ -164,7 +164,7 @@
def copy_bone_simple(arm, from_bone, name, parent=False):
ebone = arm.edit_bones[from_bone]
ebone_new = arm.edit_bones.new(name)
-
+
if parent:
ebone_new.connected = ebone.connected
ebone_new.parent = ebone.parent
@@ -429,6 +429,7 @@
bone_typeinfo = bone_typeinfos.setdefault(bone_name, [])
+
type_func = getattr(submod, func_name)
bone_typeinfo.append((submod_name, type_func))
Modified: trunk/blender/release/scripts/modules/rigify/arm.py
===================================================================
--- trunk/blender/release/scripts/modules/rigify/arm.py 2009-12-05 20:06:19 UTC (rev 25141)
+++ trunk/blender/release/scripts/modules/rigify/arm.py 2009-12-05 20:45:51 UTC (rev 25142)
@@ -338,10 +338,7 @@
bpy.ops.object.mode_set(mode='EDIT')
# remove the shoulder and re-parent
-
-
-
- chain_init()
+
chain_ik()
chain_switch()
chain_shoulder()
Modified: trunk/blender/release/scripts/modules/rigify/finger.py
===================================================================
--- trunk/blender/release/scripts/modules/rigify/finger.py 2009-12-05 20:06:19 UTC (rev 25141)
+++ trunk/blender/release/scripts/modules/rigify/finger.py 2009-12-05 20:45:51 UTC (rev 25142)
@@ -98,7 +98,7 @@
# first make a new bone at the location of the finger
#control_ebone = arm.edit_bones.new(base_name)
- control_ebone = copy_bone_simple(arm, base_name, base_name)
+ control_ebone = copy_bone_simple(arm, bone_definition[0], base_name)
control_bone_name = control_ebone.name # we dont know if we get the name requested
control_ebone.connected = orig_ebone.connected
Modified: trunk/blender/release/scripts/modules/rigify/leg.py
===================================================================
--- trunk/blender/release/scripts/modules/rigify/leg.py 2009-12-05 20:06:19 UTC (rev 25141)
+++ trunk/blender/release/scripts/modules/rigify/leg.py 2009-12-05 20:45:51 UTC (rev 25142)
@@ -17,7 +17,7 @@
# ##### END GPL LICENSE BLOCK #####
import bpy
-from rigify import bone_class_instance, copy_bone_simple, copy_bone_simple_list, add_pole_target_bone, add_stretch_to
+from rigify import bone_class_instance, copy_bone_simple, copy_bone_simple_list, add_pole_target_bone, add_stretch_to, blend_bone_list
from rna_prop_ui import rna_idprop_ui_get, rna_idprop_ui_prop_get
METARIG_NAMES = "hips", "thigh", "shin", "foot", "toe", "heel"
@@ -249,7 +249,9 @@
else:
con.minimum_x = -180.0 # XXX -deg
con.maximum_x = 0.0
-
+
+ bpy.ops.object.mode_set(mode='EDIT')
+
return None, ik_chain.thigh, ik_chain.shin, ik_chain.foot, ik_chain.toe, None
@@ -323,5 +325,14 @@
mod.coefficients[0] = 1.0
mod.coefficients[1] = -1.0
+ bpy.ops.object.mode_set(mode='EDIT')
+
# dont blend the hips or heel
return None, fk_chain.thigh, fk_chain.shin, fk_chain.foot, fk_chain.toe, None
+
+def main(obj, bone_definition, base_names):
+ bones_ik = ik(obj, bone_definition, base_names)
+ bones_fk = fk(obj, bone_definition, base_names)
+
+ bpy.ops.object.mode_set(mode='OBJECT')
+ blend_bone_list(obj, bone_definition, bones_ik, bones_fk)
Modified: trunk/blender/release/scripts/modules/rigify/spine.py
===================================================================
--- trunk/blender/release/scripts/modules/rigify/spine.py 2009-12-05 20:06:19 UTC (rev 25141)
+++ trunk/blender/release/scripts/modules/rigify/spine.py 2009-12-05 20:45:51 UTC (rev 25142)
@@ -123,10 +123,12 @@
mt.ribcage = bone_definition[1]
mt.update()
- spine_chain_orig = bone_definition[2:]
+ spine_chain_orig = tuple(bone_definition[2:])
spine_chain = [arm.edit_bones[child_name] for child_name in spine_chain_orig]
- spine_chain_basename = base_names[spine_chain[0].name].rsplit(".", 1) # probably 'ORG-spine.01' -> 'spine'
+ spine_chain_basename = base_names[spine_chain[0].name].rsplit(".", 1)[0] # probably 'ORG-spine.01' -> 'spine'
spine_chain_len = len(spine_chain_orig)
+ print(spine_chain_orig)
+ print(spine_chain_len)
'''
children = mt.ribcage_e.children
@@ -180,10 +182,6 @@
ex.ribcage_e.translate(Vector(0.0, -ex.ribcage_e.length / 2.0, 0.0))
ex.ribcage_e.parent = mt.ribcage_e
- # rename!
- for child in spine_chain:
- child.name = "ORG-" + child.name
-
spine_chain = [child.name for child in spine_chain]
# We have 3 spine chains
@@ -198,11 +196,11 @@
del spine_chain_attrs
for i, child_name in enumerate(spine_chain):
- child_name_orig = spine_chain_orig[i]
+ child_name_orig = base_names[spine_chain_orig[i]]
attr = mt_chain.attr_names[i] # eg. spine_04
- setattr(mt_chain, attr, spine_chain[i]) # use the new name
+ setattr(mt_chain, attr, spine_chain_orig[i]) # the original bone
ebone = copy_bone_simple(arm, child_name, child_name_orig) # use the original name
setattr(ex_chain, attr, ebone.name)
@@ -210,7 +208,7 @@
ebone = copy_bone_simple(arm, child_name, "MCH-rev_%s" % child_name_orig)
setattr(rv_chain, attr, ebone.name)
ebone.connected = False
-
+
mt_chain.update()
ex_chain.update()
rv_chain.update()
@@ -284,7 +282,7 @@
con.target = obj
con.subtarget = ex.pelvis
con.owner_space = 'LOCAL'
- con.target_space = 'LOCAL'
+ con.target_space = 'LOCAL'
# df.ribcage_p / DEF-wgt_rib_cage
con = df.ribcage_p.constraints.new('COPY_ROTATION')
@@ -332,10 +330,14 @@
con = ex.pelvis_p.constraints.new('COPY_LOCATION')
con.target = obj
con.subtarget = mt_chain.spine_01
+ con.owner_space = 'WORLD'
+ con.target_space = 'WORLD'
con = ex.pelvis_p.constraints.new('COPY_ROTATION')
con.target = obj
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list