commit from r27250 to fix bug #21433, broke local axis rotation for pose bones and...
[blender.git] / source / blender / editors / transform / transform.c
index 7e381b24186ab7e4509a40e970e7206542d9ae5f..e4639b268de3328b5271ebe724b64a805ec7d531 100644 (file)
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  * All rights reserved.
 #include "WM_types.h"
 #include "WM_api.h"
 
-#include "BLI_arithb.h"
+#include "BLI_math.h"
 #include "BLI_blenlib.h"
 #include "BLI_editVert.h"
 #include "BLI_ghash.h"
 
 #include "transform.h"
 
+void drawTransformApply(const struct bContext *C, struct ARegion *ar, void *arg);
+
 /* ************************** SPACE DEPENDANT CODE **************************** */
 
 void setTransformViewMatrices(TransInfo *t)
 {
-       if(t->spacetype==SPACE_VIEW3D && t->ar->regiontype == RGN_TYPE_WINDOW) {
+       if(t->spacetype==SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) {
                RegionView3D *rv3d = t->ar->regiondata;
 
-               Mat4CpyMat4(t->viewmat, rv3d->viewmat);
-               Mat4CpyMat4(t->viewinv, rv3d->viewinv);
-               Mat4CpyMat4(t->persmat, rv3d->persmat);
-               Mat4CpyMat4(t->persinv, rv3d->persinv);
+               copy_m4_m4(t->viewmat, rv3d->viewmat);
+               copy_m4_m4(t->viewinv, rv3d->viewinv);
+               copy_m4_m4(t->persmat, rv3d->persmat);
+               copy_m4_m4(t->persinv, rv3d->persinv);
                t->persp = rv3d->persp;
        }
        else {
-               Mat4One(t->viewmat);
-               Mat4One(t->viewinv);
-               Mat4One(t->persmat);
-               Mat4One(t->persinv);
-               t->persp = V3D_ORTHO;
+               unit_m4(t->viewmat);
+               unit_m4(t->viewinv);
+               unit_m4(t->persmat);
+               unit_m4(t->persinv);
+               t->persp = RV3D_ORTHO;
        }
 
        calculateCenter2D(t);
@@ -217,7 +219,7 @@ void projectIntView(TransInfo *t, float *vec, int *adr)
 
                UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1);
        }
-       else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
+       else if(ELEM3(t->spacetype, SPACE_IPO, SPACE_NLA, SPACE_ACTION)) {
                int out[2] = {0, 0};
 
                UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1);
@@ -297,7 +299,7 @@ void removeAspectRatio(TransInfo *t, float *vec)
        }
 }
 
-static void viewRedrawForce(bContext *C, TransInfo *t)
+static void viewRedrawForce(const bContext *C, TransInfo *t)
 {
        if (t->spacetype == SPACE_VIEW3D)
        {
@@ -305,8 +307,10 @@ static void viewRedrawForce(bContext *C, TransInfo *t)
                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);
+               
        }
        else if (t->spacetype == SPACE_ACTION) {
                //SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
@@ -322,7 +326,7 @@ static void viewRedrawForce(bContext *C, TransInfo *t)
        else if(t->spacetype == SPACE_NODE)
        {
                //ED_area_tag_redraw(t->sa);
-               WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL);
+               WM_event_add_notifier(C, NC_SPACE|ND_SPACE_NODE_VIEW, NULL);
        }
        else if(t->spacetype == SPACE_SEQ)
        {
@@ -330,20 +334,22 @@ static void viewRedrawForce(bContext *C, TransInfo *t)
        }
        else if (t->spacetype==SPACE_IMAGE) {
                // XXX how to deal with lock?
-#if 0
                SpaceImage *sima= (SpaceImage*)t->sa->spacedata.first;
-               if(sima->lock) force_draw_plus(SPACE_VIEW3D, 0);
-               else force_draw(0);
-#endif
-
-               WM_event_add_notifier(C, NC_GEOM|ND_DATA, t->obedit->data);
+               if(sima->lock) WM_event_add_notifier(C, NC_GEOM|ND_DATA, t->obedit->data);
+               else ED_area_tag_redraw(t->sa);
        }
 }
 
 static void viewRedrawPost(TransInfo *t)
 {
        ED_area_headerprint(t->sa, NULL);
-
+       
+       if(t->spacetype == SPACE_VIEW3D) {
+               /* if autokeying is enabled, send notifiers that keyframes were added */
+               if (IS_AUTOKEY_ON(t->scene))
+                       WM_main_add_notifier(NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
+       }
+       
 #if 0 // TRANSFORM_FIX_ME
        if(t->spacetype==SPACE_VIEW3D) {
                allqueue(REDRAWBUTSOBJECT, 0);
@@ -454,68 +460,31 @@ static void view_editmove(unsigned short event)
 #endif
 }
 
-#if 0
-static char *transform_to_undostr(TransInfo *t)
-{
-       switch (t->mode) {
-               case TFM_TRANSLATION:
-                       return "Translate";
-               case TFM_ROTATION:
-                       return "Rotate";
-               case TFM_RESIZE:
-                       return "Scale";
-               case TFM_TOSPHERE:
-                       return "To Sphere";
-               case TFM_SHEAR:
-                       return "Shear";
-               case TFM_WARP:
-                       return "Warp";
-               case TFM_SHRINKFATTEN:
-                       return "Shrink/Fatten";
-               case TFM_TILT:
-                       return "Tilt";
-               case TFM_TRACKBALL:
-                       return "Trackball";
-               case TFM_PUSHPULL:
-                       return "Push/Pull";
-               case TFM_BEVEL:
-                       return "Bevel";
-               case TFM_BWEIGHT:
-                       return "Bevel Weight";
-               case TFM_CREASE:
-                       return "Crease";
-               case TFM_BONESIZE:
-                       return "Bone Width";
-               case TFM_BONE_ENVELOPE:
-                       return "Bone Envelope";
-               case TFM_TIME_TRANSLATE:
-                       return "Translate Anim. Data";
-               case TFM_TIME_SCALE:
-                       return "Scale Anim. Data";
-               case TFM_TIME_SLIDE:
-                       return "Time Slide";
-               case TFM_BAKE_TIME:
-                       return "Key Time";
-               case TFM_MIRROR:
-                       return "Mirror";
-       }
-       return "Transform";
-}
-#endif
-
 /* ************************************************* */
 
 /* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
-#define TFM_MODAL_CANCEL                       1
-#define TFM_MODAL_CONFIRM                      2
-#define TFM_MODAL_TRANSLATE                    3
-#define TFM_MODAL_ROTATE                       4
-#define TFM_MODAL_RESIZE                       5
-#define TFM_MODAL_SNAP_GEARS           6
-#define TFM_MODAL_SNAP_GEARS_OFF       7
+#define TFM_MODAL_CANCEL               1
+#define TFM_MODAL_CONFIRM              2
+#define TFM_MODAL_TRANSLATE            3
+#define TFM_MODAL_ROTATE               4
+#define TFM_MODAL_RESIZE               5
+#define TFM_MODAL_SNAP_INV_ON  6
+#define TFM_MODAL_SNAP_INV_OFF 7
+#define TFM_MODAL_SNAP_TOGGLE  8
+#define TFM_MODAL_AXIS_X               9
+#define TFM_MODAL_AXIS_Y               10
+#define TFM_MODAL_AXIS_Z               11
+#define TFM_MODAL_PLANE_X              12
+#define TFM_MODAL_PLANE_Y              13
+#define TFM_MODAL_PLANE_Z              14
+#define TFM_MODAL_CONS_OFF             15
+#define TFM_MODAL_ADD_SNAP             16
+#define TFM_MODAL_REMOVE_SNAP  17
+/*     18 and 19 used by numinput, defined in transform.h
+ * */
 
 /* called in transform_ops.c, on each regeneration of keymaps */
-void transform_modal_keymap(wmWindowManager *wm)
+wmKeyMap* transform_modal_keymap(wmKeyConfig *keyconf)
 {
        static EnumPropertyItem modal_items[] = {
        {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
@@ -523,20 +492,32 @@ void transform_modal_keymap(wmWindowManager *wm)
        {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
        {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""},
        {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""},
-       {TFM_MODAL_SNAP_GEARS, "SNAP_GEARS", 0, "Snap On", ""},
-       {TFM_MODAL_SNAP_GEARS_OFF, "SNAP_GEARS_OFF", 0, "Snap Off", ""},
+       {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Invert Snap On", ""},
+       {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Invert Snap Off", ""},
+       {TFM_MODAL_SNAP_TOGGLE, "SNAP_TOGGLE", 0, "Snap Toggle", ""},
+       {TFM_MODAL_AXIS_X, "AXIS_X", 0, "Orientation X axis", ""},
+       {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Orientation Y axis", ""},
+       {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Orientation Z axis", ""},
+       {TFM_MODAL_PLANE_X, "PLANE_X", 0, "Orientation X plane", ""},
+       {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Orientation Y plane", ""},
+       {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Orientation Z plane", ""},
+       {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Remove Constraints", ""},
+       {TFM_MODAL_ADD_SNAP, "ADD_SNAP", 0, "Add Snap Point", ""},
+       {TFM_MODAL_REMOVE_SNAP, "REMOVE_SNAP", 0, "Remove Last Snap Point", ""},
+       {NUM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""},
+       {NUM_MODAL_INCREMENT_DOWN, "INCREMENT_DOWN", 0, "Numinput Increment Down", ""},
        {0, NULL, 0, NULL, NULL}};
        
-       wmKeyMap *keymap= WM_modalkeymap_get(wm, "Transform Modal Map");
+       wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Transform Modal Map");
        
        /* this function is called for each spacetype, only needs to add map once */
-       if(keymap) return;
+       if(keymap) return NULL;
        
-       keymap= WM_modalkeymap_add(wm, "Transform Modal Map", modal_items);
+       keymap= WM_modalkeymap_add(keyconf, "Transform Modal Map", modal_items);
        
        /* items for modal map */
        WM_modalkeymap_add_item(keymap, ESCKEY,    KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL);
-       WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, TFM_MODAL_CONFIRM);
+       WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM);
        WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM);
        WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM);
 
@@ -544,37 +525,42 @@ void transform_modal_keymap(wmWindowManager *wm)
        WM_modalkeymap_add_item(keymap, RKEY, KM_PRESS, 0, 0, TFM_MODAL_ROTATE);
        WM_modalkeymap_add_item(keymap, SKEY, KM_PRESS, 0, 0, TFM_MODAL_RESIZE);
        
-       WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_SNAP_GEARS);
-       WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, TFM_MODAL_SNAP_GEARS_OFF);
-       
-       /* assign map to operators */
-       WM_modalkeymap_assign(keymap, "TFM_OT_transform");
-       WM_modalkeymap_assign(keymap, "TFM_OT_translate");
-       WM_modalkeymap_assign(keymap, "TFM_OT_rotate");
-       WM_modalkeymap_assign(keymap, "TFM_OT_tosphere");
-       WM_modalkeymap_assign(keymap, "TFM_OT_resize");
-       WM_modalkeymap_assign(keymap, "TFM_OT_shear");
-       WM_modalkeymap_assign(keymap, "TFM_OT_warp");
-       WM_modalkeymap_assign(keymap, "TFM_OT_shrink_fatten");
-       WM_modalkeymap_assign(keymap, "TFM_OT_tilt");
-       WM_modalkeymap_assign(keymap, "TFM_OT_trackball");
+       WM_modalkeymap_add_item(keymap, TABKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_SNAP_TOGGLE);
+
+       WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_SNAP_INV_ON);
+       WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, TFM_MODAL_SNAP_INV_OFF);
        
+       WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, 0, 0, TFM_MODAL_ADD_SNAP);
+       WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, KM_ALT, 0, TFM_MODAL_REMOVE_SNAP);
+
+       WM_modalkeymap_add_item(keymap, UPARROWKEY, KM_PRESS, 0, 0, NUM_MODAL_INCREMENT_UP);
+       WM_modalkeymap_add_item(keymap, DOWNARROWKEY, KM_PRESS, 0, 0, NUM_MODAL_INCREMENT_DOWN);
+
+       return keymap;
 }
 
 
-void transformEvent(TransInfo *t, wmEvent *event)
+int transformEvent(TransInfo *t, wmEvent *event)
 {
        float mati[3][3] = {{1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 1.0f}};
        char cmode = constraintModeToChar(t);
+       int handled = 1;
 
        t->redraw |= handleMouseInput(t, &t->mouse, event);
 
        if (event->type == MOUSEMOVE)
        {
+               if (t->modifiers & MOD_CONSTRAINT_SELECT)
+                       t->con.mode |= CON_SELECT;
+
                t->mval[0] = event->x - t->ar->winrct.xmin;
                t->mval[1] = event->y - t->ar->winrct.ymin;
 
-               t->redraw = 1;
+               t->redraw |= TREDRAW_SOFT;
+
+               if (t->state == TRANS_STARTING) {
+                   t->state = TRANS_RUNNING;
+               }
 
                applyMouseInput(t, &t->mouse, t->mval, t->values);
        }
@@ -588,7 +574,6 @@ void transformEvent(TransInfo *t, wmEvent *event)
                        case TFM_MODAL_CONFIRM:
                                t->state = TRANS_CONFIRM;
                                break;
-                               
                        case TFM_MODAL_TRANSLATE:
                                /* only switch when... */
                                if( ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
@@ -596,7 +581,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
                                        restoreTransObjects(t);
                                        initTranslation(t);
                                        initSnapping(t, NULL); // need to reinit after mode change
-                                       t->redraw = 1;
+                                       t->redraw |= TREDRAW_HARD;
                                }
                                break;
                        case TFM_MODAL_ROTATE:
@@ -614,7 +599,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
                                                initRotation(t);
                                        }
                                        initSnapping(t, NULL); // need to reinit after mode change
-                                       t->redraw = 1;
+                                       t->redraw |= TREDRAW_HARD;
                                }
                                break;
                        case TFM_MODAL_RESIZE:
@@ -624,19 +609,119 @@ void transformEvent(TransInfo *t, wmEvent *event)
                                        restoreTransObjects(t);
                                        initResize(t);
                                        initSnapping(t, NULL); // need to reinit after mode change
-                                       t->redraw = 1;
+                                       t->redraw |= TREDRAW_HARD;
                                }
                                break;
                                
-                       case TFM_MODAL_SNAP_GEARS:
-                               t->modifiers |= MOD_SNAP_GEARS;
-                               t->redraw = 1;
+                       case TFM_MODAL_SNAP_INV_ON:
+                               t->modifiers |= MOD_SNAP_INVERT;
+                               t->redraw |= TREDRAW_HARD;
+                               break;
+                       case TFM_MODAL_SNAP_INV_OFF:
+                               t->modifiers &= ~MOD_SNAP_INVERT;
+                               t->redraw |= TREDRAW_HARD;
+                               break;
+                       case TFM_MODAL_SNAP_TOGGLE:
+                               t->modifiers ^= MOD_SNAP;
+                               t->redraw |= TREDRAW_HARD;
+                               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), "along X");
+                                               }
+                                               else {
+                                                       setUserConstraint(t, t->current_orientation, (CON_AXIS0), "along %s X");
+                                               }
+                                       }
+                                       t->redraw |= TREDRAW_HARD;
+                               }
+                               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), "along Y");
+                                               }
+                                               else {
+                                                       setUserConstraint(t, t->current_orientation, (CON_AXIS1), "along %s Y");
+                                               }
+                                       }
+                                       t->redraw |= TREDRAW_HARD;
+                               }
+                               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), "along %s Z");
+                                       }
+                                       t->redraw |= TREDRAW_HARD;
+                               }
+                               break;
+                       case TFM_MODAL_PLANE_X:
+                               if ((t->flag & (T_NO_CONSTRAINT|T_2D_EDIT))== 0) {
+                                       if (cmode == 'X') {
+                                               stopConstraint(t);
+                                       }
+                                       else {
+                                               setUserConstraint(t, t->current_orientation, (CON_AXIS1|CON_AXIS2), "locking %s X");
+                                       }
+                                       t->redraw |= TREDRAW_HARD;
+                               }
+                               break;
+                       case TFM_MODAL_PLANE_Y:
+                               if ((t->flag & (T_NO_CONSTRAINT|T_2D_EDIT))== 0) {
+                                       if (cmode == 'Y') {
+                                               stopConstraint(t);
+                                       }
+                                       else {
+                                               setUserConstraint(t, t->current_orientation, (CON_AXIS0|CON_AXIS2), "locking %s Y");
+                                       }
+                                       t->redraw |= TREDRAW_HARD;
+                               }
+                               break;
+                       case TFM_MODAL_PLANE_Z:
+                               if ((t->flag & (T_NO_CONSTRAINT|T_2D_EDIT))== 0) {
+                                       if (cmode == 'Z') {
+                                               stopConstraint(t);
+                                       }
+                                       else {
+                                               setUserConstraint(t, t->current_orientation, (CON_AXIS0|CON_AXIS1), "locking %s Z");
+                                       }
+                                       t->redraw |= TREDRAW_HARD;
+                               }
+                               break;
+                       case TFM_MODAL_CONS_OFF:
+                               if ((t->flag & T_NO_CONSTRAINT)==0) {
+                                       stopConstraint(t);
+                                       t->redraw |= TREDRAW_HARD;
+                               }
+                               break;
+                       case TFM_MODAL_ADD_SNAP:
+                               addSnapPoint(t);
+                               t->redraw |= TREDRAW_HARD;
                                break;
