Rigify: support new 2.81 features of constraints and drivers in utils.
Allow easily inserting constraints and support rotation mode.
This commit is contained in:
parent
0dbe126969
commit
c34c7c0c4a
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue