diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-03-30 22:00:55 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-09-14 09:29:26 +0300 |
commit | 3423174b37a0784dc12035ff3f2fb536835099e1 (patch) | |
tree | 3a54580902cdebdef5ebacd6099e86cc79ba75b3 /rigify/__init__.py | |
parent | 12af8a28c14b608e9b9b08568d981273c86590c1 (diff) |
Rigify: redesign generate.py and introduce a base rig class.
The main goals are to provide an official way for rigs to
interact in a structured way, and to remove mode switching
within rigs.
This involves introducing a base class for rigs that holds
rig-to-rig and rig-to-bone references, converting the main
generator into a class and passing it to rigs, and splitting
the single generate method into multiple passes.
For backward compatibility, old rigs are automatically handled
via a wrapper that translates between old and new API.
In addition, a way to create objects that receive the generate
callbacks that aren't rigs is introduced via the GeneratorPlugin
class. The UI script generation code is converted into a plugin.
Making generic rig 'template' classes that are intended to be
subclassed in specific rigs involves splitting operations done
in each stage into multiple methods that can be overridden
separately. The main callback thus ends up simply calling a
sequence of other methods.
To make such code cleaner it's better to allow registering
those methods as new callbacks that would be automatically
called by the system. This can be done via decorators.
A new metaclass used for all rig and generate plugin classes
builds and validates a table of all decorated methods, and
allows calling them all together with the main callback.
A new way to switch parents for IK bones based on the new
features is introduced, and used in the existing limb rigs.
Reviewers: icappiello campbellbarton
Differential Revision: https://developer.blender.org/D4624
Diffstat (limited to 'rigify/__init__.py')
-rw-r--r-- | rigify/__init__.py | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/rigify/__init__.py b/rigify/__init__.py index 000100f4..0ca663a8 100644 --- a/rigify/__init__.py +++ b/rigify/__init__.py @@ -20,9 +20,9 @@ bl_info = { "name": "Rigify", - "version": (0, 5, 1), - "author": "Nathan Vegdahl, Lucio Rossi, Ivan Cappiello", - "blender": (2, 80, 0), + "version": (0, 6, 0), + "author": "Nathan Vegdahl, Lucio Rossi, Ivan Cappiello, Alexander Gavrilov", + "blender": (2, 81, 0), "description": "Automatic rigging from building-block components", "location": "Armature properties, Bone properties, View3d tools panel, Armature Add menu", "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/" @@ -32,14 +32,17 @@ bl_info = { if "bpy" in locals(): import importlib - importlib.reload(generate) - importlib.reload(ui) + # Don't reload base_rig or base_generate, because it would break issubclass checks, + # unless _all_ modules with classes inheriting from BaseRig are also reloaded. importlib.reload(utils) + importlib.reload(rig_ui_template) importlib.reload(feature_set_list) - importlib.reload(metarig_menu) importlib.reload(rig_lists) + importlib.reload(generate) + importlib.reload(ui) + importlib.reload(metarig_menu) else: - from . import (utils, feature_set_list, rig_lists, generate, ui, metarig_menu) + from . import (utils, base_rig, base_generate, rig_ui_template, feature_set_list, rig_lists, generate, ui, metarig_menu) import bpy import sys @@ -459,12 +462,6 @@ def register(): IDStore.rigify_transfer_only_selected = BoolProperty( name="Transfer Only Selected", description="Transfer selected bones only", default=True) - IDStore.rigify_transfer_start_frame = IntProperty( - name="Start Frame", - description="First Frame to Transfer", default=0, min= 0) - IDStore.rigify_transfer_end_frame = IntProperty( - name="End Frame", - description="Last Frame to Transfer", default=0, min= 0) # Update legacy on restart or reload. if (ui and 'legacy' in str(ui)) or bpy.context.preferences.addons['rigify'].preferences.legacy_mode: @@ -486,11 +483,14 @@ def register_rig_parameters(): pass else: for rig in rig_lists.rigs: - r = rig_lists.rigs[rig]['module'] + 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: r.add_parameters(RigifyParameterValidator(RigifyParameters, rig, RIGIFY_PARAMETER_TABLE)) - except AttributeError: - pass + except Exception: + import traceback + traceback.print_exc() def unregister(): @@ -522,8 +522,6 @@ def unregister(): del IDStore.rigify_rig_ui del IDStore.rigify_rig_basename del IDStore.rigify_transfer_only_selected - del IDStore.rigify_transfer_start_frame - del IDStore.rigify_transfer_end_frame # Classes. for cls in classes: |