-                       case TFM_MODAL_SNAP_GEARS_OFF:
-                               t->modifiers &= ~MOD_SNAP_GEARS;
-                               t->redraw = 1;
+                       case TFM_MODAL_REMOVE_SNAP:
+                               removeSnapPoint(t);
+                               t->redraw |= TREDRAW_HARD;
+                               break;
+                       default:
+                               handled = 0;
                                break;
                }
+
+               // Modal numinput events
+               t->redraw |= handleNumInput(&(t->num), event);
        }
        /* else do non-mapped events */
        else if (event->val==KM_PRESS) {
@@ -645,16 +730,10 @@ void transformEvent(TransInfo *t, wmEvent *event)
                        t->state = TRANS_CANCEL;
                        break;
                /* enforce redraw of transform when modifiers are used */
-               case LEFTCTRLKEY:
-               case RIGHTCTRLKEY:
-                       t->modifiers |= MOD_SNAP_GEARS;
-                       t->redraw = 1;
-                       break;
-
                case LEFTSHIFTKEY:
                case RIGHTSHIFTKEY:
                        t->modifiers |= MOD_CONSTRAINT_PLANE;
-                       t->redraw = 1;
+                       t->redraw |= TREDRAW_HARD;
                        break;
 
                case SPACEKEY:
@@ -665,7 +744,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
                                getmouseco_sc(mval);
                                BIF_selectOrientation();
                                calc_manipulator_stats(curarea);
-                               Mat3CpyMat4(t->spacemtx, G.vd->twmat);
+                               copy_m3_m4(t->spacemtx, G.vd->twmat);
                                warp_pointer(mval[0], mval[1]);
 #endif
                        }
@@ -702,7 +781,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
                                                postSelectConstraint(t);
                                        }
                                }
-                               t->redraw = 1;
+                               t->redraw |= TREDRAW_HARD;
                        }
                        break;
                case ESCKEY:
@@ -719,7 +798,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
                                restoreTransObjects(t);
                                initTranslation(t);
                                initSnapping(t, NULL); // need to reinit after mode change
-                               t->redraw = 1;
+                               t->redraw |= TREDRAW_HARD;
                        }
                        break;
                case SKEY:
@@ -729,7 +808,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
                                restoreTransObjects(t);
                                initResize(t);
                                initSnapping(t, NULL); // need to reinit after mode change
-                               t->redraw = 1;
+                               t->redraw |= TREDRAW_HARD;
                        }
                        break;
                case RKEY:
@@ -747,7 +826,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
                                        initRotation(t);
                                }
                                initSnapping(t, NULL); // need to reinit after mode change
-                               t->redraw = 1;
+                               t->redraw |= TREDRAW_HARD;
                        }
                        break;
                case CKEY:
@@ -759,100 +838,93 @@ void transformEvent(TransInfo *t, wmEvent *event)
                        }
                        else {
                                stopConstraint(t);
-                               t->redraw = 1;
+                               t->redraw |= TREDRAW_HARD;
                        }
                        break;
                case XKEY:
                        if ((t->flag & T_NO_CONSTRAINT)==0) {
-                               if (cmode == 'X') {
-                                       if (t->flag & T_2D_EDIT) {
+                               if (t->flag & T_2D_EDIT) {
+                                       if (cmode == 'X') {
                                                stopConstraint(t);
+                                       } else {
+                                               setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS0), "along X");
                                        }
-                                       else {
-                                               if (t->con.mode & CON_USER) {
+                               } else {
+                                       if (cmode == 'X') {
+                                               if (t->con.orientation != V3D_MANIP_GLOBAL) {
                                                        stopConstraint(t);
-                                               }
-                                               else {
+                                               } else {
+                                                       short orientation = t->current_orientation != V3D_MANIP_GLOBAL ? t->current_orientation : V3D_MANIP_LOCAL;
                                                        if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0)
-                                                               setUserConstraint(t, (CON_AXIS0), "along %s X");
+                                                               setUserConstraint(t, orientation, (CON_AXIS0), "along %s X");
                                                        else if (t->modifiers & MOD_CONSTRAINT_PLANE)
-                                                               setUserConstraint(t, (CON_AXIS1|CON_AXIS2), "locking %s X");
+                                                               setUserConstraint(t, orientation, (CON_AXIS1|CON_AXIS2), "locking %s X");
                                                }
-                                       }
-                               }
-                               else {
-                                       if (t->flag & T_2D_EDIT) {
-                                               setConstraint(t, mati, (CON_AXIS0), "along X axis");
-                                       }
-                                       else {
+                                       } else {
                                                if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0)
-                                                       setConstraint(t, mati, (CON_AXIS0), "along global X");
+                                                       setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS0), "along %s X");
                                                else if (t->modifiers & MOD_CONSTRAINT_PLANE)
-                                                       setConstraint(t, mati, (CON_AXIS1|CON_AXIS2), "locking global X");
+                                                       setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS1|CON_AXIS2), "locking %s X");
                                        }
                                }
-                               t->redraw = 1;
+                               t->redraw |= TREDRAW_HARD;
                        }
                        break;
                case YKEY:
                        if ((t->flag & T_NO_CONSTRAINT)==0) {
-                               if (cmode == 'Y') {
-                                       if (t->flag & T_2D_EDIT) {
+                               if (t->flag & T_2D_EDIT) {
+                                       if (cmode == 'Y') {
                                                stopConstraint(t);
+                                       } else {
+                                               setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS1), "along Y");
                                        }
-                                       else {
-                                               if (t->con.mode & CON_USER) {
+                               } else {
+                                       if (cmode == 'Y') {
+                                               if (t->con.orientation != V3D_MANIP_GLOBAL) {
                                                        stopConstraint(t);
-                                               }
-                                               else {
+                                               } else {
+                                                       short orientation = t->current_orientation != V3D_MANIP_GLOBAL ? t->current_orientation : V3D_MANIP_LOCAL;
                                                        if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0)
-                                                               setUserConstraint(t, (CON_AXIS1), "along %s Y");
+                                                               setUserConstraint(t, orientation, (CON_AXIS1), "along %s Y");
                                                        else if (t->modifiers & MOD_CONSTRAINT_PLANE)
-                                                               setUserConstraint(t, (CON_AXIS0|CON_AXIS2), "locking %s Y");
+                                                               setUserConstraint(t, orientation, (CON_AXIS0|CON_AXIS2), "locking %s Y");
                                                }
-                                       }
-                               }
-                               else {
-                                       if (t->flag & T_2D_EDIT) {
-                                               setConstraint(t, mati, (CON_AXIS1), "along Y axis");
-                                       }
-                                       else {
+                                       } else {
                                                if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0)
-                                                       setConstraint(t, mati, (CON_AXIS1), "along global Y");
+                                                       setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS1), "along %s Y");
                                                else if (t->modifiers & MOD_CONSTRAINT_PLANE)
-                                                       setConstraint(t, mati, (CON_AXIS0|CON_AXIS2), "locking global Y");
+                                                       setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS0|CON_AXIS2), "locking %s Y");
                                        }
                                }
-                               t->redraw = 1;
+                               t->redraw |= TREDRAW_HARD;
                        }
                        break;
                case ZKEY:
-                       if ((t->flag & T_NO_CONSTRAINT)==0) {
+                       if ((t->flag & (T_NO_CONSTRAINT|T_2D_EDIT))==0) {
                                if (cmode == 'Z') {
-                                       if (t->con.mode & CON_USER) {
+                                       if (t->con.orientation != V3D_MANIP_GLOBAL) {
                                                stopConstraint(t);
-                                       }
-                                       else {
+                                       } else {
+                                               short orientation = t->current_orientation != V3D_MANIP_GLOBAL ? t->current_orientation : V3D_MANIP_LOCAL;
                                                if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0)
-                                                       setUserConstraint(t, (CON_AXIS2), "along %s Z");
-                                               else if ((t->modifiers & MOD_CONSTRAINT_PLANE) && ((t->flag & T_2D_EDIT)==0))
-                                                       setUserConstraint(t, (CON_AXIS0|CON_AXIS1), "locking %s Z");
+                                                       setUserConstraint(t, orientation, (CON_AXIS2), "along %s Z");
+                                               else if (t->modifiers & MOD_CONSTRAINT_PLANE)
+                                                       setUserConstraint(t, orientation, (CON_AXIS0|CON_AXIS1), "locking %s Z");
                                        }
-                               }
-                               else if ((t->flag & T_2D_EDIT)==0) {
+                               } else {
                                        if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0)
-                                               setConstraint(t, mati, (CON_AXIS2), "along global Z");
+                                               setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS2), "along %s Z");
                                        else if (t->modifiers & MOD_CONSTRAINT_PLANE)
-                                               setConstraint(t, mati, (CON_AXIS0|CON_AXIS1), "locking global Z");
+                                               setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS0|CON_AXIS1), "locking %s Z");
                                }
-                               t->redraw = 1;
+                               t->redraw |= TREDRAW_HARD;
                        }
                        break;
                case OKEY:
                        if (t->flag & T_PROP_EDIT && event->shift) {
                                t->prop_mode = (t->prop_mode + 1) % 6;
                                calculatePropRatio(t);
-                               t->redraw = 1;
+                               t->redraw |= TREDRAW_HARD;
                        }
                        break;
                case PADPLUSKEY:
@@ -896,6 +968,9 @@ void transformEvent(TransInfo *t, wmEvent *event)
 //             case NDOFMOTION:
 //            viewmoveNDOF(1);
   //         break;
+               default:
+                       handled = 0;
+                       break;
                }
 
                // Numerical input events
@@ -920,7 +995,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
                                else
                                {
                                        /* Otherwise, just redraw, NDof input was cancelled */
-                                       t->redraw = 1;
+                                       t->redraw |= TREDRAW_HARD;
                                }
                                break;
                        case NDOF_NOMOVE:
@@ -931,9 +1006,11 @@ void transformEvent(TransInfo *t, wmEvent *event)
                                }
                                break;
                        case NDOF_REFRESH:
-                               t->redraw = 1;
+                               t->redraw |= TREDRAW_HARD;
+                               break;
+                       default:
+                               handled = 0;
                                break;
-
                }
 
                // Snapping events
@@ -941,29 +1018,19 @@ void transformEvent(TransInfo *t, wmEvent *event)
 
                //arrows_move_cursor(event->type);
        }
-       else {
+       else if (event->val==KM_RELEASE) {
                switch (event->type){
-               case LEFTMOUSE:
-                       t->state = TRANS_CONFIRM;
-                       break;
                case LEFTSHIFTKEY:
                case RIGHTSHIFTKEY:
                        t->modifiers &= ~MOD_CONSTRAINT_PLANE;
-                       t->redraw = 1;
+                       t->redraw |= TREDRAW_HARD;
                        break;
 
-               case LEFTCTRLKEY:
-               case RIGHTCTRLKEY:
-                       t->modifiers &= ~MOD_SNAP_GEARS;
-                       /* no redraw on release modifier keys! this makes sure you can assign the 'grid' still
-                          after releasing modifer key */
-                       //t->redraw = 1;
-                       break;
                case MIDDLEMOUSE:
                        if ((t->flag & T_NO_CONSTRAINT)==0) {
                                t->modifiers &= ~MOD_CONSTRAINT_SELECT;
                                postSelectConstraint(t);
-                               t->redraw = 1;
+                               t->redraw |= TREDRAW_HARD;
                        }
                        break;
 //             case LEFTMOUSE:
@@ -972,15 +1039,30 @@ void transformEvent(TransInfo *t, wmEvent *event)
 ////                   if (t->options & CTX_TWEAK)
 //                             t->state = TRANS_CONFIRM;
 //                     break;
+               default:
+                       handled = 0;
+                       break;
+               }
+
+               /* confirm transform if launch key is released after mouse move */
+               /* XXX Keyrepeat bug in Xorg fucks this up, will test when fixed */
+               if (event->type == LEFTMOUSE /*t->launch_event*/ && t->state != TRANS_STARTING)
+               {
+                       t->state = TRANS_CONFIRM;
                }
        }
 
        // Per transform event, if present
        if (t->handleEvent)
                t->redraw |= t->handleEvent(t, event);
+
+       if (handled || t->redraw)
+               return 0;
+       else
+               return OPERATOR_PASS_THROUGH;
 }
 
-int calculateTransformCenter(bContext *C, wmEvent *event, int centerMode, float *vec)
+int calculateTransformCenter(bContext *C, int centerMode, float *vec)
 {
        TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data");
        int success = 1;
@@ -991,9 +1073,9 @@ int calculateTransformCenter(bContext *C, wmEvent *event, int centerMode, float
 
        t->mode = TFM_DUMMY;
 
-       initTransInfo(C, t, NULL, event);                                       // internal data, mouse, vectors
+       initTransInfo(C, t, NULL, NULL);        // internal data, mouse, vectors
 
-       createTransData(C, t);                  // make TransData structs from selection
+       createTransData(C, t);                          // make TransData structs from selection
 
        t->around = centerMode;                         // override userdefined mode
 
@@ -1009,10 +1091,11 @@ int calculateTransformCenter(bContext *C, wmEvent *event, int centerMode, float
                VECCOPY(vec, t->con.center);
        }
 
-       postTrans(t);
 
        /* aftertrans does insert ipos and action channels, and clears base flags, doesnt read transdata */
-       special_aftertrans_update(t);
+       special_aftertrans_update(C, t);
+
+       postTrans(C, t);
 
        MEM_freeN(t);
 
@@ -1103,32 +1186,28 @@ static void drawArc(float size, float angle_start, float angle_end, int segments
        glEnd();
 }
 
-void drawHelpline(const struct bContext *C, TransInfo *t)
+static void drawHelpline(bContext *C, int x, int y, void *customdata)
 {
+       TransInfo *t = (TransInfo*)customdata;
+
        if (t->helpline != HLP_NONE && !(t->flag & T_USES_MANIPULATOR))
        {
                float vecrot[3], cent[2];
+               int mval[2] = {x, y};
 
                VECCOPY(vecrot, t->center);
                if(t->flag & T_EDIT) {
                        Object *ob= t->obedit;
-                       if(ob) Mat4MulVecfl(ob->obmat, vecrot);
+                       if(ob) mul_m4_v3(ob->obmat, vecrot);
                }
                else if(t->flag & T_POSE) {
                        Object *ob=t->poseobj;
-                       if(ob) Mat4MulVecfl(ob->obmat, vecrot);
+                       if(ob) mul_m4_v3(ob->obmat, vecrot);
                }
 
                projectFloatView(t, vecrot, cent);      // no overflow in extreme cases
 
-               glDisable(GL_DEPTH_TEST);
-
-               glMatrixMode(GL_PROJECTION);
                glPushMatrix();
-               glMatrixMode(GL_MODELVIEW);
-               glPushMatrix();
-
-               ED_region_pixelspace(t->ar);
 
                switch(t->helpline)
                {
@@ -1141,7 +1220,7 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
                                glVertex2fv(cent);
                                glEnd();
 
-                               glTranslatef(t->mval[0], t->mval[1], 0);
+                               glTranslatef(mval[0], mval[1], 0);
                                glRotatef(-180 / M_PI * atan2f(cent[0] - t->mval[0], cent[1] - t->mval[1]), 0, 0, 1);
 
                                setlinestyle(0);
@@ -1153,7 +1232,7 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
                        case HLP_HARROW:
                                UI_ThemeColor(TH_WIRE);
 
-                               glTranslatef(t->mval[0], t->mval[1], 0);
+                               glTranslatef(mval[0], mval[1], 0);
 
                                glLineWidth(3.0);
                                drawArrow(RIGHT, 5, 10, 5);
@@ -1163,7 +1242,7 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
                        case HLP_VARROW:
                                UI_ThemeColor(TH_WIRE);
 
-                               glTranslatef(t->mval[0], t->mval[1], 0);
+                               glTranslatef(mval[0], mval[1], 0);
 
                                glLineWidth(3.0);
                                glBegin(GL_LINES);
@@ -1186,7 +1265,7 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
                                        glVertex2fv(cent);
                                        glEnd();
 
-                                       glTranslatef(cent[0], cent[1], 0);
+                                       glTranslatef(cent[0] - t->mval[0] + mval[0], cent[1] - t->mval[1] + mval[1], 0);
 
                                        setlinestyle(0);
                                        glLineWidth(3.0);
@@ -1215,7 +1294,7 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
                                        char col[3], col2[3];
                                        UI_GetThemeColor3ubv(TH_GRID, col);
 
-                                       glTranslatef(t->mval[0], t->mval[1], 0);
+                                       glTranslatef(mval[0], mval[1], 0);
 
                                        glLineWidth(3.0);
 
@@ -1235,23 +1314,24 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
                                }
                }
 
-               glMatrixMode(GL_PROJECTION);
                glPopMatrix();
-               glMatrixMode(GL_MODELVIEW);
-               glPopMatrix();
-
-               glEnable(GL_DEPTH_TEST);
        }
 }
 
-void drawTransform(const struct bContext *C, struct ARegion *ar, void *arg)
+void drawTransformView(const struct bContext *C, struct ARegion *ar, void *arg)
 {
        TransInfo *t = arg;
 
        drawConstraint(C, t);
        drawPropCircle(C, t);
        drawSnapping(C, t);
-       drawHelpline(C, t);
+}
+
+void drawTransformPixel(const struct bContext *C, struct ARegion *ar, void *arg)
+{
+//     TransInfo *t = arg;
+//
+//     drawHelpline(C, t->mval[0], t->mval[1], t);
 }
 
 void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
@@ -1285,6 +1365,38 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
                proportional = 0;
        }
 
