ok, apparently didn't commit this either. apparently includes a merge with trunk...
[blender-staging.git] / source / blender / editors / transform / transform.c
index 7497cd730559d2915aa91afec62764719ae9b68f..66ced74e1a8108f10f78ccdc1c79474c173ccabe 100644 (file)
 #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"
@@ -129,18 +129,18 @@ void setTransformViewMatrices(TransInfo *t)
        if(t->spacetype==SPACE_VIEW3D && 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);
@@ -330,13 +330,9 @@ 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);
        }
 }
 
@@ -513,6 +509,7 @@ static char *transform_to_undostr(TransInfo *t)
 #define TFM_MODAL_RESIZE                       5
 #define TFM_MODAL_SNAP_GEARS           6
 #define TFM_MODAL_SNAP_GEARS_OFF       7
+#define TFM_MODAL_SNAP_GEARS_TOGGLE    8
 
 /* called in transform_ops.c, on each regeneration of keymaps */
 void transform_modal_keymap(wmKeyConfig *keyconf)
@@ -525,6 +522,7 @@ void transform_modal_keymap(wmKeyConfig *keyconf)
        {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_GEARS_TOGGLE, "SNAP_GEARS_TOGGLE", 0, "Snap Toggle", ""},
        {0, NULL, 0, NULL, NULL}};
        
        wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Transform Modal Map");
@@ -536,7 +534,7 @@ void transform_modal_keymap(wmKeyConfig *keyconf)
        
        /* 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,8 +542,7 @@ void transform_modal_keymap(wmKeyConfig *keyconf)
        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);
+       WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_SNAP_GEARS_TOGGLE);
        
        /* assign map to operators */
        WM_modalkeymap_assign(keymap, "TFM_OT_transform");
@@ -558,7 +555,8 @@ void transform_modal_keymap(wmKeyConfig *keyconf)
        WM_modalkeymap_assign(keymap, "TFM_OT_shrink_fatten");
        WM_modalkeymap_assign(keymap, "TFM_OT_tilt");
        WM_modalkeymap_assign(keymap, "TFM_OT_trackball");
-       
+       WM_modalkeymap_assign(keymap, "TFM_OT_mirror");
+       WM_modalkeymap_assign(keymap, "TFM_OT_edge_slide");
 }
 
 
@@ -576,6 +574,10 @@ void transformEvent(TransInfo *t, wmEvent *event)
 
                t->redraw = 1;
 
+               if (t->state == TRANS_STARTING) {
+                   t->state = TRANS_RUNNING;
+               }
+
                applyMouseInput(t, &t->mouse, t->mval, t->values);
        }
 
@@ -588,7 +590,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) ) {
@@ -636,6 +637,10 @@ void transformEvent(TransInfo *t, wmEvent *event)
                                t->modifiers &= ~MOD_SNAP_GEARS;
                                t->redraw = 1;
                                break;
+                       case TFM_MODAL_SNAP_GEARS_TOGGLE:
+                               t->modifiers ^= MOD_SNAP_GEARS;
+                               t->redraw = 1;
+                               break;
                }
        }
        /* else do non-mapped events */
@@ -645,12 +650,6 @@ 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;
@@ -665,7 +664,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
                        }
@@ -944,24 +943,14 @@ 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;
                        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;
@@ -976,6 +965,13 @@ void transformEvent(TransInfo *t, wmEvent *event)
 //                             t->state = TRANS_CONFIRM;
 //                     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
@@ -1012,11 +1008,12 @@ 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);
 
+       postTrans(t);
+
        MEM_freeN(t);
 
        return success;
@@ -1115,11 +1112,11 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
                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
@@ -1351,12 +1348,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;
@@ -1371,12 +1370,12 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
                t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL);
        }
        else if(t->spacetype == SPACE_IMAGE) {
-               Mat3One(t->spacemtx);
+               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
 
@@ -1560,7 +1559,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)
@@ -1573,12 +1572,12 @@ 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);
 
