[Bf-extensions-cvs] [d43b2ca4] master: Rigify: only show the Rigify Animation Tools panel for old rigs.

Alexander Gavrilov noreply at git.blender.org
Sat Sep 14 08:34:18 CEST 2019


Commit: d43b2ca4a9f31a9a3f988473a65de2095c9cfcc8
Author: Alexander Gavrilov
Date:   Sat Sep 14 09:19:39 2019 +0300
Branches: master
https://developer.blender.org/rBAd43b2ca4a9f31a9a3f988473a65de2095c9cfcc8

Rigify: only show the Rigify Animation Tools panel for old rigs.

New rigs provide the same buttons in their generated script UI,
and aren't compatible with the old panel code. To distinguish
rigs, remove old snap operators from the script.

Differential Revision: https://developer.blender.org/D4624

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

M	rigify/rig_ui_template.py
M	rigify/ui.py

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

diff --git a/rigify/rig_ui_template.py b/rigify/rig_ui_template.py
index 8c66b8b3..d7c2e870 100644
--- a/rigify/rig_ui_template.py
+++ b/rigify/rig_ui_template.py
@@ -299,7 +299,7 @@ def parse_bone_names(names_string):
 
 ''']
 
-UTILITIES_FUNC_ARM_FKIK = ['''
+UTILITIES_FUNC_OLD_ARM_FKIK = ['''
 ######################
 ## IK Arm functions ##
 ######################
@@ -416,7 +416,7 @@ def ik2fk_arm(obj, fk, ik):
     correct_scale(view_layer, uarmi, uarm.matrix)
 ''']
 
-UTILITIES_FUNC_LEG_FKIK = ['''
+UTILITIES_FUNC_OLD_LEG_FKIK = ['''
 ######################
 ## IK Leg functions ##
 ######################
@@ -558,7 +558,7 @@ def ik2fk_leg(obj, fk, ik):
     correct_scale(view_layer, thighi, thigh.matrix)
 ''']
 
-UTILITIES_FUNC_POLE = ['''
+UTILITIES_FUNC_OLD_POLE = ['''
 ################################
 ## IK Rotation-Pole functions ##
 ################################
@@ -623,9 +623,9 @@ def rotPoleToggle(rig, limb_type, controls, ik_ctrl, fk_ctrl, parent, pole):
             bpy.ops.pose.select_all(action='DESELECT')
 ''']
 
-REGISTER_OP_ARM_FKIK = ['Rigify_Arm_FK2IK', 'Rigify_Arm_IK2FK']
+REGISTER_OP_OLD_ARM_FKIK = ['Rigify_Arm_FK2IK', 'Rigify_Arm_IK2FK']
 
-UTILITIES_OP_ARM_FKIK = ['''
+UTILITIES_OP_OLD_ARM_FKIK = ['''
 ##################################
 ## IK/FK Arm snapping operators ##
 ##################################
@@ -681,9 +681,9 @@ class Rigify_Arm_IK2FK(bpy.types.Operator):
         return {'FINISHED'}
 ''']
 
-REGISTER_OP_LEG_FKIK = ['Rigify_Leg_FK2IK', 'Rigify_Leg_IK2FK']
+REGISTER_OP_OLD_LEG_FKIK = ['Rigify_Leg_FK2IK', 'Rigify_Leg_IK2FK']
 
-UTILITIES_OP_LEG_FKIK = ['''
+UTILITIES_OP_OLD_LEG_FKIK = ['''
 ##################################
 ## IK/FK Leg snapping operators ##
 ##################################
@@ -743,9 +743,9 @@ class Rigify_Leg_IK2FK(bpy.types.Operator):
         return {'FINISHED'}
 ''']
 
-REGISTER_OP_POLE = ['Rigify_Rot2PoleSwitch']
+REGISTER_OP_OLD_POLE = ['Rigify_Rot2PoleSwitch']
 
-UTILITIES_OP_POLE = ['''
+UTILITIES_OP_OLD_POLE = ['''
 ###########################
 ## IK Rotation Pole Snap ##
 ###########################
@@ -774,24 +774,24 @@ class Rigify_Rot2PoleSwitch(bpy.types.Operator):
         return {'FINISHED'}
 ''']
 
-REGISTER_RIG_ARM = REGISTER_OP_ARM_FKIK + REGISTER_OP_POLE
+REGISTER_RIG_OLD_ARM = REGISTER_OP_OLD_ARM_FKIK + REGISTER_OP_OLD_POLE
 
-UTILITIES_RIG_ARM = [
+UTILITIES_RIG_OLD_ARM = [
     *UTILITIES_FUNC_COMMON_IKFK,
-    *UTILITIES_FUNC_ARM_FKIK,
-    *UTILITIES_FUNC_POLE,
-    *UTILITIES_OP_ARM_FKIK,
-    *UTILITIES_OP_POLE,
+    *UTILITIES_FUNC_OLD_ARM_FKIK,
+    *UTILITIES_FUNC_OLD_POLE,
+    *UTILITIES_OP_OLD_ARM_FKIK,
+    *UTILITIES_OP_OLD_POLE,
 ]
 
-REGISTER_RIG_LEG = REGISTER_OP_LEG_FKIK + REGISTER_OP_POLE
+REGISTER_RIG_OLD_LEG = REGISTER_OP_OLD_LEG_FKIK + REGISTER_OP_OLD_POLE
 
-UTILITIES_RIG_LEG = [
+UTILITIES_RIG_OLD_LEG = [
     *UTILITIES_FUNC_COMMON_IKFK,
-    *UTILITIES_FUNC_LEG_FKIK,
-    *UTILITIES_FUNC_POLE,
-    *UTILITIES_OP_LEG_FKIK,
-    *UTILITIES_OP_POLE,
+    *UTILITIES_FUNC_OLD_LEG_FKIK,
+    *UTILITIES_FUNC_OLD_POLE,
+    *UTILITIES_OP_OLD_LEG_FKIK,
+    *UTILITIES_OP_OLD_POLE,
 ]
 
 ##############################
@@ -801,18 +801,9 @@ UTILITIES_RIG_LEG = [
 UI_REGISTER = [
     'RigUI',
     'RigLayers',
-    *REGISTER_OP_ARM_FKIK,
-    *REGISTER_OP_LEG_FKIK,
 ]
 
-# Include arm and leg utilities for now in case somebody wants to use
-# legacy limb rigs, which expect these to be available by default.
 UI_UTILITIES = [
-    *UTILITIES_FUNC_COMMON_IKFK,
-    *UTILITIES_FUNC_ARM_FKIK,
-    *UTILITIES_FUNC_LEG_FKIK,
-    *UTILITIES_OP_ARM_FKIK,
-    *UTILITIES_OP_LEG_FKIK,
 ]
 
 UI_SLIDERS = '''
diff --git a/rigify/ui.py b/rigify/ui.py
index c0b827b1..2f858925 100644
--- a/rigify/ui.py
+++ b/rigify/ui.py
@@ -670,8 +670,15 @@ class VIEW3D_PT_rigify_animation_tools(bpy.types.Panel):
 
     @classmethod
     def poll(cls, context):
-        return context.object and context.object.type == 'ARMATURE'\
-               and context.active_object.data.get("rig_id") is not None
+        obj = context.active_object
+        if obj and obj.type == 'ARMATURE':
+            rig_id = obj.data.get("rig_id")
+            if rig_id is not None:
+                has_arm = hasattr(bpy.types, 'POSE_OT_rigify_arm_ik2fk_' + rig_id)
+                has_leg = hasattr(bpy.types, 'POSE_OT_rigify_leg_ik2fk_' + rig_id)
+                return has_arm or has_leg
+
+        return False
 
     def draw(self, context):
         obj = context.active_object



More information about the Bf-extensions-cvs mailing list