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
path: root/rigify
diff options
context:
space:
mode:
authorDemeter Dzadik <demeter@blender.studio>2020-09-07 17:18:44 +0300
committerDemeter Dzadik <demeter@blender.studio>2020-09-07 17:21:03 +0300
commit943e7dfb1c0142afbca812447d2d77aaef5c8591 (patch)
treef7e3cfcb39ec857c9b73804d0d769ee9932d592e /rigify
parentda2b17e46cb937493454e3f47498cc76a0a51404 (diff)
Rigify: Code Cleanup: Use ControlLayersOption class
This class exists specifically for the purpose of defining and drawing the UI for bone layer assignment parameters, as seen in other rig types like super_chain, limb_rigs, simple_tentacle, etc. Only super_face was missing it for some reason. Although the way it is used may be questionable, it's consistent with the rest of the codebase. No functional changes. Note for future: I would also like to use the ControlLayersOption class in even more places, and also maybe rename it and make improvements to it as needed. This would also be part of a bigger design of how Rigify handles bone organization, which I should write down. Reviewed By: sybren Differential Revision: https://developer.blender.org/D8802
Diffstat (limited to 'rigify')
-rw-r--r--rigify/rigs/faces/super_face.py65
-rw-r--r--rigify/utils/layers.py4
2 files changed, 10 insertions, 59 deletions
diff --git a/rigify/rigs/faces/super_face.py b/rigify/rigs/faces/super_face.py
index f945a855..e3617695 100644
--- a/rigify/rigs/faces/super_face.py
+++ b/rigify/rigs/faces/super_face.py
@@ -4,6 +4,7 @@ from ...utils import copy_bone, flip_bone
from ...utils import org, strip_org, make_deformer_name, connected_children_names, make_mechanism_name
from ...utils import create_widget
from ...utils.mechanism import make_property
+from ...utils.layers import ControlLayersOption
from ..widgets import create_face_widget, create_eye_widget, create_eyes_widget, create_ear_widget, create_jaw_widget, create_teeth_widget
@@ -1029,69 +1030,15 @@ def add_parameters(params):
"""
# Setting up extra layers for the tweak bones
- params.primary_layers_extra = bpy.props.BoolProperty(
- name="primary_layers_extra",
- default=True,
- description=""
- )
- params.primary_layers = bpy.props.BoolVectorProperty(
- size=32,
- description="Layers for the primary controls to be on",
- default=tuple([i == 1 for i in range(0, 32)])
- )
- params.secondary_layers_extra = bpy.props.BoolProperty(
- name="secondary_layers_extra",
- default=True,
- description=""
- )
- params.secondary_layers = bpy.props.BoolVectorProperty(
- size=32,
- description="Layers for the secondary controls to be on",
- default=tuple([i == 1 for i in range(0, 32)])
- )
+ ControlLayersOption.FACE_PRIMARY.add_parameters(params)
+ ControlLayersOption.FACE_SECONDARY.add_parameters(params)
def parameters_ui(layout, params):
""" Create the ui for the rig parameters."""
- layers = ["primary_layers", "secondary_layers"]
-
- bone_layers = bpy.context.active_pose_bone.bone.layers[:]
-
- for layer in layers:
- r = layout.row()
- r.prop( params, layer + "_extra" )
- r.active = getattr( params, layer + "_extra" )
-
- col = r.column(align=True)
- row = col.row(align=True)
- for i in range(8):
- icon = "NONE"
- if bone_layers[i]:
- icon = "LAYER_ACTIVE"
- row.prop(params, layer, index=i, toggle=True, text="", icon=icon)
-
- row = col.row(align=True)
- for i in range(16, 24):
- icon = "NONE"
- if bone_layers[i]:
- icon = "LAYER_ACTIVE"
- row.prop(params, layer, index=i, toggle=True, text="", icon=icon)
-
- col = r.column(align=True)
- row = col.row(align=True)
-
- for i in range(8, 16):
- icon = "NONE"
- if bone_layers[i]:
- icon = "LAYER_ACTIVE"
- row.prop(params, layer, index=i, toggle=True, text="", icon=icon)
-
- row = col.row(align=True)
- for i in range(24, 32):
- icon = "NONE"
- if bone_layers[i]:
- icon = "LAYER_ACTIVE"
- row.prop(params, layer, index=i, toggle=True, text="", icon=icon)
+
+ ControlLayersOption.FACE_PRIMARY.parameters_ui(layout, params)
+ ControlLayersOption.FACE_SECONDARY.parameters_ui(layout, params)
def create_sample(obj):
diff --git a/rigify/utils/layers.py b/rigify/utils/layers.py
index 7d85cd4d..52deeac0 100644
--- a/rigify/utils/layers.py
+++ b/rigify/utils/layers.py
@@ -137,3 +137,7 @@ class ControlLayersOption:
ControlLayersOption.FK = ControlLayersOption('fk', description="Layers for the FK controls to be on")
ControlLayersOption.TWEAK = ControlLayersOption('tweak', description="Layers for the tweak controls to be on")
+
+# Layer parameters used by the super_face rig.
+ControlLayersOption.FACE_PRIMARY = ControlLayersOption('primary', description="Layers for the primary controls to be on")
+ControlLayersOption.FACE_SECONDARY = ControlLayersOption('secondary', description="Layers for the secondary controls to be on")