diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-10-15 15:33:10 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-10-15 15:36:32 +0300 |
commit | 0c859edf37b06de18bc0a6ac96c20ecbdc1b4052 (patch) | |
tree | 14a71fe0b95b6fe6ff522a32ee78b2db8fb95e02 /rigify/utils/misc.py | |
parent | 0c21df4e49166d7aa0b7606db0f9e34ab93a7b68 (diff) |
Rigify: fix incorrect layer assignment for tweak bones in the cat metarig.
The layer selection for the spine tweaks happens to be the default value,
so simply copying the data does not overwrite non-default garbage values
remaining in some of the bones. To fix it's necessary to clear params.
Diffstat (limited to 'rigify/utils/misc.py')
-rw-r--r-- | rigify/utils/misc.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/rigify/utils/misc.py b/rigify/utils/misc.py index 4d0fbad3..64367bb7 100644 --- a/rigify/utils/misc.py +++ b/rigify/utils/misc.py @@ -24,6 +24,7 @@ import collections from itertools import tee, chain, islice, repeat from mathutils import Vector, Matrix, Color +from rna_prop_ui import rna_idprop_value_to_python #============================================= @@ -170,8 +171,30 @@ def copy_attributes(a, b): pass +def property_to_python(value): + value = rna_idprop_value_to_python(value) + + if isinstance(value, dict): + return { k: property_to_python(v) for k, v in value.items() } + elif isinstance(value, list): + return map_list(property_to_python, value) + else: + return value + + +def clone_parameters(target): + return property_to_python(dict(target)) + + def assign_parameters(target, val_dict=None, **params): - data = { **val_dict, **params } if val_dict else params + if val_dict is not None: + for key in list(target.keys()): + del target[key] + + data = { **val_dict, **params } + else: + data = params + for key, value in data.items(): try: target[key] = value |