Skip to content

Commit 540b1f1

Browse files
committed
fix bendy_jaw: jaw rotation wrong for asymmetic mouths
1 parent efbab8d commit 540b1f1

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

rigs/experimental/bendy_jaw.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(self, obj, bone_name, params):
3434
self.main_mch = self.get_jaw()
3535
self.lip_len = None
3636
self.mouth_bones = self.get_mouth()
37+
self.rotation_mode = params.rotation_mode
3738

3839
self.layer_generator = ControlLayersGenerator(self)
3940

@@ -104,11 +105,9 @@ def orient_org_bones(self):
104105
bpy.ops.object.mode_set(mode='EDIT')
105106
edit_bones = self.obj.data.edit_bones
106107

107-
top_org = self.mouth_bones['top'][0]
108-
bottom_org = self.mouth_bones['bottom'][0]
109-
alignment_axis = edit_bones[bottom_org].head - edit_bones[top_org].head
110-
111-
align_bone_z_axis(self.obj, self.main_mch, alignment_axis)
108+
if self.rotation_mode == 'automatic':
109+
alignment_axis = edit_bones[self.main_mch].tail - edit_bones[self.base_bone].head
110+
align_bone_z_axis(self.obj, self.main_mch, alignment_axis)
112111

113112
def create_mch(self):
114113
bpy.ops.object.mode_set(mode='EDIT')
@@ -152,9 +151,6 @@ def create_controls(self):
152151
self.bones['jaw_ctrl']['jaw'] = jaw_ctrl
153152
edit_bones[jaw_ctrl].use_connect = False
154153

155-
bpy.ops.object.mode_set(mode='OBJECT')
156-
create_jaw_widget(self.obj, jaw_ctrl)
157-
158154
super().create_controls()
159155

160156
def make_constraints(self):
@@ -324,6 +320,9 @@ def create_widgets(self):
324320
create_cube_widget(self.obj, corner_2)
325321
create_cube_widget(self.obj, bottom_main)
326322

323+
jaw_ctrl = self.bones['jaw_ctrl']['jaw']
324+
create_jaw_widget(self.obj, jaw_ctrl)
325+
327326
super().create_widgets()
328327

329328
def generate(self):
@@ -496,11 +495,25 @@ def add_parameters(params):
496495
""" Add the parameters of this rig type to the
497496
RigifyParameters PropertyGroup
498497
"""
498+
items = [
499+
('manual', 'Manual', ''),
500+
('automatic', 'Automatic', '')
501+
]
502+
503+
params.rotation_mode = bpy.props.EnumProperty(
504+
items=items,
505+
name="Rotation Mode",
506+
description="Auto will align z-axis of jaw ctrl along the plane defined by the main and jaw bones",
507+
default='automatic'
508+
)
499509

500510
ControlLayersGenerator.add_layer_parameters(params)
501511

502512

503513
def parameters_ui(layout, params):
504514
""" Create the ui for the rig parameters."""
505515

516+
r = layout.row()
517+
r.prop(params, "rotation_mode")
518+
506519
ControlLayersGenerator.add_layers_ui(layout, params)

0 commit comments

Comments
 (0)