[Bf-extensions-cvs] [2687cca6] master: Rigify: move constraints to control and deform bones in super_copy.

Alexander Gavrilov noreply at git.blender.org
Tue Dec 8 19:56:58 CET 2020


Commit: 2687cca6c373d8e0e47c39c5382d643ea02b8745
Author: Alexander Gavrilov
Date:   Tue Dec 8 14:47:21 2020 +0300
Branches: master
https://developer.blender.org/rBA2687cca6c373d8e0e47c39c5382d643ea02b8745

Rigify: move constraints to control and deform bones in super_copy.

Use DEF: or CTRL: prefix on constraint names to move them during relink.

===================================================================

M	rigify/rigs/basic/raw_copy.py
M	rigify/rigs/basic/super_copy.py

===================================================================

diff --git a/rigify/rigs/basic/raw_copy.py b/rigify/rigs/basic/raw_copy.py
index 44c10a6c..407241cb 100644
--- a/rigify/rigs/basic/raw_copy.py
+++ b/rigify/rigs/basic/raw_copy.py
@@ -62,6 +62,17 @@ class RelinkConstraintsMixin:
                 self.relink_constraint(con, [''])
 
 
+    def relink_move_constraints(self, from_bone, to_bone, *, prefix=''):
+        if self.params.relink_constraints:
+            src = self.get_bone(from_bone).constraints
+            dest = self.get_bone(to_bone).constraints
+
+            for con in list(src):
+                if con.name.startswith(prefix):
+                    dest.copy(con)
+                    src.remove(con)
+
+
     def relink_bone_parent(self, bone_name):
         if self.params.relink_constraints:
             self.generator.disable_auto_parent(bone_name)
diff --git a/rigify/rigs/basic/super_copy.py b/rigify/rigs/basic/super_copy.py
index dcff41fe..e2f70842 100644
--- a/rigify/rigs/basic/super_copy.py
+++ b/rigify/rigs/basic/super_copy.py
@@ -86,9 +86,14 @@ class Rig(BaseRig, RelinkConstraintsMixin):
         self.relink_bone_constraints(bones.org)
 
         if self.make_control:
+            self.relink_move_constraints(bones.org, bones.ctrl, prefix='CTRL:')
+
             # Constrain the original bone.
             self.make_constraint(bones.org, 'COPY_TRANSFORMS', bones.ctrl, insert_index=0)
 
+        if self.make_deform:
+            self.relink_move_constraints(bones.org, bones.deform, prefix='DEF:')
+
 
     def generate_widgets(self):
         bones = self.bones
@@ -151,6 +156,13 @@ class Rig(BaseRig, RelinkConstraintsMixin):
 
         self.add_relink_constraints_ui(layout, params)
 
+        if params.relink_constraints and (params.make_control or params.make_deform):
+            col = layout.column()
+            if params.make_control:
+                col.label(text="'CTRL:...' constraints are moved to the control bone.", icon='INFO')
+            if params.make_deform:
+                col.label(text="'DEF:...' constraints are moved to the deform bone.", icon='INFO')
+
 
 def create_sample(obj):
     """ Create a sample metarig for this rig type.



More information about the Bf-extensions-cvs mailing list