From dba0b84359e47b374647e10fa6ae72dd6a9f4528 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Thu, 8 Oct 2020 11:20:06 -0300 Subject: Cleanup: Simplify transform_orientation_matrix_get This simplifies obtaining the parameters for internal functions. (switch was complicating a little) Also removes ureachable code. --- .../editors/transform/transform_orientations.c | 38 +++++----------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 548c1042682..eabc5ede993 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -537,41 +537,24 @@ short ED_transform_calc_orientation_from_type_ex(const bContext *C, short transform_orientation_matrix_get( bContext *C, TransInfo *t, short orientation, const float custom[3][3], float r_spacemtx[3][3]) { - Object *ob = NULL; - Object *obedit = NULL; - Scene *scene = NULL; - RegionView3D *rv3d = NULL; - int orientation_index_custom = 0; - if (orientation == V3D_ORIENT_CUSTOM_MATRIX) { copy_m3_m3(r_spacemtx, custom); return V3D_ORIENT_CUSTOM_MATRIX; } + Object *ob = CTX_data_active_object(C); + Object *obedit = CTX_data_edit_object(C); + Scene *scene = t->scene; + RegionView3D *rv3d = NULL; + int orientation_index_custom = 0; + if (orientation >= V3D_ORIENT_CUSTOM) { orientation_index_custom = orientation - V3D_ORIENT_CUSTOM; orientation = V3D_ORIENT_CUSTOM; } - switch (orientation) { - case V3D_ORIENT_GIMBAL: - case V3D_ORIENT_LOCAL: - case V3D_ORIENT_NORMAL: - ob = CTX_data_active_object(C); - obedit = CTX_data_edit_object(C); - break; - case V3D_ORIENT_VIEW: - if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) { - rv3d = t->region->regiondata; - } - break; - case V3D_ORIENT_CURSOR: - case V3D_ORIENT_CUSTOM: - scene = t->scene; - break; - case V3D_ORIENT_GLOBAL: - case V3D_ORIENT_CUSTOM_MATRIX: - default: - break; + + if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) { + rv3d = t->region->regiondata; } return ED_transform_calc_orientation_from_type_ex(C, @@ -584,9 +567,6 @@ short transform_orientation_matrix_get( orientation, orientation_index_custom, t->around); - - unit_m3(r_spacemtx); - return V3D_ORIENT_GLOBAL; } const char *transform_orientations_spacename_get(TransInfo *t, const short orient_type) -- cgit v1.2.3