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

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2021-07-11 16:13:28 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2021-07-11 19:21:57 +0300
commite1f331e0af4461dbf80e03e76d9576fa748a0460 (patch)
tree57b4f05b59cce0372c09b227ec80afdf48e7fddb /rigify/utils/mechanism.py
parent7884a7bbf9e2c9358609129ad8f4fca351d7f278 (diff)
Rigify: add more utility code for the upcoming face rig.
Move widget and driver utilities from the feature set and rewrite create_circle_widget. Also increase the line length for autopep8.
Diffstat (limited to 'rigify/utils/mechanism.py')
-rw-r--r--rigify/utils/mechanism.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/rigify/utils/mechanism.py b/rigify/utils/mechanism.py
index b4b2d389..413d8a00 100644
--- a/rigify/utils/mechanism.py
+++ b/rigify/utils/mechanism.py
@@ -312,6 +312,11 @@ def make_driver(owner, prop, *, index=-1, type='SUM', expression=None, variables
return fcu
+#=============================================
+# Driver variable utilities
+#=============================================
+
+
def driver_var_transform(target, bone=None, *, type='LOC_X', space='WORLD', rotation_mode='AUTO'):
"""
Create a Transform Channel driver variable specification.
@@ -337,6 +342,38 @@ def driver_var_transform(target, bone=None, *, type='LOC_X', space='WORLD', rota
return { 'type': 'TRANSFORMS', 'targets': [ target_map ] }
+def driver_var_distance(target, *, bone1=None, target2=None, bone2=None, space1='WORLD', space2='WORLD'):
+ """
+ Create a Distance driver variable specification.
+
+ Usage:
+ make_driver(..., variables=[driver_var_distance(...)])
+
+ Target bone name can be provided via a 'lazy' callable closure without arguments.
+ """
+
+ assert space1 in {'WORLD', 'TRANSFORM', 'LOCAL'}
+ assert space2 in {'WORLD', 'TRANSFORM', 'LOCAL'}
+
+ target1_map = {
+ 'id': target,
+ 'transform_space': space1 + '_SPACE',
+ }
+
+ if bone1 is not None:
+ target1_map['bone_target'] = bone1
+
+ target2_map = {
+ 'id': target2 or target,
+ 'transform_space': space2 + '_SPACE',
+ }
+
+ if bone2 is not None:
+ target2_map['bone_target'] = bone2
+
+ return {'type': 'LOC_DIFF', 'targets': [target1_map, target2_map]}
+
+
#=============================================
# Constraint management
#=============================================