[Bf-extensions-cvs] [5ae815cb] master: Rigify: properly set custom property defaults and overridable flags.

Alexander Gavrilov noreply at git.blender.org
Sun Mar 24 16:51:46 CET 2019


Commit: 5ae815cbc321dcc1c60224293ded7849940052a7
Author: Alexander Gavrilov
Date:   Sun Mar 24 18:45:16 2019 +0300
Branches: master
https://developer.blender.org/rBA5ae815cbc321dcc1c60224293ded7849940052a7

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.

===================================================================

M	rigify/legacy/rigs/biped/limb_common.py
M	rigify/legacy/rigs/finger.py
M	rigify/legacy/rigs/neck_short.py
M	rigify/legacy/rigs/pitchipoy/limbs/arm.py
M	rigify/legacy/rigs/pitchipoy/limbs/leg.py
M	rigify/legacy/rigs/pitchipoy/limbs/paw.py
M	rigify/legacy/rigs/pitchipoy/limbs/super_limb.py
M	rigify/legacy/rigs/pitchipoy/super_face.py
M	rigify/legacy/rigs/pitchipoy/super_finger.py
M	rigify/legacy/rigs/pitchipoy/super_torso_turbo.py
M	rigify/legacy/rigs/pitchipoy/tentacle.py
M	rigify/legacy/rigs/spine.py
M	rigify/rigs/experimental/super_chain.py
M	rigify/rigs/faces/super_face.py
M	rigify/rigs/limbs/arm.py
M	rigify/rigs/limbs/leg.py
M	rigify/rigs/limbs/paw.py
M	rigify/rigs/limbs/super_finger.py
M	rigify/rigs/spines/super_spine.py
M	rigify/utils/mechanism.py

===================================================================

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 11b

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list