[Bf-extensions-cvs] [7412d6c3] master: Rigify: Remove Legacy Mode

Demeter Dzadik noreply at git.blender.org
Wed Jun 23 16:43:41 CEST 2021


Commit: 7412d6c3e44bfda9df89e790fd0eb08cadc801b4
Author: Demeter Dzadik
Date:   Wed Jun 23 16:43:23 2021 +0200
Branches: master
https://developer.blender.org/rBA7412d6c3e44bfda9df89e790fd0eb08cadc801b4

Rigify: Remove Legacy Mode

This patch removes the Legacy Mode checkbox from the addon preferences and all associated code.

Ability to convert old legacy metarigs is not removed.
LegacyRig wrapper class is not removed.
Various legacy-only functions and imports were not removed, with the reasoning that they are still used by [this unmaintained feature set](https://github.com/cessen/cessen_rigify_ext).

Initially discussed in T88711, let's put any further discussion here, since that thread has many topics.

Reviewed By: angavrilov

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

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

M	rigify/__init__.py
M	rigify/base_rig.py
D	rigify/legacy/__init__.py
D	rigify/legacy/generate.py
D	rigify/legacy/metarig_menu.py
D	rigify/legacy/metarigs/__init__.py
D	rigify/legacy/metarigs/human.py
D	rigify/legacy/metarigs/pitchipoy_human.py
D	rigify/legacy/rig_lists.py
D	rigify/legacy/rig_ui_pitchipoy_template.py
D	rigify/legacy/rig_ui_template.py
D	rigify/legacy/rigs/__init__.py
D	rigify/legacy/rigs/basic/__init__.py
D	rigify/legacy/rigs/basic/copy.py
D	rigify/legacy/rigs/basic/copy_chain.py
D	rigify/legacy/rigs/biped/__init__.py
D	rigify/legacy/rigs/biped/arm/__init__.py
D	rigify/legacy/rigs/biped/arm/deform.py
D	rigify/legacy/rigs/biped/arm/fk.py
D	rigify/legacy/rigs/biped/arm/ik.py
D	rigify/legacy/rigs/biped/leg/__init__.py
D	rigify/legacy/rigs/biped/leg/deform.py
D	rigify/legacy/rigs/biped/leg/fk.py
D	rigify/legacy/rigs/biped/leg/ik.py
D	rigify/legacy/rigs/biped/limb_common.py
D	rigify/legacy/rigs/finger.py
D	rigify/legacy/rigs/misc/__init__.py
D	rigify/legacy/rigs/misc/delta.py
D	rigify/legacy/rigs/neck_short.py
D	rigify/legacy/rigs/palm.py
D	rigify/legacy/rigs/pitchipoy/__init__.py
D	rigify/legacy/rigs/pitchipoy/limbs/__init__.py
D	rigify/legacy/rigs/pitchipoy/limbs/arm.py
D	rigify/legacy/rigs/pitchipoy/limbs/leg.py
D	rigify/legacy/rigs/pitchipoy/limbs/limb_utils.py
D	rigify/legacy/rigs/pitchipoy/limbs/paw.py
D	rigify/legacy/rigs/pitchipoy/limbs/super_limb.py
D	rigify/legacy/rigs/pitchipoy/limbs/ui.py
D	rigify/legacy/rigs/pitchipoy/simple_tentacle.py
D	rigify/legacy/rigs/pitchipoy/super_copy.py
D	rigify/legacy/rigs/pitchipoy/super_face.py
D	rigify/legacy/rigs/pitchipoy/super_finger.py
D	rigify/legacy/rigs/pitchipoy/super_palm.py
D	rigify/legacy/rigs/pitchipoy/super_torso_turbo.py
D	rigify/legacy/rigs/pitchipoy/super_widgets.py
D	rigify/legacy/rigs/pitchipoy/tentacle.py
D	rigify/legacy/rigs/spine.py
D	rigify/legacy/ui.py
D	rigify/legacy/utils.py
M	rigify/ui.py

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

diff --git a/rigify/__init__.py b/rigify/__init__.py
index 4d208e4c..e91fca51 100644
--- a/rigify/__init__.py
+++ b/rigify/__init__.py
@@ -66,7 +66,6 @@ initial_load_order = [
     'rot_mode',
     'ui',
 ]
-utils_module_name = __name__ + '.utils'
 
 
 def get_loaded_modules():
@@ -84,7 +83,10 @@ def reload_modules():
         importlib.reload(sys.modules[name])
 
 def compare_module_list(a, b):
-    # Allow 'utils' to move around
+    # HACK: ignore the "utils" module when comparing module load orders,
+    # because it is inconsistent for reasons unknown.
+    # See rBAa918332cc3f821f5a70b1de53b65dd9ca596b093.
+    utils_module_name = __name__ + '.utils'
     a_copy = list(a)
     a_copy.remove(utils_module_name)
     b_copy = list(b)
@@ -106,16 +108,13 @@ def load_initial_modules():
     return load_list
 
 def load_rigs():
-    if not legacy_loaded:
-        rig_lists.get_internal_rigs()
-        metarig_menu.init_metarig_menu()
+    rig_lists.get_internal_rigs()
+    metarig_menu.init_metarig_menu()
 
 
 if "reload_list" in locals():
     reload_modules()
 else:
-    legacy_loaded = False
-
     load_list = load_initial_modules()
 
     from . import (base_rig, base_generate, rig_ui_template, feature_set_list, rig_lists, generate, ui, metarig_menu)
@@ -150,77 +149,13 @@ class RigifyPreferences(AddonPreferences):
     # when defining this in a submodule of a python package.
     bl_idname = __name__
 
-    def update_legacy(self, context):
-        global legacy_loaded, reload_list
-
-        if self.legacy_mode:
-            if legacy_loaded:    # already in legacy mode. needed when rigify is reloaded
-                return
-            else:
-                unregister()
-                reload_modules()
-
-                globals().pop('utils')
-                globals().pop('rig_lists')
-                globals().pop('generate')
-                globals().pop('ui')
-                globals().pop('metarig_menu')
-
-                from .legacy import utils, rig_lists, generate, ui, metarig_menu
-
-                print("ENTERING RIGIFY LEGACY\r\n")
-
-                legacy_loaded = True
-                reload_list += [ m.__name__ for m in [ legacy, utils, rig_lists, generate, ui, metarig_menu ] ]
-
-                globals()['utils'] = legacy.utils
-                globals()['rig_lists'] = legacy.rig_lists
-                globals()['generate'] = legacy.generate
-                globals()['ui'] = legacy.ui
-                globals()['metarig_menu'] = legacy.metarig_menu
-
-                register()
-
-        else:
-            unregister()
-
-            globals().pop('utils')
-            globals().pop('rig_lists')
-            globals().pop('generate')
-            globals().pop('ui')
-            globals().pop('metarig_menu')
-
-            from . import utils, rig_lists, generate, ui, metarig_menu
-
-            print("EXIT RIGIFY LEGACY\r\n")
-
-            globals()['utils'] = utils
-            globals()['rig_lists'] = rig_lists
-            globals()['generate'] = generate
-            globals()['ui'] = ui
-            globals()['metarig_menu'] = metarig_menu
-
-            legacy_loaded = False
-            reload_list = reload_list_init
-            reload_modules()
-
-            load_rigs()
-
-            register()
-
     def register_feature_sets(self, register):
         """Call register or unregister of external feature sets"""
-        if self.legacy_mode:
-            return
-
         for set_name in feature_set_list.get_installed_list():
             feature_set_list.call_register_function(set_name, register)
 
     def update_external_rigs(self, force=False):
         """Get external feature sets"""
-        if self.legacy_mode:
-            return
-
         set_list = feature_set_list.get_installed_list()
 
         # Update feature set list
@@ -243,25 +178,12 @@ class RigifyPreferences(AddonPreferences):
             # Re-register rig parameters
             register_rig_parameters()
 
-    legacy_mode: BoolProperty(
-        name='Legacy Mode',
-        description='When enabled the add-on will run in legacy mode using the old 2.76b feature set',
-        default=False,
-        update=update_legacy
-    )
-
     rigify_feature_sets: bpy.props.CollectionProperty(type=RigifyFeatureSets)
     active_feature_set_index: IntProperty()
 
     def draw(self, context):
         layout = self.layout
 
-        layout.prop(self, 'legacy_mode')
-
-        if self.legacy_mode:
-            return
-
-
         layout.label(text="Feature Sets:")
 
         layout.operator("wm.rigify_add_feature_set", text="Install Feature Set from File...", icon='FILEBROWSER')
@@ -618,42 +540,30 @@ def register():
         name="Transfer Only Selected",
         description="Transfer selected bones only", default=True)
 