+               /* free data */
+               postTrans(t);
+
                /* send events out for redraws */
                viewRedrawPost(t);
 
@@ -1655,8 +1654,8 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl
                /* axis-angle get limited with euler... */
                float eul[3], oldeul[3];
                
-               AxisAngleToEulO(axis, *angle, eul, EULER_ORDER_DEFAULT);
-               AxisAngleToEulO(oldAxis, oldAngle, 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];
@@ -1665,7 +1664,7 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl
                if (protectflag & OB_LOCK_ROTZ)
                        eul[2]= oldeul[2];
                
-               EulOToAxisAngle(eul, EULER_ORDER_DEFAULT, axis, angle);
+               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(axis[0], axis[1]) && IS_EQ(axis[1], axis[2])) {
@@ -1698,8 +1697,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];
@@ -1708,11 +1707,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);
                }
        }
 }
@@ -1731,7 +1730,7 @@ static void constraintTransLim(TransInfo *t, TransData *td)
                 *      - current space should be local
                 */
                memset(&cob, 0, sizeof(bConstraintOb));
-               Mat4One(cob.matrix);
+               unit_m4(cob.matrix);
                VECCOPY(cob.matrix[3], td->loc);
                
                /* Evaluate valid constraints */
@@ -1752,8 +1751,8 @@ static void constraintTransLim(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 */
@@ -1766,8 +1765,8 @@ static void constraintTransLim(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);
                                }
                        }
                }
@@ -1792,21 +1791,21 @@ static void constraintRotLim(TransInfo *t, TransData *td)
                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->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;
                }
@@ -1829,8 +1828,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 */
@@ -1843,8 +1842,8 @@ 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);
                                }
                        }
                }
@@ -1852,15 +1851,15 @@ static void constraintRotLim(TransInfo *t, TransData *td)
                /* copy results from cob->matrix */
                if (td->rotOrder == ROT_MODE_QUAT) {
                        /* quats */
-                       Mat4ToQuat(cob.matrix, td->ext->quat);
+                       mat4_to_quat( td->ext->quat,cob.matrix);
                }
                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);
                }
        }
 }
@@ -1886,7 +1885,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
                        if (td->flag & TD_SINGLESIZE)
                                return;
                        
-                       SizeToMat4(td->ext->size, cob.matrix);
+                       size_to_mat4( cob.matrix,td->ext->size);
                }
                
                /* Evaluate valid constraints */
@@ -1907,8 +1906,8 @@ static void constraintSizeLim(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 */
@@ -1921,8 +1920,8 @@ static void constraintSizeLim(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);
                                }
                        }
                }
@@ -1937,7 +1936,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
                        if (td->flag & TD_SINGLESIZE)
                                return;
                        
-                       Mat4ToSize(cob.matrix, td->ext->size);
+                       mat4_to_size( td->ext->size,cob.matrix);
                }
        }
 }
@@ -1967,11 +1966,11 @@ void initWarp(TransInfo *t)
        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);
