Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_orientations.c
| Show First 20 Lines • Show All 379 Lines • ▼ Show 20 Lines | |||||
| void BIF_selectTransformOrientationValue(bContext *C, int orientation) | void BIF_selectTransformOrientationValue(bContext *C, int orientation) | ||||
| { | { | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| if (v3d) /* currently using generic poll */ | if (v3d) /* currently using generic poll */ | ||||
| v3d->twmode = orientation; | v3d->twmode = orientation; | ||||
| } | } | ||||
| // This is important for the shortcut when selecting seperate transformations | |||||
| void BIF_selectTransformOrientationCustomValue(bContext *C, int orientation, int type_transform, int sub_orientation) | |||||
| { | |||||
| View3D *v3d = CTX_wm_view3d(C); | |||||
| if (v3d) /* currently using generic poll */ { | |||||
| if (type_transform == V3D_MANIP_TRANSLATE) | |||||
| v3d->twtrans = sub_orientation; | |||||
| else if (type_transform == V3D_MANIP_ROTATE) | |||||
| v3d->twrots = sub_orientation; | |||||
| else if (type_transform == V3D_MANIP_SCALE) | |||||
| v3d->twscale = sub_orientation; | |||||
| } | |||||
| } | |||||
| int BIF_countTransformOrientation(const bContext *C) | int BIF_countTransformOrientation(const bContext *C) | ||||
| { | { | ||||
| ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces; | ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces; | ||||
| return BLI_listbase_count(transform_spaces); | return BLI_listbase_count(transform_spaces); | ||||
| } | } | ||||
| bool applyTransformOrientation(const bContext *C, float mat[3][3], char *r_name, int index) | bool applyTransformOrientation(const bContext *C, float mat[3][3], char *r_name, int index) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | default: /* V3D_MANIP_CUSTOM */ | ||||
| } | } | ||||
| else { | else { | ||||
| unit_m3(t->spacemtx); | unit_m3(t->spacemtx); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| void initTransformOrientationCustom(bContext *C, TransInfo *t, short manipulator_orientation, float omtx[3][3]) | |||||
| { | |||||
| Object *ob = CTX_data_active_object(C); | |||||
| Object *obedit = CTX_data_active_object(C); | |||||
| bPoseChannel *posebone = CTX_data_active_pose_bone(C); | |||||
| switch (manipulator_orientation) | |||||
| { | |||||
| case V3D_MANIP_GLOBAL: | |||||
| unit_m3(omtx); | |||||
| BLI_strncpy(t->spacename, IFACE_("global"), sizeof(t->spacename)); | |||||
| break; | |||||
| case V3D_MANIP_GIMBAL: | |||||
| unit_m3(omtx); | |||||
| if (gimbal_axis(ob, omtx)) { | |||||
| BLI_strncpy(t->spacename, IFACE_("gimbal"), sizeof(t->spacename)); | |||||
| break; | |||||
| } | |||||
| /* fall-through */ /* no gimbal fallthrough to normal */ | |||||
| case V3D_MANIP_NORMAL: | |||||
| if (obedit || (ob && ob->mode & OB_MODE_POSE)) { | |||||
| BLI_strncpy(t->spacename, IFACE_("normal"), sizeof(t->spacename)); | |||||
| ED_getTransformOrientationMatrix(C, omtx, t->around); | |||||
| break; | |||||
| } | |||||
| /* fall-through */ /* we define 'normal' as 'local' in Object mode */ | |||||
| case V3D_MANIP_LOCAL: | |||||
| BLI_strncpy(t->spacename, IFACE_("local"), sizeof(t->spacename)); | |||||
| if (ob) { | |||||
| copy_m3_m4(omtx, ob->obmat); | |||||
| normalize_m3(omtx); | |||||
| } | |||||
| else { | |||||
| unit_m3(omtx); | |||||
| } | |||||
| break; | |||||
| case V3D_MANIP_VIEW: | |||||
| if ((t->spacetype == SPACE_VIEW3D) && | |||||
| (t->ar->regiontype == RGN_TYPE_WINDOW)) | |||||
| { | |||||
| RegionView3D *rv3d = t->ar->regiondata; | |||||
| float mat[3][3]; | |||||
| BLI_strncpy(t->spacename, IFACE_("view"), sizeof(t->spacename)); | |||||
| copy_m3_m4(mat, rv3d->viewinv); | |||||
| normalize_m3(mat); | |||||
| copy_m3_m3(omtx, mat); | |||||
| } | |||||
| else { | |||||
| unit_m3(omtx); | |||||
| } | |||||
| break; | |||||
| default: | |||||
| if (applyTransformOrientation(C, omtx, t->spacename, t->current_orientation - V3D_MANIP_CUSTOM)) { | |||||
| BLI_strncpy(t->spacename, IFACE_("custom"), sizeof(t->spacename)); | |||||
| /* pass */ | |||||
| } | |||||
| else { | |||||
| unit_m3(omtx); | |||||
| } | |||||
| break; | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * utility function - get first n, selected vert/edge/faces | * utility function - get first n, selected vert/edge/faces | ||||
| */ | */ | ||||
| static unsigned int bm_mesh_elems_select_get_n__internal( | static unsigned int bm_mesh_elems_select_get_n__internal( | ||||
| BMesh *bm, BMElem **elems, const unsigned int n, | BMesh *bm, BMElem **elems, const unsigned int n, | ||||
| const BMIterType itype, const char htype) | const BMIterType itype, const char htype) | ||||
| { | { | ||||
| BMIter iter; | BMIter iter; | ||||
| ▲ Show 20 Lines • Show All 575 Lines • Show Last 20 Lines | |||||