-    # Update legacy on restart or reload.
-    if legacy_loaded or bpy.context.preferences.addons['rigify'].preferences.legacy_mode:
-        bpy.context.preferences.addons['rigify'].preferences.legacy_mode = True
-
-    bpy.context.preferences.addons['rigify'].preferences.register_feature_sets(True)
-    bpy.context.preferences.addons['rigify'].preferences.update_external_rigs()
+    bpy.context.preferences.addons[__package__].preferences.register_feature_sets(True)
+    bpy.context.preferences.addons[__package__].preferences.update_external_rigs()
 
     # Add rig parameters
     register_rig_parameters()
 
 
 def register_rig_parameters():
-    if bpy.context.preferences.addons['rigify'].preferences.legacy_mode:
-        for rig in rig_lists.rig_list:
-            r = utils.get_rig_type(rig)
-            try:
+    for rig in rig_lists.rigs:
+        rig_module = rig_lists.rigs[rig]['module']
+        rig_class = rig_module.Rig
+        r = rig_class if hasattr(rig_class, 'add_parameters') else rig_module
+        try:
+            if hasattr(r, 'add_parameters'):
                 r.add_parameters(RigifyParameterValidator(RigifyParameters, rig, RIGIFY_PARAMETER_TABLE))
-            except AttributeError:
-                pass
-    else:
-        for rig in rig_lists.rigs:
-            rig_module = rig_lists.rigs[rig]['module']
-            rig_class = rig_module.Rig
-            r = rig_class if hasattr(rig_class, 'add_parameters') else rig_module
-            try:
-                if hasattr(r, 'add_parameters'):
-                    r.add_parameters(RigifyParameterValidator(RigifyParameters, rig, RIGIFY_PARAMETER_TABLE))
-            except Exception:
-                import traceback
-                traceback.print_exc()
+        except Exception:
+            import traceback
+            traceback.print_exc()
 
 
 def unregister():
     from bpy.utils import unregister_class
 
