[Bf-blender-cvs] [682a74e0909] master: Armature: add B-Bone Y scale channel and extra flag fields to DNA.

Alexander Gavrilov noreply at git.blender.org
Fri Jun 18 17:56:28 CEST 2021


Commit: 682a74e0909ba4e669a3f282b3bc5da0ae81e4da
Author: Alexander Gavrilov
Date:   Fri Dec 11 19:17:39 2020 +0300
Branches: master
https://developer.blender.org/rB682a74e0909ba4e669a3f282b3bc5da0ae81e4da

Armature: add B-Bone Y scale channel and extra flag fields to DNA.

In addition to the base bone transformation itself, B-Bones have
controls that affect transformation of its segments. For rotation
the features are quite complete, allowing to both reorient the
Bezier handles via properties, and to control them using custom
handle bones. However for scaling there are two deficiencies.

First, there are only X and Y scale factors (actually X and Z),
while lengthwise all segments have the same scaling. The ease
option merely affects the shape of the curve, and does not cause
actual scaling.

Second, scaling can only be controlled via properties, thus
requiring up to 6 drivers per joint between B-Bones to transfer
scaling factors from the handle bone. This is very inefficient.

Finally, the Z channels are confusingly called Y.

This commit adds a B-Bone Y Scale channel and extra B-Bone flag
fields to DNA with appropriate versioning (including for F-Curves
and drivers) in preparation to addressing these limitations.

Functionality is not changed, so the new fields are not used
until the following commits.

Differential Revision: https://developer.blender.org/D9870

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

M	release/scripts/startup/bl_ui/properties_data_bone.py
M	source/blender/blenkernel/BKE_armature.h
M	source/blender/blenkernel/intern/action.c
M	source/blender/blenkernel/intern/armature.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
M	source/blender/draw/engines/overlay/overlay_armature.c
M	source/blender/editors/armature/armature_add.c
M	source/blender/editors/armature/armature_intern.h
M	source/blender/editors/armature/armature_utils.c
M	source/blender/editors/armature/pose_transform.c
M	source/blender/editors/armature/pose_utils.c
M	source/blender/editors/space_view3d/view3d_gizmo_armature.c
M	source/blender/makesdna/DNA_action_types.h
M	source/blender/makesdna/DNA_armature_types.h
M	source/blender/makesdna/intern/dna_rename_defs.h
M	source/blender/makesrna/intern/rna_armature.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py b/release/scripts/startup/bl_ui/properties_data_bone.py
index 6452ad8465b..7afc19f5e95 100644
--- a/release/scripts/startup/bl_ui/properties_data_bone.py
+++ b/release/scripts/startup/bl_ui/properties_data_bone.py
@@ -156,11 +156,11 @@ class BONE_PT_curved(BoneButtonsPanel, Panel):
 
         col = topcol.column(align=True)
         col.prop(bbone, "bbone_curveinx", text="Curve In X")
-        col.prop(bbone, "bbone_curveiny", text="In Y")
+        col.prop(bbone, "bbone_curveinz", text="Z")
 
         col = topcol.column(align=True)
         col.prop(bbone, "bbone_curveoutx", text="Curve Out X")
-        col.prop(bbone, "bbone_curveouty", text="Out Y")
+        col.prop(bbone, "bbone_curveoutz", text="Z")
 
         col = topcol.column(align=True)
         col.prop(bbone, "bbone_rollin", text="Roll In")
@@ -168,12 +168,10 @@ class BONE_PT_curved(BoneButtonsPanel, Panel):
         col.prop(bone, "use_endroll_as_inroll")
 
         col = topcol.column(align=True)
-        col.prop(bbone, "bbone_scaleinx", text="Scale In X")
-        col.prop(bbone, "bbone_scaleiny", text="In Y")
+        col.prop(bbone, "bbone_scalein", text="Scale In")
 
         col = topcol.column(align=True)