+       // If modal, save settings back in scene if not set as operator argument
+       if (t->flag & T_MODAL) {
+
+               /* save settings if not set in operator */
+               if (RNA_struct_find_property(op->ptr, "proportional") && !RNA_property_is_set(op->ptr, "proportional")) {
+                       ts->proportional = proportional;
+               }
+
+               if (RNA_struct_find_property(op->ptr, "proportional_size") && !RNA_property_is_set(op->ptr, "proportional_size")) {
+                       ts->proportional_size = t->prop_size;
+               }
+                       
+               if (RNA_struct_find_property(op->ptr, "proportional_editing_falloff") && !RNA_property_is_set(op->ptr, "proportional_editing_falloff")) {
+                       ts->prop_mode = t->prop_mode;
+               }
+               
+               /* do we check for parameter? */
+               if (t->modifiers & MOD_SNAP) {
+                       ts->snap_flag |= SCE_SNAP;
+               } else {
+                       ts->snap_flag &= ~SCE_SNAP;
+               }
+
+               if(t->spacetype == SPACE_VIEW3D) {
+                       if (RNA_struct_find_property(op->ptr, "constraint_orientation") && !RNA_property_is_set(op->ptr, "constraint_orientation")) {
+                               View3D *v3d = t->view;
+       
+                               v3d->twmode = t->current_orientation;
+                       }
+               }
+       }
+       
        if (RNA_struct_find_property(op->ptr, "proportional"))
        {
                RNA_enum_set(op->ptr, "proportional", proportional);
@@ -1292,6 +1404,11 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
                RNA_float_set(op->ptr, "proportional_size", t->prop_size);
        }
 
+       if (RNA_struct_find_property(op->ptr, "axis"))
+       {
+               RNA_float_set_array(op->ptr, "axis", t->axis);
+       }
+
        if (RNA_struct_find_property(op->ptr, "mirror"))
        {
                RNA_boolean_set(op->ptr, "mirror", t->flag & T_MIRROR);
@@ -1299,7 +1416,14 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 
        if (RNA_struct_find_property(op->ptr, "constraint_axis"))
        {
-               RNA_enum_set(op->ptr, "constraint_orientation", t->current_orientation);
+               /* constraint orientation can be global, event if user selects something else
+                * so use the orientation in the constraint if set
+                * */
+               if (t->con.mode & CON_APPLY) {
+                       RNA_enum_set(op->ptr, "constraint_orientation", t->con.orientation);
+               } else {
+                       RNA_enum_set(op->ptr, "constraint_orientation", t->current_orientation);
+               }
 
                if (t->con.mode & CON_APPLY)
                {
@@ -1316,20 +1440,6 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 
                RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
        }
-
-       // XXX If modal, save settings back in scene
-       if (t->flag & T_MODAL)
-       {
-               ts->prop_mode = t->prop_mode;
-               ts->proportional = proportional;
-
-               if(t->spacetype == SPACE_VIEW3D)
-               {
-                       View3D *v3d = t->view;
-
-                       v3d->twmode = t->current_orientation;
-               }
-       }
 }
 
 int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int mode)
@@ -1338,12 +1448,14 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
 
        /* added initialize, for external calls to set stuff in TransInfo, like undo string */
 
-       t->state = TRANS_RUNNING;
+       t->state = TRANS_STARTING;
 
        t->options = options;
 
        t->mode = mode;
 
+       t->launch_event = event ? event->type : -1;
+
        if (!initTransInfo(C, t, op, event))                                    // internal data, mouse, vectors
        {
                return 0;
@@ -1354,19 +1466,23 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
                //calc_manipulator_stats(curarea);
                initTransformOrientation(C, t);
 
-               t->draw_handle = ED_region_draw_cb_activate(t->ar->type, drawTransform, t, REGION_DRAW_POST);
+               t->draw_handle_apply = ED_region_draw_cb_activate(t->ar->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW);
+               t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
+               //t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL);
+               t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), NULL, drawHelpline, t);
        }
        else if(t->spacetype == SPACE_IMAGE) {
-               Mat3One(t->spacemtx);
-               t->draw_handle = ED_region_draw_cb_activate(t->ar->type, drawTransform, t, REGION_DRAW_POST);
+               unit_m3(t->spacemtx);
+               t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
+               //t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL);
        }
        else
-               Mat3One(t->spacemtx);
+               unit_m3(t->spacemtx);
 
        createTransData(C, t);                  // make TransData structs from selection
 
        if (t->total == 0) {
-               postTrans(t);
+               postTrans(C, t);
                return 0;
        }
 
@@ -1472,6 +1588,9 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
        case TFM_ALIGN:
                initAlign(t);
                break;
+       case TFM_SEQ_SLIDE:
+               initSeqSlide(t);
+               break;
        }
 
        /* overwrite initial values if operator supplied a non-null vector */
@@ -1484,6 +1603,13 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
                t->flag |= T_AUTOVALUES;
        }
 
+       /* Transformation axis from operator */
+       if (RNA_struct_find_property(op->ptr, "axis") && RNA_property_is_set(op->ptr, "axis"))
+       {
+               RNA_float_get_array(op->ptr, "axis", t->axis);
+               normalize_v3(t->axis);
+       }
+
        /* Constraint init from operator */
        if (RNA_struct_find_property(op->ptr, "constraint_axis") && RNA_property_is_set(op->ptr, "constraint_axis"))
        {
@@ -1505,26 +1631,25 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
                                t->con.mode |= CON_AXIS2;
                        }
 
-                       setUserConstraint(t, t->con.mode, "%s");
+                       setUserConstraint(t, t->current_orientation, t->con.mode, "%s");
                }
        }
 
        return 1;
 }
 
-void transformApply(bContext *C, TransInfo *t)
+void transformApply(const bContext *C, TransInfo *t)
 {
-       if (t->redraw)
+       if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT)))
        {
-               if (t->modifiers & MOD_CONSTRAINT_SELECT)
-                       t->con.mode |= CON_SELECT;
-
                selectConstraint(t);
                if (t->transform) {
                        t->transform(t, t->mval);  // calls recalcData()
                        viewRedrawForce(C, t);
                }
-               t->redraw = 0;
+               t->redraw = TREDRAW_NOTHING;
+       } else if (t->redraw & TREDRAW_SOFT) {
+               viewRedrawForce(C, t);
        }
 
        /* If auto confirm is on, break after one pass */
@@ -1537,7 +1662,17 @@ void transformApply(bContext *C, TransInfo *t)
        {
                // TRANSFORM_FIX_ME
                //do_screenhandlers(G.curscreen);
-               t->redraw = 1;
+               t->redraw |= TREDRAW_HARD;
+       }
+}
+
+void drawTransformApply(const struct bContext *C, struct ARegion *ar, void *arg)
+{
+       TransInfo *t = arg;
+
+       if (t->redraw & TREDRAW_SOFT) {
+               t->redraw |= TREDRAW_HARD;
+               transformApply(C, t);
        }
 }
 
@@ -1545,7 +1680,7 @@ int transformEnd(bContext *C, TransInfo *t)
 {
        int exit_code = OPERATOR_RUNNING_MODAL;
 
-       if (t->state != TRANS_RUNNING)
+       if (t->state != TRANS_STARTING && t->state != TRANS_RUNNING)
        {
                /* handle restoring objects */
                if(t->state == TRANS_CANCEL)
@@ -1558,11 +1693,11 @@ int transformEnd(bContext *C, TransInfo *t)
                        exit_code = OPERATOR_FINISHED;
                }
 
-               /* free data */
-               postTrans(t);
-
                /* aftertrans does insert keyframes, and clears base flags, doesnt read transdata */
-               special_aftertrans_update(t);
+               special_aftertrans_update(C, t);
+
+               /* free data */
+               postTrans(C, t);
 
                /* send events out for redraws */
                viewRedrawPost(t);
@@ -1619,7 +1754,7 @@ static void protectedRotateBits(short protectflag, float *eul, float *oldeul)
 
 /* this function only does the delta rotation */
 /* axis-angle is usually internally stored as quats... */
-static void protectedAxisAngleBits(short protectflag, float *quat, float *oldquat)
+static void protectedAxisAngleBits(short protectflag, float axis[3], float *angle, float oldAxis[3], float oldAngle)
 {
        /* check that protection flags are set */
        if ((protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ|OB_LOCK_ROTW)) == 0)
@@ -1628,21 +1763,20 @@ static void protectedAxisAngleBits(short protectflag, float *quat, float *oldqua
        if (protectflag & OB_LOCK_ROT4D) {
                /* axis-angle getting limited as 4D entities that they are... */
                if (protectflag & OB_LOCK_ROTW)
-                       quat[0]= oldquat[0];
+                       *angle= oldAngle;
                if (protectflag & OB_LOCK_ROTX)
-                       quat[1]= oldquat[1];
+                       axis[0]= oldAxis[0];
                if (protectflag & OB_LOCK_ROTY)
-                       quat[2]= oldquat[2];
+                       axis[1]= oldAxis[1];
                if (protectflag & OB_LOCK_ROTZ)
-                       quat[3]= oldquat[3];
+                       axis[2]= oldAxis[2];
        }
        else {
                /* axis-angle get limited with euler... */
-               float eul[3], oldeul[3], quat1[4];
+               float eul[3], oldeul[3];
                
-               QUATCOPY(quat1, quat);
-               AxisAngleToEulO(quat+1, quat[0], eul, EULER_ORDER_DEFAULT);
-               AxisAngleToEulO(oldquat+1, oldquat[0], oldeul, EULER_ORDER_DEFAULT);
+               axis_angle_to_eulO( eul, EULER_ORDER_DEFAULT,axis, *angle);
+               axis_angle_to_eulO( oldeul, EULER_ORDER_DEFAULT,oldAxis, oldAngle);
                
                if (protectflag & OB_LOCK_ROTX)
                        eul[0]= oldeul[0];
@@ -1651,12 +1785,12 @@ static void protectedAxisAngleBits(short protectflag, float *quat, float *oldqua
                if (protectflag & OB_LOCK_ROTZ)
                        eul[2]= oldeul[2];
                
-               EulOToAxisAngle(eul, EULER_ORDER_DEFAULT, quat+1, quat);
+               eulO_to_axis_angle( axis, angle,eul, EULER_ORDER_DEFAULT);
                
                /* when converting to axis-angle, we need a special exception for the case when there is no axis */
-               if (IS_EQ(quat[1], quat[2]) && IS_EQ(quat[2], quat[3])) {
+               if (IS_EQ(axis[0], axis[1]) && IS_EQ(axis[1], axis[2])) {
                        /* for now, rotate around y-axis then (so that it simply becomes the roll) */
-                       quat[2]= 1.0f;
+                       axis[1]= 1.0f;
                }
        }
 }
@@ -1684,8 +1818,8 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu
                float eul[3], oldeul[3], quat1[4];
                
                QUATCOPY(quat1, quat);
-               QuatToEul(quat, eul);
-               QuatToEul(oldquat, oldeul);
+               quat_to_eul( eul,quat);
+               quat_to_eul( oldeul,oldquat);
                
                if (protectflag & OB_LOCK_ROTX)
                        eul[0]= oldeul[0];
@@ -1694,11 +1828,11 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu
                if (protectflag & OB_LOCK_ROTZ)
                        eul[2]= oldeul[2];
                
-               EulToQuat(eul, quat);
+               eul_to_quat( quat,eul);
                
                /* quaternions flip w sign to accumulate rotations correctly */
                if ( (quat1[0]<0.0f && quat[0]>0.0f) || (quat1[0]>0.0f && quat[0]<0.0f) ) {
-                       QuatMulf(quat, -1.0f);
+                       mul_qt_fl(quat, -1.0f);
                }
        }
 }
@@ -1711,71 +1845,55 @@ static void constraintTransLim(TransInfo *t, TransData *td)
                bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_LOCLIMIT);
                bConstraintOb cob;
                bConstraint *con;
-
+               
                /* Make a temporary bConstraintOb for using these limit constraints
                 *      - they only care that cob->matrix is correctly set ;-)
                 *      - current space should be local
                 */
                memset(&cob, 0, sizeof(bConstraintOb));
-               Mat4One(cob.matrix);
-               if (td->tdi) {
-                       TransDataIpokey *tdi= td->tdi;
-                       cob.matrix[3][0]= tdi->locx[0];
-                       cob.matrix[3][1]= tdi->locy[0];
-                       cob.matrix[3][2]= tdi->locz[0];
-               }
-               else {
-                       VECCOPY(cob.matrix[3], td->loc);
-               }
-
+               unit_m4(cob.matrix);
+               VECCOPY(cob.matrix[3], td->loc);
+               
                /* Evaluate valid constraints */
                for (con= td->con; con; con= con->next) {
                        float tmat[4][4];
-
+                       
                        /* only consider constraint if enabled */
                        if (con->flag & CONSTRAINT_DISABLE) continue;
                        if (con->enforce == 0.0f) continue;
-
+                       
                        /* only use it if it's tagged for this purpose (and the right type) */
                        if (con->type == CONSTRAINT_TYPE_LOCLIMIT) {
                                bLocLimitConstraint *data= con->data;
-
+                               
                                if ((data->flag2 & LIMIT_TRANSFORM)==0)
                                        continue;
-
+                               
                                /* do space conversions */
                                if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
                                        /* just multiply by td->mtx (this should be ok) */
-                                       Mat4CpyMat4(tmat, cob.matrix);
-                                       Mat4MulMat34(cob.matrix, td->mtx, tmat);
+                                       copy_m4_m4(tmat, cob.matrix);
+                                       mul_m4_m3m4(cob.matrix, td->mtx, tmat);
                                }
                                else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) {
                                        /* skip... incompatable spacetype */
                                        continue;
                                }
-
+                               
                                /* do constraint */
                                cti->evaluate_constraint(con, &cob, NULL);
-
+                               
                                /* convert spaces again */
                                if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
                                        /* just multiply by td->mtx (this should be ok) */
-                                       Mat4CpyMat4(tmat, cob.matrix);
-                                       Mat4MulMat34(cob.matrix, td->smtx, tmat);
+                                       copy_m4_m4(tmat, cob.matrix);
+                                       mul_m4_m3m4(cob.matrix, td->smtx, tmat);
                                }
                        }
                }
-
+               
                /* copy results from cob->matrix */
-               if (td->tdi) {
-                       TransDataIpokey *tdi= td->tdi;
-                       tdi->locx[0]= cob.matrix[3][0];
-                       tdi->locy[0]= cob.matrix[3][1];
-                       tdi->locz[0]= cob.matrix[3][2];
-               }
-               else {
-                       VECCOPY(td->loc, cob.matrix[3]);
-               }
+               VECCOPY(td->loc, cob.matrix[3]);
        }
 }
 
@@ -1791,35 +1909,24 @@ static void constraintRotLim(TransInfo *t, TransData *td)
                 *      - current space should be local
                 */
                memset(&cob, 0, sizeof(bConstraintOb));
-               if (td->flag & TD_USEQUAT) {
+               if (td->rotOrder == ROT_MODE_QUAT) {
                        /* quats */
                        if (td->ext)
-                               QuatToMat4(td->ext->quat, cob.matrix);
+                               quat_to_mat4( cob.matrix,td->ext->quat);
                        else
                                return;
                }
-               else if (td->tdi) { // XXX depreceated
-                       /* ipo-keys eulers */
-                       TransDataIpokey *tdi= td->tdi;
-                       float eul[3];
-                       
-                       eul[0]= tdi->rotx[0];
-                       eul[1]= tdi->roty[0];
-                       eul[2]= tdi->rotz[0];
-                       
-                       EulOToMat4(eul, td->rotOrder, cob.matrix);
-               }
-               else if (td->rotOrder == PCHAN_ROT_AXISANGLE) {
+               else if (td->rotOrder == ROT_MODE_AXISANGLE) {
                        /* axis angle */
                        if (td->ext)
-                               AxisAngleToMat4(&td->ext->quat[1], td->ext->quat[0], cob.matrix);
+                               axis_angle_to_mat4( cob.matrix,&td->ext->quat[1], td->ext->quat[0]);
                        else
                                return;
                }
                else {
                        /* eulers */
                        if (td->ext)
-                               EulOToMat4(td->ext->rot, td->rotOrder, cob.matrix);
+                               eulO_to_mat4( cob.matrix,td->ext->rot, td->rotOrder);
                        else
                                return;
                }
@@ -1842,8 +1949,8 @@ static void constraintRotLim(TransInfo *t, TransData *td)
                                /* do space conversions */
                                if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
                                        /* just multiply by td->mtx (this should be ok) */
-                                       Mat4CpyMat4(tmat, cob.matrix);
-                                       Mat4MulMat34(cob.matrix, td->mtx, tmat);
+                                       copy_m4_m4(tmat, cob.matrix);
+                                       mul_m4_m3m4(cob.matrix, td->mtx, tmat);
                                }
                                else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) {
                                        /* skip... incompatable spacetype */
@@ -1856,35 +1963,24 @@ static void constraintRotLim(TransInfo *t, TransData *td)
                                /* convert spaces again */
                                if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
                                        /* just multiply by td->mtx (this should be ok) */
-                                       Mat4CpyMat4(tmat, cob.matrix);
-                                       Mat4MulMat34(cob.matrix, td->smtx, tmat);
+                                       copy_m4_m4(tmat, cob.matrix);
+                                       mul_m4_m3m4(cob.matrix, td->smtx, tmat);
                                }
                        }
                }
                
                /* copy results from cob->matrix */
