diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2020-05-11 15:47:15 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2020-05-11 15:47:25 +0300 |
commit | 76c64af00caa7308368dfe0221b617c2aae3cde4 (patch) | |
tree | 1847b1d65e6ff5639dba22510ac4de4108cde45e | |
parent | 267e4d130a26c0ecf4c1c7a70b67303a7620abb2 (diff) |
Fix T76630: Crash when changing transform value with Custom Orientation
4 files changed, 25 insertions, 17 deletions
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 */ } |