Fix T42444: Neg scale rotated object flips 2x axis
[blender.git] / source / blender / editors / transform / transform.c
index 72df4e053bc37d813a75d533fca9ce496c448cf6..d704f62654baaaab0591de3328ef63213863be63 100644 (file)
 #include <math.h>
 #include <float.h>
 
-#ifndef WIN32
-#  include <unistd.h>
-#else
-#  include <io.h>
-#endif
-
 #include "MEM_guardedalloc.h"
 
 #include "DNA_anim_types.h"
 #include "DNA_armature_types.h"
 #include "DNA_constraint_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
 #include "DNA_mask_types.h"
 #include "DNA_movieclip_types.h"
 #include "DNA_scene_types.h"  /* PET modes */
 #include "BLI_listbase.h"
 #include "BLI_string.h"
 #include "BLI_ghash.h"
-#include "BLI_linklist.h"
 
 #include "BKE_nla.h"
 #include "BKE_editmesh_bvh.h"
 #include "BKE_context.h"
 #include "BKE_constraint.h"
-#include "BKE_global.h"
 #include "BKE_particle.h"
-#include "BKE_pointcache.h"
 #include "BKE_unit.h"
 #include "BKE_mask.h"
+#include "BKE_report.h"
 
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
@@ -81,7 +71,6 @@
 #include "ED_view3d.h"
 #include "ED_mesh.h"
 #include "ED_clip.h"
-#include "ED_mask.h"
 #include "ED_node.h"
 
 #include "WM_types.h"
@@ -98,6 +87,9 @@
 
 #include "transform.h"
 
+/* Disabling, since when you type you know what you are doing, and being able to set it to zero is handy. */
+// #define USE_NUM_NO_ZERO
+
 #define MAX_INFO_LEN 256
 
 static void drawTransformApply(const struct bContext *C, ARegion *ar, void *arg);
@@ -202,9 +194,9 @@ static bool transdata_check_local_center(TransInfo *t, short around)
 {
        return ((around == V3D_LOCAL) && (
                    (t->flag & (T_OBJECT | T_POSE)) ||
-                   (t->obedit && ELEM4(t->obedit->type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE)) ||
+                   (t->obedit && ELEM(t->obedit->type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE)) ||
                    (t->spacetype == SPACE_IPO) ||
-                   (t->options & (CTX_MOVIECLIP | CTX_MASK)))
+                   (t->options & (CTX_MOVIECLIP | CTX_MASK | CTX_PAINT_CURVE)))
                );
 }
 