-        col.prop(bbone, "bbone_scaleoutx", text="Scale Out X")
-        col.prop(bbone, "bbone_scaleouty", text="Out Y")
+        col.prop(bbone, "bbone_scaleout", text="Scale Out")
 
         col = topcol.column(align=True)
         col.prop(bbone, "bbone_easein", text="Ease In")
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 3002a9cc10d..112b8bf3ad4 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -80,11 +80,10 @@ typedef struct EditBone {
   /* Bendy-Bone parameters */
   short segments;
   float roll1, roll2;
-  float curve_in_x, curve_in_y;
-  float curve_out_x, curve_out_y;
+  float curve_in_x, curve_in_z;
+  float curve_out_x, curve_out_z;
   float ease1, ease2;
-  float scale_in_x, scale_in_y;
-  float scale_out_x, scale_out_y;
+  float scale_in[3], scale_out[3];
 
   /** for envelope scaling */
   float oldlength;
@@ -92,6 +91,10 @@ typedef struct EditBone {
   /** Type of next/prev bone handles */
   char bbone_prev_type;
   char bbone_next_type;
+  /** B-Bone flags. */
+  int bbone_flag;
+  short bbone_prev_flag;
+  short bbone_next_flag;
   /** Next/prev bones to use as handle references when calculating bbones (optional) */
   struct EditBone *bbone_prev;
   struct EditBone *bbone_next;
@@ -298,8 +301,8 @@ typedef struct BBoneSplineParameters {
   /* Control values. */
   float ease1, ease2;
   float roll1, roll2;
-  float scale_in_x, scale_in_y, scale_out_x, scale_out_y;
-  float curve_in_x, curve_in_y, curve_out_x, curve_out_y;
+  float scale_in[3], scale_out[3];
+  float curve_in_x, curve_in_z, curve_out_x, curve_out_z;
 } BBoneSplineParameters;
 
 void BKE_pchan_bbone_handles_get(struct bPoseChannel *pchan,
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index a7e36b09516..5db2eceb0d1 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -665,8 +665,8 @@ bPoseChannel *BKE_pose_channel_ensure(bPose *pose, const char *name)
   unit_axis_angle(chan->rotAxis, &chan->rotAngle);
   chan->size[0] = chan->size[1] = chan->size[2] = 1.0f;
 
-  chan->scale_in_x = chan->scale_in_y = 1.0f;
-  chan->scale_out_x = chan->scale_out_y = 1.0f;
+  copy_v3_fl(chan->scale_in, 1.0f);
+  copy_v3_fl(chan->scale_out, 1.0f);
 
   chan->limitmin[0] = chan->limitmin[1] = chan->limitmin[2] = -M_PI;
   chan->limitmax[0] = chan->limitmax[1] = chan->limitmax[2] = M_PI;
@@ -1659,11 +1659,12 @@ void BKE_pose_rest(bPose *pose, bool selected_bones_only)
     pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f;
 
     pchan->roll1 = pchan->roll2 = 0.0f;
-    pchan->curve_in_x = pchan->curve_in_y = 0.0f;
-    pchan->curve_out_x = pchan->curve_out_y = 0.0f;
+    pchan->curve_in_x = pchan->curve_in_z = 0.0f;
+    pchan->curve_out_x = pchan->curve_out_z = 0.0f;
     pchan->ease1 = pchan->ease2 = 0.0f;
-    pchan->scale_in_x = pchan->scale_in_y = 1.0f;
-    pchan->scale_out_x = pchan->scale_out_y = 1.0f;
+
+    copy_v3_fl(pchan->scale_in, 1.0f);
+    copy_v3_fl(pchan->scale_out, 1.0f);
 
     pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE | POSE_BBONE_SHAPE);
   }
@@ -1686,15 +1687,14 @@ void BKE_pose_copy_pchan_result(bPoseChannel *pchanto, const bPoseChannel *pchan
   pchanto->roll1 = pchanfrom->roll1;
   pchanto->roll2 = pchanfrom->roll2;
   pchanto->curve_in_x = pchanfrom->curve_in_x;
-  pchanto->curve_in_y = pchanfrom->curve_in_y;
+  pchanto->curve_in_z = pchanfrom->curve_in_z;
   pchanto->curve_out_x = pchanfrom->curve_out_x;
-  pchanto->curve_out_y = pchanfrom->curve_out_y;
+  pchanto->curve_out_z = pchanfrom->curve_out_z;
   pchanto->ease1 = pchanfrom->ease1;
   pchanto->ease2 = pchanfrom->ease2;
-  pchanto->scale_in_x = pchanfrom->scale_in_x;
-  pchanto->scale_in_y = pchanfrom->scale_in_y;
-  pchanto->scale_out_x = pchanfrom->scale_out_x;
-  pchanto->scale_out_y = pchanfrom->scale_out_y;
+
+  copy_v3_v3(pchanto->scale_in, pchanfrom->scale_in);
+  copy_v3_v3(pchanto->scale_out, pchanfrom->scale_out);
 
   pchanto->rotmode = pchanfrom->rotmode;
   pchanto->flag = pchanfrom->flag;
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 4ea71922df5..f6b861946ec 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1103,7 +1103,7 @@ void BKE_pchan_bbone_spline_params_get(struct bPoseChannel *pchan,
     param->roll1 = bone->roll1 + (!rest ? pchan->roll1 : 0.0f);
     param->roll2 = bone->roll2 + (!rest ? pchan->roll2 : 0.0f);
 
-    if (bone->flag & BONE_ADD_PARENT_END_ROLL) {
+    if (bone->bbone_flag & BBONE_ADD_PARENT_END_ROLL) {
       if (prev) {
         if (prev->bone) {
           param->roll1 += prev->bone->roll2;
@@ -1115,17 +1115,20 @@ void BKE_pchan_bbone_spline_params_get(struct bPoseChannel *pchan,
       }
     }
 
-    param->scale_in_x = bone->scale_in_x * (!rest ? pchan->scale_in_x : 1.0f);
-    param->scale_in_y = bone->scale_in_y * (!rest ? pchan->scale_in_y : 1.0f);
-    param->scale_out_x = bone->scale_out_x * (!rest ? pchan->scale_out_x : 1.0f);
-    param->scale_out_y = bone->scale_out_y * (!rest ? pchan->scale_out_y : 1.0f);
+    copy_v3_v3(param->scale_in, bone->scale_in);
+    copy_v3_v3(param->scale_out, bone->scale_out);
 
-    /* Extra curve x / y */
+    if (!rest) {
+      mul_v3_v3(param->scale_in, pchan->scale_in);
+      mul_v3_v3(param->scale_out, pchan->scale_out);
+    }
+
+    /* Extra curve x / z */
     param->curve_in_x = bone->curve_in_x + (!rest ? pchan->curve_in_x : 0.0f);
-    param->curve_in_y = bone->curve_in_y + (!rest ? pchan->curve_in_y : 0.0f);
+    param->curve_in_z = bone->curve_in_z + (!rest ? pchan->curve_in_z : 0.0f);
 
     param->curve_out_x = bone->curve_out_x + (!rest ? pchan->curve_out_x : 0.0f);
-    param->curve_out_y = bone->curve_out_y + (!rest ? pchan->curve_out_y : 0.0f);
+    param->curve_out_z = bone->curve_out_z + (!rest ? pchan->curve_out_z : 0.0f);
   }
 }
 
@@ -1250,13 +1253,13 @@ void BKE_pchan_bbone_handles_compute(const BBoneSplineParameters *param,
      * in the bone length getting scaled up too (from 1 to 8), causing the curve to flatten out.
      */
     const float xscale_correction = (param->do_scale) ? param->scale[0] : 1.0f;
-    const float yscale_correction = (param->do_scale) ? param->scale[2] : 1.0f;
+    const float zscale_correction = (param->do_scale) ? param->scale[2] : 1.0f;
 
     h1[0] += param->curve_in_x * xscale_correction;
-    h1[2] += param->curve_in_y * yscale_correction;
+    h1[2] += param->curve_in_z * zscale_correction;
 
     h2[0] += param->curve_out_x * xscale_correction;
-    h2[2] += param->curve_out_y * yscale_correction;
+    h2[2] += param->curve_out_z * zscale_correction;
   }
 }
 
@@ -1266,7 +1269,7 @@ static void make_bbone_spline_matrix(BBoneSplineParameters *param,
                                      const float axis[3],
                                      float roll,
                                      float scalex,
-                                     float scaley,
+                                     float scalez,
                                      float result[4][4])
 {
   float mat3[3][3];
@@ -1283,7 +1286,7 @@ static void make_bbone_spline_matrix(BBoneSplineParameters *param,
 
   /* BBone scale... */
   mul_v3_fl(result[0], scalex);
-  mul_v3_fl(result[2], scaley);
+  mul_v3_fl(result[2], scalez);
 }
 
 /* Fade from first to second derivative when the handle is very short. */
@@ -1352,8 +1355,8 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters *param,
                              bezt_controls[0],
                              axis,
                              roll1,
-                             param->scale_in_x,
-                             param->scale_in_y,
+                             param->scale_in[0],
+                             param->scale_in[2],
                              result_array[0].mat);
 
     for (int a = 1; a < param->segments; a++) {
@@ -1361,11 +1364,11 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters *param,
 
       float fac = ((float)a) / param->segments;
       float roll = interpf(roll2, roll1, fac);
-      float scalex = interpf(param->scale_out_x, param->scale_in_x, fac);
-      float scaley = interpf(param->scale_out_y, param->scale_in_y, fac);
+      float scalex = interpf(param->scale_out[0], param->scale_in[0], fac);
+      float scalez = interpf(param->scale_out[2], param->scale_in[2], fac);
 
       make_bbone_spline_matrix(
-          param, scalemats, cur, axis, roll, scalex, scaley, result_array[a].mat);
+          param, scalemats, cur, axis, roll, scalex, scalez, result_array[a].mat);
     }
 
     negate_v3(bezt_deriv2[1]);
@@ -1375,8 +1378,8 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters *param,
                              bezt_controls[3],
                              axis,
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list