[Bf-blender-cvs] [51bf04383aa] master: Fix T78045: CTL-ALT-S does nothing in pose mode and crashes when called from the menu

Germano Cavalcante noreply at git.blender.org
Tue Jun 23 00:06:42 CEST 2020


Commit: 51bf04383aa0300b60bca71c5ce388e338751932
Author: Germano Cavalcante
Date:   Mon Jun 22 19:06:04 2020 -0300
Branches: master
https://developer.blender.org/rB51bf04383aa0300b60bca71c5ce388e338751932

Fix T78045: CTL-ALT-S does nothing in pose mode and crashes when called from the menu

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

M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform_convert.c
M	source/blender/editors/transform/transform_convert_armature.c
M	source/blender/editors/transform/transform_mode.c
M	source/blender/editors/transform/transform_mode.h
M	source/blender/editors/transform/transform_mode_bbone_resize.c
M	source/blender/editors/transform/transform_mode_boneenvelope.c
M	source/blender/editors/transform/transform_ops.c

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

diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index b02b1814c67..00f1d78881f 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1819,6 +1819,8 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
   int options = 0;
   PropertyRNA *prop;
 
+  mode = transform_mode_really_used(C, mode);
+
   t->context = C;
 
   /* added initialize, for external calls to set stuff in TransInfo, like undo string */
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index 064057990e0..e1e3c3d81b5 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -1294,19 +1294,6 @@ void createTransData(bContext *C, TransInfo *t)
     }
   }
 
-  /* exception... hackish, we want bonesize to use bone orientation matrix (ton) */
-  if (t->mode == TFM_BONESIZE) {
-    t->flag &= ~(T_EDIT | T_POINTS);
-    t->flag |= T_POSE;
-    t->obedit_type = -1;
-    t->data_type = TC_NONE;
-
-    FOREACH_TRANS_DATA_CONTAINER (t, tc) {
-      tc->poseobj = tc->obedit;
-      tc->obedit = NULL;
-    }
-  }
-
   BLI_assert((!(t->flag & T_EDIT)) == (!(t->obedit_type != -1)));
 }
 
