Skip to content

Commit 1ff692c

Browse files
committed
Support putting tweak controls on different layers for super_finger.
1 parent 83ff6e0 commit 1ff692c

File tree

7 files changed

+87
-199
lines changed

7 files changed

+87
-199
lines changed

rigs/limbs/arm.py

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from ...utils import MetarigError, make_mechanism_name, org
1010
from ...utils import create_limb_widget, connected_children_names
1111
from ...utils import align_bone_y_axis, align_bone_x_axis, align_bone_z_axis
12+
from ...utils import layout_layer_selection_ui
1213
from rna_prop_ui import rna_idprop_ui_prop_get
1314
from ..widgets import create_ikarrow_widget
1415
from math import trunc, pi
@@ -1151,46 +1152,8 @@ def parameters_ui(layout, params):
11511152
r = layout.row()
11521153
r.prop(params, "bbones")
11531154

1154-
bone_layers = bpy.context.active_pose_bone.bone.layers[:]
1155-
1156-
for layer in ['fk', 'tweak']:
1157-
r = layout.row()
1158-
r.prop(params, layer + "_extra_layers")
1159-
r.active = params.tweak_extra_layers
1160-
1161-
col = r.column(align=True)
1162-
row = col.row(align=True)
1163-
1164-
for i in range(8):
1165-
icon = "NONE"
1166-
if bone_layers[i]:
1167-
icon = "LAYER_ACTIVE"
1168-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1169-
1170-
row = col.row(align=True)
1171-
1172-
for i in range(16, 24):
1173-
icon = "NONE"
1174-
if bone_layers[i]:
1175-
icon = "LAYER_ACTIVE"
1176-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1177-
1178-
col = r.column(align=True)
1179-
row = col.row(align=True)
1180-
1181-
for i in range(8, 16):
1182-
icon = "NONE"
1183-
if bone_layers[i]:
1184-
icon = "LAYER_ACTIVE"
1185-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1186-
1187-
row = col.row(align=True)
1188-
1189-
for i in range(24, 32):
1190-
icon = "NONE"
1191-
if bone_layers[i]:
1192-
icon = "LAYER_ACTIVE"
1193-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1155+
layout_layer_selection_ui(layout, params, "fk_extra_layers", "fk_layers")
1156+
layout_layer_selection_ui(layout, params, "tweak_extra_layers", "tweak_layers")
11941157

11951158

11961159
def create_sample(obj):

rigs/limbs/leg.py

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ...utils import MetarigError, make_mechanism_name, org
1111
from ...utils import create_limb_widget, connected_children_names
1212
from ...utils import align_bone_y_axis, align_bone_x_axis, align_bone_z_axis
13+
from ...utils import layout_layer_selection_ui
1314
from rna_prop_ui import rna_idprop_ui_prop_get
1415
from ..widgets import create_ikarrow_widget
1516
from math import trunc, pi
@@ -1474,46 +1475,8 @@ def parameters_ui(layout, params):
14741475
r = layout.row()
14751476
r.prop(params, "bbones")
14761477

1477-
bone_layers = bpy.context.active_pose_bone.bone.layers[:]
1478-
1479-
for layer in ['fk', 'tweak']:
1480-
r = layout.row()
1481-
r.prop(params, layer + "_extra_layers")
1482-
r.active = params.tweak_extra_layers
1483-
1484-
col = r.column(align=True)
1485-
row = col.row(align=True)
1486-
1487-
for i in range(8):
1488-
icon = "NONE"
1489-
if bone_layers[i]:
1490-
icon = "LAYER_ACTIVE"
1491-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1492-
1493-
row = col.row(align=True)
1494-
1495-
for i in range(16, 24):
1496-
icon = "NONE"
1497-
if bone_layers[i]:
1498-
icon = "LAYER_ACTIVE"
1499-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1500-
1501-
col = r.column(align=True)
1502-
row = col.row(align=True)
1503-
1504-
for i in range(8, 16):
1505-
icon = "NONE"
1506-
if bone_layers[i]:
1507-
icon = "LAYER_ACTIVE"
1508-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1509-
1510-
row = col.row(align=True)
1511-
1512-
for i in range(24, 32):
1513-
icon = "NONE"
1514-
if bone_layers[i]:
1515-
icon = "LAYER_ACTIVE"
1516-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1478+
layout_layer_selection_ui(layout, params, "fk_extra_layers", "fk_layers")
1479+
layout_layer_selection_ui(layout, params, "tweak_extra_layers", "tweak_layers")
15171480

15181481

15191482
def create_sample(obj):