-               if (td->flag & TD_USEQUAT) {
+               if (td->rotOrder == ROT_MODE_QUAT) {
                        /* quats */
-                       Mat4ToQuat(cob.matrix, td->ext->quat);
-               }
-               else if (td->tdi) {
-                       /* ipo-keys eulers */
-                       TransDataIpokey *tdi= td->tdi;
-                       float eul[3];
-                       
-                       Mat4ToEulO(cob.matrix, eul, td->rotOrder);
-                       
-                       tdi->rotx[0]= eul[0];
-                       tdi->roty[0]= eul[1];
-                       tdi->rotz[0]= eul[2];
+                       mat4_to_quat( td->ext->quat,cob.matrix);
                }
-               else if (td->rotOrder == PCHAN_ROT_AXISANGLE) {
+               else if (td->rotOrder == ROT_MODE_AXISANGLE) {
                        /* axis angle */
-                       Mat4ToAxisAngle(cob.matrix, &td->ext->quat[1], &td->ext->quat[0]);
+                       mat4_to_axis_angle( &td->ext->quat[1], &td->ext->quat[0],cob.matrix);
                }
                else {
                        /* eulers */
-                       Mat4ToEulO(cob.matrix, td->ext->rot, td->rotOrder);
+                       mat4_to_eulO( td->ext->rot, td->rotOrder,cob.matrix);
                }
        }
 }
@@ -1895,22 +1991,13 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
                bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_SIZELIMIT);
                bConstraintOb cob;
                bConstraint *con;
-
+               
                /* Make a temporary bConstraintOb for using these limit constraints
                 *      - they only care that cob->matrix is correctly set ;-)
                 *      - current space should be local
                 */
                memset(&cob, 0, sizeof(bConstraintOb));
-               if (td->tdi) {
-                       TransDataIpokey *tdi= td->tdi;
-                       float size[3];
-
-                       size[0]= tdi->sizex[0];
-                       size[1]= tdi->sizey[0];
-                       size[2]= tdi->sizez[0];
-                       SizeToMat4(size, cob.matrix);
-               }
-               else if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
+               if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
                        /* scale val and reset size */
                        return; // TODO: fix this case
                }
@@ -1918,60 +2005,50 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
                        /* Reset val if SINGLESIZE but using a constraint */
                        if (td->flag & TD_SINGLESIZE)
                                return;
-
-                       SizeToMat4(td->ext->size, cob.matrix);
+                       
+                       size_to_mat4( cob.matrix,td->ext->size);
                }
-
+               
                /* Evaluate valid constraints */
                for (con= td->con; con; con= con->next) {
                        /* only consider constraint if enabled */
                        if (con->flag & CONSTRAINT_DISABLE) continue;
                        if (con->enforce == 0.0f) continue;
-
+                       
                        /* we're only interested in Limit-Scale constraints */
                        if (con->type == CONSTRAINT_TYPE_SIZELIMIT) {
                                bSizeLimitConstraint *data= con->data;
                                float tmat[4][4];
-
+                               
                                /* only use it if it's tagged for this purpose */
                                if ((data->flag2 & LIMIT_TRANSFORM)==0)
                                        continue;
-
+                               
                                /* do space conversions */
                                if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
                                        /* just multiply by td->mtx (this should be ok) */
-                                       Mat4CpyMat4(tmat, cob.matrix);
-                                       Mat4MulMat34(cob.matrix, td->mtx, tmat);
+                                       copy_m4_m4(tmat, cob.matrix);
+                                       mul_m4_m3m4(cob.matrix, td->mtx, tmat);
                                }
                                else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) {
                                        /* skip... incompatable spacetype */
                                        continue;
                                }
-
+                               
                                /* do constraint */
                                cti->evaluate_constraint(con, &cob, NULL);
-
+                               
                                /* convert spaces again */
                                if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
                                        /* just multiply by td->mtx (this should be ok) */
-                                       Mat4CpyMat4(tmat, cob.matrix);
-                                       Mat4MulMat34(cob.matrix, td->smtx, tmat);
+                                       copy_m4_m4(tmat, cob.matrix);
+                                       mul_m4_m3m4(cob.matrix, td->smtx, tmat);
                                }
                        }
                }
-
+               
                /* copy results from cob->matrix */
-               if (td->tdi) {
-                       TransDataIpokey *tdi= td->tdi;
-                       float size[3];
-
-                       Mat4ToSize(cob.matrix, size);
-
-                       tdi->sizex[0]= size[0];
-                       tdi->sizey[0]= size[1];
-                       tdi->sizez[0]= size[2];
-               }
-               else if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
+               if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
                        /* scale val and reset size */
                        return; // TODO: fix this case
                }
@@ -1979,8 +2056,8 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
                        /* Reset val if SINGLESIZE but using a constraint */
                        if (td->flag & TD_SINGLESIZE)
                                return;
-
-                       Mat4ToSize(cob.matrix, td->ext->size);
+                       
+                       mat4_to_size( td->ext->size,cob.matrix);
                }
        }
 }
@@ -1991,36 +2068,38 @@ void initWarp(TransInfo *t)
 {
        float max[3], min[3];
        int i;
-
+       
        t->mode = TFM_WARP;
        t->transform = Warp;
        t->handleEvent = handleEventWarp;
-
+       
        initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO);
-
+       
        t->idx_max = 0;
        t->num.idx_max = 0;
        t->snap[0] = 0.0f;
        t->snap[1] = 5.0f;
        t->snap[2] = 1.0f;
+       
+       t->num.increment = 1.0f;
 
        t->flag |= T_NO_CONSTRAINT;
-
+       
        /* we need min/max in view space */
        for(i = 0; i < t->total; i++) {
                float center[3];
                VECCOPY(center, t->data[i].center);
-               Mat3MulVecfl(t->data[i].mtx, center);
-               Mat4MulVecfl(t->viewmat, center);
-               VecSubf(center, center, t->viewmat[3]);
+               mul_m3_v3(t->data[i].mtx, center);
+               mul_m4_v3(t->viewmat, center);
+               sub_v3_v3v3(center, center, t->viewmat[3]);
                if (i)
-                       MinMax3(min, max, center);
+                       minmax_v3_v3v3(min, max, center);
                else {
                        VECCOPY(max, center);
                        VECCOPY(min, center);
                }
        }
-
+       
        t->center[0]= (min[0]+max[0])/2.0f;
        t->center[1]= (min[1]+max[1])/2.0f;
        t->center[2]= (min[2]+max[2])/2.0f;
@@ -2032,7 +2111,7 @@ void initWarp(TransInfo *t)
 int handleEventWarp(TransInfo *t, wmEvent *event)
 {
        int status = 0;
-
+       
        if (event->type == MIDDLEMOUSE && event->val==KM_PRESS)
        {
                // Use customData pointer to signal warp direction
@@ -2040,10 +2119,10 @@ int handleEventWarp(TransInfo *t, wmEvent *event)
                        t->customData = (void*)1;
                else
                        t->customData = 0;
-
+               
                status = 1;
        }
-
+       
        return status;
 }
 
@@ -2053,7 +2132,7 @@ int Warp(TransInfo *t, short mval[2])
        float vec[3], circumfac, dist, phi0, co, si, *curs, cursor[3], gcursor[3];
        int i;
        char str[50];
-
+       
        curs= give_cursor(t->scene, t->view);
        /*
         * gcursor is the one used for helpline.
@@ -2068,79 +2147,79 @@ int Warp(TransInfo *t, short mval[2])
        VECCOPY(cursor, curs);
        VECCOPY(gcursor, cursor);
        if (t->flag & T_EDIT) {
-               VecSubf(cursor, cursor, t->obedit->obmat[3]);
-               VecSubf(gcursor, gcursor, t->obedit->obmat[3]);
-               Mat3MulVecfl(t->data->smtx, gcursor);
+               sub_v3_v3v3(cursor, cursor, t->obedit->obmat[3]);
+               sub_v3_v3v3(gcursor, gcursor, t->obedit->obmat[3]);
+               mul_m3_v3(t->data->smtx, gcursor);
        }
-       Mat4MulVecfl(t->viewmat, cursor);
-       VecSubf(cursor, cursor, t->viewmat[3]);
-
+       mul_m4_v3(t->viewmat, cursor);
+       sub_v3_v3v3(cursor, cursor, t->viewmat[3]);
+       
        /* amount of degrees for warp */
        circumfac = 360.0f * t->values[0];
-
+       
        if (t->customData) /* non-null value indicates reversed input */
        {
                circumfac *= -1;
        }
-
+       
        snapGrid(t, &circumfac);
        applyNumInput(&t->num, &circumfac);
-
+       
        /* header print for NumInput */
        if (hasNumInput(&t->num)) {
                char c[20];
-
+               
                outputNumInput(&(t->num), c);
-
+               
                sprintf(str, "Warp: %s", c);
        }
        else {
                /* default header print */
                sprintf(str, "Warp: %.3f", circumfac);
        }
-
+       
        circumfac*= (float)(-M_PI/360.0);
-
+       
        for(i = 0; i < t->total; i++, td++) {
                float loc[3];
                if (td->flag & TD_NOACTION)
                        break;
-
+               
                if (td->flag & TD_SKIP)
                        continue;
-
+               
                /* translate point to center, rotate in such a way that outline==distance */
                VECCOPY(vec, td->iloc);
-               Mat3MulVecfl(td->mtx, vec);
-               Mat4MulVecfl(t->viewmat, vec);
-               VecSubf(vec, vec, t->viewmat[3]);
-
+               mul_m3_v3(td->mtx, vec);
+               mul_m4_v3(t->viewmat, vec);
+               sub_v3_v3v3(vec, vec, t->viewmat[3]);
+               
                dist= vec[0]-cursor[0];
-
+               
                /* t->val is X dimension projected boundbox */
                phi0= (circumfac*dist/t->val);
-
+               
                vec[1]= (vec[1]-cursor[1]);
-
+               
                co= (float)cos(phi0);
                si= (float)sin(phi0);
                loc[0]= -si*vec[1]+cursor[0];
                loc[1]= co*vec[1]+cursor[1];
                loc[2]= vec[2];
-
-               Mat4MulVecfl(t->viewinv, loc);
-               VecSubf(loc, loc, t->viewinv[3]);
-               Mat3MulVecfl(td->smtx, loc);
-
-               VecSubf(loc, loc, td->iloc);
-               VecMulf(loc, td->factor);
-               VecAddf(td->loc, td->iloc, loc);
+               
+               mul_m4_v3(t->viewinv, loc);
+               sub_v3_v3v3(loc, loc, t->viewinv[3]);
+               mul_m3_v3(td->smtx, loc);
+               
+               sub_v3_v3v3(loc, loc, td->iloc);
+               mul_v3_fl(loc, td->factor);
+               add_v3_v3v3(td->loc, td->iloc, loc);
        }
-
+       
        recalcData(t);
-
+       
        ED_area_headerprint(t->sa, str);
-
+       
        return 1;
 }
 
@@ -2151,14 +2230,16 @@ void initShear(TransInfo *t)
        t->mode = TFM_SHEAR;
        t->transform = Shear;
        t->handleEvent = handleEventShear;
-
+       
        initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE);
-
+       
        t->idx_max = 0;
        t->num.idx_max = 0;
        t->snap[0] = 0.0f;
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
+       
+       t->num.increment = 0.1f;
 
        t->flag |= T_NO_CONSTRAINT;
 }
@@ -2166,7 +2247,7 @@ void initShear(TransInfo *t)
 int handleEventShear(TransInfo *t, wmEvent *event)
 {
        int status = 0;
-
+       
        if (event->type == MIDDLEMOUSE && event->val==KM_PRESS)
        {
                // Use customData pointer to signal Shear direction
@@ -2180,10 +2261,10 @@ int handleEventShear(TransInfo *t, wmEvent *event)
                        initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE);
                        t->customData = 0;
                }
-
+               
                status = 1;
        }
-
+       
        return status;
 }
 
@@ -2196,69 +2277,69 @@ int Shear(TransInfo *t, short mval[2])
        float value;
        int i;
        char str[50];
-
-       Mat3CpyMat4(persmat, t->viewmat);
-       Mat3Inv(persinv, persmat);
-
+       
+       copy_m3_m4(persmat, t->viewmat);
+       invert_m3_m3(persinv, persmat);
+       
        value = 0.05f * t->values[0];
-
+       
        snapGrid(t, &value);
-
+       
        applyNumInput(&t->num, &value);
-
+       
        /* header print for NumInput */
        if (hasNumInput(&t->num)) {
                char c[20];
-
+               
                outputNumInput(&(t->num), c);
-
+               
                sprintf(str, "Shear: %s %s", c, t->proptext);
        }
        else {
                /* default header print */
                sprintf(str, "Shear: %.3f %s", value, t->proptext);
        }
-
-       Mat3One(smat);
-
+       
+       unit_m3(smat);
+       
        // Custom data signals shear direction
        if (t->customData == 0)
                smat[1][0] = value;
        else
                smat[0][1] = value;
-
-       Mat3MulMat3(tmat, smat, persmat);
-       Mat3MulMat3(totmat, persinv, tmat);
-
+       
+       mul_m3_m3m3(tmat, smat, persmat);
+       mul_m3_m3m3(totmat, persinv, tmat);
+       
        for(i = 0 ; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
-
+               
                if (td->flag & TD_SKIP)
                        continue;
-
+               
                if (t->obedit) {
                        float mat3[3][3];
-                       Mat3MulMat3(mat3, totmat, td->mtx);
-                       Mat3MulMat3(tmat, td->smtx, mat3);
+                       mul_m3_m3m3(mat3, totmat, td->mtx);
+                       mul_m3_m3m3(tmat, td->smtx, mat3);
                }
                else {
-                       Mat3CpyMat3(tmat, totmat);
+                       copy_m3_m3(tmat, totmat);
                }
-               VecSubf(vec, td->center, t->center);
-
-               Mat3MulVecfl(tmat, vec);
-
-               VecAddf(vec, vec, t->center);
-               VecSubf(vec, vec, td->center);
-
-               VecMulf(vec, td->factor);
-
-               VecAddf(td->loc, td->iloc, vec);
+               sub_v3_v3v3(vec, td->center, t->center);
+               
+               mul_m3_v3(tmat, vec);
+               
+               add_v3_v3v3(vec, vec, t->center);
+               sub_v3_v3v3(vec, vec, td->center);
+               
+               mul_v3_fl(vec, td->factor);
+               
+               add_v3_v3v3(td->loc, td->iloc, vec);
        }
-
+       
        recalcData(t);
-
+       
        ED_area_headerprint(t->sa, str);
 
        return 1;
@@ -2270,9 +2351,9 @@ void initResize(TransInfo *t)
 {
        t->mode = TFM_RESIZE;
        t->transform = Resize;
-
+       
        initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
-
+       
        t->flag |= T_NULL_ONE;
        t->num.flag |= NUM_NULL_ONE;
        t->num.flag |= NUM_AFFECT_ALL;
@@ -2280,12 +2361,14 @@ void initResize(TransInfo *t)
                t->flag |= T_NO_ZERO;
                t->num.flag |= NUM_NO_ZERO;
        }
