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/basic/super_copy.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/basic/super_copy.py')
-rw-r--r-- | rigify/rigs/basic/super_copy.py | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/rigify/rigs/basic/super_copy.py b/rigify/rigs/basic/super_copy.py index fc4b4d33..450bda2c 100644 --- a/rigify/rigs/basic/super_copy.py +++ b/rigify/rigs/basic/super_copy.py @@ -15,21 +15,27 @@ class Rig(BaseRig, RelinkConstraintsMixin): """ A "copy" rig. All it does is duplicate the original bone and constrain it. This is a control and deformation rig. - """ - def find_org_bones(self, pose_bone): - return pose_bone.name + bones: BaseRig.ToplevelBones[str, str, str, str] + + org_name: str + + make_control: bool + make_widget: bool + make_deform: bool + + def find_org_bones(self, pose_bone) -> str: + return pose_bone.name def initialize(self): """ Gather and validate data about the rig. """ - self.org_name = strip_org(self.bones.org) + self.org_name = strip_org(self.bones.org) self.make_control = self.params.make_control - self.make_widget = self.params.make_widget - self.make_deform = self.params.make_deform - + self.make_widget = self.params.make_widget + self.make_deform = self.params.make_deform def generate_bones(self): bones = self.bones @@ -42,7 +48,6 @@ class Rig(BaseRig, RelinkConstraintsMixin): if self.make_deform: bones.deform = self.copy_bone(bones.org, make_deformer_name(self.org_name), bbone=True) - def parent_bones(self): bones = self.bones @@ -54,14 +59,12 @@ class Rig(BaseRig, RelinkConstraintsMixin): if self.make_control and new_parent: self.set_bone_parent(bones.ctrl, new_parent) - def configure_bones(self): bones = self.bones if self.make_control: self.copy_bone_properties(bones.org, bones.ctrl) - def rig_bones(self): bones = self.bones @@ -76,52 +79,50 @@ class Rig(BaseRig, RelinkConstraintsMixin): if self.make_deform: self.relink_move_constraints(bones.org, bones.deform, prefix='DEF:') - def generate_widgets(self): bones = self.bones if self.make_control: # Create control widget if self.make_widget: - create_registered_widget(self.obj, bones.ctrl, self.params.super_copy_widget_type or 'circle') + create_registered_widget(self.obj, bones.ctrl, + self.params.super_copy_widget_type or 'circle') else: create_bone_widget(self.obj, bones.ctrl) - @classmethod - def add_parameters(self, params): + def add_parameters(cls, params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ params.make_control = bpy.props.BoolProperty( - name = "Control", - default = True, - description = "Create a control bone for the copy" + name="Control", + default=True, + description="Create a control bone for the copy" ) params.make_widget = bpy.props.BoolProperty( - name = "Widget", - default = True, - description = "Choose a widget for the bone control" + name="Widget", + default=True, + description="Choose a widget for the bone control" ) params.super_copy_widget_type = bpy.props.StringProperty( - name = "Widget Type", - default = 'circle', - description = "Choose the type of the widget to create" + name="Widget Type", + default='circle', + description="Choose the type of the widget to create" ) params.make_deform = bpy.props.BoolProperty( - name = "Deform", - default = True, - description = "Create a deform bone for the copy" + name="Deform", + default=True, + description="Create a deform bone for the copy" ) - self.add_relink_constraints_params(params) - + cls.add_relink_constraints_params(params) @classmethod - def parameters_ui(self, layout, params): + def parameters_ui(cls, layout, params): """ Create the ui for the rig parameters. """ layout.prop(params, "make_control") @@ -136,7 +137,7 @@ class Rig(BaseRig, RelinkConstraintsMixin): layout.prop(params, "make_deform") - self.add_relink_constraints_ui(layout, params) + cls.add_relink_constraints_ui(layout, params) if params.relink_constraints and (params.make_control or params.make_deform): col = layout.column() |