Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-12-14 17:21:06 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-12-14 17:21:06 +0300
commit3bf27683be8401a53c761201fcd09974a53a80b7 (patch)
tree192bfe2dcf91260939590a7c10e1fdf0901bfcb1 /release
parent32d5429e353b68ed90f2e32edc48a7841a2b4138 (diff)
automatic layer placement, users can set the layers if they want.
predefined layer types 'main', 'extra', 'ik', 'fk'
Diffstat (limited to 'release')
-rw-r--r--release/scripts/modules/rigify/__init__.py17
-rw-r--r--release/scripts/modules/rigify/arm_biped_generic.py28
-rw-r--r--release/scripts/modules/rigify/copy.py12
-rw-r--r--release/scripts/modules/rigify/finger_curl.py12
-rw-r--r--release/scripts/modules/rigify/leg_biped_generic.py27
-rw-r--r--release/scripts/modules/rigify/neck_flex.py14
-rw-r--r--release/scripts/modules/rigify/palm_curl.py7
-rw-r--r--release/scripts/modules/rigify/spine_pivot_flex.py16
-rw-r--r--release/test/pep8.py4
9 files changed, 122 insertions, 15 deletions
diff --git a/release/scripts/modules/rigify/__init__.py b/release/scripts/modules/rigify/__init__.py
index 9e59f0965e0..9dd00cf66e9 100644
--- a/release/scripts/modules/rigify/__init__.py
+++ b/release/scripts/modules/rigify/__init__.py
@@ -24,6 +24,7 @@ from Mathutils import Vector
# TODO, have these in a more general module
from rna_prop_ui import rna_idprop_ui_prop_get
SPECIAL_TYPES = "root",
+LAYER_TYPES = "main", "extra", "ik", "fk"
class RigifyError(Exception):
@@ -81,6 +82,22 @@ def get_bone_type_options(pbone, type_name):
return options
+def get_layer_dict(options):
+ '''
+ Extracts layer info from a bone options dict
+ defaulting to the layer index if not set.
+ '''
+ layer_default = [False] * 32
+ result = {}
+ for i, layer_type in enumerate(LAYER_TYPES):
+ # no matter if its not defined
+ layer_index = options.get("layer_" + layer_type, i + 2)
+ layer = layer_default[:]
+ layer[layer_index-1] = True
+ result[layer_type] = layer
+ return result
+
+
def validate_rig(context, obj):
'''
Makes no changes
diff --git a/release/scripts/modules/rigify/arm_biped_generic.py b/release/scripts/modules/rigify/arm_biped_generic.py
index 22de14ade54..1c4c6fd2a6b 100644
--- a/release/scripts/modules/rigify/arm_biped_generic.py
+++ b/release/scripts/modules/rigify/arm_biped_generic.py
@@ -19,7 +19,7 @@
# <pep8 compliant>
import bpy
-from rigify import RigifyError
+from rigify import RigifyError, get_layer_dict
from rigify_utils import bone_class_instance, copy_bone_simple, add_pole_target_bone, add_stretch_to, blend_bone_list, get_side_name, get_base_name
from rna_prop_ui import rna_idprop_ui_prop_get
from Mathutils import Vector
@@ -170,8 +170,17 @@ def ik(obj, definitions, base_names, options):
prop["soft_min"] = 0.0
prop["soft_max"] = 1.0
- bpy.ops.object.mode_set(mode='EDIT')
+ # last step setup layers
+ layers = get_layer_dict(options)
+ lay = layers["ik"]
+ for attr in ik_chain.attr_names:
+ getattr(ik_chain, attr + "_b").layer = lay
+ for attr in ik.attr_names:
+ getattr(ik, attr + "_b").layer = lay
+
+
+ bpy.ops.object.mode_set(mode='EDIT')
# don't blend the shoulder
return [None] + ik_chain.names()
@@ -184,7 +193,7 @@ def fk(obj, definitions, base_names, options):
mt.shoulder, mt.arm, mt.forearm, mt.hand = definitions
mt.update()
- ex = bone_class_instance(obj, ["socket", "arm_hinge", "hand_delta"])
+ ex = bone_class_instance(obj, ["socket", "hand_delta"])
fk_chain = mt.copy(base_names=base_names)
# shoulder is used as a hinge
@@ -263,8 +272,19 @@ def fk(obj, definitions, base_names, options):
hinge_setup()
- bpy.ops.object.mode_set(mode='EDIT')
+ # last step setup layers
+ layers = get_layer_dict(options)
+ lay = layers["fk"]
+ for attr in fk_chain.attr_names:
+ getattr(fk_chain, attr + "_b").layer = lay
+
+ lay = layers["extra"]
+ for attr in ex.attr_names:
+ getattr(ex, attr + "_b").layer = lay
+
+
+ bpy.ops.object.mode_set(mode='EDIT')
return None, fk_chain.arm, fk_chain.forearm, fk_chain.hand
diff --git a/release/scripts/modules/rigify/copy.py b/release/scripts/modules/rigify/copy.py
index 77bf2d35bb8..d388ee18316 100644
--- a/release/scripts/modules/rigify/copy.py
+++ b/release/scripts/modules/rigify/copy.py
@@ -19,6 +19,7 @@
# <pep8 compliant>
import bpy
+from rigify import get_layer_dict
from rigify_utils import bone_class_instance
METARIG_NAMES = ("cpy",)
@@ -55,12 +56,17 @@ def main(obj, bone_definition, base_names, options):
cp.update()
mt.update()
+ if not cp.cpy_b.connected:
+ con = cp.cpy_p.constraints.new('COPY_LOCATION')
+ con.target = obj
+ con.subtarget = mt.cpy
+
con = cp.cpy_p.constraints.new('COPY_ROTATION')
con.target = obj
con.subtarget = mt.cpy
- con = cp.cpy_p.constraints.new('COPY_LOCATION')
- con.target = obj
- con.subtarget = mt.cpy
+ # setup layers last
+ layers = get_layer_dict(options)
+ cp.cpy_b.layer = layers["main"]
return [mt.cpy]
diff --git a/release/scripts/modules/rigify/finger_curl.py b/release/scripts/modules/rigify/finger_curl.py
index 03c76672d6c..cec6504a8aa 100644
--- a/release/scripts/modules/rigify/finger_curl.py
+++ b/release/scripts/modules/rigify/finger_curl.py
@@ -19,7 +19,7 @@
# <pep8 compliant>
import bpy
-from rigify import RigifyError
+from rigify import RigifyError, get_layer_dict
from rigify_utils import copy_bone_simple, get_side_name
from rna_prop_ui import rna_idprop_ui_prop_get
from functools import reduce
@@ -213,5 +213,15 @@ def main(obj, bone_definition, base_names, options):
i += 1
+
+ # last step setup layers
+ layers = get_layer_dict(options)
+ lay = layers["extra"]
+ for child_bone_name, driver_bone_name in driver_bone_pairs:
+ arm.bones[driver_bone_name].layer = lay
+
+ lay = layers["main"]
+ arm.bones[control_bone_name].layer = lay
+
# no blending the result of this
return None
diff --git a/release/scripts/modules/rigify/leg_biped_generic.py b/release/scripts/modules/rigify/leg_biped_generic.py
index c48ff093a2f..2c5481be1b7 100644
--- a/release/scripts/modules/rigify/leg_biped_generic.py
+++ b/release/scripts/modules/rigify/leg_biped_generic.py
@@ -19,7 +19,7 @@
# <pep8 compliant>
import bpy
-from rigify import RigifyError
+from rigify import RigifyError, get_layer_dict
from rigify_utils import bone_class_instance, copy_bone_simple, blend_bone_list, get_side_name, get_base_name
from rna_prop_ui import rna_idprop_ui_prop_get
@@ -131,8 +131,6 @@ def ik(obj, bone_definition, base_names, options):
# setup the existing bones
mt_chain = bone_class_instance(obj, ["thigh", "shin", "foot", "toe"])
mt = bone_class_instance(obj, ["hips", "heel"])
- #ex = bone_class_instance(obj, [""])
- ex = bone_class_instance(obj, ["thigh_socket", "thigh_hinge", "foot_roll_1", "foot_roll_2", "foot_roll_3"])
# children of ik_foot
ik = bone_class_instance(obj, ["foot", "foot_roll", "foot_roll_01", "foot_roll_02", "knee_target"])
@@ -215,7 +213,6 @@ def ik(obj, bone_definition, base_names, options):
bpy.ops.object.mode_set(mode='OBJECT')
ik.update()
- ex.update()
mt_chain.update()
ik_chain.update()
@@ -269,6 +266,15 @@ def ik(obj, bone_definition, base_names, options):
con.minimum_x = -180.0 # XXX -deg
con.maximum_x = 0.0
+
+ # last step setup layers
+ layers = get_layer_dict(options)
+ lay = layers["ik"]
+ for attr in ik_chain.attr_names:
+ getattr(ik_chain, attr + "_b").layer = lay
+ for attr in ik.attr_names:
+ getattr(ik, attr + "_b").layer = lay
+
bpy.ops.object.mode_set(mode='EDIT')
return None, ik_chain.thigh, ik_chain.shin, ik_chain.foot, ik_chain.toe, None
@@ -348,6 +354,19 @@ def fk(obj, bone_definition, base_names, options):
mod.coefficients[0] = 1.0
mod.coefficients[1] = -1.0
+
+
+ # last step setup layers
+ layers = get_layer_dict(options)
+ lay = layers["fk"]
+ for attr in fk_chain.attr_names:
+ getattr(fk_chain, attr + "_b").layer = lay
+
+ lay = layers["extra"]
+ for attr in ex.attr_names:
+ getattr(ex, attr + "_b").layer = lay
+
+
bpy.ops.object.mode_set(mode='EDIT')
# dont blend the hips or heel
diff --git a/release/scripts/modules/rigify/neck_flex.py b/release/scripts/modules/rigify/neck_flex.py
index 377fd9c9bc8..137fb626bcf 100644
--- a/release/scripts/modules/rigify/neck_flex.py
+++ b/release/scripts/modules/rigify/neck_flex.py
@@ -19,7 +19,7 @@
# <pep8 compliant>
import bpy
-from rigify import RigifyError
+from rigify import RigifyError, get_layer_dict
from rigify_utils import bone_class_instance, copy_bone_simple
from rna_prop_ui import rna_idprop_ui_prop_get
@@ -121,7 +121,7 @@ def main(obj, bone_definition, base_names, options):
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", "head_ctrl"]) # hinge & extras
+ ex = bone_class_instance(obj, ["head", "head_hinge", "neck_socket", "head_ctrl"]) # hinge & extras
# Add the head hinge at the bodys location, becomes the parent of the original head
@@ -296,5 +296,15 @@ def main(obj, bone_definition, base_names, options):
con.target = obj
con.subtarget = neck_p.name
+
+ # last step setup layers
+ layers = get_layer_dict(options)
+ lay = layers["extra"]
+ for attr in ex_chain.attr_names:
+ getattr(ex_chain, attr + "_b").layer = lay
+ for attr in ex.attr_names:
+ getattr(ex, attr + "_b").layer = lay
+
+
# 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 ee99ef6e82a..8e0a80f98e8 100644
--- a/release/scripts/modules/rigify/palm_curl.py
+++ b/release/scripts/modules/rigify/palm_curl.py
@@ -19,6 +19,7 @@
# <pep8 compliant>
import bpy
+from rigify import get_layer_dict
from rigify_utils import copy_bone_simple, get_side_name
from rna_prop_ui import rna_idprop_ui_prop_get
@@ -232,5 +233,11 @@ def main(obj, bone_definition, base_names, options):
if x_direction(): # flip
driver.expression = "-(%s)" % driver.expression
+
+ # last step setup layers
+ layers = get_layer_dict(options)
+ arm.bones[control_name].layer = layers["extra"]
+
+
# no blending the result of this
return None
diff --git a/release/scripts/modules/rigify/spine_pivot_flex.py b/release/scripts/modules/rigify/spine_pivot_flex.py
index 4765f0591f7..ca954eeef4f 100644
--- a/release/scripts/modules/rigify/spine_pivot_flex.py
+++ b/release/scripts/modules/rigify/spine_pivot_flex.py
@@ -19,6 +19,7 @@
# <pep8 compliant>
import bpy
+from rigify import get_layer_dict
from rigify_utils import bone_class_instance, copy_bone_simple
from rna_prop_ui import rna_idprop_ui_prop_get
@@ -495,5 +496,20 @@ def main(obj, bone_definition, base_names, options):
mod.coefficients[0] = - (i - 1)
mod.coefficients[1] = spine_chain_len
+
+ # last step setup layers
+ layers = get_layer_dict(options)
+ lay = layers["extra"]
+ for attr in ex.attr_names:
+ getattr(ex, attr + "_b").layer = lay
+ for attr in ex_chain.attr_names:
+ getattr(ex_chain, attr + "_b").layer = lay
+
+ lay = layers["main"]
+ for attr in df.attr_names:
+ getattr(df, attr + "_b").layer = lay
+ for attr in rv_chain .attr_names:
+ getattr(rv_chain , attr + "_b").layer = lay
+
# no support for blending chains
return None
diff --git a/release/test/pep8.py b/release/test/pep8.py
index 57ce0a96120..0c0c013ad84 100644
--- a/release/test/pep8.py
+++ b/release/test/pep8.py
@@ -29,7 +29,9 @@ import os
# sudo pip install pep8
#
# in debian install pylint pyflakes pep8 with apt-get/aptitude/etc
-#
+#
+# on *nix run
+# python release/test/pep8.py > tmp.err 2>&1
# how many lines to read into the file, pep8 comment
# should be directly after the licence header, ~20 in most cases