diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-03-24 18:45:16 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-03-24 18:51:05 +0300 |
commit | 5ae815cbc321dcc1c60224293ded7849940052a7 (patch) | |
tree | 8d3cc00893cb7514684d633005c632d663d2cc2c /rigify/legacy | |
parent | 51ceed0bfbd22e8270028b593c6832505d4c49e1 (diff) |
Rigify: properly set custom property defaults and overridable flags.
Refactor rigs to use the new make_property utility function,
and implement new 2.8 specific settings using it.
The default value is now important for NLA evaluation, and the
override flag will be used by the upcoming static override feature.
Default can be backported to 2.79 for 2.8 forward compatibility.
Diffstat (limited to 'rigify/legacy')
-rw-r--r-- | rigify/legacy/rigs/biped/limb_common.py | 46 | ||||
-rw-r--r-- | rigify/legacy/rigs/finger.py | 13 | ||||
-rw-r--r-- | rigify/legacy/rigs/neck_short.py | 24 | ||||
-rw-r--r-- | rigify/legacy/rigs/pitchipoy/limbs/arm.py | 11 | ||||
-rw-r--r-- | rigify/legacy/rigs/pitchipoy/limbs/leg.py | 10 | ||||
-rw-r--r-- | rigify/legacy/rigs/pitchipoy/limbs/paw.py | 10 | ||||
-rw-r--r-- | rigify/legacy/rigs/pitchipoy/limbs/super_limb.py | 31 | ||||
-rw-r--r-- | rigify/legacy/rigs/pitchipoy/super_face.py | 15 | ||||
-rw-r--r-- | rigify/legacy/rigs/pitchipoy/super_finger.py | 11 | ||||
-rw-r--r-- | rigify/legacy/rigs/pitchipoy/super_torso_turbo.py | 16 | ||||
-rw-r--r-- | rigify/legacy/rigs/pitchipoy/tentacle.py | 12 | ||||
-rw-r--r-- | rigify/legacy/rigs/spine.py | 35 |
12 files changed, 61 insertions, 173 deletions
diff --git a/rigify/legacy/rigs/biped/limb_common.py b/rigify/legacy/rigs/biped/limb_common.py index 05e3e59c..75dc3969 100644 --- a/rigify/legacy/rigs/biped/limb_common.py +++ b/rigify/legacy/rigs/biped/limb_common.py @@ -19,7 +19,6 @@ from math import pi import bpy -from rna_prop_ui import rna_idprop_ui_prop_get from mathutils import Vector from ...utils import angle_on_plane, align_bone_roll, align_bone_z_axis @@ -27,6 +26,7 @@ from ...utils import new_bone, copy_bone, put_bone, make_nonscaling_child from ...utils import strip_org, make_mechanism_name, make_deformer_name, insert_before_lr from ...utils import create_widget, create_limb_widget, create_line_widget, create_sphere_widget +from ....utils.mechanism import make_property class FKLimb: def __init__(self, obj, bone1, bone2, bone3, primary_rotation_axis, layers): @@ -155,17 +155,9 @@ class FKLimb: # Set up custom properties if parent is not None: - prop = rna_idprop_ui_prop_get(ulimb_p, "isolate", create=True) - ulimb_p["isolate"] = 0.0 - prop["soft_min"] = prop["min"] = 0.0 - prop["soft_max"] = prop["max"] = 1.0 - - prop = rna_idprop_ui_prop_get(ulimb_p, "stretch_length", create=True) - ulimb_p["stretch_length"] = 1.0 - prop["min"] = 0.05 - prop["max"] = 20.0 - prop["soft_min"] = 0.25 - prop["soft_max"] = 4.0 + make_property(ulimb_p, "isolate", 0.0) + + make_property(ulimb_p, "stretch_length", 1.0, min=0.05, max=20.0, soft_min=0.25, soft_max=4.0) # Stretch drivers def add_stretch_drivers(pose_bone): @@ -501,28 +493,13 @@ class IKLimb: # Set up custom properties if self.switch is True: - prop = rna_idprop_ui_prop_get(elimb_p, "ikfk_switch", create=True) - elimb_p["ikfk_switch"] = 0.0 - prop["soft_min"] = prop["min"] = 0.0 - prop["soft_max"] = prop["max"] = 1.0 + make_property(elimb_p, "ikfk_switch", 0.0) if self.pole_parent is not None: - prop = rna_idprop_ui_prop_get(pole_p, "follow", create=True) - pole_p["follow"] = 1.0 - prop["soft_min"] = prop["min"] = 0.0 - prop["soft_max"] = prop["max"] = 1.0 - - prop = rna_idprop_ui_prop_get(elimb_p, "stretch_length", create=True) - elimb_p["stretch_length"] = 1.0 - prop["min"] = 0.05 - prop["max"] = 20.0 - prop["soft_min"] = 0.25 - prop["soft_max"] = 4.0 - - prop = rna_idprop_ui_prop_get(elimb_p, "auto_stretch", create=True) - elimb_p["auto_stretch"] = 1.0 - prop["soft_min"] = prop["min"] = 0.0 - prop["soft_max"] = prop["max"] = 1.0 + make_property(pole_p, "follow", 1.0) + + make_property(elimb_p, "stretch_length", 1.0, min=0.05, max=20.0, soft_min=0.25, soft_max=4.0) + make_property(elimb_p, "auto_stretch", 1.0) # Stretch parameter drivers def add_stretch_drivers(pose_bone): @@ -1096,10 +1073,7 @@ class RubberHoseLimb: flimb1_smoother_p.bone.bbone_easeout = 1.0 # Custom properties - prop = rna_idprop_ui_prop_get(jhose_p, "smooth_bend", create=True) - jhose_p["smooth_bend"] = 0.0 - prop["soft_min"] = prop["min"] = 0.0 - prop["soft_max"] = prop["max"] = 1.0 + make_property(jhose_p, "smooth_bend", 0.0) # Constraints con = ulimb1_p.constraints.new('COPY_LOCATION') diff --git a/rigify/legacy/rigs/finger.py b/rigify/legacy/rigs/finger.py index 70bbc112..94684606 100644 --- a/rigify/legacy/rigs/finger.py +++ b/rigify/legacy/rigs/finger.py @@ -21,7 +21,6 @@ import re import bpy -from rna_prop_ui import rna_idprop_ui_prop_get from mathutils import Vector from ..utils import MetarigError @@ -30,6 +29,7 @@ from ..utils import connected_children_names from ..utils import strip_org, make_mechanism_name, make_deformer_name from ..utils import create_widget, create_limb_widget +from ...utils.mechanism import make_property class Rig: """ A finger rig. It takes a single chain of bones. @@ -187,15 +187,12 @@ class Rig: for bone in helpers: # Add custom prop prop_name = "bend_%02d" % i - prop = rna_idprop_ui_prop_get(pb[ctrl], prop_name, create=True) - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 if i == 1: - pb[ctrl][prop_name] = 0.0 + propval = 0.0 else: - pb[ctrl][prop_name] = val + propval = val + + make_property(pb[ctrl], prop_name, propval) # Add driver if 'X' in self.primary_rotation_axis: diff --git a/rigify/legacy/rigs/neck_short.py b/rigify/legacy/rigs/neck_short.py index 63174d40..e7743ddf 100644 --- a/rigify/legacy/rigs/neck_short.py +++ b/rigify/legacy/rigs/neck_short.py @@ -19,7 +19,6 @@ # <pep8 compliant> import bpy -from rna_prop_ui import rna_idprop_ui_prop_get from ..utils import MetarigError from ..utils import copy_bone, new_bone, put_bone @@ -27,6 +26,7 @@ from ..utils import connected_children_names from ..utils import strip_org, make_mechanism_name, make_deformer_name from ..utils import create_circle_widget +from ...utils.mechanism import make_property script1 = """ head_neck = ["%s", "%s"] @@ -190,27 +190,11 @@ class Rig: head_ctrl_p.custom_shape_transform = pb[self.org_bones[-1]] # Custom properties - prop = rna_idprop_ui_prop_get(head_ctrl_p, "inf_extent", create=True) - head_ctrl_p["inf_extent"] = 0.5 - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 - - prop = rna_idprop_ui_prop_get(head_ctrl_p, "neck_follow", create=True) - head_ctrl_p["neck_follow"] = 1.0 - prop["min"] = 0.0 - prop["max"] = 2.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 + make_property(head_ctrl_p, "inf_extent", 0.5) + make_property(head_ctrl_p, "neck_follow", 1.0, max=2.0, soft_max=1.0) if self.isolate: - prop = rna_idprop_ui_prop_get(head_ctrl_p, "isolate", create=True) - head_ctrl_p["isolate"] = 0.0 - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 + make_property(head_ctrl_p, "isolate", 0.0) # Constraints diff --git a/rigify/legacy/rigs/pitchipoy/limbs/arm.py b/rigify/legacy/rigs/pitchipoy/limbs/arm.py index 17bf5535..9de1657a 100644 --- a/rigify/legacy/rigs/pitchipoy/limbs/arm.py +++ b/rigify/legacy/rigs/pitchipoy/limbs/arm.py @@ -23,7 +23,8 @@ from ....utils import create_widget, copy_bone from ....utils import strip_org from .limb_utils import * from ..super_widgets import create_hand_widget -from rna_prop_ui import rna_idprop_ui_prop_get + +from .....utils.mechanism import make_property def create_arm( cls, bones ): org_bones = cls.org_bones @@ -81,13 +82,7 @@ def create_arm( cls, bones ): # Create ik/fk switch property pb_parent = pb[ bones['parent'] ] - pb_parent['IK_Strertch'] = 1.0 - prop = rna_idprop_ui_prop_get( pb_parent, 'IK_Strertch', create=True ) - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 - prop["description"] = 'IK Stretch' + prop = make_property(pb_parent, 'IK_Strertch', 1.0, description='IK Stretch') # Add driver to limit scale constraint influence b = bones['ik']['mch_str'] diff --git a/rigify/legacy/rigs/pitchipoy/limbs/leg.py b/rigify/legacy/rigs/pitchipoy/limbs/leg.py index 14fd6f13..96aa1c02 100644 --- a/rigify/legacy/rigs/pitchipoy/limbs/leg.py +++ b/rigify/legacy/rigs/pitchipoy/limbs/leg.py @@ -25,6 +25,8 @@ from rna_prop_ui import rna_idprop_ui_prop_get from ..super_widgets import create_foot_widget, create_ballsocket_widget from .limb_utils import * +from .....utils.mechanism import make_property + def create_leg( cls, bones ): org_bones = list( [cls.org_bones[0]] + connected_children_names(cls.obj, cls.org_bones[0]) @@ -236,13 +238,7 @@ def create_leg( cls, bones ): # Create ik/fk switch property pb_parent = pb[ bones['parent'] ] - pb_parent['IK_Strertch'] = 1.0 - prop = rna_idprop_ui_prop_get( pb_parent, 'IK_Strertch', create=True ) - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 - prop["description"] = 'IK Stretch' + prop = make_property(pb_parent, 'IK_Strertch', 1.0, description='IK Stretch') # Add driver to limit scale constraint influence b = bones['ik']['mch_str'] diff --git a/rigify/legacy/rigs/pitchipoy/limbs/paw.py b/rigify/legacy/rigs/pitchipoy/limbs/paw.py index 03ccd25f..7691007a 100644 --- a/rigify/legacy/rigs/pitchipoy/limbs/paw.py +++ b/rigify/legacy/rigs/pitchipoy/limbs/paw.py @@ -25,6 +25,8 @@ from rna_prop_ui import rna_idprop_ui_prop_get from ..super_widgets import create_foot_widget, create_ballsocket_widget from .limb_utils import * +from .....utils.mechanism import make_property + def create_paw( cls, bones ): org_bones = list( [cls.org_bones[0]] + connected_children_names(cls.obj, cls.org_bones[0]) @@ -105,13 +107,7 @@ def create_paw( cls, bones ): # Create ik/fk switch property pb_parent = pb[ bones['parent'] ] - pb_parent['IK_Strertch'] = 1.0 - prop = rna_idprop_ui_prop_get( pb_parent, 'IK_Strertch', create=True ) - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 - prop["description"] = 'IK Stretch' + prop = make_property(pb_parent, 'IK_Strertch', 1.0, description='IK Stretch') # Add driver to limit scale constraint influence b = bones['ik']['mch_str'] diff --git a/rigify/legacy/rigs/pitchipoy/limbs/super_limb.py b/rigify/legacy/rigs/pitchipoy/limbs/super_limb.py index 11bac486..5852ad46 100644 --- a/rigify/legacy/rigs/pitchipoy/limbs/super_limb.py +++ b/rigify/legacy/rigs/pitchipoy/limbs/super_limb.py @@ -10,10 +10,10 @@ from ....utils import strip_org, make_deformer_name, create_widget from ....utils import create_circle_widget, create_sphere_widget from ....utils import MetarigError, make_mechanism_name, org from ....utils import create_limb_widget, connected_children_names -from rna_prop_ui import rna_idprop_ui_prop_get from ..super_widgets import create_ikarrow_widget from math import trunc +from .....utils.mechanism import make_property class Rig: @@ -79,14 +79,7 @@ class Rig: name = 'FK_limb_follow' - pb[ mch ][ name ] = 0.0 - prop = rna_idprop_ui_prop_get( pb[ mch ], name, create = True ) - - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 - prop["description"] = name + make_property(pb[ mch ], name, 0.0) drv = pb[ mch ].constraints[ 0 ].driver_add("influence").driver @@ -335,17 +328,11 @@ class Rig: name = 'rubber_tweak' if i == trunc( len( tweaks[1:-1] ) / 2 ): - pb[t][name] = 0.0 + defval = 0.0 else: - pb[t][name] = 1.0 - - prop = rna_idprop_ui_prop_get( pb[t], name, create=True ) + defval = 1.0 - prop["min"] = 0.0 - prop["max"] = 2.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 - prop["description"] = name + make_property(pb[t], name, defval, max=2.0, soft_max=1.0) for j,d in enumerate(def_bones[:-1]): drvs = {} @@ -498,13 +485,7 @@ class Rig: pb_parent = pb[ parent ] # Create ik/fk switch property - pb_parent['IK/FK'] = 0.0 - prop = rna_idprop_ui_prop_get( pb_parent, 'IK/FK', create=True ) - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 - prop["description"] = 'IK/FK Switch' + prop = make_property(pb_parent, 'IK/FK', 0.0, description='IK/FK Switch') # Constrain org to IK and FK bones iks = [ ik['ctrl']['limb'] ] diff --git a/rigify/legacy/rigs/pitchipoy/super_face.py b/rigify/legacy/rigs/pitchipoy/super_face.py index ce593f55..4079309f 100644 --- a/rigify/legacy/rigs/pitchipoy/super_face.py +++ b/rigify/legacy/rigs/pitchipoy/super_face.py @@ -4,9 +4,9 @@ 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_circle_widget, create_sphere_widget, create_widget, create_cube_widget from ...utils import MetarigError -from rna_prop_ui import rna_idprop_ui_prop_get from .super_widgets import create_face_widget, create_eye_widget, create_eyes_widget, create_ear_widget, create_jaw_widget, create_teeth_widget +from ....utils.mechanism import make_property script = """ all_controls = [%s] @@ -920,16 +920,11 @@ class Rig: for bone, prop_name in zip( [ jaw_ctrl, eyes_ctrl ], [ jaw_prop, eyes_prop ] ): if bone == jaw_ctrl: - pb[ bone ][ prop_name ] = 0.0 + defval = 0.0 else: - pb[ bone ][ prop_name ] = 1.0 - - prop = rna_idprop_ui_prop_get( pb[ bone ], prop_name ) - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 - prop["description"] = prop_name + defval = 1.0 + + make_property(pb[ bone ], prop_name, defval) # Jaw drivers mch_jaws = all_bones['mch']['jaw'][1:-1] diff --git a/rigify/legacy/rigs/pitchipoy/super_finger.py b/rigify/legacy/rigs/pitchipoy/super_finger.py index 32172542..a1b7a506 100644 --- a/rigify/legacy/rigs/pitchipoy/super_finger.py +++ b/rigify/legacy/rigs/pitchipoy/super_finger.py @@ -4,7 +4,8 @@ from ...utils import copy_bone, flip_bone from ...utils import strip_org, make_deformer_name, connected_children_names, make_mechanism_name from ...utils import create_circle_widget, create_sphere_widget, create_widget from ...utils import MetarigError -from rna_prop_ui import rna_idprop_ui_prop_get + +from ....utils.mechanism import make_property script = """ controls = [%s] @@ -149,13 +150,7 @@ class Rig: pb[tip_name].lock_rotation = True,True,True pb[tip_name].lock_rotation_w = True - pb_master['finger_curve'] = 0.0 - prop = rna_idprop_ui_prop_get(pb_master, 'finger_curve') - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 - prop["description"] = "Rubber hose finger cartoon effect" + make_property(pb_master, 'finger_curve', 0.0, description="Rubber hose finger cartoon effect") # Pose settings for org, ctrl, deform, mch, mch_drv in zip(self.org_bones, ctrl_chain, def_chain, mch_chain, mch_drv_chain): diff --git a/rigify/legacy/rigs/pitchipoy/super_torso_turbo.py b/rigify/legacy/rigs/pitchipoy/super_torso_turbo.py index d9645adb..706b82cf 100644 --- a/rigify/legacy/rigs/pitchipoy/super_torso_turbo.py +++ b/rigify/legacy/rigs/pitchipoy/super_torso_turbo.py @@ -4,7 +4,8 @@ from ...utils import copy_bone, flip_bone, put_bone, org from ...utils import strip_org, make_deformer_name, connected_children_names from ...utils import create_circle_widget, create_sphere_widget, create_widget from ...utils import MetarigError, make_mechanism_name, create_cube_widget -from rna_prop_ui import rna_idprop_ui_prop_get + +from ....utils.mechanism import make_property script = """ controls = [%s] @@ -518,16 +519,11 @@ class Rig: for prop in props: if prop == 'neck_follow': - torso[prop] = 0.5 + defval = 0.5 else: - torso[prop] = 0.0 - - prop = rna_idprop_ui_prop_get( torso, prop, create=True ) - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 - prop["description"] = prop + defval = 0.0 + + make_property(torso, prop, defval) # driving the follow rotation switches for neck and head for bone, prop, in zip( owners, props ): diff --git a/rigify/legacy/rigs/pitchipoy/tentacle.py b/rigify/legacy/rigs/pitchipoy/tentacle.py index 0d24be16..c3a8c85a 100644 --- a/rigify/legacy/rigs/pitchipoy/tentacle.py +++ b/rigify/legacy/rigs/pitchipoy/tentacle.py @@ -4,7 +4,8 @@ from ...utils import strip_org, make_deformer_name, connected_children_names from ...utils import make_mechanism_name, put_bone, create_sphere_widget from ...utils import create_widget, create_circle_widget from ...utils import MetarigError -from rna_prop_ui import rna_idprop_ui_prop_get + +from ....utils.mechanism import make_property script = """ controls = [%s] @@ -263,14 +264,7 @@ class Rig: prop_names = [ prop_name_r, prop_name_s ] for prop_name in prop_names: - master_pb[prop_name] = 1.0 - - prop = rna_idprop_ui_prop_get( master_pb, prop_name ) - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 - prop["description"] = prop_name + make_property(master_pb, prop_name, 1.0) # driving the MCH follow rotation switch diff --git a/rigify/legacy/rigs/spine.py b/rigify/legacy/rigs/spine.py index 680a4ceb..44b9acc8 100644 --- a/rigify/legacy/rigs/spine.py +++ b/rigify/legacy/rigs/spine.py @@ -27,7 +27,6 @@ from math import floor import bpy from mathutils import Vector -from rna_prop_ui import rna_idprop_ui_prop_get from ..utils import MetarigError from ..utils import copy_bone, new_bone, flip_bone, put_bone @@ -35,6 +34,8 @@ from ..utils import connected_children_names from ..utils import strip_org, make_mechanism_name, make_deformer_name from ..utils import create_circle_widget, create_cube_widget +from ...utils.mechanism import make_property + script = """ main = "%s" spine = [%s] @@ -202,20 +203,10 @@ class Rig: bone = pb[par_name] # Custom bend_alpha property - prop = rna_idprop_ui_prop_get(pb[name], "bend_alpha", create=True) - pb[name]["bend_alpha"] = i / (len(self.org_bones) - 1) # set bend alpha - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 + make_property(pb[name], "bend_alpha", i / (len(self.org_bones) - 1)) # set bend alpha # Custom auto_rotate - prop = rna_idprop_ui_prop_get(pb[name], "auto_rotate", create=True) - pb[name]["auto_rotate"] = 1.0 - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 + make_property(pb[name], "auto_rotate", 1.0) # Constraints con1 = bone.constraints.new('COPY_TRANSFORMS') @@ -351,12 +342,11 @@ class Rig: main_control_p = pb[main_control] # Custom pivot_slide property - prop = rna_idprop_ui_prop_get(main_control_p, "pivot_slide", create=True) - main_control_p["pivot_slide"] = self.pivot_rest - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 1.0 / len(self.org_bones) - prop["soft_max"] = 1.0 - (1.0 / len(self.org_bones)) + make_property( + main_control_p, "pivot_slide", self.pivot_rest, + soft_min = 1.0 / len(self.org_bones), + soft_max = 1.0 - (1.0 / len(self.org_bones)) + ) # Anchor constraints con = bone_p.constraints.new('COPY_LOCATION') @@ -408,12 +398,7 @@ class Rig: for n in range(i + 1, j): bone = pb[flex_subs[n]] # Custom bend_alpha property - prop = rna_idprop_ui_prop_get(bone, "bend_alpha", create=True) - bone["bend_alpha"] = (n - i) / (j - i) # set bend alpha - prop["min"] = 0.0 - prop["max"] = 1.0 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 + make_property(bone, "bend_alpha", (n - i) / (j - i), overridable=False) # set bend alpha con = bone.constraints.new('COPY_TRANSFORMS') con.name = "copy_transforms" |