@@ -2025,12 +2024,12 @@ 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];
@@ -2068,9 +2067,9 @@ int Warp(TransInfo *t, short mval[2])
                
                /* 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];
                
@@ -2085,13 +2084,13 @@ int Warp(TransInfo *t, short mval[2])
                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);
+               mul_m4_v3(t->viewinv, loc);
+               sub_v3_v3v3(loc, loc, t->viewinv[3]);
+               mul_m3_v3(td->smtx, loc);
                
-               VecSubf(loc, loc, td->iloc);
-               VecMulf(loc, td->factor);
-               VecAddf(td->loc, td->iloc, loc);
+               sub_v3_v3v3(loc, loc, td->iloc);
+               mul_v3_fl(loc, td->factor);
+               add_v3_v3v3(td->loc, td->iloc, loc);
        }
        
        recalcData(t);
@@ -2154,8 +2153,8 @@ int Shear(TransInfo *t, short mval[2])
        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];
        
@@ -2176,7 +2175,7 @@ int Shear(TransInfo *t, short mval[2])
                sprintf(str, "Shear: %.3f %s", value, t->proptext);
        }
        
-       Mat3One(smat);
+       unit_m3(smat);
        
        // Custom data signals shear direction
        if (t->customData == 0)
@@ -2184,8 +2183,8 @@ int Shear(TransInfo *t, short mval[2])
        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)
@@ -2196,22 +2195,22 @@ int Shear(TransInfo *t, short mval[2])
                
                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);
+               sub_v3_v3v3(vec, td->center, t->center);
                
-               Mat3MulVecfl(tmat, vec);
+               mul_m3_v3(tmat, vec);
                
-               VecAddf(vec, vec, t->center);
-               VecSubf(vec, vec, td->center);
+               add_v3_v3v3(vec, vec, t->center);
+               sub_v3_v3v3(vec, vec, td->center);
                
-               VecMulf(vec, td->factor);
+               mul_v3_fl(vec, td->factor);
                
-               VecAddf(td->loc, td->iloc, vec);
+               add_v3_v3v3(td->loc, td->iloc, vec);
        }
        
        recalcData(t);
@@ -2284,12 +2283,12 @@ 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];
@@ -2303,11 +2302,11 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][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) {
@@ -2342,13 +2341,13 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][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, td->axismtx, tmat);
-                       //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);
@@ -2356,7 +2355,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
                if ((t->flag & T_V3D_ALIGN)==0) {       // align mode doesn't resize objects itself
                        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];
@@ -2367,9 +2366,9 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
                                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);
                        }
                }
                
@@ -2378,26 +2377,26 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
        
        /* 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);
+               sub_v3_v3v3(vec, td->center, center);
        
-       Mat3MulVecfl(tmat, vec);
+       mul_m3_v3(tmat, vec);
        
-       VecAddf(vec, vec, center);
+       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);
+               sub_v3_v3v3(vec, vec, td->center);
        
-       VecMulf(vec, td->factor);
+       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);
-       VecAddf(td->loc, td->iloc, vec);
+       add_v3_v3v3(td->loc, td->iloc, vec);
        
        constraintTransLim(t, td);
 }
@@ -2438,13 +2437,13 @@ int Resize(TransInfo *t, short mval[2])
        
        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);
        
@@ -2460,7 +2459,7 @@ int Resize(TransInfo *t, short mval[2])
        
        /* 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);
@@ -2499,7 +2498,7 @@ void initToSphere(TransInfo *t)
        
        // 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;
@@ -2546,15 +2545,15 @@ int ToSphere(TransInfo *t, short mval[2])
                if (td->flag & TD_SKIP)
                        continue;
                
-               VecSubf(vec, td->iloc, t->center);
+               sub_v3_v3v3(vec, td->iloc, t->center);
                
-               radius = Normalize(vec);
+               radius = normalize_v3(vec);
                
                tratio = ratio * td->factor;
                
-               VecMulf(vec, radius * (1.0f - tratio) + t->val * tratio);
+               mul_v3_fl(vec, radius * (1.0f - tratio) + t->val * tratio);
                
-               VecAddf(td->loc, t->center, vec);
+               add_v3_v3v3(td->loc, t->center, vec);
        }
        
        
@@ -2607,25 +2606,25 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
        }
        
        if (t->flag & T_POINTS) {
-               Mat3MulMat3(totmat, mat, td->mtx);
-               Mat3MulMat3(smat, td->smtx, totmat);
+               mul_m3_m3m3(totmat, mat, td->mtx);
+               mul_m3_m3m3(smat, td->smtx, totmat);
                
-               VecSubf(vec, td->iloc, center);
-               Mat3MulVecfl(smat, vec);
+               sub_v3_v3v3(vec, td->iloc, center);
+               mul_m3_v3(smat, vec);
                
-               VecAddf(td->loc, vec, center);
+               add_v3_v3v3(td->loc, vec, center);
                
-               VecSubf(vec,td->loc,td->iloc);
+               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);
@@ -2648,28 +2647,28 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                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);
+                       sub_v3_v3v3(vec, td->center, center);
                        
-                       Mat3MulVecfl(pmtx, vec);        // To Global space
-                       Mat3MulVecfl(mat, vec);         // Applying rotation
-                       Mat3MulVecfl(imtx, vec);        // To Local space
+                       mul_m3_v3(pmtx, vec);   // To Global space
+                       mul_m3_v3(mat, vec);            // Applying rotation
+                       mul_m3_v3(imtx, vec);   // To Local space
                        
-                       VecAddf(vec, vec, center);
+                       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
+                       sub_v3_v3v3(vec, vec, td->center); // Translation needed from the initial location
                        
-                       Mat3MulVecfl(pmtx, vec);        // To Global space
-                       Mat3MulVecfl(td->smtx, vec);// To Pose space
+                       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);
                }
@@ -2678,11 +2677,11 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself
                        /* euler or quaternion/axis-angle? */
                        if (td->rotOrder == ROT_MODE_QUAT) {
-                               Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
+                               mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
                                
-                               Mat3ToQuat(fmat, quat); // Actual transform
+                               mat3_to_quat( quat,fmat);       // Actual transform
                                
-                               QuatMul(td->ext->quat, quat, td->ext->iquat);
+                               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);
                                
