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:
Diffstat (limited to 'rigify/rigs/spines')
-rw-r--r--rigify/rigs/spines/basic_spine.py100
-rw-r--r--rigify/rigs/spines/basic_tail.py20
-rw-r--r--rigify/rigs/spines/spine_rigs.py94
-rw-r--r--rigify/rigs/spines/super_head.py85
-rw-r--r--rigify/rigs/spines/super_spine.py22
5 files changed, 175 insertions, 146 deletions
diff --git a/rigify/rigs/spines/basic_spine.py b/rigify/rigs/spines/basic_spine.py
index 6b069c64..355b55f3 100644
--- a/rigify/rigs/spines/basic_spine.py
+++ b/rigify/rigs/spines/basic_spine.py
@@ -8,7 +8,8 @@ from mathutils import Matrix
from ...utils.layers import ControlLayersOption
from ...utils.naming import strip_org, make_mechanism_name, make_derived_name
-from ...utils.bones import BoneDict, put_bone, align_bone_to_axis, align_bone_orientation, set_bone_widget_transform
+from ...utils.bones import (put_bone, align_bone_to_axis, align_bone_orientation,
+ set_bone_widget_transform, TypedBoneDict)
from ...utils.widgets import adjust_widget_transform_mesh
from ...utils.widgets_basic import create_circle_widget
from ...utils.misc import map_list
@@ -22,6 +23,9 @@ class Rig(BaseSpineRig):
Spine rig with fixed pivot, hip/chest controls and tweaks.
"""
+ pivot_pos: int
+ use_fk: bool
+
def initialize(self):
super().initialize()
@@ -34,34 +38,28 @@ class Rig(BaseSpineRig):
####################################################
# BONES
- #
- # org[]:
- # ORG bones
- # ctrl:
- # master, hips, chest:
- # Main controls.
- # fk:
- # chest[], hips[]:
- # FK controls.
- # tweak[]:
- # Tweak control chain.
- # mch:
- # pivot:
- # Pivot tweak parent.
- # chain:
- # chest[], hips[]:
- # Tweak parents, distributing master deform.
- # wgt_hips, wgt_chest:
- # Widget position bones.
- # deform[]:
- # DEF bones
- #
- ####################################################
+
+ class SplitChainBones(TypedBoneDict):
+ chest: list[str]
+ hips: list[str]
+
+ class CtrlBones(BaseSpineRig.CtrlBones):
+ hips: str # Hip control
+ chest: str # Chest control
+ fk: 'Rig.SplitChainBones' # FK controls
+
+ class MchBones(BaseSpineRig.MchBones):
+ pivot: str # Central pivot between sub-chains
+ chain: 'Rig.SplitChainBones' # Tweak parents, distributing master deform.
+ wgt_hips: str # Hip widget position bone.
+ wgt_chest: str # Chest widget position bone.
+
+ bones: BaseSpineRig.ToplevelBones[list[str], CtrlBones, MchBones, list[str]]
####################################################
# Master control bone
- def get_master_control_pos(self, orgs):
+ def get_master_control_pos(self, orgs: list[str]):
base_bone = self.get_bone(orgs[0])
return (base_bone.head + base_bone.tail) / 2
@@ -76,12 +74,12 @@ class Rig(BaseSpineRig):
self.bones.ctrl.hips = self.make_hips_control_bone(orgs[pivot-1], 'hips')
self.bones.ctrl.chest = self.make_chest_control_bone(orgs[pivot], 'chest')
- def make_hips_control_bone(self, org, name):
+ def make_hips_control_bone(self, org: str, name: str):
name = self.copy_bone(org, name, parent=False)
align_bone_to_axis(self.obj, name, 'y', length=self.length / 4, flip=True)
return name
- def make_chest_control_bone(self, org, name):
+ def make_chest_control_bone(self, org: str, name: str):
name = self.copy_bone(org, name, parent=False)
align_bone_to_axis(self.obj, name, 'y', length=self.length / 3)
return name
@@ -100,7 +98,7 @@ class Rig(BaseSpineRig):
self.make_end_control_widget(ctrl.hips, mch.wgt_hips)
self.make_end_control_widget(ctrl.chest, mch.wgt_chest)
- def make_end_control_widget(self, ctrl, wgt_mch):
+ def make_end_control_widget(self, ctrl: str, wgt_mch: str):
shape_bone = self.get_bone(wgt_mch)
is_horizontal = abs(shape_bone.z_axis.normalized().y) < 0.7
@@ -117,22 +115,27 @@ class Rig(BaseSpineRig):
if is_horizontal:
# Tilt the widget toward the ground for horizontal (animal) spines
angle = math.copysign(28, shape_bone.x_axis.x)
- rotmat = Matrix.Rotation(math.radians(angle), 4, 'X')
- adjust_widget_transform_mesh(obj, rotmat, local=True)
+ rot_mat = Matrix.Rotation(math.radians(angle), 4, 'X')
+ adjust_widget_transform_mesh(obj, rot_mat, local=True)
####################################################
# FK control bones
+ fk_result: 'Rig.SplitChainBones' # ctrl.fk or mch.chain depending on use_fk
+
@stage.generate_bones
def make_control_chain(self):
if self.use_fk:
orgs = self.bones.org
- self.bones.ctrl.fk = self.fk_result = BoneDict(
- hips = map_list(self.make_control_bone, count(0), orgs[0:self.pivot_pos], repeat(True)),
- chest = map_list(self.make_control_bone, count(self.pivot_pos), orgs[self.pivot_pos:], repeat(False)),
+ self.bones.ctrl.fk = self.fk_result = self.SplitChainBones(
+ hips=map_list(self.make_control_bone,
+ count(0), orgs[0:self.pivot_pos], repeat(True)),
+ chest=map_list(self.make_control_bone,
+ count(self.pivot_pos), orgs[self.pivot_pos:], repeat(False)),
)
- def make_control_bone(self, i, org, is_hip):
+ # noinspection PyMethodOverriding
+ def make_control_bone(self, i: int, org: str, is_hip: bool):
name = self.copy_bone(org, make_derived_name(org, 'ctrl', '_fk'), parent=False)
if is_hip:
put_bone(self.obj, name, self.get_bone(name).tail)
@@ -166,7 +169,7 @@ class Rig(BaseSpineRig):
for ctrl in fk.chest:
self.make_control_widget(ctrl, False)
- def make_control_widget(self, ctrl, is_hip):
+ def make_control_widget(self, ctrl: str, is_hip: bool):
obj = create_circle_widget(self.obj, ctrl, radius=1.0, head_tail=0.5)
if is_hip:
adjust_widget_transform_mesh(obj, Matrix.Diagonal((1, -1, 1, 1)), local=True)
@@ -183,12 +186,12 @@ class Rig(BaseSpineRig):
mch.wgt_hips = self.make_mch_widget_bone(orgs[0], 'WGT-hips')
mch.wgt_chest = self.make_mch_widget_bone(orgs[-1], 'WGT-chest')
- def make_mch_pivot_bone(self, org, name):
+ def make_mch_pivot_bone(self, org: str, name: str):
name = self.copy_bone(org, make_mechanism_name(name), parent=False)
align_bone_to_axis(self.obj, name, 'y', length=self.length * 0.6 / 4)
return name
- def make_mch_widget_bone(self, org, name):
+ def make_mch_widget_bone(self, org: str, name: str):
return self.copy_bone(org, make_mechanism_name(name), parent=False)
@stage.parent_bones
@@ -211,14 +214,14 @@ class Rig(BaseSpineRig):
@stage.generate_bones
def make_mch_chain(self):
orgs = self.bones.org
- self.bones.mch.chain = BoneDict(
- hips = map_list(self.make_mch_bone, orgs[0:self.pivot_pos], repeat(True)),
- chest = map_list(self.make_mch_bone, orgs[self.pivot_pos:], repeat(False)),
+ self.bones.mch.chain = self.SplitChainBones(
+ hips=map_list(self.make_mch_bone, orgs[0:self.pivot_pos], repeat(True)),
+ chest=map_list(self.make_mch_bone, orgs[self.pivot_pos:], repeat(False)),
)
if not self.use_fk:
self.fk_result = self.bones.mch.chain
- def make_mch_bone(self, org, is_hip):
+ def make_mch_bone(self, org: str, is_hip: bool):
name = self.copy_bone(org, make_mechanism_name(strip_org(org)), parent=False)
align_bone_to_axis(self.obj, name, 'y', length=self.length / 10, flip=is_hip)
return name
@@ -242,8 +245,9 @@ class Rig(BaseSpineRig):
for mch in chain.chest:
self.rig_mch_bone(mch, ctrl.chest, len(chain.chest))
- def rig_mch_bone(self, mch, control, count):
- self.make_constraint(mch, 'COPY_TRANSFORMS', control, space='LOCAL', influence=1/count)
+ def rig_mch_bone(self, mch: str, control: str, chain_len: int):
+ self.make_constraint(mch, 'COPY_TRANSFORMS', control,
+ space='LOCAL', influence=1 / chain_len)
####################################################
# Tweak bones
@@ -260,7 +264,7 @@ class Rig(BaseSpineRig):
# SETTINGS
@classmethod
- def add_parameters(self, params):
+ def add_parameters(cls, params):
params.pivot_pos = bpy.props.IntProperty(
name='pivot_position',
default=2,
@@ -278,7 +282,7 @@ class Rig(BaseSpineRig):
ControlLayersOption.FK.add_parameters(params)
@classmethod
- def parameters_ui(self, layout, params):
+ def parameters_ui(cls, layout, params):
r = layout.row()
r.prop(params, "pivot_pos")
@@ -328,7 +332,6 @@ def create_sample(obj):
bone.parent = arm.edit_bones[bones['spine.002']]
bones['spine.003'] = bone.name
-
bpy.ops.object.mode_set(mode='OBJECT')
pbone = obj.pose.bones[bones['spine']]
pbone.rigify_type = 'spines.basic_spine'
@@ -339,7 +342,10 @@ def create_sample(obj):
pbone.rotation_mode = 'QUATERNION'
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['spine.001']]
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']]
diff --git a/rigify/rigs/spines/spine_rigs.py b/rigify/rigs/spines/spine_rigs.py
index a221089b..13cc48dd 100644
--- a/rigify/rigs/spines/spine_rigs.py
+++ b/rigify/rigs/spines/spine_rigs.py
@@ -2,6 +2,7 @@
import bpy
+from typing import Optional, NamedTuple
from itertools import count
from ...utils.layers import ControlLayersOption
@@ -24,6 +25,9 @@ class BaseSpineRig(TweakChainRig):
bbone_segments = 8
min_chain_length = 3
+ use_torso_pivot: bool # Generate the custom pivot control
+ length: float # Total length of the chain bones
+
def initialize(self):
super().initialize()
@@ -32,21 +36,21 @@ class BaseSpineRig(TweakChainRig):
####################################################
# BONES
- #
- # ctrl:
- # master
- # Main control.
- # master_pivot
- # Custom pivot under the master control.
- # mch:
- # master_pivot
- # Final output of the custom pivot.
- #
- ####################################################
+
+ class CtrlBones(TweakChainRig.CtrlBones):
+ master: str # Master control
+ master_pivot: str # Custom pivot under the master control (conditional)
+
+ class MchBones(TweakChainRig.MchBones):
+ master_pivot: str # Final output of the custom pivot (conditional)
+
+ bones: TweakChainRig.ToplevelBones[list[str], CtrlBones, MchBones, list[str]]
####################################################
# Master control bone
+ component_torso_pivot: Optional[CustomPivotControl]
+
@stage.generate_bones
def make_master_control(self):
self.bones.ctrl.master = name = self.make_master_control_bone(self.bones.org)
@@ -54,16 +58,16 @@ class BaseSpineRig(TweakChainRig):
self.component_torso_pivot = self.build_master_pivot(name)
self.build_parent_switch(name)
- def get_master_control_pos(self, orgs):
+ def get_master_control_pos(self, orgs: list[str]):
return self.get_bone(orgs[0]).head
- def make_master_control_bone(self, orgs):
+ def make_master_control_bone(self, orgs: list[str]):
name = self.copy_bone(orgs[0], 'torso')
put_bone(self.obj, name, self.get_master_control_pos(orgs))
align_bone_to_axis(self.obj, name, 'y', length=self.length * 0.6)
return name
- def build_master_pivot(self, master_name, **args):
+ def build_master_pivot(self, master_name: str, **args):
if self.use_torso_pivot:
return CustomPivotControl(
self, 'master_pivot', master_name, parent=master_name, **args
@@ -75,7 +79,7 @@ class BaseSpineRig(TweakChainRig):
else:
return self.bones.ctrl.master
- def build_parent_switch(self, master_name):
+ def build_parent_switch(self, master_name: str):
pbuilder = SwitchParentBuilder(self.generator)
org_parent = self.get_bone_parent(self.bones.org[0])
@@ -92,7 +96,7 @@ class BaseSpineRig(TweakChainRig):
self.register_parent_bones(pbuilder)
- def register_parent_bones(self, pbuilder):
+ def register_parent_bones(self, pbuilder: SwitchParentBuilder):
pbuilder.register_parent(self, self.bones.org[0], name='Hips', exclude_self=True, tags={'hips'})
pbuilder.register_parent(self, self.bones.org[-1], name='Chest', exclude_self=True, tags={'chest'})
@@ -121,7 +125,7 @@ class BaseSpineRig(TweakChainRig):
self.set_bone_parent(org, tweak)
def rig_org_bone(self, i, org, tweak, next_tweak):
- # For spine rigs, these constraints go on the deform bones. See T74483#902192.
+ # For spine rigs, these constraints go on the deformation bones. See T74483#902192.
pass
####################################################
@@ -142,31 +146,33 @@ class BaseSpineRig(TweakChainRig):
for args in zip(count(0), self.bones.deform, tweaks, tweaks[1:]):
self.rig_deform_bone(*args)
- def rig_deform_bone(self, i, deform, tweak, next_tweak):
+ # noinspection PyMethodOverriding
+ def rig_deform_bone(self, i: int, deform: str, tweak: str, next_tweak: Optional[str]):
self.make_constraint(deform, 'COPY_TRANSFORMS', tweak)
if next_tweak:
self.make_constraint(deform, 'STRETCH_TO', next_tweak, keep_axis='SWING_Y')
@stage.configure_bones
def configure_bbone_chain(self):
+ # noinspection SpellCheckingInspection
self.get_bone(self.bones.deform[0]).bone.bbone_easein = 0.0
####################################################
# SETTINGS
@classmethod
- def add_parameters(self, params):
+ def add_parameters(cls, params):
params.make_custom_pivot = bpy.props.BoolProperty(
- name = "Custom Pivot Control",
- default = False,
- description = "Create a rotation pivot control that can be repositioned arbitrarily"
+ name="Custom Pivot Control",
+ default=False,
+ description="Create a rotation pivot control that can be repositioned arbitrarily"
)
# Setting up extra layers for the FK and tweak
ControlLayersOption.TWEAK.add_parameters(params)
@classmethod
- def parameters_ui(self, layout, params):
+ def parameters_ui(cls, layout, params):
layout.prop(params, 'make_custom_pivot')
ControlLayersOption.TWEAK.parameters_ui(layout, params)
@@ -175,6 +181,19 @@ class BaseSpineRig(TweakChainRig):
class BaseHeadTailRig(ConnectingChainRig):
""" Base for head and tail rigs. """
+ class RotationBone(NamedTuple):
+ org: str
+ name: str
+ bone: str
+ def_val: float # Default value of the follow slider
+ copy_scale: bool
+
+ rotation_bones: list[RotationBone]
+
+ follow_bone: str
+ default_prop_bone: str
+ prop_bone: str
+
def initialize(self):
super().initialize()
@@ -183,7 +202,7 @@ class BaseHeadTailRig(ConnectingChainRig):
####################################################
# Utilities
- def get_parent_master(self, default_bone):
+ def get_parent_master(self, default_bone: str) -> str:
""" Return the parent's master control bone if connecting and found. """
if self.use_connect_chain and 'master' in self.rigify_parent.bones.ctrl:
@@ -191,7 +210,7 @@ class BaseHeadTailRig(ConnectingChainRig):
else:
return default_bone
- def get_parent_master_panel(self, default_bone):
+ def get_parent_master_panel(self, default_bone: str):
""" Return the parent's master control bone if connecting and found, and script panel. """
controls = self.bones.ctrl.flatten()
@@ -208,37 +227,38 @@ class BaseHeadTailRig(ConnectingChainRig):
####################################################
# Rotation follow
- def make_mch_follow_bone(self, org, name, defval, *, copy_scale=False):
+ def make_mch_follow_bone(self, org: str, name: str, def_val: float, *, copy_scale=False):
bone = self.copy_bone(org, make_derived_name('ROT-'+name, 'mch'), parent=True)
- self.rotation_bones.append((org, name, bone, defval, copy_scale))
+ self.rotation_bones.append(self.RotationBone(org, name, bone, def_val, copy_scale))
return bone
@stage.parent_bones
def align_mch_follow_bones(self):
self.follow_bone = self.get_parent_master('root')
- for org, name, bone, defval, copy_scale in self.rotation_bones:
+ for org, name, bone, def_val, copy_scale in self.rotation_bones:
align_bone_orientation(self.obj, bone, self.follow_bone)
@stage.configure_bones
def configure_mch_follow_bones(self):
self.prop_bone, panel = self.get_parent_master_panel(self.default_prop_bone)
- for org, name, bone, defval, copy_scale in self.rotation_bones:
- textname = name.replace('_',' ').title() + ' Follow'
+ for org, name, bone, def_val, copy_scale in self.rotation_bones:
+ text_name = name.replace('_', ' ').title() + ' Follow'
- self.make_property(self.prop_bone, name+'_follow', default=float(defval))
- panel.custom_prop(self.prop_bone, name+'_follow', text=textname, slider=True)
+ self.make_property(self.prop_bone, name+'_follow', default=float(def_val))
+ panel.custom_prop(self.prop_bone, name+'_follow', text=text_name, slider=True)
@stage.rig_bones
def rig_mch_follow_bones(self):
- for org, name, bone, defval, copy_scale in self.rotation_bones:
+ for org, name, bone, def_val, copy_scale in self.rotation_bones:
self.rig_mch_rotation_bone(bone, name+'_follow', copy_scale)
- def rig_mch_rotation_bone(self, mch, prop_name, copy_scale):
+ def rig_mch_rotation_bone(self, mch: str, prop_name: str, copy_scale: bool):
con = self.make_constraint(mch, 'COPY_ROTATION', self.follow_bone)
- self.make_driver(con, 'influence', variables=[(self.prop_bone, prop_name)], polynomial=[1,-1])
+ self.make_driver(con, 'influence',
+ variables=[(self.prop_bone, prop_name)], polynomial=[1, -1])
if copy_scale:
self.make_constraint(mch, 'COPY_SCALE', self.follow_bone)
@@ -256,14 +276,14 @@ class BaseHeadTailRig(ConnectingChainRig):
# Settings
@classmethod
- def add_parameters(self, params):
+ def add_parameters(cls, params):
super().add_parameters(params)
# Setting up extra layers for the FK and tweak
ControlLayersOption.TWEAK.add_parameters(params)
@classmethod
- def parameters_ui(self, layout, params):
+ def parameters_ui(cls, layout, params):
super().parameters_ui(layout, params)
ControlLayersOption.TWEAK.parameters_ui(layout, params)
diff --git a/rigify/rigs/spines/super_head.py b/rigify/rigs/spines/super_head.py
index 49f1ce3e..22a8873d 100644
--- a/rigify/rigs/spines/super_head.py
+++ b/rigify/rigs/spines/super_head.py
@@ -24,6 +24,9 @@ class Rig(BaseHeadTailRig):
use_connect_reverse = False
min_chain_length = 1
+ long_neck: bool
+ has_neck: bool
+
def initialize(self):
super().initialize()
@@ -32,27 +35,20 @@ class Rig(BaseHeadTailRig):
####################################################
# BONES
- #
- # org[]:
- # ORG bones
- # ctrl:
- # neck, head, neck_bend:
- # Main controls.
- # tweak[]:
- # Tweak control chain.
- # mch:
- # rot_neck, rot_head:
- # Main control parents, implement FK follow.
- # stretch
- # Long neck stretch behavior.
- # ik[]
- # Long neck IK behavior.
- # chain[]
- # Tweak parents.
- # deform[]:
- # DEF bones
- #
- ####################################################
+
+ class CtrlBones(BaseHeadTailRig.CtrlBones):
+ neck: str # Main neck control
+ head: str # Main head control
+ neck_bend: str # Extra neck bend control for long neck
+
+ class MchBones(BaseHeadTailRig.MchBones):
+ rot_neck: str # Main neck control parent for FK follow
+ rot_head: str # Main head control parent for FK follow
+ stretch: str # Long neck stretch helper
+ ik: list[str] # Long neck IK system
+ chain: list[str] # Tweak parents
+
+ bones: BaseHeadTailRig.ToplevelBones[list[str], CtrlBones, MchBones, list[str]]
####################################################
# Main control bones
@@ -72,7 +68,7 @@ class Rig(BaseHeadTailRig):
self.default_prop_bone = ctrl.head
- def make_neck_control_bone(self, org, name, org_head):
+ def make_neck_control_bone(self, org: str, name: str, org_head: str):
name = self.copy_bone(org, name, parent=False)
# Neck spans all neck bones (except head)
@@ -80,7 +76,7 @@ class Rig(BaseHeadTailRig):
return name
- def make_neck_bend_control_bone(self, org, name, neck):
+ def make_neck_bend_control_bone(self, org: str, name: str, neck: str):
name = self.copy_bone(org, name, parent=False)
neck_bend_eb = self.get_bone(name)
@@ -98,7 +94,7 @@ class Rig(BaseHeadTailRig):
return name
- def make_head_control_bone(self, org, name):
+ def make_head_control_bone(self, org: str, name: str):
return self.copy_bone(org, name, parent=False)
@stage.parent_bones
@@ -119,7 +115,7 @@ class Rig(BaseHeadTailRig):
if self.long_neck:
self.configure_neck_bend_bone(self.bones.ctrl.neck_bend, self.bones.org[0])
- def configure_neck_bend_bone(self, ctrl, org):
+ def configure_neck_bend_bone(self, ctrl: str, _org: str):
bone = self.get_bone(ctrl)
bone.lock_rotation = (True, True, True)
bone.lock_rotation_w = True
@@ -134,7 +130,7 @@ class Rig(BaseHeadTailRig):
if self.long_neck:
self.make_neck_bend_widget(ctrl.neck_bend)
- def make_neck_widget(self, ctrl):
+ def make_neck_widget(self, ctrl: str):
radius = 1/max(1, len(self.bones.mch.chain))
create_circle_widget(
@@ -143,7 +139,7 @@ class Rig(BaseHeadTailRig):
head_tail=0.5,
)
- def make_neck_bend_widget(self, ctrl):
+ def make_neck_bend_widget(self, ctrl: str):
radius = 1/max(1, len(self.bones.mch.chain))
create_neck_bend_widget(
@@ -152,7 +148,7 @@ class Rig(BaseHeadTailRig):
head_tail=0.0,
)
- def make_head_widget(self, ctrl):
+ def make_head_widget(self, ctrl: str):
# place wgt @ middle of head bone for long necks
if self.long_neck:
head_tail = 0.5
@@ -161,9 +157,9 @@ class Rig(BaseHeadTailRig):
create_circle_widget(
self.obj, ctrl,
- radius = 0.5,
- head_tail = head_tail,
- with_line = False,
+ radius=0.5,
+ head_tail=head_tail,
+ with_line=False,
)
####################################################
@@ -179,7 +175,7 @@ class Rig(BaseHeadTailRig):
mch.stretch = self.make_mch_stretch_bone(orgs[0], 'STR-neck', orgs[-1])
mch.rot_head = self.make_mch_follow_bone(orgs[-1], 'head', 0.0, copy_scale=True)
- def make_mch_stretch_bone(self, org, name, org_head):
+ def make_mch_stretch_bone(self, org: str, name: str, org_head: str):
name = self.copy_bone(org, make_derived_name(name, 'mch'), parent=False)
self.get_bone(name).tail = self.get_bone(org_head).head
return name
@@ -198,7 +194,7 @@ class Rig(BaseHeadTailRig):
if self.has_neck:
self.rig_mch_stretch_bone(self.bones.mch.stretch, self.bones.ctrl.head)
- def rig_mch_stretch_bone(self, mch, head):
+ def rig_mch_stretch_bone(self, mch: str, head: str):
self.make_constraint(mch, 'STRETCH_TO', head, keep_axis='SWING_Y')
####################################################
@@ -210,7 +206,7 @@ class Rig(BaseHeadTailRig):
if self.long_neck:
self.bones.mch.ik = map_list(self.make_mch_ik_bone, orgs[0:-1])
- def make_mch_ik_bone(self, org):
+ def make_mch_ik_bone(self, org: str):
return self.copy_bone(org, make_derived_name(org, 'mch', '_ik'), parent=False)
@stage.parent_bones
@@ -228,7 +224,7 @@ class Rig(BaseHeadTailRig):
for args in zip(count(0), ik):
self.rig_mch_ik_bone(*args, len(ik), head)
- def rig_mch_ik_bone(self, i, mch, ik_len, head):
+ def rig_mch_ik_bone(self, i: int, mch: str, ik_len: int, head: str):
if i == ik_len - 1:
self.make_constraint(mch, 'IK', head, chain_count=ik_len)
@@ -242,7 +238,7 @@ class Rig(BaseHeadTailRig):
orgs = self.bones.org
self.bones.mch.chain = map_list(self.make_mch_bone, orgs[1:-1])
- def make_mch_bone(self, org):
+ def make_mch_bone(self, org: str):
return self.copy_bone(org, make_derived_name(org, 'mch'), parent=False, scale=1/4)
@stage.parent_bones
@@ -267,14 +263,14 @@ class Rig(BaseHeadTailRig):
for args in zip(count(0), chain):
self.rig_mch_bone(*args, len(chain))
- def rig_mch_bone_long(self, i, mch, ik, len_mch):
+ def rig_mch_bone_long(self, i: int, mch: str, ik: str, len_mch: int):
ctrl = self.bones.ctrl
self.make_constraint(mch, 'COPY_LOCATION', ik)
step = 2/(len_mch+1)
- xval = (i+1)*step
- influence = 2*xval - xval**2 #parabolic influence of pivot
+ x_val = (i+1)*step
+ influence = 2*x_val - x_val**2 # parabolic influence of pivot
self.make_constraint(
mch, 'COPY_LOCATION', ctrl.neck_bend,
@@ -286,10 +282,10 @@ class Rig(BaseHeadTailRig):
def rig_mch_bone(self, i, mch, len_mch):
ctrl = self.bones.ctrl
- nfactor = float((i + 1) / (len_mch + 1))
+ n_factor = float((i + 1) / (len_mch + 1))
self.make_constraint(
mch, 'COPY_ROTATION', ctrl.head,
- influence=nfactor, space='LOCAL'
+ influence=n_factor, space='LOCAL'
)
self.make_constraint(mch, 'COPY_SCALE', ctrl.neck)
@@ -345,7 +341,7 @@ class Rig(BaseHeadTailRig):
else:
tweaks = [self.connected_tweak or self.bones.ctrl.head]
- for args in zip(count(0), self.bones.org, tweaks, tweaks[1:] + [None]):
+ for args in zip(count(0), self.bones.org, tweaks, [*tweaks[1:], None]):
self.rig_org_bone(*args)
@@ -392,7 +388,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['neck.001']]
diff --git a/rigify/rigs/spines/super_spine.py b/rigify/rigs/spines/super_spine.py
index 7d60a57e..dc56f7a2 100644
--- a/rigify/rigs/spines/super_spine.py
+++ b/rigify/rigs/spines/super_spine.py
@@ -32,8 +32,8 @@ class Rig(SubstitutionRig, BoneUtilityMixin):
if neck_pos >= len(orgs):
self.raise_error("Neck is too short.")
- spine_orgs = orgs[0 : neck_pos-1]
- head_orgs = orgs[neck_pos-1 : ]
+ spine_orgs = orgs[0: neck_pos-1]
+ head_orgs = orgs[neck_pos-1:]
if self.params.use_tail:
tail_pos = self.params.tail_pos
@@ -42,8 +42,8 @@ class Rig(SubstitutionRig, BoneUtilityMixin):
if tail_pos >= pivot_pos:
self.raise_error("Tail cannot be above or the same as pivot.")
- tail_orgs = list(reversed(spine_orgs[0 : tail_pos]))
- spine_orgs = spine_orgs[tail_pos : ]
+ tail_orgs = list(reversed(spine_orgs[0: tail_pos]))
+ spine_orgs = spine_orgs[tail_pos:]
pivot_pos -= tail_pos
# Split the bone chain and flip the tail
@@ -65,17 +65,17 @@ class Rig(SubstitutionRig, BoneUtilityMixin):
# Create the parts
self.assign_params(spine_orgs[0], params_copy, pivot_pos=pivot_pos, make_fk_controls=False)
- result = [ self.instantiate_rig(basic_spine.Rig, spine_orgs[0]) ]
+ result = [self.instantiate_rig(basic_spine.Rig, spine_orgs[0])]
if tail_orgs:
self.assign_params(tail_orgs[0], params_copy, connect_chain=True)
- result += [ self.instantiate_rig(basic_tail.Rig, tail_orgs[0]) ]
+ result += [self.instantiate_rig(basic_tail.Rig, tail_orgs[0])]
if head_orgs:
self.assign_params(head_orgs[0], params_copy, connect_chain=True)
- result += [ self.instantiate_rig(super_head.Rig, head_orgs[0]) ]
+ result += [self.instantiate_rig(super_head.Rig, head_orgs[0])]
return result
@@ -86,10 +86,10 @@ def add_parameters(params):
super_head.Rig.add_parameters(params)
params.neck_pos = bpy.props.IntProperty(
- name = 'neck_position',
- default = 6,
- min = 0,
- description = 'Neck start position'
+ name='neck_position',
+ default=6,
+ min=0,
+ description='Neck start position'
)
params.tail_pos = bpy.props.IntProperty(