Cleanup: Simplify transform_orientation_matrix_get

This simplifies obtaining the parameters for internal functions.
(switch was complicating a little)

Also removes ureachable code.
This commit is contained in:
Germano Cavalcante 2020-10-08 11:20:06 -03:00
parent 043ddcf3ad
commit dba0b84359
1 changed files with 9 additions and 29 deletions

View File

@ -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)