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-06-29 20:19:52 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2020-06-29 20:19:52 +0300
commitda8877fa8b295afba5a986bc710b862777fcfba3 (patch)
tree2bad3f4fe9ff8870def4ef02ce773ad85fa8a5a8 /rigify/utils
parentdb23ff3d34415a3aae1c8bd775de2db8af22d5c7 (diff)
Fix T78193 (Rigify): use bone history tracking to find derived DEF bones.
It is not really safe to assume that by swapping ORG to DEF you will get a deform bone derived from the given ORG bone. The new base rig API already tracks copying of bones, so polish it up and use here. Note however that this tracking doesn't work with bones created without self.copy_bone, e.g. by legacy rigs.
Diffstat (limited to 'rigify/utils')
-rw-r--r--rigify/utils/naming.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/rigify/utils/naming.py b/rigify/utils/naming.py
index e5c1c573..17d7496c 100644
--- a/rigify/utils/naming.py
+++ b/rigify/utils/naming.py
@@ -307,3 +307,20 @@ def random_id(length=8):
text += random.choice(chars)
text += str(hex(int(time.time())))[2:][-tlength:].rjust(tlength, '0')[::-1]
return text
+
+
+def choose_derived_bone(generator, original, subtype, *, by_owner=True, recursive=True):
+ bones = generator.obj.pose.bones
+ names = generator.find_derived_bones(original, by_owner=by_owner, recursive=recursive)
+
+ direct = make_derived_name(original, subtype)
+ if direct in names and direct in bones:
+ return direct
+
+ prefix = _PREFIX_TABLE[subtype] + '-'
+ matching = [ name for name in names if name.startswith(prefix) and name in bones ]
+
+ if len(matching) > 0:
+ return matching[0]
+
+ return None