Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2020-12-01 21:28:26 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2020-12-01 21:28:45 +0300
commit008bcf44ef35726f4c1373e46b4dd6e3a5a069e2 (patch)
treebe7522f0d1bd7ea23a6d71c781ae9b3c8995c2cb /rigify/base_generate.py
parent287f8443007100b2b27097c5fa5bf37e810801d7 (diff)
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.
Diffstat (limited to 'rigify/base_generate.py')
-rw-r--r--rigify/base_generate.py27
1 files changed, 25 insertions, 2 deletions
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')