[Bf-extensions-cvs] [d3e81ceb] master: Rigify: fix the use_global_undo change and fix driver creation for 2.8.

Alexander Gavrilov noreply at git.blender.org
Wed May 22 19:37:18 CEST 2019


Commit: d3e81ceb35f25752632698126128cdee6e07795e
Author: Alexander Gavrilov
Date:   Wed May 22 19:29:35 2019 +0300
Branches: master
https://developer.blender.org/rBAd3e81ceb35f25752632698126128cdee6e07795e

Rigify: fix the use_global_undo change and fix driver creation for 2.8.

Using obj.animation_data.drivers[-1] in driver creation is very
bad and error prone. After recent change in Blender, that won't
even work for drivers on Bone, so fix all such uses.

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

M	rigify/legacy/generate.py
M	rigify/legacy/rig_ui_pitchipoy_template.py
M	rigify/legacy/rig_ui_template.py
M	rigify/legacy/rigs/pitchipoy/limbs/arm.py
M	rigify/legacy/rigs/pitchipoy/limbs/leg.py
M	rigify/legacy/rigs/pitchipoy/limbs/paw.py
M	rigify/legacy/rigs/pitchipoy/super_torso_turbo.py
M	rigify/rigs/experimental/super_chain.py
M	rigify/rigs/limbs/arm.py
M	rigify/rigs/limbs/leg.py
M	rigify/rigs/limbs/paw.py
M	rigify/rigs/spines/super_spine.py
M	rigify/ui.py

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

diff --git a/rigify/legacy/generate.py b/rigify/legacy/generate.py
index 476cdbe8..33696cf0 100644
--- a/rigify/legacy/generate.py
+++ b/rigify/legacy/generate.py
@@ -99,6 +99,7 @@ def generate_rig(context, metarig):
     # Get rid of anim data in case the rig already existed
     print("Clear rig animation data.")
     obj.animation_data_clear()
+    obj.data.animation_data_clear()
 
     # Select generated rig object
     metarig.select_set(False)
diff --git a/rigify/legacy/rig_ui_pitchipoy_template.py b/rigify/legacy/rig_ui_pitchipoy_template.py
index 2b4ef36c..3fc50767 100644
--- a/rigify/legacy/rig_ui_pitchipoy_template.py
+++ b/rigify/legacy/rig_ui_pitchipoy_template.py
@@ -632,8 +632,8 @@ class RigUI(bpy.types.Panel):
     bl_space_type = 'VIEW_3D'
     bl_region_type = 'UI'
     bl_label = "Rig Main Properties"
-    bl_idname = rig_id + "_PT_rig_ui"
-    bl_category = 'View'
+    bl_idname = "VIEW3D_PT_rig_ui_" + rig_id
+    bl_category = 'Item'
 
     @classmethod
     def poll(self, context):
@@ -676,8 +676,8 @@ class RigLayers(bpy.types.Panel):
     bl_space_type = 'VIEW_3D'
     bl_region_type = 'UI'
     bl_label = "Rig Layers"
-    bl_idname = rig_id + "_PT_rig_layers"
-    bl_category = 'View'
+    bl_idname = "VIEW3D_PT_rig_layers_" + rig_id
+    bl_category = 'Item'
 
     @classmethod
     def poll(self, context):
diff --git a/rigify/legacy/rig_ui_template.py b/rigify/legacy/rig_ui_template.py
index 6cdd1c63..db6ab4a1 100644
--- a/rigify/legacy/rig_ui_template.py
+++ b/rigify/legacy/rig_ui_template.py
@@ -479,8 +479,8 @@ class RigUI(bpy.types.Panel):
     bl_space_type = 'VIEW_3D'
     bl_region_type = 'UI'
     bl_label = "Rig Main Properties"
-    bl_idname = rig_id + "_PT_rig_ui"
-    bl_category = 'View'
+    bl_idname = "VIEW3D_PT_rig_ui_" + rig_id
+    bl_category = 'Item'
 
     @classmethod
     def poll(self, context):
@@ -523,8 +523,8 @@ class RigLayers(bpy.types.Panel):
     bl_space_type = 'VIEW_3D'
     bl_region_type = 'UI'
     bl_label = "Rig Layers"
-    bl_idname = rig_id + "_PT_rig_layers"
-    bl_category = 'View'
+    bl_idname = "VIEW3D_PT_rig_layers_" + rig_id
+    bl_category = 'Item'
 
     @classmethod
     def poll(self, context):
diff --git a/rigify/legacy/rigs/pitchipoy/limbs/arm.py b/rigify/legacy/rigs/pitchipoy/limbs/arm.py
index 9de1657a..2bf0fe6f 100644
--- a/rigify/legacy/rigs/pitchipoy/limbs/arm.py
+++ b/rigify/legacy/rigs/pitchipoy/limbs/arm.py
@@ -86,7 +86,8 @@ def create_arm( cls, bones ):
 
     # Add driver to limit scale constraint influence
     b        = bones['ik']['mch_str']
