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:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-02-16 13:57:57 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-03-14 14:39:16 +0300
commit36e8d00aec705b06008a0bc334fe266448b4f2c2 (patch)
tree02bf0290ec6423c611e3cd4ad49c69cb77acb67e /rigify/rigs/limbs/leg.py
parenteabb5cddf79e5fae3ca429242cf2c6f5a272920e (diff)
Rigify: add support for user-defined rig packages and related utilities.
As suggested by @icappielo, and after discussion with @meta-androcto, I start a public request to commit third-party contributions already accepted to https://github.com/eigen-value/rigify/tree/rigify_0.6_beta Specifically, this includes: * User-defined rig package (feature set) support by @pioverfour. This allows users to install pre-packaged rig sets via zip files, which become accessible together with built-in rigs, as discussed in T52758. https://github.com/eigen-value/rigify/pull/1 * Modularization of python script generation, allowing rigs to add their own utility functions and operators to the generated script. This is critical to make custom rig support really useful. https://github.com/eigen-value/rigify/pull/5 * The utils.py file is split into multiple modules with a backward compatibility proxy for old functions. * Automatic verification that different rigs don't try to create different rig settings with the same name to alleviate increased risk of namespace conflicts with custom rigs. https://github.com/eigen-value/rigify/pull/7 * New utility class that implements bone layer selection UI. https://github.com/eigen-value/rigify/pull/6 * New utilities to replace copy & pasted boilerplate code for creating custom properties, constraints and drivers. https://github.com/eigen-value/rigify/pull/11 Some other random changes by MAD have likely slipped through. These changes have already been extensively discussed and accepted into the branch by @luciorossi, so I see no reason not to commit them to the official repository to be tested during 2.8 beta. Reviewers: icappiello Differential Revision: https://developer.blender.org/D4364
Diffstat (limited to 'rigify/rigs/limbs/leg.py')
-rw-r--r--rigify/rigs/limbs/leg.py102
1 files changed, 18 insertions, 84 deletions
diff --git a/rigify/rigs/limbs/leg.py b/rigify/rigs/limbs/leg.py
index 4f53fb89..743e5703 100644
--- a/rigify/rigs/limbs/leg.py
+++ b/rigify/rigs/limbs/leg.py
@@ -1,15 +1,17 @@
-import bpy, re, math
+import bpy, math
from ..widgets import create_foot_widget, create_ballsocket_widget, create_gear_widget
from .ui import create_script
from .limb_utils import *
from mathutils import Vector
-from ...utils import copy_bone, flip_bone, put_bone, create_cube_widget
-from ...utils import strip_org, strip_mch, make_deformer_name, create_widget
+from ...utils import copy_bone, flip_bone, put_bone
+from ...utils import strip_org, strip_mch
from ...utils import create_circle_widget, create_sphere_widget, create_line_widget
-from ...utils import MetarigError, make_mechanism_name, org
+from ...utils import MetarigError, make_mechanism_name
from ...utils import create_limb_widget, connected_children_names
from ...utils import align_bone_y_axis, align_bone_x_axis, align_bone_z_axis
+from ...rig_ui_template import UTILITIES_RIG_LEG, REGISTER_RIG_LEG
+from ...utils import ControlLayersOption
from rna_prop_ui import rna_idprop_ui_prop_get
from ..widgets import create_ikarrow_widget
from math import trunc, pi
@@ -47,16 +49,6 @@ class Rig:
self.rot_axis = params.rotation_axis
self.auto_align_extremity = params.auto_align_extremity
- # Assign values to tweak/FK layers props if opted by user
- if params.tweak_extra_layers:
- self.tweak_layers = list(params.tweak_layers)
- else:
- self.tweak_layers = None
-
- if params.fk_extra_layers:
- self.fk_layers = list(params.fk_layers)
- else:
- self.fk_layers = None
def orient_org_bones(self):
@@ -293,8 +285,7 @@ class Rig:
create_sphere_widget(self.obj, t, bone_transform_name=None)
- if self.tweak_layers:
- pb[t].bone.layers = self.tweak_layers
+ ControlLayersOption.TWEAK.assign(self.params, pb, tweaks['ctrl'])
return tweaks
@@ -574,9 +565,7 @@ class Rig:
create_circle_widget(self.obj, ctrls[2], radius=0.4, head_tail=0.0)
- for c in ctrls:
- if self.fk_layers:
- pb[c].bone.layers = self.fk_layers
+ ControlLayersOption.FK.assign(self.params, pb, ctrls)
return {'ctrl': ctrls, 'mch': mch}
@@ -1390,7 +1379,12 @@ class Rig:
script += extra_script % (controls_string, bones['main_parent'], 'IK_follow',
'pole_follow', 'pole_follow', 'root/parent', 'root/parent')
- return [script]
+ return {
+ 'script': [script],
+ 'utilities': UTILITIES_RIG_LEG,
+ 'register': REGISTER_RIG_LEG,
+ 'noparent_bones': [bones['ik']['mch_foot'][i] for i in [0,1]],
+ }
def add_parameters(params):
@@ -1431,30 +1425,8 @@ def add_parameters(params):
)
# Setting up extra layers for the FK and tweak
- params.tweak_extra_layers = bpy.props.BoolProperty(
- name = "tweak_extra_layers",
- default = True,
- description = ""
- )
-
- params.tweak_layers = bpy.props.BoolVectorProperty(
- size = 32,
- description = "Layers for the tweak controls to be on",
- default = tuple( [ i == 1 for i in range(0, 32) ] )
- )
-
- # Setting up extra layers for the FK and tweak
- params.fk_extra_layers = bpy.props.BoolProperty(
- name = "fk_extra_layers",
- default = True,
- description = ""
- )
-
- params.fk_layers = bpy.props.BoolVectorProperty(
- size = 32,
- description = "Layers for the FK controls to be on",
- default = tuple( [ i == 1 for i in range(0, 32) ] )
- )
+ ControlLayersOption.FK.add_parameters(params)
+ ControlLayersOption.TWEAK.add_parameters(params)
def parameters_ui(layout, params):
@@ -1474,46 +1446,8 @@ def parameters_ui(layout, params):
r = layout.row()
r.prop(params, "bbones")
- bone_layers = bpy.context.active_pose_bone.bone.layers[:]
-
- for layer in ['fk', 'tweak']:
- r = layout.row()
- r.prop(params, layer + "_extra_layers")
- r.active = params.tweak_extra_layers
-
- 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 + "_layers", 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 + "_layers", 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 + "_layers", 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 + "_layers", index=i, toggle=True, text="", icon=icon)
+ ControlLayersOption.FK.parameters_ui(layout, params)
+ ControlLayersOption.TWEAK.parameters_ui(layout, params)
def create_sample(obj):