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>2021-07-16 19:27:12 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2021-07-16 19:27:52 +0300
commit9791dfef7f73f20a1b8d4bbeac638accc71ce8e1 (patch)
tree86148060c6d658648b963ff4ae4d29d31e180973 /rigify/utils/rig.py
parent992b0592f14b54b4a1414ea44e9060693c38e75f (diff)
Rigify: add utilities for working with rig instance parent chains.
Diffstat (limited to 'rigify/utils/rig.py')
-rw-r--r--rigify/utils/rig.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/rigify/utils/rig.py b/rigify/utils/rig.py
index fa55c1aa..7969a34f 100644
--- a/rigify/utils/rig.py
+++ b/rigify/utils/rig.py
@@ -91,6 +91,36 @@ def upgradeMetarigTypes(metarig, revert=False):
# Misc
#=============================================
+
+def rig_is_child(rig, parent, *, strict=False):
+ """
+ Checks if the rig is a child of the parent.
+ Unless strict is True, returns true if the rig and parent are the same.
+ """
+ if parent is None:
+ return True
+
+ if rig and strict:
+ rig = rig.rigify_parent
+
+ while rig:
+ if rig is parent:
+ return True
+
+ rig = rig.rigify_parent
+
+ return False
+
+
+def get_parent_rigs(rig):
+ """Returns a list containing the rig and all of its parents."""
+ result = []
+ while rig:
+ result.append(rig)
+ rig = rig.rigify_parent
+ return result
+
+
def get_resource(resource_name):
""" Fetches a rig module by name, and returns it.
"""