-    drv      = pb[b].constraints[-1].driver_add("influence").driver
+    drv_fcu  = pb[b].constraints[-1].driver_add("influence")
+    drv      = drv_fcu.driver
     drv.type = 'SUM'
 
     var = drv.variables.new()
@@ -96,7 +97,7 @@ def create_arm( cls, bones ):
     var.targets[0].data_path = \
         pb_parent.path_from_id() + '['+ '"' + prop.name + '"' + ']'
 
-    drv_modifier = cls.obj.animation_data.drivers[-1].modifiers[0]
+    drv_modifier = drv_fcu.modifiers[0]
 
     drv_modifier.mode            = 'POLYNOMIAL'
     drv_modifier.poly_order      = 1
diff --git a/rigify/legacy/rigs/pitchipoy/limbs/leg.py b/rigify/legacy/rigs/pitchipoy/limbs/leg.py
index 96aa1c02..360a2a49 100644
--- a/rigify/legacy/rigs/pitchipoy/limbs/leg.py
+++ b/rigify/legacy/rigs/pitchipoy/limbs/leg.py
@@ -242,7 +242,8 @@ def create_leg( cls, bones ):
 
     # Add driver to limit scale constraint influence
     b        = bones['ik']['mch_str']
-    drv      = pb[b].constraints[-1].driver_add("influence").driver
+    drv_fcu  = pb[b].constraints[-1].driver_add("influence")
+    drv      = drv_fcu.driver
     drv.type = 'AVERAGE'
 
     var = drv.variables.new()
@@ -252,7 +253,7 @@ def create_leg( cls, bones ):
     var.targets[0].data_path = \
         pb_parent.path_from_id() + '['+ '"' + prop.name + '"' + ']'
 
-    drv_modifier = cls.obj.animation_data.drivers[-1].modifiers[0]
+    drv_modifier = drv_fcu.modifiers[0]
 
     drv_modifier.mode            = 'POLYNOMIAL'
     drv_modifier.poly_order      = 1
@@ -302,7 +303,8 @@ def create_leg( cls, bones ):
 
         # Add driver to limit scale constraint influence
         b        = org_bones[3]
-        drv      = pb[b].constraints[-1].driver_add("influence").driver
+        drv_fcu  = pb[b].constraints[-1].driver_add("influence")
+        drv      = drv_fcu.driver
         drv.type = 'AVERAGE'
 
         var = drv.variables.new()
@@ -312,7 +314,7 @@ def create_leg( cls, bones ):
         var.targets[0].data_path = \
             pb_parent.path_from_id() + '['+ '"' + prop.name + '"' + ']'
 
-        drv_modifier = cls.obj.animation_data.drivers[-1].modifiers[0]
+        drv_modifier = drv_fcu.modifiers[0]
 
         drv_modifier.mode            = 'POLYNOMIAL'
         drv_modifier.poly_order      = 1
diff --git a/rigify/legacy/rigs/pitchipoy/limbs/paw.py b/rigify/legacy/rigs/pitchipoy/limbs/paw.py
index 7691007a..dd9fa1e7 100644
--- a/rigify/legacy/rigs/pitchipoy/limbs/paw.py
+++ b/rigify/legacy/rigs/pitchipoy/limbs/paw.py
@@ -111,7 +111,8 @@ def create_paw( cls, bones ):
 
     # Add driver to limit scale constraint influence
     b        = bones['ik']['mch_str']
-    drv      = pb[b].constraints[-1].driver_add("influence").driver
+    drv_fcu  = pb[b].constraints[-1].driver_add("influence")
+    drv      = drv_fcu.driver
     drv.type = 'AVERAGE'
 
     var = drv.variables.new()
@@ -121,7 +122,7 @@ def create_paw( cls, bones ):
     var.targets[0].data_path = \
         pb_parent.path_from_id() + '['+ '"' + prop.name + '"' + ']'
 
-    drv_modifier = cls.obj.animation_data.drivers[-1].modifiers[0]
+    drv_modifier = drv_fcu.modifiers[0]
 
     drv_modifier.mode            = 'POLYNOMIAL'
     drv_modifier.poly_order      = 1
@@ -183,7 +184,8 @@ def create_paw( cls, bones ):
 
         # Add driver to limit scale constraint influence
         b        = org_bones[3]
-        drv      = pb[b].constraints[-1].driver_add("influence").driver
+        drv_fcu  = pb[b].constraints[-1].driver_add("influence")
+        drv      = drv_fcu.driver
         drv.type = 'AVERAGE'
 
         var = drv.variables.new()