@@ -2691,13 +2690,13 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                                /* calculate effect based on quats */
                                float iquat[4], tquat[4];
                                
-                               AxisAngleToQuat(iquat, td->ext->irotAxis, td->ext->irotAngle);
+                               axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle);
                                
-                               Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
-                               Mat3ToQuat(fmat, quat); // Actual transform
-                               QuatMul(tquat, 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);
                                
-                               QuatToAxisAngle(tquat, td->ext->rotAxis, td->ext->rotAngle); 
+                               quat_to_axis_angle( td->ext->rotAxis, td->ext->rotAngle,tquat); 
                                
                                /* this function works on end result */
                                protectedAxisAngleBits(td->protectflag, td->ext->rotAxis, td->ext->rotAngle, td->ext->irotAxis, td->ext->irotAngle);
@@ -2705,17 +2704,17 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                        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);
@@ -2729,16 +2728,16 @@ 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);
                        
-                       VecAddf(td->loc, td->iloc, vec);
+                       add_v3_v3v3(td->loc, td->iloc, vec);
                }
                
                
@@ -2748,10 +2747,10 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself
                        /* euler or quaternion? */
                    if ((td->rotOrder == ROT_MODE_QUAT) || (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
                                
-                               QuatMul(td->ext->quat, quat, td->ext->iquat);
+                               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);
                        }
@@ -2759,13 +2758,13 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                                /* calculate effect based on quats */
                                float iquat[4], tquat[4];
                                
-                               AxisAngleToQuat(iquat, td->ext->irotAxis, td->ext->irotAngle);
+                               axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle);
                                
-                               Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
-                               Mat3ToQuat(fmat, quat); // Actual transform
-                               QuatMul(tquat, 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);
                                