diff --git a/source/blender/editors/transform/transform_convert_armature.c b/source/blender/editors/transform/transform_convert_armature.c
index 75b51b3d2c4..ac953774d78 100644
--- a/source/blender/editors/transform/transform_convert_armature.c
+++ b/source/blender/editors/transform/transform_convert_armature.c
@@ -667,20 +667,16 @@ static void add_pose_transdata(
   mul_m3_m3m3(td->axismtx, omat, pmat);
   normalize_m3(td->axismtx);
 
-  if (ELEM(t->mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
-    bArmature *arm = tc->poseobj->data;
-
-    if ((t->mode == TFM_BONE_ENVELOPE_DIST) || (arm->drawtype == ARM_ENVELOPE)) {
-      td->loc = NULL;
-      td->val = &bone->dist;
-      td->ival = bone->dist;
-    }
-    else {
-      // abusive storage of scale in the loc pointer :)
-      td->loc = &bone->xwidth;
-      copy_v3_v3(td->iloc, td->loc);
-      td->val = NULL;
-    }
+  if (t->mode == TFM_BONE_ENVELOPE_DIST) {
+    td->loc = NULL;
+    td->val = &bone->dist;
+    td->ival = bone->dist;
+  }
+  else if (t->mode == TFM_BONESIZE) {
+    // abusive storage of scale in the loc pointer :)
+    td->loc = &bone->xwidth;
+    copy_v3_v3(td->iloc, td->loc);
+    td->val = NULL;
   }
 
   /* in this case we can do target-less IK grabbing */
@@ -988,7 +984,7 @@ void createTransArmatureVerts(TransInfo *t)
         }
         else if (ELEM(t->mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
           if (ebo->flag & BONE_SELECTED) {
-            if ((t->mode == TFM_BONE_ENVELOPE_DIST) || (arm->drawtype == ARM_ENVELOPE)) {
+            if (t->mode == TFM_BONE_ENVELOPE_DIST) {
               td->loc = NULL;
               td->val = &ebo->dist;
               td->ival = ebo->dist;
diff --git a/source/blender/editors/transform/transform_mode.c b/source/blender/editors/transform/transform_mode.c
index f028044809f..baf4bba80df 100644
--- a/source/blender/editors/transform/transform_mode.c
+++ b/source/blender/editors/transform/transform_mode.c
@@ -50,6 +50,23 @@
 /* Own include. */
 #include "transform_mode.h"
 
+int transform_mode_really_used(bContext *C, int mode)
+{
+  if (mode == TFM_BONESIZE) {
+    Object *ob = CTX_data_active_object(C);
+    BLI_assert(ob);
+    if (ob->type != OB_ARMATURE) {
+      return TFM_RESIZE;
+    }
+    bArmature *arm = ob->data;
+    if (arm->drawtype == ARM_ENVELOPE) {
+      return TFM_BONE_ENVELOPE_DIST;
+    }
+  }
+
+  return mode;
+}
+
 bool transdata_check_local_center(TransInfo *t, short around)
 {
   return ((around == V3D_AROUND_LOCAL_ORIGINS) &&
@@ -1174,25 +1191,12 @@ void transform_mode_init(TransInfo *t, wmOperator *op, const int mode)
     case TFM_CREASE:
       initCrease(t);
       break;
-    case TFM_BONESIZE: { /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */
-      /* Note: we have to pick one, use the active object. */
-      TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_OK(t);
-      bArmature *arm = tc->poseobj->data;
-      if (arm->drawtype == ARM_ENVELOPE) {
-        initBoneEnvelope(t);
-        t->mode = TFM_BONE_ENVELOPE_DIST;
-      }
-      else {
-        initBoneSize(t);
-      }
+    case TFM_BONESIZE:
+      initBoneSize(t);
       break;
-    }
     case TFM_BONE_ENVELOPE:
-      initBoneEnvelope(t);
-      break;
     case TFM_BONE_ENVELOPE_DIST:
       initBoneEnvelope(t);
-      t->mode = TFM_BONE_ENVELOPE_DIST;
       break;
     case TFM_EDGE_SLIDE:
     case TFM_VERT_SLIDE: {
diff --git a/source/blender/editors/transform/transform_mode.h b/source/blender/editors/transform/transform_mode.h
index 464deff983b..0d663377da3 100644
--- a/source/blender/editors/transform/transform_mode.h
+++ b/source/blender/editors/transform/transform_mode.h
@@ -26,6 +26,7 @@
 #define __TRANSFORM_MODE_H__
 
 struct AnimData;
+struct bContext;
 struct LinkNode;
 struct TransData;
 struct TransDataContainer;
@@ -40,6 +41,7 @@ typedef struct TransDataGenericSlideVert {
 } TransDataGenericSlideVert;
 
 /* transform_mode.c */
+int transform_mode_really_used(struct bContext *C, int mode);
 bool transdata_check_local_center(TransInfo *t, short around);
 bool transform_mode_is_changeable(const int mode);
 void protectedTransBits(short protectflag, float vec[3]);
diff --git a/source/blender/editors/transform/transform_mode_bbone_resize.c b/source/blender/editors/transform/transform_mode_bbone_resize.c
index 77850e74785..2c2253630c0 100644
--- a/source/blender/editors/transform/transform_mode_bbone_resize.c
+++ b/source/blender/editors/transform/transform_mode_bbone_resize.c
@@ -132,6 +132,11 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2]))
 
   if (t->con.applySize) {
     t->con.applySize(t, NULL, NULL, mat);
+    for (i = 0; i < 3; i++) {
+      if (!(t->con.mode & (CON_AXIS0 << i))) {
+        t->values_final[i] = 1.0f;
+      }
+    }
   }
 
   copy_m3_m3(t->mat, mat);  // used in gizmo
diff --git a/source/blender/editors/transform/transform_mode_boneenvelope.c b/source/blender/editors/transform/transform_mode_boneenvelope.c
index 7045d190478..b7a34769f5a 100644
--- a/source/blender/editors/transform/transform_mode_boneenvelope.c
+++ b/source/blender/editors/transform/transform_mode_boneenvelope.c
@@ -96,7 +96,6 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
 
 void initBoneEnvelope(TransInfo *t)
 {
-  t->mode = TFM_BONE_ENVELOPE;
   t->transform = applyBoneEnvelope;
 
   initMouseInputMode(t, &t->mouse, INPUT_SPRING);
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 95249f4d17b..f86bcc41bee 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -1049,11 +1049,11 @@ static void TRANSFORM_OT_bbone_resize(struct wmOperatorType *ot)
   ot->exec = transform_exec;
   ot->modal = transform_modal;
   ot->cancel = transform_cancel;
-  ot->poll = ED_operator_editarmature;
+  ot->poll = ED_operator_object_active;
   ot->poll_property = transform_poll_property;
 
   RNA_def_float_translation(
-      ot->srna, "value", 2, VecOne, -FLT_MAX, FLT_MAX, "Display Size", "", -FLT_MAX, FLT_MAX);
+      ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Display Size", "", -FLT_MAX, FLT_MAX);
 
   WM_operatortype_props_advanced_begin(ot);



More information about the Bf-blender-cvs mailing list