@@ -275,17 +267,28 @@ static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy)
 void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
 {
        if ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) {
-               const float mval_f[2] = {(float)dx, (float)dy};
-               ED_view3d_win_to_delta(t->ar, mval_f, r_vec, t->zfac);
+               if (t->options & CTX_PAINT_CURVE) {
+                       r_vec[0] = dx;
+                       r_vec[1] = dy;
+               }
+               else {
+                       const float mval_f[2] = {(float)dx, (float)dy};
+                       ED_view3d_win_to_delta(t->ar, mval_f, r_vec, t->zfac);
+               }
        }
        else if (t->spacetype == SPACE_IMAGE) {
                float aspx, aspy;
 
                if (t->options & CTX_MASK) {
-
                        convertViewVec2D_mask(t->view, r_vec, dx, dy);
                        ED_space_image_get_aspect(t->sa->spacedata.first, &aspx, &aspy);
                }
+               else if (t->options & CTX_PAINT_CURVE) {
+                       r_vec[0] = dx;
+                       r_vec[1] = dy;
+
+                       aspx = aspy = 1.0;
+               }
                else {
                        convertViewVec2D(t->view, r_vec, dx, dy);
                        ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
@@ -346,7 +349,6 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr
                SpaceImage *sima = t->sa->spacedata.first;
 
                if (t->options & CTX_MASK) {
-                       /* not working quite right, TODO (see below too) */
                        float aspx, aspy;
                        float v[2];
 
@@ -359,14 +361,15 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr
 
                        BKE_mask_coord_to_image(sima->image, &sima->iuser, v, v);
 
-                       v[0] = v[0] / aspx;
-                       v[1] = v[1] / aspy;
-
                        ED_image_point_pos__reverse(sima, t->ar, v, v);
 
                        adr[0] = v[0];
                        adr[1] = v[1];
                }
+               else if (t->options & CTX_PAINT_CURVE) {
+                       adr[0] = vec[0];
+                       adr[1] = vec[1];
+               }
                else {
                        float aspx, aspy, v[2];
 
@@ -417,7 +420,6 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr
                        MovieClip *clip = ED_space_clip_get_clip(sc);
 
                        if (clip) {
-                               /* not working quite right, TODO (see above too) */
                                float aspx, aspy;
                                float v[2];
 
@@ -430,9 +432,6 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr
 
                                BKE_mask_coord_to_movieclip(sc->clip, &sc->user, v, v);
 
-                               v[0] = v[0] / aspx;
-                               v[1] = v[1] / aspy;
-
                                ED_clip_point_stable_pos__reverse(sc, t->ar, v, v);
 
                                adr[0] = v[0];
@@ -472,7 +471,11 @@ void projectFloatViewEx(TransInfo *t, const float vec[3], float adr[2], const eV
        switch (t->spacetype) {
                case SPACE_VIEW3D:
                {
-                       if (t->ar->regiontype == RGN_TYPE_WINDOW) {
+                       if (t->options & CTX_PAINT_CURVE) {
+                               adr[0] = vec[0];
+                               adr[1] = vec[1];
+                       }
+                       else if (t->ar->regiontype == RGN_TYPE_WINDOW) {
                                /* allow points behind the view [#33643] */
                                if (ED_view3d_project_float_global(t->ar, vec, adr, flag) != V3D_PROJ_RET_OK) {
                                        /* XXX, 2.64 and prior did this, weak! */
@@ -500,7 +503,7 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
 
 void applyAspectRatio(TransInfo *t, float vec[2])
 {
-       if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) {
+       if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION) && !(t->options & CTX_PAINT_CURVE)) {
                SpaceImage *sima = t->sa->spacedata.first;
                float aspx, aspy;
 
@@ -577,17 +580,23 @@ void removeAspectRatio(TransInfo *t, float vec[2])
 static void viewRedrawForce(const bContext *C, TransInfo *t)
 {
        if (t->spacetype == SPACE_VIEW3D) {
-               /* Do we need more refined tags? */
-               if (t->flag & T_POSE)
-                       WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
-               else
-                       WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
+               if (t->options & CTX_PAINT_CURVE) {
+                       wmWindow *window = CTX_wm_window(C);
+                       WM_paint_cursor_tag_redraw(window, t->ar);
+               }
+               else {
+                       /* Do we need more refined tags? */
+                       if (t->flag & T_POSE)
+                               WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
+                       else
+                               WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
 
-               /* for realtime animation record - send notifiers recognised by animation editors */
-               // XXX: is this notifier a lame duck?
-               if ((t->animtimer) && IS_AUTOKEY_ON(t->scene))
-                       WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);
-               
+                       /* for realtime animation record - send notifiers recognised by animation editors */
+                       // XXX: is this notifier a lame duck?
+                       if ((t->animtimer) && IS_AUTOKEY_ON(t->scene))
+                               WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);
+
+               }
        }
        else if (t->spacetype == SPACE_ACTION) {
                //SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
@@ -613,6 +622,10 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
 
                        WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
                }
+               else if (t->options & CTX_PAINT_CURVE) {
+                       wmWindow *window = CTX_wm_window(C);
+                       WM_paint_cursor_tag_redraw(window, t->ar);
+               }
                else {
                        // XXX how to deal with lock?
                        SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
@@ -666,7 +679,7 @@ static void viewRedrawPost(bContext *C, TransInfo *t)
                allqueue(REDRAWIMAGE, 0);
                allqueue(REDRAWVIEW3D, 0);
        }
-       else if (ELEM3(t->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_IPO)) {
+       else if (ELEM(t->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_IPO)) {
                allqueue(REDRAWVIEW3D, 0);
                allqueue(REDRAWACTION, 0);
                allqueue(REDRAWNLA, 0);
@@ -945,7 +958,6 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
 
 int transformEvent(TransInfo *t, const wmEvent *event)
 {
-       float mati[3][3] = MAT3_UNITY;
        char cmode = constraintModeToChar(t);
        bool handled = false;
 
@@ -990,7 +1002,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                break;
                        case TFM_MODAL_TRANSLATE:
                                /* only switch when... */
-                               if (ELEM5(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_EDGE_SLIDE, TFM_VERT_SLIDE)) {
+                               if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_EDGE_SLIDE, TFM_VERT_SLIDE)) {
                                        resetTransModal(t);
                                        resetTransRestrictions(t);
                                        restoreTransObjects(t);
@@ -1046,7 +1058,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                        case TFM_MODAL_ROTATE:
                                /* only switch when... */
                                if (!(t->options & CTX_TEXTURE) && !(t->options & (CTX_MOVIECLIP | CTX_MASK))) {
-                                       if (ELEM6(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION, TFM_EDGE_SLIDE, TFM_VERT_SLIDE)) {
+                                       if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION, TFM_EDGE_SLIDE, TFM_VERT_SLIDE)) {
                                                resetTransModal(t);
                                                resetTransRestrictions(t);
                                                
@@ -1066,7 +1078,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                break;
                        case TFM_MODAL_RESIZE:
                                /* only switch when... */
-                               if (ELEM5(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL, TFM_EDGE_SLIDE, TFM_VERT_SLIDE)) {
+                               if (ELEM(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL, TFM_EDGE_SLIDE, TFM_VERT_SLIDE)) {
 
                                        /* Scale isn't normally very useful after extrude along normals, see T39756 */
                                        if ((t->con.mode & CON_APPLY) && (t->con.orientation == V3D_MANIP_NORMAL)) {
@@ -1113,47 +1125,22 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                handled = true;
                                break;
                        case TFM_MODAL_AXIS_X:
-                               if ((t->flag & T_NO_CONSTRAINT) == 0) {
-                                       if (cmode == 'X') {
-                                               stopConstraint(t);
-                                       }
-                                       else {
-                                               if (t->flag & T_2D_EDIT) {
-                                                       setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS0), IFACE_("along X"));
-                                               }
-                                               else {
-                                                       setUserConstraint(t, t->current_orientation, (CON_AXIS0), IFACE_("along %s X"));
-                                               }
-                                       }
+                               if (!(t->flag & T_NO_CONSTRAINT)) {
+                                       transform_event_xyz_constraint(t, XKEY, cmode);
                                        t->redraw |= TREDRAW_HARD;
                                        handled = true;
                                }
                                break;
                        case TFM_MODAL_AXIS_Y:
                                if ((t->flag & T_NO_CONSTRAINT) == 0) {
-                                       if (cmode == 'Y') {
-                                               stopConstraint(t);
-                                       }
-                                       else {
-                                               if (t->flag & T_2D_EDIT) {
-                                                       setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS1), IFACE_("along Y"));
-                                               }
-                                               else {
-                                                       setUserConstraint(t, t->current_orientation, (CON_AXIS1), IFACE_("along %s Y"));
-                                               }
-                                       }
+                                       transform_event_xyz_constraint(t, YKEY, cmode);
                                        t->redraw |= TREDRAW_HARD;
                                        handled = true;
                                }
                                break;
                        case TFM_MODAL_AXIS_Z:
-                               if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) {
-                                       if (cmode == 'Z') {
-                                               stopConstraint(t);
-                                       }
-                                       else {
-                                               setUserConstraint(t, t->current_orientation, (CON_AXIS2), IFACE_("along %s Z"));
-                                       }
+                               if ((t->flag & (T_NO_CONSTRAINT)) == 0) {
+                                       transform_event_xyz_constraint(t, ZKEY, cmode);
                                        t->redraw |= TREDRAW_HARD;
                                        handled = true;
                                }
@@ -1306,7 +1293,9 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                                        }
                                                        else {
                                                                /* bit hackish... but it prevents mmb select to print the orientation from menu */
+                                                               float mati[3][3];
                                                                strcpy(t->spacename, "global");
+                                                               unit_m3(mati);
                                                                initSelectConstraint(t, mati);
                                                        }
                                                        postSelectConstraint(t);
@@ -1327,7 +1316,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                break;
                        case GKEY:
                                /* only switch when... */
-                               if (ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
+                               if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) {
                                        resetTransModal(t);
                                        resetTransRestrictions(t);
                                        restoreTransObjects(t);
@@ -1339,7 +1328,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                break;
                        case SKEY:
                                /* only switch when... */
-                               if (ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) {
+                               if (ELEM(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL)) {
                                        resetTransModal(t);
                                        resetTransRestrictions(t);
                                        restoreTransObjects(t);
@@ -1352,7 +1341,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                        case RKEY:
                                /* only switch when... */
                                if (!(t->options & CTX_TEXTURE)) {
-                                       if (ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) {
+                                       if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION)) {
                                                resetTransModal(t);
                                                resetTransRestrictions(t);
 
@@ -1562,7 +1551,7 @@ bool calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], floa
        }
 
 
-       /* aftertrans does insert ipos and action channels, and clears base flags, doesnt read transdata */
+       /* aftertrans does insert keyframes, and clears base flags; doesn't read transdata */
        special_aftertrans_update(C, t);
 
        postTrans(C, t);
@@ -1737,7 +1726,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
                        {
                                float dx = t->mval[0] - cent[0], dy = t->mval[1] - cent[1];
                                float angle = atan2f(dy, dx);
-                               float dist = sqrtf(dx * dx + dy * dy);
+                               float dist = hypotf(dx, dy);
                                float delta_angle = min_ff(15.0f / dist, (float)M_PI / 4.0f);
                                float spacing_angle = min_ff(5.0f / dist, (float)M_PI / 12.0f);
                                UI_ThemeColor(TH_VIEW_OVERLAY);
@@ -1826,24 +1815,26 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *ar)
        
        BLF_width_and_height_default(printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]);
        
-       xco = rect.xmax - (int)printable_size[0] - 10;
-       yco = rect.ymax - (int)printable_size[1] - 10;
+       xco = (rect.xmax - U.widget_unit) - (int)printable_size[0];
+       yco = (rect.ymax - U.widget_unit);
        
        /* warning text (to clarify meaning of overlays)
         * - original color was red to match the icon, but that clashes badly with a less nasty border
         */
        UI_ThemeColorShade(TH_TEXT_HI, -50);
 #ifdef WITH_INTERNATIONAL
-       BLF_draw_default(xco, ar->winy - 17, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
+       BLF_draw_default(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
 #else
-       BLF_draw_default_ascii(xco, ar->winy - 17, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
+       BLF_draw_default_ascii(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
 #endif
        
        /* autokey recording icon... */
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glEnable(GL_BLEND);
        
-       xco -= (ICON_DEFAULT_WIDTH + 2);
+       xco -= U.widget_unit;
+       yco -= (int)printable_size[1] / 2;
+
        UI_icon_draw(xco, yco, ICON_REC);
        
        glDisable(GL_BLEND);
@@ -1884,7 +1875,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
        }
 
        if ((prop = RNA_struct_find_property(op->ptr, "value"))) {
-               float *values = (t->flag & T_AUTOVALUES) ? t->auto_values : t->values;
+               const float *values = (t->flag & T_AUTOVALUES) ? t->auto_values : t->values;
                if (RNA_property_array_check(prop)) {
                        RNA_property_float_set_array(op->ptr, prop, values);
                }
@@ -2039,7 +2030,6 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
        initTransInfo(C, t, op, event);
 
        if (t->spacetype == SPACE_VIEW3D) {
-               //calc_manipulator_stats(curarea);
                initTransformOrientation(C, t);
 
                t->draw_handle_apply = ED_region_draw_cb_activate(t->ar->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW);
@@ -2084,7 +2074,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
                 * moded are available from manipulator and doing such check could
                 * lead to keymap conflicts for other modes (see #31584)
                 */
-               if (ELEM3(mode, TFM_TRANSLATION, TFM_ROTATION, TFM_RESIZE)) {
+               if (ELEM(mode, TFM_TRANSLATION, TFM_ROTATION, TFM_RESIZE)) {
                        wmKeyMapItem *kmi;
 
                        for (kmi = t->keymap->items.first; kmi; kmi = kmi->next) {
@@ -2336,7 +2326,7 @@ int transformEnd(bContext *C, TransInfo *t)
                        exit_code = OPERATOR_FINISHED;
                }
 
-               /* aftertrans does insert keyframes, and clears base flags, doesnt read transdata */
+               /* aftertrans does insert keyframes, and clears base flags; doesn't read transdata */
                special_aftertrans_update(C, t);
 
                /* free data */
@@ -2781,7 +2771,7 @@ static void initBend(TransInfo *t)
        t->flag |= T_NO_CONSTRAINT;
 
        //copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view));
-       calculateCenterCursor(t);
+       calculateCenterCursor(t, t->center);
 
        t->val = 0.0f;
 
@@ -2860,7 +2850,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN * 2];
 
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
                
                BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Bend Angle: %s Radius: %s Alt, Clamp %s"),
                             &c[0], &c[NUM_STR_REP_LEN],
@@ -3028,7 +3018,7 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
                
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
                
                BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Shear: %s %s"), c, t->proptext);
        }
@@ -3104,9 +3094,11 @@ static void initResize(TransInfo *t)
        t->num.flag |= NUM_AFFECT_ALL;
        if (!t->obedit) {
                t->flag |= T_NO_ZERO;
+#ifdef USE_NUM_NO_ZERO
                t->num.val_flag[0] |= NUM_NO_ZERO;
                t->num.val_flag[1] |= NUM_NO_ZERO;
                t->num.val_flag[2] |= NUM_NO_ZERO;
+#endif
        }
        
        t->idx_max = 2;
@@ -3127,7 +3119,7 @@ static void headerResize(TransInfo *t, float vec[3], char str[MAX_INFO_LEN])
        char tvec[NUM_STR_REP_LEN * 3];
        size_t ofs = 0;
        if (hasNumInput(&t->num)) {
-               outputNumInput(&(t->num), tvec);
+               outputNumInput(&(t->num), tvec, &t->scene->unit);
        }
        else {
                BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", vec[0]);
@@ -3167,38 +3159,23 @@ static void headerResize(TransInfo *t, float vec[3], char str[MAX_INFO_LEN])
        }
 }
 
-/* FLT_EPSILON is too small [#29633], 0.0000001f starts to flip */
-#define TX_FLIP_EPS 0.00001f
-BLI_INLINE int tx_sign(const float a)
-{
-       return (a < -TX_FLIP_EPS ? 1 : a > TX_FLIP_EPS ? 2 : 3);
-}
-BLI_INLINE int tx_vec_sign_flip(const float a[3], const float b[3])
-{
-       return ((tx_sign(a[0]) & tx_sign(b[0])) == 0 ||
-               (tx_sign(a[1]) & tx_sign(b[1])) == 0 ||
-               (tx_sign(a[2]) & tx_sign(b[2])) == 0);
-}
-
-/* smat is reference matrix, only scaled */
+/**
+ * \a smat is reference matrix only.
+ *
+ * \note this is a tricky area, before making changes see: T29633, T42444
+ */
 static void TransMat3ToSize(float mat[3][3], float smat[3][3], float size[3])
 {
-       float vec[3];
-       
-       copy_v3_v3(vec, mat[0]);
-       size[0] = normalize_v3(vec);
-       copy_v3_v3(vec, mat[1]);
-       size[1] = normalize_v3(vec);
-       copy_v3_v3(vec, mat[2]);
-       size[2] = normalize_v3(vec);
-       
+       float rmat[3][3];
+
+       mat3_to_rot_size(rmat, size, mat);
+
        /* first tried with dotproduct... but the sign flip is crucial */
-       if (tx_vec_sign_flip(mat[0], smat[0]) ) size[0] = -size[0];
-       if (tx_vec_sign_flip(mat[1], smat[1]) ) size[1] = -size[1];
-       if (tx_vec_sign_flip(mat[2], smat[2]) ) size[2] = -size[2];
+       if (dot_v3v3(rmat[0], smat[0]) < 0.0f) size[0] = -size[0];
+       if (dot_v3v3(rmat[1], smat[1]) < 0.0f) size[1] = -size[1];
+       if (dot_v3v3(rmat[2], smat[2]) < 0.0f) size[2] = -size[2];
 }
 
-
 static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
 {
        float tmat[3][3], smat[3][3], center[3];
@@ -3396,9 +3373,11 @@ static void initSkinResize(TransInfo *t)
        t->num.flag |= NUM_AFFECT_ALL;
        if (!t->obedit) {
                t->flag |= T_NO_ZERO;
+#ifdef USE_NUM_NO_ZERO
                t->num.val_flag[0] |= NUM_NO_ZERO;
                t->num.val_flag[1] |= NUM_NO_ZERO;
                t->num.val_flag[2] |= NUM_NO_ZERO;
+#endif
        }
        
        t->idx_max = 2;
@@ -3539,7 +3518,7 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
                
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
                
                BLI_snprintf(str, MAX_INFO_LEN, IFACE_("To Sphere: %s %s"), c, t->proptext);
        }
@@ -3611,8 +3590,15 @@ static void initRotation(TransInfo *t)
        if (t->flag & T_2D_EDIT)
                t->flag |= T_NO_CONSTRAINT;
 
-       negate_v3_v3(t->axis, t->viewinv[2]);
-       normalize_v3(t->axis);
+       if (t->options & CTX_PAINT_CURVE) {
+               t->axis[0] = 0.0;
+               t->axis[1] = 0.0;
+               t->axis[2] = -1.0;
+       }
+       else {
+               negate_v3_v3(t->axis, t->viewinv[2]);
+               normalize_v3(t->axis);
+       }
 
        copy_v3_v3(t->axis_orig, t->axis);
 }
@@ -3646,7 +3632,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                
                
                if (td->flag & TD_USEQUAT) {
-                       mul_serie_m3(fmat, td->mtx, mat, td->smtx, NULL, NULL, NULL, NULL, NULL);
+                       mul_m3_series(fmat, td->smtx, mat, td->mtx);
                        mat3_to_quat(quat, fmat);   // Actual transform
                        
                        if (td->ext->quat) {
@@ -3716,7 +3702,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                if ((t->flag & T_V3D_ALIGN) == 0) { /* align mode doesn't rotate objects itself */
                        /* euler or quaternion/axis-angle? */
                        if (td->ext->rotOrder == ROT_MODE_QUAT) {
-                               mul_serie_m3(fmat, td->ext->r_mtx, mat, td->ext->r_smtx, NULL, NULL, NULL, NULL, NULL);
+                               mul_m3_series(fmat, td->ext->r_smtx, mat, td->ext->r_mtx);
                                
                                mat3_to_quat(quat, fmat); /* Actual transform */
                                
@@ -3731,7 +3717,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                                
                                axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle);
                                
-                               mul_serie_m3(fmat, td->ext->r_mtx, mat, td->ext->r_smtx, NULL, NULL, NULL, NULL, NULL);
+                               mul_m3_series(fmat, td->ext->r_smtx, mat, td->ext->r_mtx);
                                mat3_to_quat(quat, fmat); /* Actual transform */
                                mul_qt_qtqt(tquat, quat, iquat);
                                
@@ -3788,7 +3774,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                        if ((td->ext->rotOrder == ROT_MODE_QUAT) || (td->flag & TD_USEQUAT)) {
                                /* can be called for texture space translate for example, then opt out */
                                if (td->ext->quat) {
-                                       mul_serie_m3(fmat, td->mtx, mat, td->smtx, NULL, NULL, NULL, NULL, NULL);
+                                       mul_m3_series(fmat, td->smtx, mat, td->mtx);
                                        mat3_to_quat(quat, fmat);   // Actual transform
                                        
                                        mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat);
@@ -3802,7 +3788,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                                
                                axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle);
                                
-                               mul_serie_m3(fmat, td->mtx, mat, td->smtx, NULL, NULL, NULL, NULL, NULL);
+                               mul_m3_series(fmat, td->smtx, mat, td->mtx);
                                mat3_to_quat(quat, fmat);   // Actual transform
                                mul_qt_qtqt(tquat, quat, iquat);
                                
@@ -3896,7 +3882,7 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2]))
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
                
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
                
                ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("Rot: %s %s %s"), &c[0], t->con.text, t->proptext);
        }
@@ -4000,7 +3986,7 @@ static void applyTrackball(TransInfo *t, const int UNUSED(mval[2]))
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN * 2];
 
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
 
                ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("Trackball: %s %s %s"),
                                    &c[0], &c[NUM_STR_REP_LEN], t->proptext);
@@ -4041,6 +4027,9 @@ static void initTranslation(TransInfo *t)
 {
        if (t->spacetype == SPACE_ACTION) {
                /* this space uses time translate */
+               BKE_report(t->reports, RPT_ERROR, 
+                          "Use 'Time_Translate' transform mode instead of 'Translation' mode "
+                          "for translating keyframes in Dope Sheet Editor");
                t->state = TRANS_CANCEL;
        }
 
@@ -4102,7 +4091,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char str[MAX_INFO_LEN]
        float dist;
 
        if (hasNumInput(&t->num)) {
-               outputNumInput(&(t->num), tvec);
+               outputNumInput(&(t->num), tvec, &t->scene->unit);
                dist = len_v3(t->num.val);
        }
        else {
@@ -4202,7 +4191,7 @@ static void applyTranslationValue(TransInfo *t, float vec[3])
                /* handle snapping rotation before doing the translation */
                if (usingSnappingNormal(t)) {
                        if (validSnappingNormal(t)) {
-                               float *original_normal;
+                               const float *original_normal;
                                float axis[3];
                                float quat[4];
                                float mat[3][3];
@@ -4350,7 +4339,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
        ofs += BLI_strncpy_rlen(str + ofs, IFACE_("Shrink/Fatten:"), MAX_INFO_LEN - ofs);
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
                ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, " %s", c);
        }
        else {
@@ -4445,7 +4434,7 @@ static void applyTilt(TransInfo *t, const int UNUSED(mval[2]))
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
 
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
 
                BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Tilt: %s° %s"), &c[0], t->proptext);
 
@@ -4499,7 +4488,9 @@ static void initCurveShrinkFatten(TransInfo *t)
        t->num.unit_type[0] = B_UNIT_NONE;
 
        t->flag |= T_NO_ZERO;
+#ifdef USE_NUM_NO_ZERO
        t->num.val_flag[0] |= NUM_NO_ZERO;
+#endif
 
        t->flag |= T_NO_CONSTRAINT;
 }
@@ -4521,7 +4512,7 @@ static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
 
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
                BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Shrink/Fatten: %s"), c);
        }
        else {
@@ -4574,7 +4565,9 @@ static void initMaskShrinkFatten(TransInfo *t)
        t->num.unit_type[0] = B_UNIT_NONE;
 
        t->flag |= T_NO_ZERO;
+#ifdef USE_NUM_NO_ZERO
        t->num.val_flag[0] |= NUM_NO_ZERO;
+#endif
 
        t->flag |= T_NO_CONSTRAINT;
 }
@@ -4597,7 +4590,7 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
 
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
                BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Feather Shrink/Fatten: %s"), c);
        }
        else {
@@ -4690,7 +4683,7 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
 
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
 
                BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Push/Pull: %s%s %s"), c, t->con.text, t->proptext);
        }
@@ -4749,7 +4742,7 @@ static void initBevelWeight(TransInfo *t)
        t->mode = TFM_BWEIGHT;
        t->transform = applyBevelWeight;
 
-       initMouseInputMode(t, &t->mouse, INPUT_SPRING);
+       initMouseInputMode(t, &t->mouse, INPUT_SPRING_DELTA);
 
        t->idx_max = 0;
        t->num.idx_max = 0;
@@ -4773,7 +4766,6 @@ static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2]))
 
        weight = t->values[0];
 
-       weight -= 1.0f;
        if (weight > 1.0f) weight = 1.0f;
 
        snapGridIncrement(t, &weight);
@@ -4784,7 +4776,7 @@ static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2]))
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
 
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
 
                if (weight >= 0.0f)
                        BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Bevel Weight: +%s %s"), c, t->proptext);
@@ -4828,7 +4820,7 @@ static void initCrease(TransInfo *t)
        t->mode = TFM_CREASE;
        t->transform = applyCrease;
 
-       initMouseInputMode(t, &t->mouse, INPUT_SPRING);
+       initMouseInputMode(t, &t->mouse, INPUT_SPRING_DELTA);
 
        t->idx_max = 0;
        t->num.idx_max = 0;
@@ -4852,7 +4844,6 @@ static void applyCrease(TransInfo *t, const int UNUSED(mval[2]))
 
        crease = t->values[0];
 
-       crease -= 1.0f;
        if (crease > 1.0f) crease = 1.0f;
 
        snapGridIncrement(t, &crease);
@@ -4863,7 +4854,7 @@ static void applyCrease(TransInfo *t, const int UNUSED(mval[2]))
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
 
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
 
                if (crease >= 0.0f)
                        BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Crease: +%s %s"), c, t->proptext);
@@ -4933,7 +4924,7 @@ static void headerBoneSize(TransInfo *t, float vec[3], char str[MAX_INFO_LEN])
 {
        char tvec[NUM_STR_REP_LEN * 3];
        if (hasNumInput(&t->num)) {
-               outputNumInput(&(t->num), tvec);
+               outputNumInput(&(t->num), tvec, &t->scene->unit);
        }
        else {
                BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", vec[0]);
@@ -5070,7 +5061,7 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
                
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
                BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Envelope: %s"), c);
        }
        else {
@@ -5443,7 +5434,17 @@ static bool createEdgeSlideVerts(TransInfo *t)
        while (1) {
                float vec_a[3], vec_b[3];
                BMLoop *l_a, *l_b;
+               BMLoop *l_a_prev, *l_b_prev;
                BMVert *v_first;
+               /* If this succeeds call get_next_loop()
+                * which calculates the direction to slide based on clever checks.
+                *
+                * otherwise we simply use 'e_dir' as an edge-rail.
+                * (which is better when the attached edge is a boundary, see: T40422)
+                */
+#define EDGESLIDE_VERT_IS_INNER(v, e_dir) \
+               ((BM_edge_is_boundary(e_dir) == false) && \
+                (BM_vert_edge_count_nonwire(v) == 2))
 
                v = NULL;
                BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
@@ -5464,7 +5465,6 @@ static bool createEdgeSlideVerts(TransInfo *t)
                e = v->e;
 
                /*first, rewind*/
-               numsel = 0;
                do {
                        e = get_other_edge(v, e);
                        if (!e) {
@@ -5472,8 +5472,6 @@ static bool createEdgeSlideVerts(TransInfo *t)
                                break;
                        }
 
-                       numsel += 1;
-
                        if (!BM_elem_flag_test(BM_edge_other_vert(e, v), BM_ELEM_TAG))
                                break;
 
@@ -5493,10 +5491,12 @@ static bool createEdgeSlideVerts(TransInfo *t)
                        }
                        else {
                                BMLoop *l_tmp = BM_loop_other_edge_loop(l_a, v);
-                               if (BM_vert_edge_count_nonwire(v) == 2)
+                               if (EDGESLIDE_VERT_IS_INNER(v, l_tmp->e)) {
                                        get_next_loop(v, l_a, e, l_tmp->e, vec_a);
-                               else
+                               }
+                               else {
                                        sub_v3_v3v3(vec_a, BM_edge_other_vert(l_tmp->e, v)->co, v->co);
+                               }
                        }
                }
 
@@ -5508,17 +5508,21 @@ static bool createEdgeSlideVerts(TransInfo *t)
                        }
                        else {
                                BMLoop *l_tmp = BM_loop_other_edge_loop(l_b, v);
-                               if (BM_vert_edge_count_nonwire(v) == 2)
+                               if (EDGESLIDE_VERT_IS_INNER(v, l_tmp->e)) {
                                        get_next_loop(v, l_b, e, l_tmp->e, vec_b);
-                               else
+                               }
+                               else {
                                        sub_v3_v3v3(vec_b, BM_edge_other_vert(l_tmp->e, v)->co, v->co);
-
+                               }
                        }
                }
                else {
                        l_b = NULL;
                }
 
+               l_a_prev = NULL;
+               l_b_prev = NULL;
+
                /*iterate over the loop*/
                v_first = v;
                do {
@@ -5536,14 +5540,14 @@ static bool createEdgeSlideVerts(TransInfo *t)
                        copy_v3_v3(sv->v_co_orig, v->co);
                        sv->loop_nr = loop_nr;
 
-                       if (l_a) {
-                               BMLoop *l_tmp = BM_loop_other_edge_loop(l_a, v);
+                       if (l_a || l_a_prev) {
+                               BMLoop *l_tmp = BM_loop_other_edge_loop(l_a ? l_a : l_a_prev, v);
                                sv->v_a = BM_edge_other_vert(l_tmp->e, v);
                                copy_v3_v3(sv->dir_a, vec_a);
                        }
 
-                       if (l_b) {
-                               BMLoop *l_tmp = BM_loop_other_edge_loop(l_b, v);
+                       if (l_b || l_b_prev) {
+                               BMLoop *l_tmp = BM_loop_other_edge_loop(l_b ? l_b : l_b_prev, v);
                                sv->v_b = BM_edge_other_vert(l_tmp->e, v);
                                copy_v3_v3(sv->dir_b, vec_b);
                        }
@@ -5565,7 +5569,7 @@ static bool createEdgeSlideVerts(TransInfo *t)
                                if (l_a) {
                                        BMLoop *l_tmp = BM_loop_other_edge_loop(l_a, v);
                                        sv->v_a = BM_edge_other_vert(l_tmp->e, v);
-                                       if (BM_vert_edge_count_nonwire(v) == 2) {
+                                       if (EDGESLIDE_VERT_IS_INNER(v, l_tmp->e)) {
                                                get_next_loop(v, l_a, e_prev, l_tmp->e, sv->dir_a);
                                        }
                                        else {
@@ -5576,7 +5580,7 @@ static bool createEdgeSlideVerts(TransInfo *t)
                                if (l_b) {
                                        BMLoop *l_tmp = BM_loop_other_edge_loop(l_b, v);
                                        sv->v_b = BM_edge_other_vert(l_tmp->e, v);
-                                       if (BM_vert_edge_count_nonwire(v) == 2) {
+                                       if (EDGESLIDE_VERT_IS_INNER(v, l_tmp->e)) {
                                                get_next_loop(v, l_b, e_prev, l_tmp->e, sv->dir_b);
                                        }
                                        else {
@@ -5592,28 +5596,53 @@ static bool createEdgeSlideVerts(TransInfo *t)
                        l_a_ok_prev = (l_a != NULL);
                        l_b_ok_prev = (l_b != NULL);
 
-                       l_a = l_a ? get_next_loop(v, l_a, e_prev, e, vec_a) : NULL;
-                       l_b = l_b ? get_next_loop(v, l_b, e_prev, e, vec_b) : NULL;
-
-                       /* find the opposite loop if it was missing previously */
-                       if      (l_a == NULL && l_b && (l_b->radial_next != l_b)) l_a = l_b->radial_next;
-                       else if (l_b == NULL && l_a && (l_a->radial_next != l_a)) l_b = l_a->radial_next;
-
-                       /* if there are non-contiguous faces, we can still recover the loops of the new edges faces */
-                       /* note!, the behavior in this case means edges may move in opposite directions,
-                        * this could be made to work more usefully. */
-                       if (!(l_a && l_b) && (e->l != NULL)) {
-                               if (l_a_ok_prev) {
-                                       l_a = e->l;
-                                       if (l_a->radial_next != l_a) {
-                                               l_b = l_a->radial_next;
-                                       }
+                       l_a_prev = l_a;
+                       l_b_prev = l_b;
+
+                       if (l_a) {
+                               l_a = get_next_loop(v, l_a, e_prev, e, vec_a);
+                       }
+                       else {
+                               zero_v3(vec_a);
+                       }
+
+                       if (l_b) {
+                               l_b = get_next_loop(v, l_b, e_prev, e, vec_b);
+                       }
+                       else {
+                               zero_v3(vec_b);
+                       }
+
+
+                       if (l_a && l_b) {
+                               /* pass */
+                       }
+                       else {
+                               if (l_a || l_b) {
+                                       /* find the opposite loop if it was missing previously */
+                                       if      (l_a == NULL && l_b && (l_b->radial_next != l_b)) l_a = l_b->radial_next;
+                                       else if (l_b == NULL && l_a && (l_a->radial_next != l_a)) l_b = l_a->radial_next;
                                }
-                               else if (l_b_ok_prev) {
-                                       l_b = e->l;
-                                       if (l_b->radial_next != l_b) {
-                                               l_a = l_b->radial_next;
+                               else if (e->l != NULL) {
+                                       /* if there are non-contiguous faces, we can still recover the loops of the new edges faces */
+                                       /* note!, the behavior in this case means edges may move in opposite directions,
+                                        * this could be made to work more usefully. */
+
+                                       if (l_a_ok_prev) {
+                                               l_a = e->l;
+                                               l_b = (l_a->radial_next != l_a) ? l_a->radial_next : NULL;
                                        }
+                                       else if (l_b_ok_prev) {
+                                               l_b = e->l;
+                                               l_a = (l_b->radial_next != l_b) ? l_b->radial_next : NULL;
+                                       }
+                               }
+
+                               if (!l_a_ok_prev && l_a) {
+                                       get_next_loop(v, l_a, e, e_prev, vec_a);
+                               }
+                               if (!l_b_ok_prev && l_b) {
+                                       get_next_loop(v, l_b, e, e_prev, vec_b);
                                }
                        }
 
@@ -5622,6 +5651,8 @@ static bool createEdgeSlideVerts(TransInfo *t)
                } while ((e != v_first->e) && (l_a || l_b));
 
                loop_nr++;
+
+#undef EDGESLIDE_VERT_IS_INNER
        }
 
        /* use for visibility checks */
@@ -6205,7 +6236,7 @@ static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
 
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
 
                if (is_proportional) {
                        BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Edge Slide: %s (E)ven: %s"),
@@ -6249,8 +6280,8 @@ static void calcVertSlideCustomPoints(struct TransInfo *t)
 {
        VertSlideData *sld = t->customData;
        TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index];
-       float *co_orig = sv->co_orig_2d;
-       float *co_curr = sv->co_link_orig_2d[sv->co_link_curr];
+       const float *co_orig = sv->co_orig_2d;
+       const float *co_curr = sv->co_link_orig_2d[sv->co_link_curr];
        const int mval_start[2] = {co_orig[0], co_orig[1]};
        const int mval_end[2]   = {co_curr[0], co_curr[1]};
 
@@ -6728,7 +6759,7 @@ static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2]))
        ofs += BLI_strncpy_rlen(str + ofs, IFACE_("Vert Slide: "), MAX_INFO_LEN - ofs);
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
                ofs += BLI_strncpy_rlen(str + ofs, &c[0], MAX_INFO_LEN - ofs);
        }
        else {
@@ -6795,7 +6826,7 @@ static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2]))
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
 
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
 
                BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Roll: %s"), &c[0]);
        }
@@ -6869,7 +6900,7 @@ static void applyBakeTime(TransInfo *t, const int mval[2])
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
 
-               outputNumInput(&(t->num), c);
+               outputNumInput(&(t->num), c, &t->scene->unit);
 
                if (time >= 0.0f)
                        BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Time: +%s %s"), c, t->proptext);
@@ -7080,7 +7111,7 @@ static void headerSeqSlide(TransInfo *t, float val[2], char str[MAX_INFO_LEN])
        size_t ofs = 0;
 
        if (hasNumInput(&t->num)) {
-               outputNumInput(&(t->num), tvec);
+               outputNumInput(&(t->num), tvec, &t->scene->unit);
        }
        else {
                BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.0f, %.0f", val[0], val[1]);
@@ -7306,7 +7337,7 @@ static void headerTimeTranslate(TransInfo *t, char str[MAX_INFO_LEN])
 
        /* if numeric input is active, use results from that, otherwise apply snapping to result */
        if (hasNumInput(&t->num)) {
-               outputNumInput(&(t->num), tvec);
+               outputNumInput(&(t->num), tvec, &t->scene->unit);
        }
        else {
                const Scene *scene = t->scene;
@@ -7323,13 +7354,17 @@ static void headerTimeTranslate(TransInfo *t, char str[MAX_INFO_LEN])
                        /* second step */
                        val = floorf((double)val / secf + 0.5);
                }
-               else {
-                       /* nearest frame/second/marker */
+               else if (autosnap == SACTSNAP_SECOND) {
+                       /* nearest second */
                        val = (float)((double)val / secf);
                }
                
                if (autosnap == SACTSNAP_FRAME)
                        BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%d.00 (%.4f)", (int)val, val);
+               else if (autosnap == SACTSNAP_SECOND)
+                       BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%d.00 sec (%.4f)", (int)val, val);
+               else if (autosnap == SACTSNAP_TSTEP)
+                       BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f sec", val);
                else
                        BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", val);
        }
@@ -7466,7 +7501,7 @@ static void headerTimeSlide(TransInfo *t, float sval, char str[MAX_INFO_LEN])
        char tvec[NUM_STR_REP_LEN * 3];
 
        if (hasNumInput(&t->num)) {
-               outputNumInput(&(t->num), tvec);
+               outputNumInput(&(t->num), tvec, &t->scene->unit);
        }
        else {
                float minx = *((float *)(t->customData));
@@ -7614,7 +7649,7 @@ static void headerTimeScale(TransInfo *t, char str[MAX_INFO_LEN])
        char tvec[NUM_STR_REP_LEN * 3];
 
        if (hasNumInput(&t->num))
-               outputNumInput(&(t->num), tvec);
+               outputNumInput(&(t->num), tvec, &t->scene->unit);
        else
                BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", t->values[0]);
 
@@ -7680,16 +7715,11 @@ static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2]))
 
 
 /* TODO, move to: transform_queries.c */
-bool checkUseLocalCenter_GraphEdit(TransInfo *t)
-{
-       return ((t->around == V3D_LOCAL) && !ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE));
-}
-
 bool checkUseAxisMatrix(TransInfo *t)
 {
        /* currently only checks for editmode */
        if (t->flag & T_EDIT) {
-               if ((t->around == V3D_LOCAL) && (ELEM4(t->obedit->type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE))) {
+               if ((t->around == V3D_LOCAL) && (ELEM(t->obedit->type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE))) {
                        /* not all editmode supports axis-matrix */
                        return true;
                }