-                               QuatToAxisAngle(quat, td->ext->rotAxis, td->ext->rotAngle); 
+                               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);
@@ -2773,19 +2772,19 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                        else {
                                float obmat[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 */
-                               VecAddf(eul, td->ext->irot, td->ext->drot); /* we have to correct for delta rot */
-                               EulOToMat3(eul, td->rotOrder, obmat);
+                               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 */
-                               Mat3MulMat3(fmat, smat, obmat);
+                               mul_m3_m3m3(fmat, smat, obmat);
                                
-                               Mat3ToCompatibleEulO(fmat, eul, td->ext->rot, td->rotOrder);
+                               mat3_to_compatible_eulO( eul, td->ext->rot, td->rotOrder,fmat);
                                
                                /* correct back for delta rot */
-                               VecSubf(eul, eul, td->ext->drot);
+                               sub_v3_v3v3(eul, eul, td->ext->drot);
                                
                                /* and apply */
                                protectedRotateBits(td->protectflag, eul, td->ext->irot);
@@ -2803,7 +2802,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
        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++) {
                
@@ -2815,10 +2814,10 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
                
                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);
@@ -2835,8 +2834,8 @@ int Rotation(TransInfo *t, short mval[2])
        float mat[3][3];
        
        VECCOPY(axis, t->viewinv[2]);
-       VecMulf(axis, -1.0f);
-       Normalize(axis);
+       mul_v3_fl(axis, -1.0f);
+       normalize_v3(axis);
        
        final = t->values[0];
        
@@ -2872,11 +2871,11 @@ int Rotation(TransInfo *t, short mval[2])
                sprintf(str, "Rot: %.2f%s %s", 180.0*final/M_PI, t->con.text, t->proptext);
        }
        
-       VecRotToMat3(axis, final, mat);
+       vec_rot_to_mat3( mat,axis, final);
        
        // TRANSFORM_FIX_ME
 //     t->values[0] = final;           // used in manipulator
-//     Mat3CpyMat3(t->mat, mat);       // used in manipulator
+//     copy_m3_m3(t->mat, mat);        // used in manipulator
        
        applyRotation(t, final, axis);
        
@@ -2917,10 +2916,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)
@@ -2930,10 +2929,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);
@@ -2949,8 +2948,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];
@@ -2975,13 +2974,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);
 
@@ -3033,7 +3032,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];
@@ -3041,7 +3040,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;
 
@@ -3116,12 +3115,12 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
                                float mat[3][3];
                                float angle;
                                
-                               Crossf(axis, original_normal, t->tsnap.snapNormal);
-                               angle = saacos(Inpf(original_normal, t->tsnap.snapNormal));
+                               cross_v3_v3v3(axis, original_normal, t->tsnap.snapNormal);
+                               angle = saacos(dot_v3v3(original_normal, t->tsnap.snapNormal));
                                
-                               AxisAngleToQuat(quat, axis, angle);
+                               axis_angle_to_quat(quat, axis, angle);
                                
-                               QuatToMat3(quat, mat);
+                               quat_to_mat3( mat,quat);
                                
                                ElementRotation(t, td, mat, V3D_LOCAL);
                        }
@@ -3129,7 +3128,7 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
                        {
                                float mat[3][3];
                                
-                               Mat3One(mat);
+                               unit_m3(mat);
                                
                                ElementRotation(t, td, mat, V3D_LOCAL);
                        }
@@ -3143,12 +3142,12 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
                        VECCOPY(tvec, vec);
                }
                
-               Mat3MulVecfl(td->smtx, tvec);
-               VecMulf(tvec, td->factor);
+               mul_m3_v3(td->smtx, tvec);
+               mul_v3_fl(tvec, td->factor);
                
                protectedTransBits(td->protectflag, tvec);
                
-               VecAddf(td->loc, td->iloc, tvec);
+               add_v3_v3v3(td->loc, td->iloc, tvec);
                
                constraintTransLim(t, td);
        }
@@ -3255,10 +3254,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);
@@ -3465,23 +3464,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);
@@ -3794,8 +3793,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);
@@ -3803,9 +3802,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;
 }
 
@@ -3837,13 +3836,13 @@ int BoneSize(TransInfo *t, short mval[2])
                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);
        
@@ -3931,11 +3930,179 @@ int BoneEnvelope(TransInfo *t, short mval[2])
 }
 
 /* ********************  Edge Slide   *************** */
