[Bf-extensions-cvs] [008bcf44] master: Rigify: internal API enhancements.
Alexander Gavrilov
noreply at git.blender.org
Tue Dec 1 19:52:36 CET 2020
Commit: 008bcf44ef35726f4c1373e46b4dd6e3a5a069e2
Author: Alexander Gavrilov
Date: Tue Dec 1 21:28:26 2020 +0300
Branches: master
https://developer.blender.org/rBA008bcf44ef35726f4c1373e46b4dd6e3a5a069e2
Rigify: internal API enhancements.
Add a LazyRigComponent class that has to be explicitly enabled
to start receiving callbacks.
Support calling GeneratorPlugin instance callbacks in the same
stage they were created.
===================================================================
M rigify/base_generate.py
M rigify/base_rig.py
===================================================================
diff --git a/rigify/base_generate.py b/rigify/base_generate.py
index ce04b8fc..da4949b2 100644
--- a/rigify/base_generate.py
+++ b/rigify/base_generate.py
@@ -31,6 +31,7 @@ from .utils.misc import clone_parameters, assign_parameters
from . import base_rig
+from itertools import count
#=============================================
# Generator Plugin
@@ -284,13 +285,24 @@ class BaseGenerator:
self.stage = method_name
- for rig in [*self.rig_list, *self.plugin_list]:
+ for rig in self.rig_list:
rig.rigify_invoke_stage(method_name)
assert(self.context.active_object == self.obj)
assert(self.obj.mode == 'OBJECT')
assert(num_bones == len(self.obj.data.bones))
+ # Allow plugins to be added to the end of the list on the fly
+ for i in count(0):
+ if i >= len(self.plugin_list):
+ break
+
+ self.plugin_list[i].rigify_invoke_stage(method_name)
+
+ assert(self.context.active_object == self.obj)
+ assert(self.obj.mode == 'OBJECT')
+ assert(num_bones == len(self.obj.data.bones))
+
def __run_edit_stage(self, method_name):
assert(self.context.active_object == self.obj)
@@ -299,13 +311,24 @@ class BaseGenerator:
self.stage = method_name
- for rig in [*self.rig_list, *self.plugin_list]:
+ for rig in self.rig_list:
rig.rigify_invoke_stage(method_name)
assert(self.context.active_object == self.obj)
assert(self.obj.mode == 'EDIT')
assert(num_bones == len(self.obj.data.edit_bones))
+ # Allow plugins to be added to the end of the list on the fly
+ for i in count(0):
+ if i >= len(self.plugin_list):
+ break
+
+ self.plugin_list[i].rigify_invoke_stage(method_name)
+
+ assert(self.context.active_object == self.obj)
+ assert(self.obj.mode == 'EDIT')
+ assert(num_bones == len(self.obj.data.edit_bones))
+
def invoke_initialize(self):
self.__run_object_stage('initialize')
diff --git a/rigify/base_rig.py b/rigify/base_rig.py
index d878143b..c25e701d 100644
--- a/rigify/base_rig.py
+++ b/rigify/base_rig.py
@@ -267,14 +267,25 @@ class RigUtility(BoneUtilityMixin, MechanismUtilityMixin):
self.owner.register_new_bone(new_name, old_name)
-class RigComponent(GenerateCallbackHost, RigUtility):
- """Base class for utility classes that generate part of a rig using callbacks."""
+class LazyRigComponent(GenerateCallbackHost, RigUtility):
+ """Base class for utility classes that generate part of a rig using callbacks. Starts as disabled."""
def __init__(self, owner):
super().__init__(owner)
- self.owner.rigify_sub_objects = objects = self.owner.rigify_sub_objects or []
+ self.is_component_enabled = False
+
+ def enable_component(self):
+ if not self.is_component_enabled:
+ self.is_component_enabled = True
+ self.owner.rigify_sub_objects = objects = self.owner.rigify_sub_objects or []
+ objects.append(self)
+
- objects.append(self)
+class RigComponent(LazyRigComponent):
+ """Base class for utility classes that generate part of a rig using callbacks."""
+ def __init__(self, owner):
+ super().__init__(owner)
+ self.enable_component()
#=============================================
More information about the Bf-extensions-cvs
mailing list