-    bpy.context.preferences.addons['rigify'].preferences.register_feature_sets(False)
+    bpy.context.preferences.addons[__package__].preferences.register_feature_sets(False)
 
     # Properties on PoseBones and Armature.
     del bpy.types.PoseBone.rigify_type
diff --git a/rigify/base_rig.py b/rigify/base_rig.py
index c25e701d..0cc2bc1d 100644
--- a/rigify/base_rig.py
+++ b/rigify/base_rig.py
@@ -159,7 +159,7 @@ class BaseRig(GenerateCallbackHost, RaiseErrorMixin, BoneUtilityMixin, Mechanism
     """
     Base class for all rigs.
 
-    The main weak areas in the legacy Rigify rig class structure
+    The main weak areas in the legacy (pre-2.76b) Rigify rig class structure
     was that there were no provisions for intelligent interactions
     between rigs, and all processing was done via one generate
     method, necessitating frequent expensive mode switches.
diff --git a/rigify/legacy/__init__.py b/rigify/legacy/__init__.py
deleted file mode 100644
index 76c3a72f..00000000
--- a/rigify/legacy/__init__.py
+++ /dev/null
@@ -1,104 +0,0 @@
-#====================== BEGIN GPL LICENSE BLOCK ======================
-#
-#  This program is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU General Public License
-#  as published by the Free Software Foundation; either version 2
-#  of the License, or (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, write to the Free Software Foundation,
-#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-#======================= END GPL LICENSE BLOCK ========================
-
-# <pep8 compliant>
-
-bl_info = {
-    "name": "Rigify",
-    "version": (0, 4),
-    "author": "Nathan Vegdahl",
-    "blender": (2, 66, 0),
-    "description": "Automatic rigging from building-block components",
-    "location": "Armature properties, Bone properties, View3d tools panel, Armature Add menu",
-    "doc_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"
-               "Scripts/Rigging/Rigify",
-    "tracker_url": "http://github.com/cessen/rigify/issues",
-    "category": "Rigging",
-}
-
-
-if "bpy" in locals():
-    import importlib
-    importlib.reload(generate)
-    importlib.reload(ui)
-    importlib.reload(utils)
-    importlib.reload(metarig_menu)
-    importlib.reload(rig_lists)
-else:
-    from . import utils, rig_lists, generate, ui, metarig_menu
-
-import bpy
-
-
-class RigifyName(bpy.types.PropertyGroup):
-    name: bpy.props.StringProperty()
-
-
-class RigifyParameters(bpy.types.PropertyGroup):
-    name: bpy.props.StringProperty()
-
-
-class RigifyArmatureLayer(bpy.types.PropertyGroup):
-    name: bpy.props.StringProperty(name="Layer Name", default=" ")
-    row: bpy.props.IntProperty(name="Layer Row", default=1, min=1, max=32)
-
-
-##### REGISTER #####
-
-def register():
-    ui.register()
-    metarig_menu.register()
-
-    bpy.utils.register_class(RigifyName)
-    bpy.utils.register_class(RigifyParameters)
-    bpy.utils.register_class(RigifyArmatureLayer)
-
-    bpy.types.PoseBone.rigify_type = bpy.props.StringProperty(name="Rigify Type", description="Rig type for this bone")
-    bpy.types.Pos

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list