[Bf-extensions-cvs] [c34c7c0c] master: Rigify: support new 2.81 features of constraints and drivers in utils.

Alexander Gavrilov noreply at git.blender.org
Sat Sep 28 09:36:27 CEST 2019


Commit: c34c7c0c4a328176813f3e5cc2ed672a3ae292b2
Author: Alexander Gavrilov
Date:   Sat Sep 28 10:35:18 2019 +0300
Branches: master
https://developer.blender.org/rBAc34c7c0c4a328176813f3e5cc2ed672a3ae292b2

Rigify: support new 2.81 features of constraints and drivers in utils.

Allow easily inserting constraints and support rotation mode.

===================================================================

M	rigify/utils/mechanism.py

===================================================================

diff --git a/rigify/utils/mechanism.py b/rigify/utils/mechanism.py
index 937e07e9..8cd34624 100644
--- a/rigify/utils/mechanism.py
+++ b/rigify/utils/mechanism.py
@@ -37,7 +37,7 @@ def _set_default_attr(obj, options, attr, value):
         options.setdefault(attr, value)
 
 def make_constraint(
-        owner, type, target=None, subtarget=None, *,
+        owner, type, target=None, subtarget=None, *, insert_index=None,
         space=None, track_axis=None, use_xyz=None, use_limit_xyz=None,
         **options):
     """
@@ -46,6 +46,7 @@ def make_constraint(
     Specially handled keyword arguments:
 
       target, subtarget: if both not None, passed through to the constraint
+      insert_index     : insert at the specified index in the stack, instead of at the end
       space            : assigned to both owner_space and target_space
       track_axis       : allows shorter X, Y, Z, -X, -Y, -Z notation
       use_xyz          : list of 3 items is assigned to use_x, use_y and use_z options
@@ -57,6 +58,9 @@ def make_constraint(
     """
     con = owner.constraints.new(type)
 
+    if insert_index is not None:
+        owner.constraints.move(len(owner.constraints)-1, insert_index)
+
     if target is not None and hasattr(con, 'target'):
         con.target = target
 
@@ -264,7 +268,7 @@ def make_driver(owner, prop, *, index=-1, type='SUM', expression=None, variables
     return fcu
 
 
-def driver_var_transform(target, bone=None, *, type='LOC_X', space='WORLD'):
+def driver_var_transform(target, bone=None, *, type='LOC_X', space='WORLD', rotation_mode='AUTO'):
     """
     Create a Transform Channel driver variable specification.
 
@@ -278,6 +282,7 @@ def driver_var_transform(target, bone=None, *, type='LOC_X', space='WORLD'):
         'id': target,
         'transform_type': type,
         'transform_space': space + '_SPACE',
+        'rotation_mode': rotation_mode,
     }
 
     if bone is not None:



More information about the Bf-extensions-cvs mailing list