diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-09-28 10:35:18 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-09-28 10:35:36 +0300 |
commit | c34c7c0c4a328176813f3e5cc2ed672a3ae292b2 (patch) | |
tree | 1257bf7041b772c04a6d6e2d9232a951665069bf /rigify | |
parent | 0dbe12696971b4040b44ed9e968f95d55a4e60ae (diff) |
Rigify: support new 2.81 features of constraints and drivers in utils.
Allow easily inserting constraints and support rotation mode.
Diffstat (limited to 'rigify')
-rw-r--r-- | rigify/utils/mechanism.py | 9 |
1 files changed, 7 insertions, 2 deletions
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: |