-
+       
        t->idx_max = 2;
        t->num.idx_max = 2;
        t->snap[0] = 0.0f;
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
+
+       t->num.increment = t->snap[1];
 }
 
 static void headerResize(TransInfo *t, float vec[3], char *str) {
@@ -2298,7 +2381,7 @@ static void headerResize(TransInfo *t, float vec[3], char *str) {
                sprintf(&tvec[20], "%.4f", vec[1]);
                sprintf(&tvec[40], "%.4f", vec[2]);
        }
-
+       
        if (t->con.mode & CON_APPLY) {
                switch(t->num.idx_max) {
                case 0:
@@ -2326,14 +2409,14 @@ static void headerResize(TransInfo *t, float vec[3], char *str) {
 static void TransMat3ToSize( float mat[][3], float smat[][3], float *size)
 {
        float vec[3];
-
-       VecCopyf(vec, mat[0]);
-       size[0]= Normalize(vec);
-       VecCopyf(vec, mat[1]);
-       size[1]= Normalize(vec);
-       VecCopyf(vec, mat[2]);
-       size[2]= Normalize(vec);
-
+       
+       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);
+       
        /* first tried with dotproduct... but the sign flip is crucial */
        if( VECSIGNFLIP(mat[0], smat[0]) ) size[0]= -size[0];
        if( VECSIGNFLIP(mat[1], smat[1]) ) size[1]= -size[1];
@@ -2344,26 +2427,26 @@ static void TransMat3ToSize( float mat[][3], float smat[][3], float *size)
 static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
        float tmat[3][3], smat[3][3], center[3];
        float vec[3];
-
+       
        if (t->flag & T_EDIT) {
-               Mat3MulMat3(smat, mat, td->mtx);
-               Mat3MulMat3(tmat, td->smtx, smat);
+               mul_m3_m3m3(smat, mat, td->mtx);
+               mul_m3_m3m3(tmat, td->smtx, smat);
        }
        else {
-               Mat3CpyMat3(tmat, mat);
+               copy_m3_m3(tmat, mat);
        }
-
+       
        if (t->con.applySize) {
                t->con.applySize(t, td, tmat);
        }
-
+       
        /* local constraint shouldn't alter center */
        if (t->around == V3D_LOCAL) {
                if (t->flag & T_OBJECT) {
                        VECCOPY(center, td->center);
                }
                else if (t->flag & T_EDIT) {
-
+                       
                        if(t->around==V3D_LOCAL && (t->settings->selectmode & SCE_SELECT_FACE)) {
                                VECCOPY(center, td->center);
                        }
@@ -2378,43 +2461,29 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
        else {
                VECCOPY(center, t->center);
        }
-
+       
        if (td->ext) {
                float fsize[3];
-
+               
                if (t->flag & (T_OBJECT|T_TEXTURE|T_POSE)) {
                        float obsizemat[3][3];
                        // Reorient the size mat to fit the oriented object.
-                       Mat3MulMat3(obsizemat, tmat, td->axismtx);
-                       //printmatrix3("obsizemat", obsizemat);
+                       mul_m3_m3m3(obsizemat, tmat, td->axismtx);
+                       //print_m3("obsizemat", obsizemat);
                        TransMat3ToSize(obsizemat, td->axismtx, fsize);
-                       //printvecf("fsize", fsize);
+                       //print_v3("fsize", fsize);
                }
                else {
-                       Mat3ToSize(tmat, fsize);
+                       mat3_to_size( fsize,tmat);
                }
-
+               
                protectedSizeBits(td->protectflag, fsize);
-
+               
                if ((t->flag & T_V3D_ALIGN)==0) {       // align mode doesn't resize objects itself
-                       /* handle ipokeys? */
-                       if(td->tdi) {
-                               TransDataIpokey *tdi= td->tdi;
-                               /* calculate delta size (equal for size and dsize) */
-
-                               vec[0]= (tdi->oldsize[0])*(fsize[0] -1.0f) * td->factor;
-                               vec[1]= (tdi->oldsize[1])*(fsize[1] -1.0f) * td->factor;
-                               vec[2]= (tdi->oldsize[2])*(fsize[2] -1.0f) * td->factor;
-
-                               add_tdi_poin(tdi->sizex, tdi->oldsize,   vec[0]);
-                               add_tdi_poin(tdi->sizey, tdi->oldsize+1, vec[1]);
-                               add_tdi_poin(tdi->sizez, tdi->oldsize+2, vec[2]);
-
-                       }
-                       else if((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)){
+                       if((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)){
                                /* scale val and reset size */
-                               *td->val = td->ival * fsize[0] * td->factor;
-
+                               *td->val = td->ival * (1 + (fsize[0] - 1) * td->factor);
+                               
                                td->ext->size[0] = td->ext->isize[0];
                                td->ext->size[1] = td->ext->isize[1];
                                td->ext->size[2] = td->ext->isize[2];
@@ -2423,46 +2492,39 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
                                /* Reset val if SINGLESIZE but using a constraint */
                                if (td->flag & TD_SINGLESIZE)
                                        *td->val = td->ival;
-
-                               td->ext->size[0] = td->ext->isize[0] * (fsize[0]) * td->factor;
-                               td->ext->size[1] = td->ext->isize[1] * (fsize[1]) * td->factor;
-                               td->ext->size[2] = td->ext->isize[2] * (fsize[2]) * td->factor;
+                               
+                               td->ext->size[0] = td->ext->isize[0] * (1 + (fsize[0] - 1) * td->factor);
+                               td->ext->size[1] = td->ext->isize[1] * (1 + (fsize[1] - 1) * td->factor);
+                               td->ext->size[2] = td->ext->isize[2] * (1 + (fsize[2] - 1) * td->factor);
                        }
                }
-
+               
                constraintSizeLim(t, td);
        }
-
+       
        /* For individual element center, Editmode need to use iloc */
        if (t->flag & T_POINTS)
-               VecSubf(vec, td->iloc, center);
+               sub_v3_v3v3(vec, td->iloc, center);
        else
-               VecSubf(vec, td->center, center);
-
-       Mat3MulVecfl(tmat, vec);
-
-       VecAddf(vec, vec, center);
+               sub_v3_v3v3(vec, td->center, center);
+       
+       mul_m3_v3(tmat, vec);
+       
+       add_v3_v3v3(vec, vec, center);
        if (t->flag & T_POINTS)
-               VecSubf(vec, vec, td->iloc);
+               sub_v3_v3v3(vec, vec, td->iloc);
        else
-               VecSubf(vec, vec, td->center);
-
-       VecMulf(vec, td->factor);
-
+               sub_v3_v3v3(vec, vec, td->center);
+       
+       mul_v3_fl(vec, td->factor);
+       
        if (t->flag & (T_OBJECT|T_POSE)) {
-               Mat3MulVecfl(td->smtx, vec);
+               mul_m3_v3(td->smtx, vec);
        }
-
+       
        protectedTransBits(td->protectflag, vec);
-
-       if(td->tdi) {
-               TransDataIpokey *tdi= td->tdi;
-               add_tdi_poin(tdi->locx, tdi->oldloc, vec[0]);
-               add_tdi_poin(tdi->locy, tdi->oldloc+1, vec[1]);
-               add_tdi_poin(tdi->locz, tdi->oldloc+2, vec[2]);
-       }
-       else VecAddf(td->loc, td->iloc, vec);
-
+       add_v3_v3v3(td->loc, td->iloc, vec);
+       
        constraintTransLim(t, td);
 }
 
@@ -2473,7 +2535,7 @@ int Resize(TransInfo *t, short mval[2])
        float ratio;
        int i;
        char str[200];
-
+       
        /* for manipulator, center handle, the scaling can't be done relative to center */
        if( (t->flag & T_USES_MANIPULATOR) && t->con.mode==0)
        {
@@ -2483,60 +2545,60 @@ int Resize(TransInfo *t, short mval[2])
        {
                ratio = t->values[0];
        }
-
+       
        size[0] = size[1] = size[2] = ratio;
-
+       
        snapGrid(t, size);
-
+       
        if (hasNumInput(&t->num)) {
                applyNumInput(&t->num, size);
                constraintNumInput(t, size);
        }
-
+       
        applySnapping(t, size);
-
+       
        if (t->flag & T_AUTOVALUES)
        {
                VECCOPY(size, t->auto_values);
        }
-
+       
        VECCOPY(t->values, size);
-
-       SizeToMat3(size, mat);
-
+       
+       size_to_mat3( mat,size);
+       
        if (t->con.applySize) {
                t->con.applySize(t, NULL, mat);
        }
-
-       Mat3CpyMat3(t->mat, mat);       // used in manipulator
-
+       
+       copy_m3_m3(t->mat, mat);        // used in manipulator
+       
        headerResize(t, size, str);
-
+       
        for(i = 0, td=t->data; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
-
+               
                if (td->flag & TD_SKIP)
                        continue;
-
+               
                ElementResize(t, td, mat);
        }
-
+       
        /* evil hack - redo resize if cliping needed */
        if (t->flag & T_CLIP_UV && clipUVTransform(t, size, 1)) {
-               SizeToMat3(size, mat);
-
+               size_to_mat3( mat,size);
+               
                if (t->con.applySize)
                        t->con.applySize(t, NULL, mat);
-
+               
                for(i = 0, td=t->data; i < t->total; i++, td++)
                        ElementResize(t, td, mat);
        }
-
+       
        recalcData(t);
-
+       
        ED_area_headerprint(t->sa, str);
-
+       
        return 1;
 }
 
@@ -2546,26 +2608,28 @@ void initToSphere(TransInfo *t)
 {
        TransData *td = t->data;
        int i;
-
+       
        t->mode = TFM_TOSPHERE;
        t->transform = ToSphere;
-
+       
        initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO);
-
+       
        t->idx_max = 0;
        t->num.idx_max = 0;
        t->snap[0] = 0.0f;
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
+       
+       t->num.increment = t->snap[1];
 
        t->num.flag |= NUM_NULL_ONE | NUM_NO_NEGATIVE;
        t->flag |= T_NO_CONSTRAINT;
-
+       
        // Calculate average radius
        for(i = 0 ; i < t->total; i++, td++) {
-               t->val += VecLenf(t->center, td->iloc);
+               t->val += len_v3v3(t->center, td->iloc);
        }
-
+       
        t->val /= (float)t->total;
 }
 
@@ -2576,56 +2640,56 @@ int ToSphere(TransInfo *t, short mval[2])
        int i;
        char str[64];
        TransData *td = t->data;
-
+       
        ratio = t->values[0];
-
+       
        snapGrid(t, &ratio);
-
+       
        applyNumInput(&t->num, &ratio);
-
+       
        if (ratio < 0)
                ratio = 0.0f;
        else if (ratio > 1)
                ratio = 1.0f;
-
+       
        /* header print for NumInput */
        if (hasNumInput(&t->num)) {
                char c[20];
-
+               
                outputNumInput(&(t->num), c);
-
+               
                sprintf(str, "To Sphere: %s %s", c, t->proptext);
        }
        else {
                /* default header print */
                sprintf(str, "To Sphere: %.4f %s", ratio, t->proptext);
        }
-
-
+       
+       
        for(i = 0 ; i < t->total; i++, td++) {
                float tratio;
                if (td->flag & TD_NOACTION)
                        break;
-
+               
                if (td->flag & TD_SKIP)
                        continue;
-
-               VecSubf(vec, td->iloc, t->center);
-
-               radius = Normalize(vec);
-
+               
+               sub_v3_v3v3(vec, td->iloc, t->center);
+               
+               radius = normalize_v3(vec);
+               
                tratio = ratio * td->factor;
-
-               VecMulf(vec, radius * (1.0f - tratio) + t->val * tratio);
-
-               VecAddf(td->loc, t->center, vec);
+               
+               mul_v3_fl(vec, radius * (1.0f - tratio) + t->val * tratio);
+               
+               add_v3_v3v3(td->loc, t->center, vec);
        }
-
-
+       
+       
        recalcData(t);
-
+       
        ED_area_headerprint(t->sa, str);
-
+       
        return 1;
 }
 
@@ -2636,61 +2700,66 @@ void initRotation(TransInfo *t)
 {
        t->mode = TFM_ROTATION;
        t->transform = Rotation;
-
+       
        initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
-
+       
        t->ndof.axis = 16;
        /* Scale down and flip input for rotation */
        t->ndof.factor[0] = -0.2f;
-
+       
        t->idx_max = 0;
        t->num.idx_max = 0;
        t->snap[0] = 0.0f;
        t->snap[1] = (float)((5.0/180)*M_PI);
        t->snap[2] = t->snap[1] * 0.2f;
+       
+       t->num.increment = 1.0f;
 
        if (t->flag & T_2D_EDIT)
                t->flag |= T_NO_CONSTRAINT;
+
+       negate_v3_v3(t->axis, t->viewinv[2]);
+       normalize_v3(t->axis);
 }
 
 static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short around) {
        float vec[3], totmat[3][3], smat[3][3];
        float eul[3], fmat[3][3], quat[4];
        float *center = t->center;
-
+       
        /* local constraint shouldn't alter center */
        if (around == V3D_LOCAL) {
                if (t->flag & (T_OBJECT|T_POSE)) {
                        center = td->center;
                }
                else {
-                       /* !TODO! Make this if not rely on G */
                        if(around==V3D_LOCAL && (t->settings->selectmode & SCE_SELECT_FACE)) {
                                center = td->center;
                        }
                }
        }
-
+       
        if (t->flag & T_POINTS) {
-               Mat3MulMat3(totmat, mat, td->mtx);
-               Mat3MulMat3(smat, td->smtx, totmat);
-
-               VecSubf(vec, td->iloc, center);
-               Mat3MulVecfl(smat, vec);
-
-               VecAddf(td->loc, vec, center);
-
-               VecSubf(vec,td->loc,td->iloc);
+               mul_m3_m3m3(totmat, mat, td->mtx);
+               mul_m3_m3m3(smat, td->smtx, totmat);
+               
+               sub_v3_v3v3(vec, td->iloc, center);
+               mul_m3_v3(smat, vec);
+               
+               add_v3_v3v3(td->loc, vec, center);
+               
+               sub_v3_v3v3(vec,td->loc,td->iloc);
                protectedTransBits(td->protectflag, vec);
-               VecAddf(td->loc, td->iloc, vec);
-
+               add_v3_v3v3(td->loc, td->iloc, vec);
+               
+               
                if(td->flag & TD_USEQUAT) {
-                       Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
-                       Mat3ToQuat(fmat, quat); // Actual transform
-
+                       mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
+                       mat3_to_quat( quat,fmat);       // Actual transform
+                       
                        if(td->ext->quat){
-                               QuatMul(td->ext->quat, quat, td->ext->iquat);
-
+                               mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat);
+                               
                                /* is there a reason not to have this here? -jahka */
                                protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
                        }
@@ -2710,80 +2779,76 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
         */
        else if (t->flag & T_POSE) {
                float pmtx[3][3], imtx[3][3];
-
+               
                // Extract and invert armature object matrix
-               Mat3CpyMat4(pmtx, t->poseobj->obmat);
-               Mat3Inv(imtx, pmtx);
-
+               copy_m3_m4(pmtx, t->poseobj->obmat);
+               invert_m3_m3(imtx, pmtx);
+               
                if ((td->flag & TD_NO_LOC) == 0)
                {
-                       VecSubf(vec, td->center, center);
-
-                       Mat3MulVecfl(pmtx, vec);        // To Global space
-                       Mat3MulVecfl(mat, vec);         // Applying rotation
-                       Mat3MulVecfl(imtx, vec);        // To Local space
-
-                       VecAddf(vec, vec, center);
+                       sub_v3_v3v3(vec, td->center, center);
+                       
+                       mul_m3_v3(pmtx, vec);   // To Global space
+                       mul_m3_v3(mat, vec);            // Applying rotation
+                       mul_m3_v3(imtx, vec);   // To Local space
+                       
+                       add_v3_v3v3(vec, vec, center);
                        /* vec now is the location where the object has to be */
-
-                       VecSubf(vec, vec, td->center); // Translation needed from the initial location
-
-                       Mat3MulVecfl(pmtx, vec);        // To Global space
-                       Mat3MulVecfl(td->smtx, vec);// To Pose space
-
+                       
+                       sub_v3_v3v3(vec, vec, td->center); // Translation needed from the initial location
+                       
+                       mul_m3_v3(pmtx, vec);   // To Global space
+                       mul_m3_v3(td->smtx, vec);// To Pose space
+                       
                        protectedTransBits(td->protectflag, vec);
-
-                       VecAddf(td->loc, td->iloc, vec);
-
+                       
+                       add_v3_v3v3(td->loc, td->iloc, vec);
+                       
                        constraintTransLim(t, td);
                }
-
+               
                /* rotation */
                if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself
                        /* euler or quaternion/axis-angle? */
-                       if (td->flag & TD_USEQUAT) {
-                               Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
-
-                               Mat3ToQuat(fmat, quat); // Actual transform
-
-                               QuatMul(td->ext->quat, quat, td->ext->iquat);
+                       if (td->rotOrder == ROT_MODE_QUAT) {
+                               mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
+                               
+                               mat3_to_quat( quat,fmat);       // Actual transform
+                               
+                               mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat);
                                /* this function works on end result */
                                protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
                                
                        }
-                       else if (td->rotOrder == PCHAN_ROT_AXISANGLE) {
+                       else if (td->rotOrder == ROT_MODE_AXISANGLE) {
                                /* calculate effect based on quats */
-                               float iquat[4];
-                               
-                               /* td->ext->(i)quat is in axis-angle form, not quats! */
-                               AxisAngleToQuat(iquat, &td->ext->iquat[1], td->ext->iquat[0]);
+                               float iquat[4], tquat[4];
                                
-                               Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
-                               Mat3ToQuat(fmat, quat); // Actual transform
+                               axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle);
                                
-                               QuatMul(td->ext->quat, quat, iquat);
+                               mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
+                               mat3_to_quat( quat,fmat);       // Actual transform
+                               mul_qt_qtqt(tquat, quat, iquat);
                                
-                               /* make temp copy (since stored in same place) */
-                               QUATCOPY(quat, td->ext->quat); // this is just a 4d vector copying macro
-                               QuatToAxisAngle(quat, &td->ext->quat[1], &td->ext->quat[0]); 
+                               quat_to_axis_angle( td->ext->rotAxis, td->ext->rotAngle,tquat); 
                                
                                /* this function works on end result */
-                               protectedAxisAngleBits(td->protectflag, td->ext->quat, td->ext->iquat);
+                               protectedAxisAngleBits(td->protectflag, td->ext->rotAxis, td->ext->rotAngle, td->ext->irotAxis, td->ext->irotAngle);
                        }
                        else { 
                                float eulmat[3][3];
                                
-                               Mat3MulMat3(totmat, mat, td->mtx);
-                               Mat3MulMat3(smat, td->smtx, totmat);
+                               mul_m3_m3m3(totmat, mat, td->mtx);
+                               mul_m3_m3m3(smat, td->smtx, totmat);
                                
                                /* calculate the total rotatation in eulers */
                                VECCOPY(eul, td->ext->irot);
-                               EulOToMat3(eul, td->rotOrder, eulmat);
+                               eulO_to_mat3( eulmat,eul, td->rotOrder);
                                
                                /* mat = transform, obmat = bone rotation */
-                               Mat3MulMat3(fmat, smat, eulmat);
+                               mul_m3_m3m3(fmat, smat, eulmat);
                                
-                               Mat3ToCompatibleEulO(fmat, eul, td->ext->rot, td->rotOrder);
+                               mat3_to_compatible_eulO( eul, td->ext->rot, td->rotOrder,fmat);
                                
                                /* and apply (to end result only) */
                                protectedRotateBits(td->protectflag, eul, td->ext->irot);
@@ -2797,99 +2862,69 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                if ((td->flag & TD_NO_LOC) == 0)
                {
                        /* translation */
-                       VecSubf(vec, td->center, center);
-                       Mat3MulVecfl(mat, vec);
-                       VecAddf(vec, vec, center);
+                       sub_v3_v3v3(vec, td->center, center);
+                       mul_m3_v3(mat, vec);
+                       add_v3_v3v3(vec, vec, center);
                        /* vec now is the location where the object has to be */
-                       VecSubf(vec, vec, td->center);
-                       Mat3MulVecfl(td->smtx, vec);
-
+                       sub_v3_v3v3(vec, vec, td->center);
+                       mul_m3_v3(td->smtx, vec);
+                       
                        protectedTransBits(td->protectflag, vec);
-
-                       if(td->tdi) {
-                               TransDataIpokey *tdi= td->tdi;
-                               add_tdi_poin(tdi->locx, tdi->oldloc, vec[0]);
-                               add_tdi_poin(tdi->locy, tdi->oldloc+1, vec[1]);
-                               add_tdi_poin(tdi->locz, tdi->oldloc+2, vec[2]);
-                       }
-                       else VecAddf(td->loc, td->iloc, vec);
+                       
+                       add_v3_v3v3(td->loc, td->iloc, vec);
                }
-
-
+               
+               
                constraintTransLim(t, td);
-
+               
                /* rotation */
                if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself
                        /* euler or quaternion? */
-                   if (td->flag & TD_USEQUAT) {
-                               Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
-                               Mat3ToQuat(fmat, quat); // Actual transform
-
-                               QuatMul(td->ext->quat, quat, td->ext->iquat);
+                   if ((td->rotOrder == ROT_MODE_QUAT) || (td->flag & TD_USEQUAT)) {
+                               mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
+                               mat3_to_quat( quat,fmat);       // Actual transform
+                               
+                               mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat);
                                /* this function works on end result */
                                protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
                        }
+                       else if (td->rotOrder == ROT_MODE_AXISANGLE) {
+                               /* calculate effect based on quats */
+                               float iquat[4], tquat[4];
+                               
+                               axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle);
+                               
+                               mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
+                               mat3_to_quat( quat,fmat);       // Actual transform
+                               mul_qt_qtqt(tquat, quat, iquat);
+                               
+                               quat_to_axis_angle( td->ext->rotAxis, td->ext->rotAngle,quat); 
+                               
+                               /* this function works on end result */
+                               protectedAxisAngleBits(td->protectflag, td->ext->rotAxis, td->ext->rotAngle, td->ext->irotAxis, td->ext->irotAngle);
+                       }
                        else {
                                float obmat[3][3];
-
-                               /* are there ipo keys? */
-                               if(td->tdi) {
-                                       TransDataIpokey *tdi= td->tdi;
-                                       float current_rot[3];
-                                       float rot[3];
-
-                                       /* current IPO value for compatible euler */
-                                       current_rot[0] = (tdi->rotx) ? tdi->rotx[0] : 0.0f;
-                                       current_rot[1] = (tdi->roty) ? tdi->roty[0] : 0.0f;
-                                       current_rot[2] = (tdi->rotz) ? tdi->rotz[0] : 0.0f;
-                                       VecMulf(current_rot, (float)(M_PI_2 / 9.0));
-
-                                       /* calculate the total rotatation in eulers */
-                                       VecAddf(eul, td->ext->irot, td->ext->drot);
-                                       EulToMat3(eul, obmat);
-                                       /* mat = transform, obmat = object rotation */
-                                       Mat3MulMat3(fmat, mat, obmat);
-
-                                       Mat3ToCompatibleEul(fmat, eul, current_rot);
-
-                                       /* correct back for delta rot */
-                                       if(tdi->flag & TOB_IPODROT) {
-                                               VecSubf(rot, eul, td->ext->irot);
-                                       }
-                                       else {
-                                               VecSubf(rot, eul, td->ext->drot);
-                                       }
-
-                                       VecMulf(rot, (float)(9.0/M_PI_2));
-                                       VecSubf(rot, rot, tdi->oldrot);
-
-                                       protectedRotateBits(td->protectflag, rot, tdi->oldrot);
-
-                                       add_tdi_poin(tdi->rotx, tdi->oldrot, rot[0]);
-                                       add_tdi_poin(tdi->roty, tdi->oldrot+1, rot[1]);
-                                       add_tdi_poin(tdi->rotz, tdi->oldrot+2, rot[2]);
-                               }
-                               else {
-                                       Mat3MulMat3(totmat, mat, td->mtx);
-                                       Mat3MulMat3(smat, td->smtx, totmat);
-
-                                       /* calculate the total rotatation in eulers */
-                                       VecAddf(eul, td->ext->irot, td->ext->drot); /* we have to correct for delta rot */
-                                       EulToMat3(eul, obmat);
-                                       /* mat = transform, obmat = object rotation */
-                                       Mat3MulMat3(fmat, smat, obmat);
-
-                                       Mat3ToCompatibleEul(fmat, eul, td->ext->rot);
-
-                                       /* correct back for delta rot */
-                                       VecSubf(eul, eul, td->ext->drot);
-
-                                       /* and apply */
-                                       protectedRotateBits(td->protectflag, eul, td->ext->irot);
-                                       VECCOPY(td->ext->rot, eul);
-                               }
+                               
+                               mul_m3_m3m3(totmat, mat, td->mtx);
+                               mul_m3_m3m3(smat, td->smtx, totmat);
+                               
+                               /* calculate the total rotatation in eulers */
+                               add_v3_v3v3(eul, td->ext->irot, td->ext->drot); /* we have to correct for delta rot */
+                               eulO_to_mat3( obmat,eul, td->rotOrder);
+                               /* mat = transform, obmat = object rotation */
+                               mul_m3_m3m3(fmat, smat, obmat);
+                               
+                               mat3_to_compatible_eulO( eul, td->ext->rot, td->rotOrder,fmat);
+                               
+                               /* correct back for delta rot */
+                               sub_v3_v3v3(eul, eul, td->ext->drot);
+                               
+                               /* and apply */
+                               protectedRotateBits(td->protectflag, eul, td->ext->irot);
+                               VECCOPY(td->ext->rot, eul);
                        }
-
+                       
                        constraintRotLim(t, td);
                }
        }
@@ -2900,25 +2935,25 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
        TransData *td = t->data;
        float mat[3][3];
        int i;
-
-       VecRotToMat3(axis, angle, mat);
-
+       
+       vec_rot_to_mat3( mat,axis, angle);
+       
        for(i = 0 ; i < t->total; i++, td++) {
-
+               
                if (td->flag & TD_NOACTION)
                        break;
-
+               
                if (td->flag & TD_SKIP)
                        continue;
-
+               
                if (t->con.applyRot) {
                        t->con.applyRot(t, td, axis, NULL);
-                       VecRotToMat3(axis, angle * td->factor, mat);
+                       vec_rot_to_mat3( mat,axis, angle * td->factor);
                }
                else if (t->flag & T_PROP_EDIT) {
-                       VecRotToMat3(axis, angle * td->factor, mat);
+                       vec_rot_to_mat3( mat,axis, angle * td->factor);
                }
-
+               
                ElementRotation(t, td, mat, t->around);
        }
 }
@@ -2926,62 +2961,64 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
 int Rotation(TransInfo *t, short mval[2])
 {
        char str[64];
-
+       
        float final;
-
-       float axis[3];
+       
        float mat[3][3];
-
-       VECCOPY(axis, t->viewinv[2]);
-       VecMulf(axis, -1.0f);
-       Normalize(axis);
-
+       
        final = t->values[0];
-
+       
        applyNDofInput(&t->ndof, &final);
-
+       
        snapGrid(t, &final);
-
-       if (t->con.applyRot) {
-               t->con.applyRot(t, NULL, axis, &final);
+       
+       if ((t->con.mode & CON_APPLY) && t->con.applyRot) {
+               t->con.applyRot(t, NULL, t->axis, &final);
+       } else {
+               /* reset axis if constraint is not set */
+               negate_v3_v3(t->axis, t->viewinv[2]);
+               normalize_v3(t->axis);
        }
-
+       
        applySnapping(t, &final);
-
+       
        if (hasNumInput(&t->num)) {
                char c[20];
-
+               
                applyNumInput(&t->num, &final);
-
+               
                outputNumInput(&(t->num), c);
-
+               
                sprintf(str, "Rot: %s %s %s", &c[0], t->con.text, t->proptext);
-
+               
                /* Clamp between -180 and 180 */
                while (final >= 180.0)
                        final -= 360.0;
-
+               
                while (final <= -180.0)
                        final += 360.0;
-
+               
                final *= (float)(M_PI / 180.0);
        }
        else {
                sprintf(str, "Rot: %.2f%s %s", 180.0*final/M_PI, t->con.text, t->proptext);
        }
+       
+       // fixes [#21433] but breaks, typical local axis rotation - campbell
+       // t->values[0] = final;
 
-       VecRotToMat3(axis, final, mat);
-
+       vec_rot_to_mat3( mat, t->axis, final);
+       
        // TRANSFORM_FIX_ME
 //     t->values[0] = final;           // used in manipulator
-//     Mat3CpyMat3(t->mat, mat);       // used in manipulator
-
-       applyRotation(t, final, axis);
-
+//     copy_m3_m3(t->mat, mat);        // used in manipulator
+       
+       applyRotation(t, final, t->axis);
+       
        recalcData(t);
-
+       
        ED_area_headerprint(t->sa, str);
-
+       
        return 1;
 }
 
@@ -3006,6 +3043,8 @@ void initTrackball(TransInfo *t)
        t->snap[1] = (float)((5.0/180)*M_PI);
        t->snap[2] = t->snap[1] * 0.2f;
 
+       t->num.increment = 1.0f;
+
        t->flag |= T_NO_CONSTRAINT;
 }
 
@@ -3015,10 +3054,10 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
        float mat[3][3], smat[3][3], totmat[3][3];
        int i;
 
-       VecRotToMat3(axis1, angles[0], smat);
-       VecRotToMat3(axis2, angles[1], totmat);
+       vec_rot_to_mat3( smat,axis1, angles[0]);
+       vec_rot_to_mat3( totmat,axis2, angles[1]);
 
-       Mat3MulMat3(mat, smat, totmat);
+       mul_m3_m3m3(mat, smat, totmat);
 
        for(i = 0 ; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
@@ -3028,10 +3067,10 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
                        continue;
 
                if (t->flag & T_PROP_EDIT) {
-                       VecRotToMat3(axis1, td->factor * angles[0], smat);
-                       VecRotToMat3(axis2, td->factor * angles[1], totmat);
+                       vec_rot_to_mat3( smat,axis1, td->factor * angles[0]);
+                       vec_rot_to_mat3( totmat,axis2, td->factor * angles[1]);
 
-                       Mat3MulMat3(mat, smat, totmat);
+                       mul_m3_m3m3(mat, smat, totmat);
                }
 
                ElementRotation(t, td, mat, t->around);
@@ -3047,8 +3086,8 @@ int Trackball(TransInfo *t, short mval[2])
 
        VECCOPY(axis1, t->persinv[0]);
        VECCOPY(axis2, t->persinv[1]);
-       Normalize(axis1);
-       Normalize(axis2);
+       normalize_v3(axis1);
+       normalize_v3(axis2);
 
        phi[0] = t->values[0];
        phi[1] = t->values[1];
@@ -3073,13 +3112,13 @@ int Trackball(TransInfo *t, short mval[2])
                sprintf(str, "Trackball: %.2f %.2f %s", 180.0*phi[0]/M_PI, 180.0*phi[1]/M_PI, t->proptext);
        }
 
-       VecRotToMat3(axis1, phi[0], smat);
-       VecRotToMat3(axis2, phi[1], totmat);
+       vec_rot_to_mat3( smat,axis1, phi[0]);
+       vec_rot_to_mat3( totmat,axis2, phi[1]);
 
-       Mat3MulMat3(mat, smat, totmat);
+       mul_m3_m3m3(mat, smat, totmat);
 
        // TRANSFORM_FIX_ME
-       //Mat3CpyMat3(t->mat, mat);     // used in manipulator
+       //copy_m3_m3(t->mat, mat);      // used in manipulator
 
        applyTrackball(t, axis1, axis2, phi);
 
@@ -3106,11 +3145,13 @@ void initTranslation(TransInfo *t)
        t->ndof.axis = (t->flag & T_2D_EDIT)? 1|2: 1|2|4;
 
        if(t->spacetype == SPACE_VIEW3D) {
-               View3D *v3d = t->view;
+               RegionView3D *rv3d = t->ar->regiondata;
 
-               t->snap[0] = 0.0f;
-               t->snap[1] = v3d->gridview * 1.0f;
-               t->snap[2] = t->snap[1] * 0.1f;
+               if (rv3d) {
+                       t->snap[0] = 0.0f;
+                       t->snap[1] = rv3d->gridview * 1.0f;
+                       t->snap[2] = t->snap[1] * 0.1f;
+               }
        }
        else if(t->spacetype == SPACE_IMAGE) {
                t->snap[0] = 0.0f;
@@ -3121,6 +3162,8 @@ void initTranslation(TransInfo *t)
                t->snap[0] = 0.0f;
                t->snap[1] = t->snap[2] = 1.0f;
        }
+
+       t->num.increment = t->snap[1];
 }
 
 static void headerTranslation(TransInfo *t, float vec[3], char *str) {
@@ -3131,7 +3174,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) {
 
        if (hasNumInput(&t->num)) {
                outputNumInput(&(t->num), tvec);
-               dist = VecLength(t->num.val);
+               dist = len_v3(t->num.val);
        }
        else {
                float dvec[3];
@@ -3139,7 +3182,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) {
                VECCOPY(dvec, vec);
                applyAspectRatio(t, dvec);
 
-               dist = VecLength(vec);
+               dist = len_v3(vec);
                if(t->scene->unit.system) {
                        int i, do_split= t->scene->unit.flag & USER_UNIT_OPT_SPLIT ? 1:0;
 
@@ -3199,10 +3242,10 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
        for(i = 0 ; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
-
+               
                if (td->flag & TD_SKIP)
                        continue;
-
+               
                /* handle snapping rotation before doing the translation */
                if (usingSnappingNormal(t))
                {
@@ -3213,48 +3256,41 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
                                float quat[4];
                                float mat[3][3];
                                float angle;
-
-                               Crossf(axis, original_normal, t->tsnap.snapNormal);
-                               angle = saacos(Inpf(original_normal, t->tsnap.snapNormal));
-
-                               AxisAngleToQuat(quat, axis, angle);
-
-                               QuatToMat3(quat, mat);
-
+                               
+                               cross_v3_v3v3(axis, original_normal, t->tsnap.snapNormal);
+                               angle = saacos(dot_v3v3(original_normal, t->tsnap.snapNormal));
+                               
+                               axis_angle_to_quat(quat, axis, angle);
+                               
+                               quat_to_mat3( mat,quat);
+                               
                                ElementRotation(t, td, mat, V3D_LOCAL);
                        }
                        else
                        {
                                float mat[3][3];
-
-                               Mat3One(mat);
-
+                               
+                               unit_m3(mat);
+                               
                                ElementRotation(t, td, mat, V3D_LOCAL);
                        }
                }
-
+               
                if (t->con.applyVec) {
                        float pvec[3];
                        t->con.applyVec(t, td, vec, tvec, pvec);
                }
-               else {
-                       VECCOPY(tvec, vec);
-               }
-
-               Mat3MulVecfl(td->smtx, tvec);
-               VecMulf(tvec, td->factor);
-
-               protectedTransBits(td->protectflag, tvec);
-
-               /* transdata ipokey */
-               if(td->tdi) {
-                       TransDataIpokey *tdi= td->tdi;
-                       add_tdi_poin(tdi->locx, tdi->oldloc, tvec[0]);
-                       add_tdi_poin(tdi->locy, tdi->oldloc+1, tvec[1]);
-                       add_tdi_poin(tdi->locz, tdi->oldloc+2, tvec[2]);
+               else {
+                       VECCOPY(tvec, vec);
                }
-               else VecAddf(td->loc, td->iloc, tvec);
-
+               
+               mul_m3_v3(td->smtx, tvec);
+               mul_v3_fl(tvec, td->factor);
+               
+               protectedTransBits(td->protectflag, tvec);
+               
+               add_v3_v3v3(td->loc, td->iloc, tvec);
+               
                constraintTransLim(t, td);
        }
 }
@@ -3262,11 +3298,11 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
 /* uses t->vec to store actual translation in */
 int Translation(TransInfo *t, short mval[2])
 {
-       float tvec[3];
        char str[250];
 
        if (t->con.mode & CON_APPLY) {
                float pvec[3] = {0.0f, 0.0f, 0.0f};
+               float tvec[3];
                applySnapping(t, t->values);
                t->con.applyVec(t, NULL, t->values, tvec, pvec);
                VECCOPY(t->values, tvec);
@@ -3318,6 +3354,8 @@ void initShrinkFatten(TransInfo *t)
                t->snap[1] = 1.0f;
                t->snap[2] = t->snap[1] * 0.1f;
 
+               t->num.increment = t->snap[1];
+
                t->flag |= T_NO_CONSTRAINT;
        }
 }
@@ -3360,10 +3398,10 @@ int ShrinkFatten(TransInfo *t, short mval[2])
                        continue;
 
                VECCOPY(vec, td->axismtx[2]);
-               VecMulf(vec, distance);
-               VecMulf(vec, td->factor);
+               mul_v3_fl(vec, distance);
+               mul_v3_fl(vec, td->factor);
 
-               VecAddf(td->loc, td->iloc, vec);
+               add_v3_v3v3(td->loc, td->iloc, vec);
        }
 
        recalcData(t);
@@ -3392,6 +3430,8 @@ void initTilt(TransInfo *t)
        t->snap[1] = (float)((5.0/180)*M_PI);
        t->snap[2] = t->snap[1] * 0.2f;
 
+       t->num.increment = t->snap[1];
+
        t->flag |= T_NO_CONSTRAINT;
 }
 
@@ -3461,6 +3501,11 @@ void initCurveShrinkFatten(TransInfo *t)
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
 
+       t->num.increment = t->snap[1];
+
+       t->flag |= T_NO_ZERO;
+       t->num.flag |= NUM_NO_ZERO;
+
        t->flag |= T_NO_CONSTRAINT;
 }
 
@@ -3498,7 +3543,7 @@ int CurveShrinkFatten(TransInfo *t, short mval[2])
                if(td->val) {
                        //*td->val= ratio;
                        *td->val= td->ival*ratio;
-                       if (*td->val <= 0.0f) *td->val = 0.0001f;
+                       if (*td->val <= 0.0f) *td->val = 0.001f;
                }
        }
 
