Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_orientations.c
| Show First 20 Lines • Show All 515 Lines • ▼ Show 20 Lines | short ED_transform_calc_orientation_from_type_ex(const bContext *C, | ||||
| RegionView3D *rv3d, | RegionView3D *rv3d, | ||||
| Object *ob, | Object *ob, | ||||
| Object *obedit, | Object *obedit, | ||||
| const short orientation_type, | const short orientation_type, | ||||
| int orientation_index_custom, | int orientation_index_custom, | ||||
| const int pivot_point) | const int pivot_point) | ||||
| { | { | ||||
| switch (orientation_type) { | switch (orientation_type) { | ||||
| case V3D_ORIENT_GLOBAL: { | |||||
| unit_m3(r_mat); | |||||
| return V3D_ORIENT_GLOBAL; | |||||
| } | |||||
| case V3D_ORIENT_GIMBAL: { | case V3D_ORIENT_GIMBAL: { | ||||
| if (ob && gimbal_axis(ob, r_mat)) { | if (ob && gimbal_axis(ob, r_mat)) { | ||||
| return V3D_ORIENT_GIMBAL; | break; | ||||
| } | } | ||||
| /* if not gimbal, fall through to normal */ | /* If not gimbal, fall through to normal. */ | ||||
| ATTR_FALLTHROUGH; | ATTR_FALLTHROUGH; | ||||
| } | } | ||||
| case V3D_ORIENT_NORMAL: { | case V3D_ORIENT_NORMAL: { | ||||
| if (obedit || (ob && ob->mode & OB_MODE_POSE)) { | if (obedit || (ob && ob->mode & OB_MODE_POSE)) { | ||||
| ED_getTransformOrientationMatrix(C, ob, obedit, pivot_point, r_mat); | ED_getTransformOrientationMatrix(C, ob, obedit, pivot_point, r_mat); | ||||
| return V3D_ORIENT_NORMAL; | break; | ||||
| } | } | ||||
| /* no break we define 'normal' as 'local' in Object mode */ | /* No break we define 'normal' as 'local' in Object mode. */ | ||||
| ATTR_FALLTHROUGH; | ATTR_FALLTHROUGH; | ||||
| } | } | ||||
| case V3D_ORIENT_LOCAL: { | case V3D_ORIENT_LOCAL: { | ||||
| if (ob) { | if (ob) { | ||||
| if (ob->mode & OB_MODE_POSE) { | if (ob->mode & OB_MODE_POSE) { | ||||
| /* each bone moves on its own local axis, but to avoid confusion, | /* each bone moves on its own local axis, but to avoid confusion, | ||||
| * use the active pones axis for display T33575, this works as expected on a single | * use the active pones axis for display T33575, this works as expected on a single | ||||
| * bone and users who select many bones will understand what's going on and what local | * bone and users who select many bones will understand what's going on and what local | ||||
| * means when they start transforming */ | * means when they start transforming */ | ||||
| ED_getTransformOrientationMatrix(C, ob, obedit, pivot_point, r_mat); | ED_getTransformOrientationMatrix(C, ob, obedit, pivot_point, r_mat); | ||||
| } | } | ||||
| else { | else { | ||||
| transform_orientations_create_from_axis(r_mat, UNPACK3(ob->obmat)); | transform_orientations_create_from_axis(r_mat, UNPACK3(ob->obmat)); | ||||
| } | } | ||||
| return V3D_ORIENT_LOCAL; | break; | ||||
| } | |||||
| /* If not local, fall through to global. */ | |||||
| ATTR_FALLTHROUGH; | |||||
| } | } | ||||
| case V3D_ORIENT_GLOBAL: { | |||||
| unit_m3(r_mat); | unit_m3(r_mat); | ||||
| return V3D_ORIENT_GLOBAL; | break; | ||||
| } | } | ||||
| case V3D_ORIENT_VIEW: { | case V3D_ORIENT_VIEW: { | ||||
| if (rv3d != NULL) { | if (rv3d != NULL) { | ||||
| copy_m3_m4(r_mat, rv3d->viewinv); | copy_m3_m4(r_mat, rv3d->viewinv); | ||||
| normalize_m3(r_mat); | normalize_m3(r_mat); | ||||
| } | } | ||||
| else { | else { | ||||
| unit_m3(r_mat); | unit_m3(r_mat); | ||||
| } | } | ||||
| return V3D_ORIENT_VIEW; | break; | ||||
| } | } | ||||
| case V3D_ORIENT_CURSOR: { | case V3D_ORIENT_CURSOR: { | ||||
| BKE_scene_cursor_rot_to_mat3(&scene->cursor, r_mat); | BKE_scene_cursor_rot_to_mat3(&scene->cursor, r_mat); | ||||
| return V3D_ORIENT_CURSOR; | break; | ||||
| } | } | ||||
| case V3D_ORIENT_CUSTOM_MATRIX: { | case V3D_ORIENT_CUSTOM_MATRIX: { | ||||
| /* Do nothing. */; | /* Do nothing. */; | ||||
| break; | break; | ||||
| } | } | ||||
| case V3D_ORIENT_CUSTOM: | case V3D_ORIENT_CUSTOM: | ||||
| default: { | default: { | ||||
| BLI_assert(orientation_type >= V3D_ORIENT_CUSTOM); | BLI_assert(orientation_type >= V3D_ORIENT_CUSTOM); | ||||
| ▲ Show 20 Lines • Show All 770 Lines • Show Last 20 Lines | |||||