Page MenuHome

T63138: redesign generate.py and introduce a base rig class.
ClosedPublic

Authored by Alexander Gavrilov (angavrilov) on Mar 30 2019, 8:03 PM.

Details

Summary

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.

Four simplest rig types demonstrate the use of all callbacks,
bone creation and parenting utilities, constraint & driver
creation tools, and python script generation.

Diff Detail

Event Timeline

Github branch: https://github.com/angavrilov/rigify/tree/generate-rewrite-2.8

Spine rig split into middle and head that interact to merge the B-Bone chain, as a feature set zip file:

i'd like to have an opinion on this from @Campbell Barton (campbellbarton) and @Nathan Vegdahl (cessen). They are the authors the original rigify framework.

For the record, this was tested by @Damien Picard (pioverfour) for obvious breakage and the small issues that came up fixed before the last update of the diff.

This is quite a big patch, if you commit something like this, you become the defacto maintainer :)

Are there any parts of this patch in-particular which you are unsure of and want reviewed?

Replied on some small issues inline.

rigify/base_generate.py
108

Any reason not to use __slots__, it's partly personal preference however I've found it can help avoid bugs (typos in attribute assignments), and generally worth using unless attributes are dynamically generated for example.

185

No need to subclass object (was only for Python2 compatibility).

rigify/rig_ui_template.py
1239

No need for trailing ;

rigify/rigs/limbs/arm.py
837

While this isn't new code the [:] is redundant here.

This revision is now accepted and ready to land.Sep 13 2019, 9:01 PM