[Bf-extensions-cvs] [25c81824] blender-v2.92-release master: Rigify: fix the ORG bone rename affecting objects dependent on the rig.

Alexander Gavrilov noreply at git.blender.org
Mon Jan 18 11:27:18 CET 2021


Commit: 25c81824e45b28910cf93a9997e6629dc162f4e7
Author: Alexander Gavrilov
Date:   Sun Jan 17 00:12:58 2021 +0300
Branches: blender-v2.92-release master
https://developer.blender.org/rBA25c81824e45b28910cf93a9997e6629dc162f4e7

Rigify: fix the ORG bone rename affecting objects dependent on the rig.

The issue is that if a different object has a constraint or driver
targeting a control of the rig, renaming the bone after join when
re-generating the rig would change that target to the ORG bone.

To fix this, apply the renames to the temporary copy of the metarig
before joining it to the rig armature object. This also requires
moving the driver freeze to this stage.

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

M	rigify/generate.py

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

diff --git a/rigify/generate.py b/rigify/generate.py
index 613ef59f..62f84682 100644
--- a/rigify/generate.py
+++ b/rigify/generate.py
@@ -172,6 +172,14 @@ class Generator(base_generate.BaseGenerator):
 
         bpy.ops.object.duplicate()
 
+        # Rename org bones in the temporary object
+        temp_obj = context.view_layer.objects.active
+
+        assert temp_obj and temp_obj != metarig
+
+        self.__freeze_driver_vars(temp_obj)
+        self.__rename_org_bones(temp_obj)
+
         # Select the target rig and join
         select_object(context, obj)
 
@@ -192,6 +200,9 @@ class Generator(base_generate.BaseGenerator):
             for track in obj.animation_data.nla_tracks:
                 obj.animation_data.nla_tracks.remove(track)
 
+
+    def __freeze_driver_vars(self, obj):
+        if obj.animation_data:
             # Freeze drivers referring to custom properties
             for d in obj.animation_data.drivers:
                 for var in d.driver.variables:
@@ -202,9 +213,7 @@ class Generator(base_generate.BaseGenerator):
                             tar.data_path = "RIGIFY-" + tar.data_path
 
 
-    def __rename_org_bones(self):
-        obj = self.obj
-
+    def __rename_org_bones(self, obj):
         #----------------------------------
         # Make a list of the original bones so we can keep track of them.
         original_bones = [bone.name for bone in obj.data.bones]
@@ -382,21 +391,13 @@ class Generator(base_generate.BaseGenerator):
             childs[child] = child.parent_bone
 
         #------------------------------------------
-        # Copy bones from metarig to obj
+        # Copy bones from metarig to obj (adds ORG_PREFIX)
         self.__duplicate_rig()
 
         obj.data.use_mirror_x = False
 
         t.tick("Duplicate rig: ")
 
-        #------------------------------------------
-        # Add the ORG_PREFIX to the original bones.
-        bpy.ops.object.mode_set(mode='OBJECT')
-
-        self.__rename_org_bones()
-
-        t.tick("Make list of org bones: ")
-
         #------------------------------------------
         # Put the rig_name in the armature custom properties
         rna_idprop_ui_prop_get(obj.data, "rig_id", create=True)



More information about the Bf-extensions-cvs mailing list