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>2020-12-21 12:29:17 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2020-12-21 15:23:04 +0300
commit1ada831ca1981c028a0a2b2983c0c384b2656ea5 (patch)
tree564f3ecb31458d29014903e495baa2512633c415 /rigify/utils
parenta7c0667baa646896d676ad154c66aed914cc560c (diff)
Rigify: generate UI script for custom properties from metarig.
Improve auto-generated UI naming and update basic.pivot, basic.raw_copy and basic.super_copy. Also allow raw_copy to generate builtin widgets.
Diffstat (limited to 'rigify/utils')
-rw-r--r--rigify/utils/bones.py13
-rw-r--r--rigify/utils/mechanism.py35
-rw-r--r--rigify/utils/naming.py4
3 files changed, 31 insertions, 21 deletions
diff --git a/rigify/utils/bones.py b/rigify/utils/bones.py
index 659afeae..0142922c 100644
--- a/rigify/utils/bones.py
+++ b/rigify/utils/bones.py
@@ -196,16 +196,9 @@ def copy_bone_properties(obj, bone_name_1, bone_name_2, transforms=True, props=T
# Copy custom properties
if props:
- for key in pose_bone_1.keys():
- if key != "_RNA_UI" \
- and key != "rigify_parameters" \
- and key != "rigify_type":
- prop1 = rna_idprop_ui_prop_get(pose_bone_1, key, create=False)
- pose_bone_2[key] = pose_bone_1[key]
- if prop1 is not None:
- prop2 = rna_idprop_ui_prop_get(pose_bone_2, key, create=True)
- for key in prop1.keys():
- prop2[key] = prop1[key]
+ from .mechanism import copy_custom_properties
+
+ copy_custom_properties(pose_bone_1, pose_bone_2)
if widget:
pose_bone_2.custom_shape = pose_bone_1.custom_shape
diff --git a/rigify/utils/mechanism.py b/rigify/utils/mechanism.py
index c048d35c..80ca4d29 100644
--- a/rigify/utils/mechanism.py
+++ b/rigify/utils/mechanism.py
@@ -387,16 +387,18 @@ def copy_custom_properties(src, dest, *, prefix='', dest_prefix='', link_driver=
if key.startswith(prefix) and key not in exclude:
new_key = dest_prefix + key[len(prefix):]
- dest[new_key] = value
-
info = rna_idprop_ui_prop_get(src, key, False)
- if info:
- info2 = rna_idprop_ui_prop_get(dest, new_key, True)
- for ki, vi in info.items():
- info2[ki] = vi
- if link_driver:
- make_driver(src, quote_property(key), variables=[(dest.id_data, dest, new_key)])
+ if src != dest or new_key != key:
+ dest[new_key] = value
+
+ if info:
+ info2 = rna_idprop_ui_prop_get(dest, new_key, True)
+ for ki, vi in info.items():
+ info2[ki] = vi
+
+ if link_driver:
+ make_driver(src, quote_property(key), variables=[(dest.id_data, dest, new_key)])
res.append((key, new_key, value, info))
@@ -412,10 +414,21 @@ def copy_custom_properties_with_ui(rig, src, dest_bone, *, ui_controls=None, **o
mapping = copy_custom_properties(src, bone, **options)
if mapping:
- panel = rig.script.panel_with_selected_check(rig, ui_controls or rig.bones.ctrl.flatten())
+ panel = rig.script.panel_with_selected_check(rig, ui_controls or rig.bones.flatten('ctrl'))
+
+ for key,new_key,value,info in sorted(mapping, key=lambda item: item[1]):
+ name = new_key
+
+ # Replace delimiters with spaces
+ if ' ' not in name:
+ name = re.sub(r'[_.-]', ' ', name)
+ # Split CamelCase
+ if ' ' not in name:
+ name = re.sub(r'([a-z])([A-Z])', r'\1 \2', name)
+ # Capitalize
+ if name.lower() == name:
+ name = name.title()
- for key,new_key,value,info in mapping:
- name = re.sub(r'[_.-]', ' ', new_key).title()
slider = type(value) is float and info and info.get("min", None) == 0 and info.get("max", None) == 1
panel.custom_prop(dest_bone, new_key, text=name, slider=slider)
diff --git a/rigify/utils/naming.py b/rigify/utils/naming.py
index 45307323..6c54b988 100644
--- a/rigify/utils/naming.py
+++ b/rigify/utils/naming.py
@@ -43,6 +43,10 @@ def split_name(name):
return NameParts(*name_parts.groups())
+def is_control_bone(name):
+ return not split_name(name).prefix
+
+
def combine_name(parts, *, prefix=None, base=None, side_z=None, side=None, number=None):
eff_prefix = prefix if prefix is not None else parts.prefix
eff_number = number if number is not None else parts.number