+#if 1
+static int createSlideVerts(TransInfo *t) {
+#else
+static BMEdge *get_other_edge(BMesh *bm, BMVert *v, BMEdge *e)
+{
+       BMIter iter;
+       BMEdge *e2;
+
+       BM_ITER(e, &iter, bm, BM_EDGES_OF_VERT, v) {
+               if (BM_TestHFlag(e2, BM_SELECT) && e2 != e)
+                       return e;
+       }
+
+       return NULL;
+}
+
+static BMLoop *get_next_loop(BMesh *bm, BMVert *v, BMFace *f, 
+                             BMEdge *olde, BMEdge *nexte)
+{
+       BMIter iter;
+       BMLoop *l, firstl;
+
+       BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) {
+               if (l->e == olde)
+                       break;
+       }
+
+       firstl = l;
+       do {
+               l = BM_OtherFaceLoop(l->e, l->f, v);
+               if (l->radial.next->data == l)
+                       return NULL;
+               
+               if (BM_OtherFaceLoop(l->e, l->f, v)->e == nexte)
+                       return BM_OtherFaceLoop(l->e, l->f, v);
+               
+               if (l->e == nexte)
+                       return l;
+
+               l = l->radial.next->data;
+       } while (l != firstl); 
+
+       return NULL;
+}
 
 static int createSlideVerts(TransInfo *t)
 {
        Mesh *me = t->obedit->data;
-       EditMesh *em = me->edit_mesh;
+       BMEditMesh *em = me->edit_btmesh;
+       BMIter iter, iter2;
+       BMEdge *e, *e1, *e2;
+       BMVert *v, *first;
+       BMLoop *l, *l1, *l2;
+       TransDataSlideVert *tempsv;
+       GHash **uvarray= NULL;
+       SlideData *sld = MEM_callocN(sizeof(*sld), "sld");
+       int  uvlay_tot= CustomData_number_of_layers(&em->fdata, CD_MTFACE);
+       int uvlay_idx;
+       TransDataSlideUv *slideuvs=NULL, *suv=NULL, *suv_last=NULL;
+       RegionView3D *v3d = t->ar->regiondata;
+       float projectMat[4][4];
+       float start[3] = {0.0f, 0.0f, 0.0f}, end[3] = {0.0f, 0.0f, 0.0f};
+       float vec[3], i, j;
+       float totvec=0.0;
+
+       if (!v3d) {
+               /*ok, let's try to survive this*/
+               unit_m4(projectMat);
+       } else {
+               view3d_get_object_project_mat(v3d, t->obedit, projectMat);
+       }
+       
+       /*ensure valid selection*/
+       BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
+               if (BM_TestHFlag(v, BM_SELECT)) {
+                       numsel = 0;
+                       BM_ITER(e, &iter2, em->bm, BM_EDGES_OF_VERT, v) {
+                               if (BM_TestHFlag(e, BM_SELECT)) {
+                                       /*BMESH_TODO: this is probably very evil,
+                                         set v->edge to a selected edge*/
+                                       v->edge = e;
+
+                                       numsel++;
+                               }
+                       }
+
+                       if (numsel > 2) {
+                               return 0; //invalid edge selection
+                       }
+               }
+       }
+
+       BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
+               if (BM_TestHFlag(e, BM_SELECT)) {
+                       if (BM_Edge_FaceCount(e) > 2)
+                               return 0; //can't handle more then 2 faces around an edge
+               }
+       }
+
+       j = 0;
+       BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
+               if (BM_TestHFlag(v, BM_SELECT)) {
+                       BMINDEX_SET(v, 1);
+                       j += 1;
+               } else BMINDEX_SET(v, 0);
+       }
+
+       if (!j)
+               return 0;
+
+       tempsv = MEM_callocN(sizeof(TransDataSlideVert)*j, "tempsv");
+
+       j = 0;
+       while (1) {
+               v = NULL;
+               BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
+                       if (BMINDEX_GET(v))
+                               break;
+
+               }
+
+               if (!v)
+                       break;
+
+               BMINDX_SET(v, 0);
+
+               if (!v->edge)
+                       continue
+               
+               first = v;
+
+               /*walk along the edge loop*/
+               e = v->edge;
+
+               /*first, rewind*/
+               numsel = 0;
+               do {
+                       e = get_other_edge(bm, v, e);
+                       if (!e) {
+                               e = v->edge;
+                               break;
+                       }
+
+                       v = BM_OtherEdgeVert(e, v);
+                       numsel += 1;
+               } while (e != v->edge);
+
+               l1 = l2 = l = NULL;
+
+               /*iterate over the loop*/
+               first = v;
+               do {
+                       TransDataSlideVert *sv = tempsv + j;
+
+                       sv->v = v;
+                       sv->origvert = *v;
+
+                       e = get_other_edge(bm, v, e);
+                       if (!e) {
+                               e = v->edge;
+                               break;
+                       }
+
+                       v = BM_OtherEdgeVert(e, v);
+                       j += 1
+               } while (e != v->edge);
+       }
+
+       MEM_freeN(tempsv);
+#endif
+#if 0
+       Mesh *me = t->obedit->data;
+       BMEditMesh *em = me->edit_btmesh;
        EditFace *efa;
        EditEdge *eed,*first=NULL,*last=NULL, *temp = NULL;
        EditVert *ev, *nearest = NULL;
