diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2022-11-13 00:54:17 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2022-11-13 16:23:29 +0300 |
commit | 01e8af3348fac2babe3b5218dbe4ecdaa0e1eace (patch) | |
tree | 3a6239133282569da143ce22bda34f14f98af473 /rigify/rigs/spines/basic_tail.py | |
parent | 68419fb3659f09e8447d351a25b1bd8e56211a5a (diff) |
Introduce a method to annotate types and names of entries in the
`bones` container of rig components and apply it, and other type
annotations, to a number of not very complex rig classes.
- Introduce BaseRigMixin as a typed base class for mixins intended
for use in rig classes (using BaseRig as a parent causes issues).
- Introduce TypedBoneDict that does not suppress the unknown attribute
analysis in PyCharm, and use it in a system of subclasses to
annotate the bones in various rigs. BaseBoneDict is necessary
because the annotation affects all subclasses, so TypedBoneDict
cannot inherit from BoneDict with the annotation.
- Add or adjust other type annotations of rig methods and utilities.
- Fix other warnings, e.g. undeclared attributes, excessively long
lines, whitespace style issues and typos.
Diffstat (limited to 'rigify/rigs/spines/basic_tail.py')
-rw-r--r-- | rigify/rigs/spines/basic_tail.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/rigify/rigs/spines/basic_tail.py b/rigify/rigs/spines/basic_tail.py index 72c5ad8b..dbbdd9f3 100644 --- a/rigify/rigs/spines/basic_tail.py +++ b/rigify/rigs/spines/basic_tail.py @@ -17,6 +17,8 @@ from .spine_rigs import BaseHeadTailRig class Rig(BaseHeadTailRig): + copy_rotation_axes: tuple[bool, bool, bool] + def initialize(self): super().initialize() @@ -66,7 +68,7 @@ class Rig(BaseHeadTailRig): for args in zip(count(0), ctrls, [self.bones.ctrl.master] + ctrls): self.rig_control_bone(*args) - def rig_control_bone(self, i, ctrl, prev_ctrl): + def rig_control_bone(self, _i: int, ctrl: str, prev_ctrl: str): self.make_constraint( ctrl, 'COPY_ROTATION', prev_ctrl, use_xyz=self.copy_rotation_axes, @@ -74,7 +76,7 @@ class Rig(BaseHeadTailRig): ) # Widgets - def make_control_widget(self, i, ctrl): + def make_control_widget(self, i: int, ctrl: str): create_circle_widget(self.obj, ctrl, radius=0.5, head_tail=0.75) #################################################### @@ -96,7 +98,7 @@ class Rig(BaseHeadTailRig): orgs = self.bones.org self.bones.ctrl.tweak = map_list(self.make_tweak_bone, count(0), orgs[0:1] + orgs) - def make_tweak_bone(self, i, org): + def make_tweak_bone(self, i: int, org: str): if i == 0: if self.check_connect_tweak(org): return self.connected_tweak @@ -113,6 +115,7 @@ class Rig(BaseHeadTailRig): #################################################### # Deform chain + # noinspection SpellCheckingInspection @stage.configure_bones def configure_deform_chain(self): if self.use_connect_chain and self.use_connect_reverse: @@ -121,12 +124,11 @@ class Rig(BaseHeadTailRig): else: self.get_bone(self.bones.deform[-1]).bone.bbone_easeout = 0.0 - #################################################### # SETTINGS @classmethod - def add_parameters(self, params): + def add_parameters(cls, params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ @@ -139,9 +141,8 @@ class Rig(BaseHeadTailRig): default=tuple([i == 0 for i in range(0, 3)]) ) - @classmethod - def parameters_ui(self, layout, params): + def parameters_ui(cls, layout, params): """ Create the ui for the rig parameters. """ @@ -195,7 +196,10 @@ def create_sample(obj, *, parent=None): except AttributeError: pass try: - pbone.rigify_parameters.tweak_layers = [False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] + pbone.rigify_parameters.tweak_layers = [ + False, False, False, False, True, False, False, False, False, False, False, False, + False, False, False, False, False, False, False, False, False, False, False, False, + False, False, False, False, False, False, False, False] except AttributeError: pass pbone = obj.pose.bones[bones['tail.001']] |