@@ -3527,6 +3572,8 @@ void initPushPull(TransInfo *t)
        t->snap[0] = 0.0f;
        t->snap[1] = 1.0f;
        t->snap[2] = t->snap[1] * 0.1f;
+
+       t->num.increment = t->snap[1];
 }
 
 
@@ -3570,23 +3617,23 @@ int PushPull(TransInfo *t, short mval[2])
                if (td->flag & TD_SKIP)
                        continue;
 
-               VecSubf(vec, t->center, td->center);
+               sub_v3_v3v3(vec, t->center, td->center);
                if (t->con.applyRot && t->con.mode & CON_APPLY) {
                        t->con.applyRot(t, td, axis, NULL);
                        if (isLockConstraint(t)) {
                                float dvec[3];
-                               Projf(dvec, vec, axis);
-                               VecSubf(vec, vec, dvec);
+                               project_v3_v3v3(dvec, vec, axis);
+                               sub_v3_v3v3(vec, vec, dvec);
                        }
                        else {
-                               Projf(vec, vec, axis);
+                               project_v3_v3v3(vec, vec, axis);
                        }
                }
-               Normalize(vec);
-               VecMulf(vec, distance);
-               VecMulf(vec, td->factor);
+               normalize_v3(vec);
+               mul_v3_fl(vec, distance);
+               mul_v3_fl(vec, td->factor);
 