@@ -3958,7 +4125,7 @@ static int createSlideVerts(TransInfo *t)
 
        if (!v3d) {
                /*ok, let's try to survive this*/
-               Mat4One(projectMat);
+               unit_m4(projectMat);
        } else {
                view3d_get_object_project_mat(v3d, t->obedit, projectMat);
        }
@@ -4251,12 +4418,12 @@ static int createSlideVerts(TransInfo *t)
                                }
 
                                if (ev == tempsv->up->v1) {
-                                       VecSubf(vec, co, co2);
+                                       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);
 
                                if (v3d) {
                                        view3d_project_float(t->ar, tempsv->down->v1->co, co, projectMat);
@@ -4264,12 +4431,12 @@ static int createSlideVerts(TransInfo *t)
                                }
 
                                if (ev == tempsv->down->v1) {
-                                       VecSubf(vec, co2, co);
+                                       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;
@@ -4281,12 +4448,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];
@@ -4398,10 +4565,12 @@ static int createSlideVerts(TransInfo *t)
        t->customData = sld;
 
        return 1;
+#endif
 }
 
 void freeSlideVerts(TransInfo *t)
 {
+#if 0
        TransDataSlideUv *suv;
        SlideData *sld = t->customData;
        int uvlay_idx;
@@ -4430,6 +4599,7 @@ void freeSlideVerts(TransInfo *t)
 
        MEM_freeN(sld);
        t->customData = NULL;
+#endif
 }
 
 void initEdgeSlide(TransInfo *t)
@@ -4447,8 +4617,9 @@ void initEdgeSlide(TransInfo *t)
 
        t->customFree = freeSlideVerts;
 
-       initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO);
+       /* 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;
@@ -4461,6 +4632,7 @@ void initEdgeSlide(TransInfo *t)
 
 int doEdgeSlide(TransInfo *t, float perc)
 {
+#if 0
        Mesh *me= t->obedit->data;
        EditMesh *em = me->edit_mesh;
        SlideData *sld = t->customData;
@@ -4487,7 +4659,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
@@ -4499,13 +4671,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);
@@ -4525,17 +4697,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);
@@ -4545,14 +4717,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);
@@ -4566,7 +4738,7 @@ int doEdgeSlide(TransInfo *t, float perc)
                }
 
        }
-
+#endif
        return 1;
 }
 
@@ -4778,7 +4950,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);
@@ -4804,7 +4976,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)
@@ -4867,9 +5039,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);
        }