rigs/limbs/paw.py

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from ...utils import MetarigError, make_mechanism_name, org
99
from ...utils import create_limb_widget, connected_children_names
1010
from ...utils import align_bone_y_axis, align_bone_x_axis, align_bone_z_axis
11+
from ...utils import layout_layer_selection_ui
1112
from rna_prop_ui import rna_idprop_ui_prop_get
1213
from ..widgets import create_ikarrow_widget, create_gear_widget
1314
from ..widgets import create_foot_widget, create_ballsocket_widget
@@ -1302,46 +1303,8 @@ def parameters_ui(layout, params):
13021303
r = layout.row()
13031304
r.prop(params, "bbones")
13041305

1305-
bone_layers = bpy.context.active_pose_bone.bone.layers[:]
1306-
1307-
for layer in ['fk', 'tweak']:
1308-
r = layout.row()
1309-
r.prop(params, layer + "_extra_layers")
1310-
r.active = params.tweak_extra_layers
1311-
1312-
col = r.column(align=True)
1313-
row = col.row(align=True)
1314-
1315-
for i in range(8):
1316-
icon = "NONE"
1317-
if bone_layers[i]:
1318-
icon = "LAYER_ACTIVE"
1319-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1320-
1321-
row = col.row(align=True)
1322-
1323-
for i in range(16, 24):
1324-
icon = "NONE"
1325-
if bone_layers[i]:
1326-
icon = "LAYER_ACTIVE"
1327-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1328-
1329-
col = r.column(align=True)
1330-
row = col.row(align=True)
1331-
1332-
for i in range(8, 16):
1333-
icon = "NONE"
1334-
if bone_layers[i]:
1335-
icon = "LAYER_ACTIVE"
1336-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1337-
1338-
row = col.row(align=True)
1339-
1340-
for i in range(24, 32):
1341-
icon = "NONE"
1342-
if bone_layers[i]:
1343-
icon = "LAYER_ACTIVE"
1344-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
1306+
layout_layer_selection_ui(layout, params, "fk_extra_layers", "fk_layers")
1307+
layout_layer_selection_ui(layout, params, "tweak_extra_layers", "tweak_layers")
13451308

13461309

13471310
def create_sample(obj):

rigs/limbs/simple_tentacle.py

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from ...utils import put_bone, create_sphere_widget
55
from ...utils import create_circle_widget, align_bone_x_axis
66
from ...utils import MetarigError
7+
from ...utils import layout_layer_selection_ui
78

89

910
class Rig:
@@ -277,45 +278,7 @@ def parameters_ui(layout, params):
277278
for i, axis in enumerate(['x', 'y', 'z']):
278279
row.prop(params, "copy_rotation_axes", index=i, toggle=True, text=axis)
279280

280-
r = layout.row()
281-
r.prop(params, "tweak_extra_layers")
282-
r.active = params.tweak_extra_layers
283-
284-
col = r.column(align=True)
285-
row = col.row(align=True)
286-
287-
bone_layers = bpy.context.active_pose_bone.bone.layers[:]
288-
289-
for i in range(8): # Layers 0-7
290-
icon = "NONE"
291-
if bone_layers[i]:
292-
icon = "LAYER_ACTIVE"
293-
row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon)
294-
295-
row = col.row(align=True)
296-
297-
for i in range(16, 24): # Layers 16-23
298-
icon = "NONE"
299-
if bone_layers[i]:
300-
icon = "LAYER_ACTIVE"
301-
row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon)
302-
303-
col = r.column(align=True)
304-
row = col.row(align=True)
305-
306-
for i in range(8, 16): # Layers 8-15
307-
icon = "NONE"
308-
if bone_layers[i]:
309-
icon = "LAYER_ACTIVE"
310-
row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon)
311-
312-
row = col.row(align=True)
313-
314-
for i in range(24, 32): # Layers 24-31
315-
icon = "NONE"
316-
if bone_layers[i]:
317-
icon = "LAYER_ACTIVE"
318-
row.prop(params, "tweak_layers", index=i, toggle=True, text="", icon=icon)
281+
layout_layer_selection_ui(layout, params, "tweak_extra_layers", "tweak_layers")
319282

320283

321284
def create_sample(obj):

rigs/limbs/super_finger.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from ...utils import strip_org, make_deformer_name, connected_children_names, make_mechanism_name
44
from ...utils import create_circle_widget, create_widget
55
from ...utils import MetarigError, align_bone_x_axis
6+
from ...utils import layout_layer_selection_ui
67
from rna_prop_ui import rna_idprop_ui_prop_get
78

