[Bf-blender-cvs] [76c64af00ca] master: Fix T76630: Crash when changing transform value with Custom Orientation

Germano Cavalcante noreply at git.blender.org
Mon May 11 14:48:30 CEST 2020


Commit: 76c64af00caa7308368dfe0221b617c2aae3cde4
Author: Germano Cavalcante
Date:   Mon May 11 09:47:15 2020 -0300
Branches: master
https://developer.blender.org/rB76c64af00caa7308368dfe0221b617c2aae3cde4

Fix T76630: Crash when changing transform value with Custom Orientation

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

M	source/blender/editors/transform/transform_constraints.c
M	source/blender/editors/transform/transform_generics.c
M	source/blender/editors/transform/transform_gizmo_3d.c
M	source/blender/editors/transform/transform_orientations.c

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

diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 94cfed32841..b07eb6edf5a 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -730,7 +730,9 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
       BLI_snprintf(text, sizeof(text), ftext, TIP_("custom matrix"));
       setConstraint(t, t->spacemtx, mode, text);
       break;
-    case V3D_ORIENT_CUSTOM: {
+    case V3D_ORIENT_CUSTOM:
+    default: {
+      BLI_assert(orientation >= V3D_ORIENT_CUSTOM);
       char orientation_str[128];
       BLI_snprintf(orientation_str,
                    sizeof(orientation_str),
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 704a48f3707..2a3c8ef60c3 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1690,25 +1690,28 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
 
     if (orient_type_constraint == -1) {
       if (orient_type_set != -1) {
-        orient_type_default = orient_type_set;
-
-        if (orient_type_default >= V3D_ORIENT_CUSTOM) {
-          if (orient_type_default >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) {
-            orient_type_default = V3D_ORIENT_GLOBAL;
-          }
-          else {
-            custom_orientation = BKE_scene_transform_orientation_find(
-                t->scene, orient_type_default - V3D_ORIENT_CUSTOM);
-            orient_type_default = V3D_ORIENT_CUSTOM;
-          }
-        }
-        orient_type_constraint = orient_type_default;
+        orient_type_default = orient_type_constraint = orient_type_set;
       }
       else {
         TransformOrientationSlot *orient_slot = &t->scene->orientation_slots[SCE_ORIENT_DEFAULT];
-        orient_type_constraint = orient_slot->type;
         custom_orientation = BKE_scene_transform_orientation_find(t->scene,
                                                                   orient_slot->index_custom);
+
+        /* Add the slot value to the orient_type to be used for Redo. */
+        orient_type_constraint = orient_slot->type + orient_slot->index_custom;
+      }
+    }
+
+    if (custom_orientation == NULL && orient_type_constraint >= V3D_ORIENT_CUSTOM) {
+      if (orient_type_constraint >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) {
+        if (orient_type_default == orient_type_constraint) {
+          orient_type_default = V3D_ORIENT_GLOBAL;
+        }
+        orient_type_constraint = V3D_ORIENT_GLOBAL;
+      }
+      else {
+        custom_orientation = BKE_scene_transform_orientation_find(
+            t->scene, orient_type_constraint - V3D_ORIENT_CUSTOM);
       }
     }
 
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 362cbc1b800..7a9be86624e 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -713,7 +713,9 @@ void ED_transform_calc_orientation_from_type_ex(const bContext *C,
       ok = true;
       break;
     }
-    case V3D_ORIENT_CUSTOM: {
+    case V3D_ORIENT_CUSTOM:
+    default: {
+      BLI_assert(orientation_type >= V3D_ORIENT_CUSTOM);
       TransformOrientation *custom_orientation = BKE_scene_transform_orientation_find(
           scene, orientation_index_custom);
       if (applyTransformOrientation(custom_orientation, r_mat, NULL)) {
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 3b1f3559daa..81c63278366 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -500,8 +500,9 @@ void initTransformOrientation(bContext *C, TransInfo *t, short orientation)
       copy_m3_m3(t->spacemtx, t->orientation.custom_matrix);
       break;
     case V3D_ORIENT_CUSTOM:
+    default:
+      BLI_assert(orientation >= V3D_ORIENT_CUSTOM);
       BLI_strncpy(t->spacename, t->orientation.custom->name, sizeof(t->spacename));
-
       if (applyTransformOrientation(t->orientation.custom, t->spacemtx, t->spacename)) {
         /* pass */
       }



More information about the Bf-blender-cvs mailing list