-               VecAddf(td->loc, td->iloc, vec);
+               add_v3_v3v3(td->loc, td->iloc, vec);
        }
 
        recalcData(t);
@@ -3615,6 +3662,8 @@ void initBevel(TransInfo *t)
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
 
+       t->num.increment = t->snap[1];
+
        /* DON'T KNOW WHY THIS IS NEEDED */
        if (G.editBMesh->imval[0] == 0 && G.editBMesh->imval[1] == 0) {
                /* save the initial mouse co */
@@ -3724,6 +3773,8 @@ void initBevelWeight(TransInfo *t)
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
 
+       t->num.increment = t->snap[1];
+
        t->flag |= T_NO_CONSTRAINT;
 }
 
@@ -3795,6 +3846,8 @@ void initCrease(TransInfo *t)
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
 
+       t->num.increment = t->snap[1];
+
        t->flag |= T_NO_CONSTRAINT;
 }
 
@@ -3869,6 +3922,8 @@ void initBoneSize(TransInfo *t)
        t->snap[0] = 0.0f;
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
+
+       t->num.increment = t->snap[1];
 }
 
 static void headerBoneSize(TransInfo *t, float vec[3], char *str) {
@@ -3899,8 +3954,8 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
        float tmat[3][3], smat[3][3], oldy;
        float sizemat[3][3];
 
-       Mat3MulMat3(smat, mat, td->mtx);
-       Mat3MulMat3(tmat, td->smtx, smat);
+       mul_m3_m3m3(smat, mat, td->mtx);
+       mul_m3_m3m3(tmat, td->smtx, smat);
 
        if (t->con.applySize) {
                t->con.applySize(t, td, tmat);
@@ -3908,9 +3963,9 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
 
        /* we've tucked the scale in loc */
        oldy= td->iloc[1];
-       SizeToMat3(td->iloc, sizemat);
-       Mat3MulMat3(tmat, tmat, sizemat);
-       Mat3ToSize(tmat, td->loc);
+       size_to_mat3( sizemat,td->iloc);
+       mul_m3_m3m3(tmat, tmat, sizemat);
+       mat3_to_size( td->loc,tmat);
        td->loc[1]= oldy;
 }
 
@@ -3921,7 +3976,7 @@ int BoneSize(TransInfo *t, short mval[2])
        float ratio;
        int i;
        char str[60];
-
+       
        // TRANSFORM_FIX_ME MOVE TO MOUSE INPUT
        /* for manipulator, center handle, the scaling can't be done relative to center */
        if( (t->flag & T_USES_MANIPULATOR) && t->con.mode==0)
@@ -3932,40 +3987,40 @@ int BoneSize(TransInfo *t, short mval[2])
        {
                ratio = t->values[0];
        }
-
+       
        size[0] = size[1] = size[2] = ratio;
-
+       
        snapGrid(t, size);
-
+       
        if (hasNumInput(&t->num)) {
                applyNumInput(&t->num, size);
                constraintNumInput(t, size);
        }
-
-       SizeToMat3(size, mat);
-
+       
+       size_to_mat3( mat,size);
+       
        if (t->con.applySize) {
                t->con.applySize(t, NULL, mat);
        }
-
-       Mat3CpyMat3(t->mat, mat);       // used in manipulator
-
+       
+       copy_m3_m3(t->mat, mat);        // used in manipulator
+       
        headerBoneSize(t, size, str);
-
+       
        for(i = 0 ; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
-
+               
                if (td->flag & TD_SKIP)
                        continue;
-
+               
                ElementBoneSize(t, td, mat);
        }
-
+       
        recalcData(t);
-
+       
        ED_area_headerprint(t->sa, str);
-
+       
        return 1;
 }
 
@@ -3976,14 +4031,16 @@ void initBoneEnvelope(TransInfo *t)
 {
        t->mode = TFM_BONE_ENVELOPE;
        t->transform = BoneEnvelope;
-
+       
        initMouseInputMode(t, &t->mouse, INPUT_SPRING);
-
+       
        t->idx_max = 0;
        t->num.idx_max = 0;
        t->snap[0] = 0.0f;
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
+       
+       t->num.increment = t->snap[1];
 
        t->flag |= T_NO_CONSTRAINT;
 }
@@ -3994,31 +4051,31 @@ int BoneEnvelope(TransInfo *t, short mval[2])
        float ratio;
        int i;
        char str[50];
-
+       
        ratio = t->values[0];
-
+       
        snapGrid(t, &ratio);
-
+       
        applyNumInput(&t->num, &ratio);
-
+       
        /* header print for NumInput */
        if (hasNumInput(&t->num)) {
                char c[20];
-
+               
                outputNumInput(&(t->num), c);
                sprintf(str, "Envelope: %s", c);
        }
        else {
                sprintf(str, "Envelope: %3f", ratio);
        }
-
+       
        for(i = 0 ; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
-
+               
                if (td->flag & TD_SKIP)
                        continue;
-
+               
                if (td->val) {
                        /* if the old/original value was 0.0f, then just use ratio */
                        if (td->ival)
@@ -4027,11 +4084,11 @@ int BoneEnvelope(TransInfo *t, short mval[2])
                                *td->val= ratio;
                }
        }
-
+       
        recalcData(t);
-
+       
        ED_area_headerprint(t->sa, str);
-
+       
        return 1;
 }
 
@@ -4047,10 +4104,8 @@ static int createSlideVerts(TransInfo *t)
        LinkNode *edgelist = NULL, *vertlist=NULL, *look;
        GHash *vertgh;
        TransDataSlideVert *tempsv;
-       float perc = 0, percp = 0,vertdist; // XXX, projectMat[4][4];
-       float shiftlabda= 0.0f,len = 0.0f;
-       int i, j, numsel, numadded=0, timesthrough = 0, vertsel=0, prop=1, cancel = 0,flip=0;
-       int wasshift = 0;
+       float vertdist; // XXX, projectMat[4][4];
+       int i, j, numsel, numadded=0, timesthrough = 0, vertsel=0;
        /* UV correction vars */
        GHash **uvarray= NULL;
        SlideData *sld = MEM_callocN(sizeof(*sld), "sld");
@@ -4061,12 +4116,15 @@ static int createSlideVerts(TransInfo *t)
        float projectMat[4][4];
        float start[3] = {0.0f, 0.0f, 0.0f}, end[3] = {0.0f, 0.0f, 0.0f};
        float vec[3];
-       //short mval[2], mvalo[2];
-       float labda = 0.0f, totvec=0.0;
-
-       view3d_get_object_project_mat(v3d, t->obedit, projectMat);
+       float totvec=0.0;
 
-       //mvalo[0] = -1; mvalo[1] = -1;
+       if (!v3d) {
+               /*ok, let's try to survive this*/
+               unit_m4(projectMat);
+       } else {
+               view3d_get_object_project_mat(v3d, t->obedit, projectMat);
+       }
+       
        numsel =0;
 
        // Get number of selected edges and clear some flags
@@ -4340,6 +4398,8 @@ static int createSlideVerts(TransInfo *t)
                        if(sv) {
                                float co[3], co2[3], vec[3];
 
+                               ev = (EditVert*)look->link;
+
                                if(!sharesFace(em, tempsv->up,sv->up)) {
                                        EditEdge *swap;
                                        swap = sv->up;
@@ -4347,27 +4407,31 @@ static int createSlideVerts(TransInfo *t)
                                        sv->down = swap;
                                }
                                
-                               view3d_project_float(t->ar, tempsv->up->v1->co, co, projectMat);
-                               view3d_project_float(t->ar, tempsv->up->v2->co, co2, projectMat);
-                               
-                               if (ev == sv->up->v1) {
-                                       VecSubf(vec, co, co2);
+                               if (v3d) {
+                                       view3d_project_float(t->ar, tempsv->up->v1->co, co, projectMat);
+                                       view3d_project_float(t->ar, tempsv->up->v2->co, co2, projectMat);
+                               }
+
+                               if (ev == tempsv->up->v1) {
+                                       sub_v3_v3v3(vec, co, co2);
                                } else {
-                                       VecSubf(vec, co2, co);
+                                       sub_v3_v3v3(vec, co2, co);
                                }
 
-                               VecAddf(start, start, vec);
+                               add_v3_v3v3(start, start, vec);
 
-                               view3d_project_float(t->ar, tempsv->down->v1->co, co, projectMat);
-                               view3d_project_float(t->ar, tempsv->down->v2->co, co2, projectMat);
-                               
-                               if (ev == sv->down->v1) {
-                                       VecSubf(vec, co2, co);
+                               if (v3d) {
+                                       view3d_project_float(t->ar, tempsv->down->v1->co, co, projectMat);
+                                       view3d_project_float(t->ar, tempsv->down->v2->co, co2, projectMat);
+                               }
+
+                               if (ev == tempsv->down->v1) {
+                                       sub_v3_v3v3(vec, co2, co);
                                } else {
-                                       VecSubf(vec, co, co2);
+                                       sub_v3_v3v3(vec, co, co2);
                                }
 
-                               VecAddf(end, end, vec);
+                               add_v3_v3v3(end, end, vec);
 
                                totvec += 1.0f;
                                nearest = (EditVert*)look->link;
@@ -4379,12 +4443,12 @@ static int createSlideVerts(TransInfo *t)
                look = look->next;
        }
 
-       VecAddf(start, start, end);
-       VecMulf(start, 0.5*(1.0/totvec));
+       add_v3_v3v3(start, start, end);
+       mul_v3_fl(start, 0.5*(1.0/totvec));
        VECCOPY(vec, start);
        start[0] = t->mval[0];
        start[1] = t->mval[1];
-       VecAddf(end, start, vec);
+       add_v3_v3v3(end, start, vec);
        
        sld->start[0] = (short) start[0];
        sld->start[1] = (short) start[1];
@@ -4498,21 +4562,56 @@ static int createSlideVerts(TransInfo *t)
        return 1;
 }
 
+void freeSlideVerts(TransInfo *t)
+{
+       TransDataSlideUv *suv;
+       SlideData *sld = t->customData;
+       int uvlay_idx;
+
+       //BLI_ghash_free(edgesgh, freeGHash, NULL);
+       BLI_ghash_free(sld->vhash, NULL, (GHashValFreeFP)MEM_freeN);
+       BLI_linklist_free(sld->vertlist, NULL);
+       BLI_linklist_free(sld->edgelist, NULL);
+
+       if (sld->uvlay_tot) {
+               for (uvlay_idx=0; uvlay_idx<sld->uvlay_tot; uvlay_idx++) {
+                       BLI_ghash_free(sld->uvhash[uvlay_idx], NULL, NULL);
+               }
+
+               suv = sld->suv_last-1;
+               while (suv >= sld->slideuv) {
+                       if (suv->fuv_list) {
+                               BLI_linklist_free(suv->fuv_list,NULL);
+                       }
+                       suv--;
+               }
+
+               MEM_freeN(sld->slideuv);
+               MEM_freeN(sld->uvhash);
+       }
+
+       MEM_freeN(sld);
+       t->customData = NULL;
+}
+
 void initEdgeSlide(TransInfo *t)
 {
        SlideData *sld;
 
        t->mode = TFM_EDGE_SLIDE;
        t->transform = EdgeSlide;
-
+       
        createSlideVerts(t);
        sld = t->customData;
 
        if (!sld)
                return;
 
-       initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO);
+       t->customFree = freeSlideVerts;
+
+       /* set custom point first if you want value to be initialized by init */
        setCustomPoints(t, &t->mouse, sld->end, sld->start);
+       initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO);
        
        t->idx_max = 0;
        t->num.idx_max = 0;
@@ -4520,6 +4619,8 @@ void initEdgeSlide(TransInfo *t)
        t->snap[1] = (float)((5.0/180)*M_PI);
        t->snap[2] = t->snap[1] * 0.2f;
 
+       t->num.increment = t->snap[1];
+
        t->flag |= T_NO_CONSTRAINT;
 }
 
@@ -4528,23 +4629,20 @@ int doEdgeSlide(TransInfo *t, float perc)
        Mesh *me= t->obedit->data;
        EditMesh *em = me->edit_mesh;
        SlideData *sld = t->customData;
-       EditEdge *first=NULL,*last=NULL, *temp = NULL;
        EditVert *ev, *nearest = sld->nearest;
        EditVert *centerVert, *upVert, *downVert;
-       LinkNode *edgelist = sld->edgelist, *vertlist=sld->vertlist, *look;
+       LinkNode *vertlist=sld->vertlist, *look;
        GHash *vertgh = sld->vhash;
        TransDataSlideVert *tempsv;