89
script = """
@@ -20,6 +21,11 @@ def __init__(self, obj, bone_name, params):
2021
self.org_bones = [bone_name] + connected_children_names(obj, bone_name)
2122
self.params = params
2223

24+
if params.tweak_extra_layers:
25+
self.tweak_layers = list(params.tweak_layers)
26+
else:
27+
self.tweak_layers = None
28+
2329
if len(self.org_bones) <= 1:
2430
raise MetarigError("RIGIFY ERROR: Bone '%s': listen bro, that finger rig jusaint put tugetha rite. A little hint, use more than one bone!!" % (strip_org(bone_name)))
2531

@@ -303,6 +309,9 @@ def generate(self):
303309
# Assigning shapes to control bones
304310
create_circle_widget(self.obj, ctrl, radius=0.3, head_tail=0.5)
305311

312+
if self.tweak_layers:
313+
pb[ctrl].bone.layers = self.tweak_layers
314+
306315
# Create ctrl master widget
307316
w = create_widget(self.obj, master_name)
308317
if w is not None:
@@ -321,6 +330,9 @@ def generate(self):
321330
# Create tip control widget
322331
create_circle_widget(self.obj, tip_name, radius=0.3, head_tail=0.0)
323332

333+
if self.tweak_layers:
334+
pb[tip_name].bone.layers = self.tweak_layers
335+
324336
# Create UI
325337
controls_string = ", ".join(
326338
["'" + x + "'" for x in ctrl_chain]
@@ -336,6 +348,19 @@ def add_parameters(params):
336348
('-X', '-X manual', ''), ('-Y', '-Y manual', ''), ('-Z', '-Z manual', '')]
337349
params.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='automatic')
338350

351+
# Setting up extra tweak layers
352+
params.tweak_extra_layers = bpy.props.BoolProperty(
353+
name="tweak_extra_layers",
354+
default=False,
355+
description=""
356+
)
357+
358+
params.tweak_layers = bpy.props.BoolVectorProperty(
359+
size=32,
360+
description="Layers for the tweak controls to be on",
361+
default=tuple([i == 1 for i in range(0, 32)])
362+
)
363+
339364

340365
def parameters_ui(layout, params):
341366
""" Create the ui for the rig parameters.
@@ -344,6 +369,7 @@ def parameters_ui(layout, params):
344369
r.label(text="Bend rotation axis:")
345370
r.prop(params, "primary_rotation_axis", text="")
346371

372+
layout_layer_selection_ui(layout, params, "tweak_extra_layers", "tweak_layers")
347373

348374
def create_sample(obj):
349375
# generated by rigify.utils.write_metarig

rigs/limbs/super_limb.py

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .leg import Rig as legRig
55
from .paw import Rig as pawRig
66

7+
from ...utils import layout_layer_selection_ui
78

89
class Rig:
910

@@ -130,46 +131,8 @@ def parameters_ui(layout, params):
130131
r = layout.row()
131132
r.prop(params, "bbones")
132133

133-
bone_layers = bpy.context.active_pose_bone.bone.layers[:]
134-
135-
for layer in ['fk', 'tweak']:
136-
r = layout.row()
137-
r.prop(params, layer + "_extra_layers")
138-
r.active = params.tweak_extra_layers
139-
140-
col = r.column(align=True)
141-
row = col.row(align=True)
142-
143-
for i in range(8):
144-
icon = "NONE"
145-
if bone_layers[i]:
146-
icon = "LAYER_ACTIVE"
147-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
148-
149-
row = col.row(align=True)
150-
151-
for i in range(16,24):
152-
icon = "NONE"
153-
if bone_layers[i]:
154-
icon = "LAYER_ACTIVE"
155-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
156-
157-
col = r.column(align=True)
158-
row = col.row(align=True)
159-
160-
for i in range(8,16):
161-
icon = "NONE"
162-
if bone_layers[i]:
163-
icon = "LAYER_ACTIVE"
164-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
165-
166-
row = col.row(align=True)
167-
168-
for i in range(24,32):
169-
icon = "NONE"
170-
if bone_layers[i]:
171-
icon = "LAYER_ACTIVE"
172-
row.prop(params, layer + "_layers", index=i, toggle=True, text="", icon=icon)
134+
layout_layer_selection_ui(layout, params, "fk_extra_layers", "fk_layers")
135+
layout_layer_selection_ui(layout, params, "tweak_extra_layers", "tweak_layers")
173136

174137

175138
def create_sample(obj):

0 commit comments

Comments
 (0)