@@ -193,7 +195,7 @@ def create_paw( cls, bones ):
         var.targets[0].data_path = \
             pb_parent.path_from_id() + '['+ '"' + prop.name + '"' + ']'
 
-        drv_modifier = cls.obj.animation_data.drivers[-1].modifiers[0]
+        drv_modifier = drv_fcu.modifiers[0]
 
         drv_modifier.mode            = 'POLYNOMIAL'
         drv_modifier.poly_order      = 1
diff --git a/rigify/legacy/rigs/pitchipoy/super_torso_turbo.py b/rigify/legacy/rigs/pitchipoy/super_torso_turbo.py
index 706b82cf..05c2b4c6 100644
--- a/rigify/legacy/rigs/pitchipoy/super_torso_turbo.py
+++ b/rigify/legacy/rigs/pitchipoy/super_torso_turbo.py
@@ -528,7 +528,8 @@ class Rig:
         # driving the follow rotation switches for neck and head
         for bone, prop, in zip( owners, props ):
             # Add driver to copy rotation constraint
-            drv = pb[ bone ].constraints[ 0 ].driver_add("influence").driver
+            drv_fcu = pb[ bone ].constraints[ 0 ].driver_add("influence")
+            drv = drv_fcu.driver
             drv.type = 'AVERAGE'
 
             var = drv.variables.new()
@@ -538,7 +539,7 @@ class Rig:
             var.targets[0].data_path = \
                 torso.path_from_id() + '['+ '"' + prop + '"' + ']'
 
-            drv_modifier = self.obj.animation_data.drivers[-1].modifiers[0]
+            drv_modifier = drv_fcu.modifiers[0]
 
             drv_modifier.mode            = 'POLYNOMIAL'
             drv_modifier.poly_order      = 1
diff --git a/rigify/rigs/experimental/super_chain.py b/rigify/rigs/experimental/super_chain.py
index 2a3a85f6..f3d0e182 100644
--- a/rigify/rigs/experimental/super_chain.py
+++ b/rigify/rigs/experimental/super_chain.py
@@ -5,7 +5,7 @@ from ...utils import strip_org, make_deformer_name, connected_children_names
 from ...utils import create_chain_widget
 from ...utils import make_mechanism_name, create_cube_widget
 from ...utils import ControlLayersOption
-from ...utils.mechanism import make_property
+from ...utils.mechanism import make_property, make_driver
 from ..limbs.limb_utils import get_bone_name
 
 
@@ -473,22 +473,7 @@ class Rig:
         # driving the follow rotation switches for neck and head
         for bone, prop, in zip(owners, props):
             # Add driver to copy rotation constraint
-            drv = pb[bone].constraints[0].driver_add("influence").driver
-            drv.type = 'AVERAGE'
-
-            var = drv.variables.new()
-            var.name = prop
-            var.type = "SINGLE_PROP"
-            var.targets[0].id = self.obj
-            var.targets[0].data_path = \
-                torso.path_from_id() + '[' + '"' + prop + '"' + ']'
-
-            drv_modifier = self.obj.animation_data.drivers[-1].modifiers[0]
-
-            drv_modifier.mode = 'POLYNOMIAL'
-            drv_modifier.poly_order = 1
-            drv_modifier.coefficients[0] = 1.0
-            drv_modifier.coefficients[1] = -1.0
+            make_driver(pb[bone].constraints[0], "influence", variables=[(self.obj, torso, prop)], polynomial=[1.0, -1.0])
 
     def locks_and_widgets(self, bones):
         bpy.ops.object.mode_set(mode='OBJECT')
diff --git a/rigify/rigs/limbs/arm.py b/rigify/rigs/limbs/arm.py
index 1fe97638..3b2f3658 100644
--- a/rigify/rigs/limbs/arm.py
+++ b/rigify/rigs/limbs/arm.py
@@ -11,7 +11,7 @@ from ...utils       import create_limb_widget, connected_children_names
 from ...utils       import align_bone_x_axis, align_bone_z_axis
 from ...rig_ui_template import UTILITIES_RIG_ARM, REGISTER_RIG_ARM
 from ...utils       import ControlLayersOption
-from ...utils.mechanism import make_property
+from ...utils.mechanism import make_property, make_driver
 from ..widgets import create_ikarrow_widget
 from math import trunc, pi
 
@@ -123,15 +123,7 @@ class Rig:
         # prop = rna_idprop_ui_prop_get( pb[ mch ], name, create = True )
         make_property(pb[main_parent], name, 0.0)
 
-        drv = pb[mch].constraints[0].driver_add("influence").driver
-
-        drv.type = 'AVERAGE'
-        var = drv.variables.new()
-        v

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list