-       float shiftlabda= 0.0f,len = 0.0f;
-       int i = 0, numadded=0, timesthrough = 0, vertsel=0, prop=1, cancel = 0,flip=0;
-       int wasshift = 0;
+       float len = 0.0f;
+       int prop=1, flip=0;
        /* UV correction vars */
        GHash **uvarray= sld->uvhash;
        int  uvlay_tot= CustomData_number_of_layers(&em->fdata, CD_MTFACE);
        int uvlay_idx;
-       TransDataSlideUv *slideuvs=sld->slideuv, *suv=sld->slideuv, *suv_last=NULL;
+       TransDataSlideUv *suv=sld->slideuv;
        float uv_tmp[2];
        LinkNode *fuv_link;
-       float labda = 0.0f;
 
        len = 0.0f;
 
@@ -4554,7 +4652,7 @@ int doEdgeSlide(TransInfo *t, float perc)
        upVert = editedge_getOtherVert(tempsv->up, centerVert);
        downVert = editedge_getOtherVert(tempsv->down, centerVert);
 
-       len = MIN2(perc, VecLenf(upVert->co,downVert->co));
+       len = MIN2(perc, len_v3v3(upVert->co,downVert->co));
        len = MAX2(len, 0);
 
        //Adjust Edgeloop
@@ -4566,13 +4664,13 @@ int doEdgeSlide(TransInfo *t, float perc)
                        tempsv = BLI_ghash_lookup(vertgh,ev);
 
                        tempev = editedge_getOtherVert((perc>=0)?tempsv->up:tempsv->down, ev);
-                       VecLerpf(ev->co, tempsv->origvert.co, tempev->co, fabs(perc));
+                       interp_v3_v3v3(ev->co, tempsv->origvert.co, tempev->co, fabs(perc));
 
                        if (uvlay_tot) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
                                for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
                                        suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
                                        if (suv && suv->fuv_list && suv->uv_up && suv->uv_down) {
-                                               Vec2Lerpf(uv_tmp, suv->origuv,  (perc>=0)?suv->uv_up:suv->uv_down, fabs(perc));
+                                               interp_v2_v2v2(uv_tmp, suv->origuv,  (perc>=0)?suv->uv_up:suv->uv_down, fabs(perc));
                                                fuv_link = suv->fuv_list;
                                                while (fuv_link) {
                                                        VECCOPY2D(((float *)fuv_link->link), uv_tmp);
@@ -4592,17 +4690,17 @@ int doEdgeSlide(TransInfo *t, float perc)
                        float newlen;
                        ev = look->link;
                        tempsv = BLI_ghash_lookup(vertgh,ev);
-                       newlen = (len / VecLenf(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co));
+                       newlen = (len / len_v3v3(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co));
                        if(newlen > 1.0) {newlen = 1.0;}
                        if(newlen < 0.0) {newlen = 0.0;}
                        if(flip == 0) {
-                               VecLerpf(ev->co, editedge_getOtherVert(tempsv->down,ev)->co, editedge_getOtherVert(tempsv->up,ev)->co, fabs(newlen));
+                               interp_v3_v3v3(ev->co, editedge_getOtherVert(tempsv->down,ev)->co, editedge_getOtherVert(tempsv->up,ev)->co, fabs(newlen));
                                if (uvlay_tot) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
                                        /* dont do anything if no UVs */
                                        for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
                                                suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
                                                if (suv && suv->fuv_list && suv->uv_up && suv->uv_down) {
-                                                       Vec2Lerpf(uv_tmp, suv->uv_down, suv->uv_up, fabs(newlen));
+                                                       interp_v2_v2v2(uv_tmp, suv->uv_down, suv->uv_up, fabs(newlen));
                                                        fuv_link = suv->fuv_list;
                                                        while (fuv_link) {
                                                                VECCOPY2D(((float *)fuv_link->link), uv_tmp);
@@ -4612,14 +4710,14 @@ int doEdgeSlide(TransInfo *t, float perc)
                                        }
                                }
                        } else{
-                               VecLerpf(ev->co, editedge_getOtherVert(tempsv->up,ev)->co, editedge_getOtherVert(tempsv->down,ev)->co, fabs(newlen));
+                               interp_v3_v3v3(ev->co, editedge_getOtherVert(tempsv->up,ev)->co, editedge_getOtherVert(tempsv->down,ev)->co, fabs(newlen));
 
                                if (uvlay_tot) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
                                        /* dont do anything if no UVs */
                                        for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
                                                suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
                                                if (suv && suv->fuv_list && suv->uv_up && suv->uv_down) {
-                                                       Vec2Lerpf(uv_tmp, suv->uv_up, suv->uv_down, fabs(newlen));
+                                                       interp_v2_v2v2(uv_tmp, suv->uv_up, suv->uv_down, fabs(newlen));
                                                        fuv_link = suv->fuv_list;
                                                        while (fuv_link) {
                                                                VECCOPY2D(((float *)fuv_link->link), uv_tmp);
@@ -4637,39 +4735,8 @@ int doEdgeSlide(TransInfo *t, float perc)
        return 1;
 }
 
-void freeSlideVerts(TransInfo *t)
-{
-       TransDataSlideUv *suv;
-       SlideData *sld = t->customData;
-       int uvlay_idx;
-
-       //BLI_ghash_free(edgesgh, freeGHash, NULL);
-       BLI_ghash_free(sld->vhash, NULL, (GHashValFreeFP)MEM_freeN);
-       BLI_linklist_free(sld->vertlist, NULL);
-       BLI_linklist_free(sld->edgelist, NULL);
-
-       if (sld->uvlay_tot) {
-               for (uvlay_idx=0; uvlay_idx<sld->uvlay_tot; uvlay_idx++) {
-                       BLI_ghash_free(sld->uvhash[uvlay_idx], NULL, NULL);
-               }
-               MEM_freeN(sld->slideuv);
-               MEM_freeN(sld->uvhash);
-
-               suv = sld->suv_last-1;
-               while (suv >= sld->slideuv) {
-                       if (suv->fuv_list) {
-                               BLI_linklist_free(suv->fuv_list,NULL);
-                       }
-                       suv--;
-               }
-       }
-
-       MEM_freeN(sld);
-}
-
 int EdgeSlide(TransInfo *t, short mval[2])
 {
-       TransData *td = t->data;
        char str[50];
        float final;
 
@@ -4693,7 +4760,12 @@ int EdgeSlide(TransInfo *t, short mval[2])
        CLAMP(final, -1.0f, 1.0f);
 
        /*do stuff here*/
-       doEdgeSlide(t, final);
+       if (t->customData)
+               doEdgeSlide(t, final);
+       else {
+               strcpy(str, "Invalid Edge Selection");
+               t->state = TRANS_CANCEL;
+       }
 
        recalcData(t);
 
@@ -4717,6 +4789,8 @@ void initBoneRoll(TransInfo *t)
        t->snap[1] = (float)((5.0/180)*M_PI);
        t->snap[2] = t->snap[1] * 0.2f;
 
+       t->num.increment = 1.0f;
+
        t->flag |= T_NO_CONSTRAINT;
 }
 
@@ -4777,6 +4851,8 @@ void initBakeTime(TransInfo *t)
        t->snap[0] = 0.0f;
        t->snap[1] = 1.0f;
        t->snap[2] = t->snap[1] * 0.1f;
+
+       t->num.increment = t->snap[1];
 }
 
 int BakeTime(TransInfo *t, short mval[2])
@@ -4871,7 +4947,7 @@ int Mirror(TransInfo *t, short mval[2])
        if (t->con.mode & CON_APPLY) {
                size[0] = size[1] = size[2] = -1;
 
-               SizeToMat3(size, mat);
+               size_to_mat3( mat,size);
 
                if (t->con.applySize) {
                        t->con.applySize(t, NULL, mat);
@@ -4897,7 +4973,7 @@ int Mirror(TransInfo *t, short mval[2])
        {
                size[0] = size[1] = size[2] = 1;
 
-               SizeToMat3(size, mat);
+               size_to_mat3( mat,size);
 
                for(i = 0, td=t->data; i < t->total; i++, td++) {
                        if (td->flag & TD_NOACTION)
@@ -4960,9 +5036,9 @@ int Align(TransInfo *t, short mval[2])
                        }
                }
 
-               Mat3Inv(invmat, td->axismtx);
+               invert_m3_m3(invmat, td->axismtx);
 
-               Mat3MulMat3(mat, t->spacemtx, invmat);
+               mul_m3_m3m3(mat, t->spacemtx, invmat);
 
                ElementRotation(t, td, mat, t->around);
        }
@@ -4977,6 +5053,92 @@ int Align(TransInfo *t, short mval[2])
        return 1;
 }
 
+/* ************************** SEQ SLIDE *************************** */
+
+void initSeqSlide(TransInfo *t)
+{
+       t->transform = SeqSlide;
+
+       initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
+
+       t->idx_max = 1;
+       t->num.flag = 0;
+       t->num.idx_max = t->idx_max;
+
+       t->ndof.axis = 1|2;
+
+       t->snap[0] = 0.0f;
+       t->snap[1] = floor(t->scene->r.frs_sec / t->scene->r.frs_sec_base);
+       t->snap[2] = 10.0f;
+
+       t->num.increment = t->snap[1];
+}
+
+static void headerSeqSlide(TransInfo *t, float val[2], char *str)
+{
+       char tvec[60];
+
+       if (hasNumInput(&t->num)) {
+               outputNumInput(&(t->num), tvec);
+       }
+       else {
+               sprintf(&tvec[0], "%.0f, %.0f", val[0], val[1]);
+       }
+
+       sprintf(str, "Sequence Slide: %s%s", &tvec[0], t->con.text);
+}
+
+static void applySeqSlide(TransInfo *t, float val[2]) {
+       TransData *td = t->data;
+       int i;
+
+       for(i = 0 ; i < t->total; i++, td++) {
+               float tvec[2];
+
+               if (td->flag & TD_NOACTION)
+                       break;
+
+               if (td->flag & TD_SKIP)
+                       continue;
+
+               copy_v2_v2(tvec, val);
+
+               mul_v2_fl(tvec, td->factor);
+
+               td->loc[0] = td->iloc[0] + tvec[0];
+               td->loc[1] = td->iloc[1] + tvec[1];
+       }
+}
+
+int SeqSlide(TransInfo *t, short mval[2])
+{
+       char str[200];
+
+       if (t->con.mode & CON_APPLY) {
+               float pvec[3] = {0.0f, 0.0f, 0.0f};
+               float tvec[3];
+               t->con.applyVec(t, NULL, t->values, tvec, pvec);
+               VECCOPY(t->values, tvec);
+       }
+       else {
+               applyNDofInput(&t->ndof, t->values);
+               snapGrid(t, t->values);
+               applyNumInput(&t->num, t->values);
+       }
+
+       t->values[0] = floor(t->values[0] + 0.5);
+       t->values[1] = floor(t->values[1] + 0.5);
+
+       headerSeqSlide(t, t->values, str);
+       applySeqSlide(t, t->values);
+
+       recalcData(t);
+
+       ED_area_headerprint(t->sa, str);
+
+       return 1;
+}
+
 /* ************************** ANIM EDITORS - TRANSFORM TOOLS *************************** */
 
 /* ---------------- Special Helpers for Various Settings ------------- */
@@ -4989,37 +5151,37 @@ int Align(TransInfo *t, short mval[2])
 static short getAnimEdit_SnapMode(TransInfo *t)
 {
        short autosnap= SACTSNAP_OFF;
-
-       /* currently, some of these are only for the action editor */
+       
        if (t->spacetype == SPACE_ACTION) {
                SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
-
+               
                if (saction)
                        autosnap= saction->autosnap;
        }
        else if (t->spacetype == SPACE_IPO) {
                SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
-
+               
                if (sipo)
                        autosnap= sipo->autosnap;
        }
        else if (t->spacetype == SPACE_NLA) {
                SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
-
+               
                if (snla)
                        autosnap= snla->autosnap;
        }
        else {
-               // TRANSFORM_FIX_ME This needs to use proper defines for t->modifiers
-//             // FIXME: this still toggles the modes...
-//             if (ctrl)
-//                     autosnap= SACTSNAP_STEP;
-//             else if (shift)
-//                     autosnap= SACTSNAP_FRAME;
-//             else if (alt)
-//                     autosnap= SACTSNAP_MARKER;
-//             else
+               autosnap= SACTSNAP_OFF;
+       }
+       
+       /* toggle autosnap on/off 
+        *      - when toggling on, prefer nearest frame over 1.0 frame increments
+        */
+       if (t->modifiers & MOD_SNAP_INVERT) {
+               if (autosnap)
                        autosnap= SACTSNAP_OFF;
+               else
+                       autosnap= SACTSNAP_FRAME;
        }
 
        return autosnap;
@@ -5033,17 +5195,21 @@ static short getAnimEdit_DrawTime(TransInfo *t)
 {
        short drawtime;
 
-       /* currently, some of these are only for the action editor */
        if (t->spacetype == SPACE_ACTION) {
                SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
-
+               
                drawtime = (saction->flag & SACTION_DRAWTIME)? 1 : 0;
        }
        else if (t->spacetype == SPACE_NLA) {
                SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
-
+               
                drawtime = (snla->flag & SNLA_DRAWTIME)? 1 : 0;
        }
+       else if (t->spacetype == SPACE_IPO) {
+               SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
+               
+               drawtime = (sipo->flag & SIPO_DRAWTIME)? 1 : 0;
+       }       
        else {
                drawtime = 0;
        }
@@ -5121,6 +5287,8 @@ void initTimeTranslate(TransInfo *t)
        /* initialise snap like for everything else */
        t->snap[0] = 0.0f;
        t->snap[1] = t->snap[2] = 1.0f;
+
+       t->num.increment = t->snap[1];
 }
 
 static void headerTimeTranslate(TransInfo *t, char *str)
@@ -5137,7 +5305,7 @@ static void headerTimeTranslate(TransInfo *t, char *str)
                const short doTime = getAnimEdit_DrawTime(t);
                const double secf= FPS;
                float val = t->values[0];
-
+               
                /* apply snapping + frame->seconds conversions */
                if (autosnap == SACTSNAP_STEP) {
                        if (doTime)
@@ -5149,8 +5317,11 @@ static void headerTimeTranslate(TransInfo *t, char *str)
                        if (doTime)
                                val= val / secf;
                }
-
-               sprintf(&tvec[0], "%.4f", val);
+               
+               if (autosnap == SACTSNAP_FRAME)
+                       sprintf(&tvec[0], "%d.00 (%.4f)", (int)val, val);
+               else
+                       sprintf(&tvec[0], "%.4f", val);
        }
 
        sprintf(str, "DeltaX: %s", &tvec[0]);
@@ -5178,7 +5349,7 @@ static void applyTimeTranslate(TransInfo *t, float sval)
                AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
 
                /* check if any need to apply nla-mapping */
-               if (adt) {
+               if (adt && t->spacetype != SPACE_SEQ) {
                        deltax = t->values[0];
 
                        if (autosnap == SACTSNAP_STEP) {
@@ -5264,6 +5435,8 @@ void initTimeSlide(TransInfo *t)
        /* initialise snap like for everything else */
        t->snap[0] = 0.0f;
        t->snap[1] = t->snap[2] = 1.0f;
+
+       t->num.increment = t->snap[1];
 }
 
 static void headerTimeSlide(TransInfo *t, float sval, char *str)
@@ -5369,11 +5542,21 @@ int TimeSlide(TransInfo *t, short mval[2])
 
 void initTimeScale(TransInfo *t)
 {
+       int center[2];
+
        t->mode = TFM_TIME_SCALE;
        t->transform = TimeScale;
 
-       initMouseInputMode(t, &t->mouse, INPUT_NONE);
-       t->helpline = HLP_SPRING; /* set manually because we don't use a predefined input */
+       /* recalculate center2d to use CFRA and mouse Y, since that's
+        * what is used in time scale */
+       t->center[0] = t->scene->r.cfra;
+       projectIntView(t, t->center, center);
+       center[1] = t->imval[1];
+
+       /* force a reinit with the center2d used here */
+       initMouseInput(t, &t->mouse, center, t->imval);
+
+       initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
 
        t->flag |= T_NULL_ONE;
        t->num.flag |= NUM_NULL_ONE;
@@ -5386,6 +5569,8 @@ void initTimeScale(TransInfo *t)
        /* initialise snap like for everything else */
        t->snap[0] = 0.0f;
        t->snap[1] = t->snap[2] = 1.0f;
+
+       t->num.increment = t->snap[1];
 }
 
 static void headerTimeScale(TransInfo *t, char *str) {
@@ -5441,19 +5626,8 @@ static void applyTimeScale(TransInfo *t) {
 
 int TimeScale(TransInfo *t, short mval[2])
 {
-       float cval, sval;
-       float deltax, startx;
-       float width= 0.0f;
        char str[200];
-
-       sval= t->imval[0];
-       cval= mval[0];
-
-       /* calculate scaling factor */
-       startx= sval-(width/2+(t->ar->winx)/2);
-       deltax= cval-(width/2+(t->ar->winx)/2);
-       t->values[0] = deltax / startx;
-
+       
        /* handle numeric-input stuff */
        t->vec[0] = t->values[0];
        applyNumInput(&t->num, &t->vec[0]);