@@ -34,6 +34,7 @@ def __init__(self, obj, bone_name, params):
34
34
self .main_mch = self .get_jaw ()
35
35
self .lip_len = None
36
36
self .mouth_bones = self .get_mouth ()
37
+ self .rotation_mode = params .rotation_mode
37
38
38
39
self .layer_generator = ControlLayersGenerator (self )
39
40
@@ -104,11 +105,9 @@ def orient_org_bones(self):
104
105
bpy .ops .object .mode_set (mode = 'EDIT' )
105
106
edit_bones = self .obj .data .edit_bones
106
107
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 )
112
111
113
112
def create_mch (self ):
114
113
bpy .ops .object .mode_set (mode = 'EDIT' )
@@ -152,9 +151,6 @@ def create_controls(self):
152
151
self .bones ['jaw_ctrl' ]['jaw' ] = jaw_ctrl
153
152
edit_bones [jaw_ctrl ].use_connect = False
154
153
155
- bpy .ops .object .mode_set (mode = 'OBJECT' )
156
- create_jaw_widget (self .obj , jaw_ctrl )
157
-
158
154
super ().create_controls ()
159
155
160
156
def make_constraints (self ):
@@ -324,6 +320,9 @@ def create_widgets(self):
324
320
create_cube_widget (self .obj , corner_2 )
325
321
create_cube_widget (self .obj , bottom_main )
326
322
323
+ jaw_ctrl = self .bones ['jaw_ctrl' ]['jaw' ]
324
+ create_jaw_widget (self .obj , jaw_ctrl )
325
+
327
326
super ().create_widgets ()
328
327
329
328
def generate (self ):
@@ -496,11 +495,25 @@ def add_parameters(params):
496
495
""" Add the parameters of this rig type to the
497
496
RigifyParameters PropertyGroup
498
497
"""
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
+ )
499
509
500
510
ControlLayersGenerator .add_layer_parameters (params )
501
511
502
512
503
513
def parameters_ui (layout , params ):
504
514
""" Create the ui for the rig parameters."""
505
515
516
+ r = layout .row ()
517
+ r .prop (params , "rotation_mode" )
518
+
506
519
ControlLayersGenerator .add_layers_ui (layout , params )
0 commit comments