Merged changes in the trunk up to revision 47977.
[blender.git] / source / blender / editors / transform / transform.c
index 8bafce70ec47ede61af080006dd71a69a0508ae1..d32206c4335f80e02dfeebb6659d8c94903cdfca 100644 (file)
@@ -51,7 +51,7 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_mask_types.h"
 #include "DNA_movieclip_types.h"
-#include "DNA_scene_types.h"           /* PET modes                    */
+#include "DNA_scene_types.h"  /* PET modes */
 
 #include "RNA_access.h"
 
@@ -105,7 +105,7 @@ static int doEdgeSlide(TransInfo *t, float perc);
 
 void setTransformViewMatrices(TransInfo *t)
 {
-       if (t->spacetype==SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) {
+       if (t->spacetype == SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) {
                RegionView3D *rv3d = t->ar->regiondata;
 
                copy_m4_m4(t->viewmat, rv3d->viewmat);
@@ -129,12 +129,12 @@ static void convertViewVec2D(View2D *v2d, float vec[3], int dx, int dy)
 {
        float divx, divy;
        
-       divx= v2d->mask.xmax - v2d->mask.xmin;
-       divy= v2d->mask.ymax - v2d->mask.ymin;
+       divx = v2d->mask.xmax - v2d->mask.xmin;
+       divy = v2d->mask.ymax - v2d->mask.ymin;
 
-       vec[0]= (v2d->cur.xmax - v2d->cur.xmin) * dx / divx;
-       vec[1]= (v2d->cur.ymax - v2d->cur.ymin) * dy / divy;
-       vec[2]= 0.0f;
+       vec[0] = (v2d->cur.xmax - v2d->cur.xmin) * dx / divx;
+       vec[1] = (v2d->cur.ymax - v2d->cur.ymin) * dy / divy;
+       vec[2] = 0.0f;
 }
 
 void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
@@ -145,7 +145,7 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
                mval_f[1] = dy;
                ED_view3d_win_to_delta(t->ar, mval_f, r_vec);
        }
-       else if (t->spacetype==SPACE_IMAGE) {
+       else if (t->spacetype == SPACE_IMAGE) {
                float aspx, aspy;
 
                convertViewVec2D(t->view, r_vec, dx, dy);
@@ -160,17 +160,17 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
        else if (ELEM(t->spacetype, SPACE_NODE, SPACE_SEQ)) {
                convertViewVec2D(&t->ar->v2d, r_vec, dx, dy);
        }
-       else if (t->spacetype==SPACE_CLIP) {
+       else if (t->spacetype == SPACE_CLIP) {
                View2D *v2d = t->view;
                float divx, divy;
                float mulx, muly;
                float aspx = 1.0f, aspy = 1.0f;
 
-               divx = v2d->mask.xmax-v2d->mask.xmin;
-               divy = v2d->mask.ymax-v2d->mask.ymin;
+               divx = v2d->mask.xmax - v2d->mask.xmin;
+               divy = v2d->mask.ymax - v2d->mask.ymin;
 
-               mulx = (v2d->cur.xmax-v2d->cur.xmin);
-               muly = (v2d->cur.ymax-v2d->cur.ymin);
+               mulx = (v2d->cur.xmax - v2d->cur.xmin);
+               muly = (v2d->cur.ymax - v2d->cur.ymin);
 
                if (t->options & CTX_MASK) {
                        /* clamp w/h, mask only */
@@ -201,18 +201,18 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
 
 void projectIntView(TransInfo *t, const float vec[3], int adr[2])
 {
-       if (t->spacetype==SPACE_VIEW3D) {
+       if (t->spacetype == SPACE_VIEW3D) {
                if (t->ar->regiontype == RGN_TYPE_WINDOW)
                        project_int_noclip(t->ar, vec, adr);
        }
-       else if (t->spacetype==SPACE_IMAGE) {
+       else if (t->spacetype == SPACE_IMAGE) {
                float aspx, aspy, v[2];
 
                ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
-               v[0]= vec[0]/aspx;
-               v[1]= vec[1]/aspy;
+               v[0] = vec[0] / aspx;
+               v[1] = vec[1] / aspy;
 
-               UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1);
+               UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr + 1);
        }
        else if (t->spacetype == SPACE_ACTION) {
                int out[2] = {0, 0};
@@ -222,32 +222,32 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2])
                if (sact->flag & SACTION_DRAWTIME) {
                        //vec[0] = vec[0]/((t->scene->r.frs_sec / t->scene->r.frs_sec_base));
                        /* same as below */
-                       UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1);
+                       UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1);
                } 
                else
 #endif
                {
-                       UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1);
+                       UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1);
                }
 
-               adr[0]= out[0];
-               adr[1]= out[1];
+               adr[0] = out[0];
+               adr[1] = out[1];
        }
        else if (ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
                int out[2] = {0, 0};
 
-               UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1);
-               adr[0]= out[0];
-               adr[1]= out[1];
+               UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1);
+               adr[0] = out[0];
+               adr[1] = out[1];
        }
-       else if (t->spacetype==SPACE_SEQ) { /* XXX not tested yet, but should work */
+       else if (t->spacetype == SPACE_SEQ) { /* XXX not tested yet, but should work */
                int out[2] = {0, 0};
 
-               UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1);
-               adr[0]= out[0];
-               adr[1]= out[1];
+               UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1);
+               adr[0] = out[0];
+               adr[1] = out[1];
        }
-       else if (t->spacetype==SPACE_CLIP) {
+       else if (t->spacetype == SPACE_CLIP) {
                float v[2];
                float aspx = 1.0f, aspy = 1.0f;
 
@@ -261,7 +261,7 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2])
                v[0] /= aspx;
                v[1] /= aspy;
 
-               UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1);
+               UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr + 1);
        }
 }
 
@@ -294,11 +294,11 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
 
 void applyAspectRatio(TransInfo *t, float vec[2])
 {
-       if ((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) {
-               SpaceImage *sima= t->sa->spacedata.first;
+       if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) {
+               SpaceImage *sima = t->sa->spacedata.first;
                float aspx, aspy;
 
-               if ((sima->flag & SI_COORDFLOATS)==0) {
+               if ((sima->flag & SI_COORDFLOATS) == 0) {
                        int width, height;
                        ED_space_image_size(sima, &width, &height);
 
@@ -310,7 +310,7 @@ void applyAspectRatio(TransInfo *t, float vec[2])
                vec[0] /= aspx;
                vec[1] /= aspy;
        }
-       else if ((t->spacetype==SPACE_CLIP) && (t->mode==TFM_TRANSLATION)) {
+       else if ((t->spacetype == SPACE_CLIP) && (t->mode == TFM_TRANSLATION)) {
                if (t->options & (CTX_MOVIECLIP | CTX_MASK)) {
                        SpaceClip *sc = t->sa->spacedata.first;
                        float aspx, aspy;
@@ -334,11 +334,11 @@ void applyAspectRatio(TransInfo *t, float vec[2])
 
 void removeAspectRatio(TransInfo *t, float vec[2])
 {
-       if ((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) {
-               SpaceImage *sima= t->sa->spacedata.first;
+       if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) {
+               SpaceImage *sima = t->sa->spacedata.first;
                float aspx, aspy;
 
-               if ((sima->flag & SI_COORDFLOATS)==0) {
+               if ((sima->flag & SI_COORDFLOATS) == 0) {
                        int width, height;
                        ED_space_image_size(sima, &width, &height);
 
@@ -350,7 +350,7 @@ void removeAspectRatio(TransInfo *t, float vec[2])
                vec[0] *= aspx;
                vec[1] *= aspy;
        }
-       else if ((t->spacetype==SPACE_CLIP) && (t->mode==TFM_TRANSLATION)) {
+       else if ((t->spacetype == SPACE_CLIP) && (t->mode == TFM_TRANSLATION)) {
                if (t->options & (CTX_MOVIECLIP | CTX_MASK)) {
                        SpaceClip *sc = t->sa->spacedata.first;
                        float aspx = 1.0f, aspy = 1.0f;
@@ -373,55 +373,55 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
        if (t->spacetype == SPACE_VIEW3D) {
                /* Do we need more refined tags? */
                if (t->flag & T_POSE)
-                       WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL);
+                       WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
                else
-                       WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+                       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);
+                       WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);
                
        }
        else if (t->spacetype == SPACE_ACTION) {
                //SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
-               WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
+               WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
        }
        else if (t->spacetype == SPACE_IPO) {
                //SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
-               WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
+               WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
        }
        else if (t->spacetype == SPACE_NLA) {
-               WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL);
+               WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
        }
        else if (t->spacetype == SPACE_NODE) {
                //ED_area_tag_redraw(t->sa);
-               WM_event_add_notifier(C, NC_SPACE|ND_SPACE_NODE_VIEW, NULL);
+               WM_event_add_notifier(C, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
        }
        else if (t->spacetype == SPACE_SEQ) {
-               WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, NULL);
+               WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, NULL);
        }
-       else if (t->spacetype==SPACE_IMAGE) {
+       else if (t->spacetype == SPACE_IMAGE) {
                // XXX how to deal with lock?
-               SpaceImage *sima= (SpaceImage*)t->sa->spacedata.first;
-               if (sima->lock) WM_event_add_notifier(C, NC_GEOM|ND_DATA, t->obedit->data);
+               SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
+               if (sima->lock) WM_event_add_notifier(C, NC_GEOM | ND_DATA, t->obedit->data);
                else ED_area_tag_redraw(t->sa);
        }
-       else if (t->spacetype==SPACE_CLIP) {
-               SpaceClip *sc = (SpaceClip*)t->sa->spacedata.first;
+       else if (t->spacetype == SPACE_CLIP) {
+               SpaceClip *sc = (SpaceClip *)t->sa->spacedata.first;
 
                if (ED_space_clip_show_trackedit(sc)) {
                        MovieClip *clip = ED_space_clip(sc);
 
                        /* objects could be parented to tracking data, so send this for viewport refresh */
-                       WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+                       WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
 
-                       WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip);
+                       WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
                }
                else if (ED_space_clip_show_maskedit(sc)) {
                        Mask *mask = ED_space_clip_mask(sc);
 
-                       WM_event_add_notifier(C, NC_MASK|NA_EDITED, mask);
+                       WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
                }
        }
 }
@@ -433,19 +433,19 @@ static void viewRedrawPost(bContext *C, TransInfo *t)
        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|NA_EDITED, NULL);
+                       WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
                
                /* XXX temp, first hack to get auto-render in compositor work (ton) */
-               WM_event_add_notifier(C, NC_SCENE|ND_TRANSFORM_DONE, CTX_data_scene(C));
+               WM_event_add_notifier(C, NC_SCENE | ND_TRANSFORM_DONE, CTX_data_scene(C));
 
        }
        
 #if 0 // TRANSFORM_FIX_ME
-       if (t->spacetype==SPACE_VIEW3D) {
+       if (t->spacetype == SPACE_VIEW3D) {
                allqueue(REDRAWBUTSOBJECT, 0);
                allqueue(REDRAWVIEW3D, 0);
        }
-       else if (t->spacetype==SPACE_IMAGE) {
+       else if (t->spacetype == SPACE_IMAGE) {
                allqueue(REDRAWIMAGE, 0);
                allqueue(REDRAWVIEW3D, 0);
        }
@@ -469,7 +469,7 @@ void BIF_selectOrientation(void)
 #if 0 // TRANSFORM_FIX_ME
        short val;
        char *str_menu = BIF_menustringTransformOrientation("Orientation");
-       val= pupmenu(str_menu);
+       val = pupmenu(str_menu);
        MEM_freeN(str_menu);
 
        if (val >= 0) {
@@ -497,8 +497,8 @@ static void view_editmove(unsigned short UNUSED(event))
        switch (event) {
                case WHEELUPMOUSE:
 
-                       if ( G.qual & LR_SHIFTKEY ) {
-                               if ( G.qual & LR_ALTKEY ) {
+                       if (G.qual & LR_SHIFTKEY) {
+                               if (G.qual & LR_ALTKEY) {
                                        G.qual &= ~LR_SHIFTKEY;
                                        persptoetsen(PAD2);
                                        G.qual |= LR_SHIFTKEY;
@@ -507,8 +507,8 @@ static void view_editmove(unsigned short UNUSED(event))
                                        persptoetsen(PAD2);
                                }
                        }
-                       else if ( G.qual & LR_CTRLKEY ) {
-                               if ( G.qual & LR_ALTKEY ) {
+                       else if (G.qual & LR_CTRLKEY) {
+                               if (G.qual & LR_ALTKEY) {
                                        G.qual &= ~LR_CTRLKEY;
                                        persptoetsen(PAD4);
                                        G.qual |= LR_CTRLKEY;
@@ -525,8 +525,8 @@ static void view_editmove(unsigned short UNUSED(event))
                        refresh = 1;
                        break;
                case WHEELDOWNMOUSE:
-                       if ( G.qual & LR_SHIFTKEY ) {
-                               if ( G.qual & LR_ALTKEY ) {
+                       if (G.qual & LR_SHIFTKEY) {
+                               if (G.qual & LR_ALTKEY) {
                                        G.qual &= ~LR_SHIFTKEY;
                                        persptoetsen(PAD8);
                                        G.qual |= LR_SHIFTKEY;
@@ -535,8 +535,8 @@ static void view_editmove(unsigned short UNUSED(event))
                                        persptoetsen(PAD8);
                                }
                        }
-                       else if ( G.qual & LR_CTRLKEY ) {
-                               if ( G.qual & LR_ALTKEY ) {
+                       else if (G.qual & LR_CTRLKEY) {
+                               if (G.qual & LR_ALTKEY) {
                                        G.qual &= ~LR_CTRLKEY;
                                        persptoetsen(PAD6);
                                        G.qual |= LR_CTRLKEY;
@@ -562,27 +562,27 @@ static void view_editmove(unsigned short UNUSED(event))
 /* ************************************************* */
 
 /* 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_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
+#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
  * */
-#define TFM_MODAL_PROPSIZE_UP  20
-#define TFM_MODAL_PROPSIZE_DOWN        21
+#define TFM_MODAL_PROPSIZE_UP   20
+#define TFM_MODAL_PROPSIZE_DOWN 21
 #define TFM_MODAL_AUTOIK_LEN_INC 22
 #define TFM_MODAL_AUTOIK_LEN_DEC 23
 
@@ -590,42 +590,43 @@ static void view_editmove(unsigned short UNUSED(event))
 #define TFM_MODAL_EDGESLIDE_DOWN 25
 
 /* called in transform_ops.c, on each regeneration of keymaps */
-wmKeyMaptransform_modal_keymap(wmKeyConfig *keyconf)
+wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
 {
        static EnumPropertyItem modal_items[] = {
-       {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
-       {TFM_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
-       {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
-       {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""},
-       {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""},
-       {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", ""},
-       {TFM_MODAL_PROPSIZE_UP, "PROPORTIONAL_SIZE_UP", 0, "Increase Proportional Influence", ""},
-       {TFM_MODAL_PROPSIZE_DOWN, "PROPORTIONAL_SIZE_DOWN", 0, "Decrease Proportional Influence", ""},
-       {TFM_MODAL_AUTOIK_LEN_INC, "AUTOIK_CHAIN_LEN_UP", 0, "Increase Max AutoIK Chain Length", ""},
-       {TFM_MODAL_AUTOIK_LEN_DEC, "AUTOIK_CHAIN_LEN_DOWN", 0, "Decrease Max AutoIK Chain Length", ""},
-       {TFM_MODAL_EDGESLIDE_UP, "EDGESLIDE_EDGE_NEXT", 0, "Select next Edge Slide Edge", ""},
-       {TFM_MODAL_EDGESLIDE_DOWN, "EDGESLIDE_PREV_NEXT", 0, "Select previous Edge Slide Edge", ""},
-       {0, NULL, 0, NULL, NULL}};
-       
-       wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Transform Modal Map");
+               {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
+               {TFM_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
+               {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Translate", ""},
+               {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""},
+               {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""},
+               {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", ""},
+               {TFM_MODAL_PROPSIZE_UP, "PROPORTIONAL_SIZE_UP", 0, "Increase Proportional Influence", ""},
+               {TFM_MODAL_PROPSIZE_DOWN, "PROPORTIONAL_SIZE_DOWN", 0, "Decrease Proportional Influence", ""},
+               {TFM_MODAL_AUTOIK_LEN_INC, "AUTOIK_CHAIN_LEN_UP", 0, "Increase Max AutoIK Chain Length", ""},
+               {TFM_MODAL_AUTOIK_LEN_DEC, "AUTOIK_CHAIN_LEN_DOWN", 0, "Decrease Max AutoIK Chain Length", ""},
+               {TFM_MODAL_EDGESLIDE_UP, "EDGESLIDE_EDGE_NEXT", 0, "Select next Edge Slide Edge", ""},
+               {TFM_MODAL_EDGESLIDE_DOWN, "EDGESLIDE_PREV_NEXT", 0, "Select previous Edge Slide Edge", ""},
+               {0, NULL, 0, NULL, NULL}
+       };
+       
+       wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Transform Modal Map");
        
        /* this function is called for each spacetype, only needs to add map once */
        if (keymap && keymap->modal_items) return NULL;
        
-       keymap= WM_modalkeymap_add(keyconf, "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);
@@ -695,8 +696,7 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
                msg1[sizeof(msg1) - 2] = axis;
                msg2[sizeof(msg2) - 2] = axis;
                msg3[sizeof(msg3) - 2] = axis;
-               constraint_plane = ((CON_AXIS0 | CON_AXIS1 | CON_AXIS2) &
-                                                       (~constraint_axis));
+               constraint_plane = ((CON_AXIS0 | CON_AXIS1 | CON_AXIS2) & (~constraint_axis));
 
                if (edit_2d && (key_type != ZKEY)) {
                        if (cmode == axis) {
@@ -733,7 +733,7 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
 
 int transformEvent(TransInfo *t, wmEvent *event)
 {
-       float mati[3][3]= MAT3_UNITY;
+       float mati[3][3] = MAT3_UNITY;
        char cmode = constraintModeToChar(t);
        int handled = 1;
 
@@ -767,7 +767,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
                                break;
                        case TFM_MODAL_TRANSLATE:
                                /* only switch when... */
-                               if ( ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
+                               if (ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
                                        resetTransRestrictions(t);
                                        restoreTransObjects(t);
                                        initTranslation(t);
@@ -786,7 +786,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
                        case TFM_MODAL_ROTATE:
                                /* only switch when... */
                                if (!(t->options & CTX_TEXTURE) && !(t->options & (CTX_MOVIECLIP | CTX_MASK))) {
-                                       if ( ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) {
+                                       if (ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) {
                                                
                                                resetTransRestrictions(t);
                                                
@@ -805,7 +805,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
                                break;
                        case TFM_MODAL_RESIZE:
                                /* only switch when... */
-                               if ( ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) {
+                               if (ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) {
                                        resetTransRestrictions(t);
                                        restoreTransObjects(t);
                                        initResize(t);
@@ -835,7 +835,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
                                t->redraw |= TREDRAW_HARD;
                                break;
                        case TFM_MODAL_AXIS_X:
-                               if ((t->flag & T_NO_CONSTRAINT)==0) {
+                               if ((t->flag & T_NO_CONSTRAINT) == 0) {
                                        if (cmode == 'X') {
                                                stopConstraint(t);
                                        }
@@ -851,7 +851,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
                                }
                                break;
                        case TFM_MODAL_AXIS_Y:
-                               if ((t->flag & T_NO_CONSTRAINT)==0) {
+                               if ((t->flag & T_NO_CONSTRAINT) == 0) {
                                        if (cmode == 'Y') {
                                                stopConstraint(t);
                                        }
@@ -867,7 +867,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
                                }
                                break;
                        case TFM_MODAL_AXIS_Z:
-                               if ((t->flag & (T_NO_CONSTRAINT|T_2D_EDIT))== 0) {
+                               if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) {
                                        if (cmode == 'Z') {
                                                stopConstraint(t);
                                        }
@@ -878,40 +878,40 @@ int transformEvent(TransInfo *t, wmEvent *event)
                                }
                                break;
                        case TFM_MODAL_PLANE_X:
-                               if ((t->flag & (T_NO_CONSTRAINT|T_2D_EDIT))== 0) {
+                               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");
+                                               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 ((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");
+                                               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 ((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");
+                                               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) {
+                               if ((t->flag & T_NO_CONSTRAINT) == 0) {
                                        stopConstraint(t);
                                        t->redraw |= TREDRAW_HARD;
                                }
@@ -926,16 +926,16 @@ int transformEvent(TransInfo *t, wmEvent *event)
                                break;
                        case TFM_MODAL_PROPSIZE_UP:
                                if (t->flag & T_PROP_EDIT) {
-                                       t->prop_size*= 1.1f;
-                                       if (t->spacetype==SPACE_VIEW3D && t->persp != RV3D_ORTHO)
-                                               t->prop_size= MIN2(t->prop_size, ((View3D *)t->view)->far);
+                                       t->prop_size *= 1.1f;
+                                       if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO)
+                                               t->prop_size = MIN2(t->prop_size, ((View3D *)t->view)->far);
                                        calculatePropRatio(t);
                                }
                                t->redraw |= TREDRAW_HARD;
                                break;
                        case TFM_MODAL_PROPSIZE_DOWN:
                                if (t->flag & T_PROP_EDIT) {
-                                       t->prop_size*= 0.90909090f;
+                                       t->prop_size *= 0.90909090f;
                                        calculatePropRatio(t);
                                }
                                t->redraw |= TREDRAW_HARD;
@@ -965,170 +965,170 @@ int transformEvent(TransInfo *t, wmEvent *event)
        /* else do non-mapped events */
        else if (event->val == KM_PRESS) {
                switch (event->type) {
-               case RIGHTMOUSE:
-                       t->state = TRANS_CANCEL;
-                       break;
-               /* enforce redraw of transform when modifiers are used */
-               case LEFTSHIFTKEY:
-               case RIGHTSHIFTKEY:
-                       t->modifiers |= MOD_CONSTRAINT_PLANE;
-                       t->redraw |= TREDRAW_HARD;
-                       break;
+                       case RIGHTMOUSE:
+                               t->state = TRANS_CANCEL;
+                               break;
+                       /* enforce redraw of transform when modifiers are used */
+                       case LEFTSHIFTKEY:
+                       case RIGHTSHIFTKEY:
+                               t->modifiers |= MOD_CONSTRAINT_PLANE;
+                               t->redraw |= TREDRAW_HARD;
+                               break;
 
-               case SPACEKEY:
-                       if ((t->spacetype==SPACE_VIEW3D) && event->alt) {
+                       case SPACEKEY:
+                               if ((t->spacetype == SPACE_VIEW3D) && event->alt) {
 #if 0 // TRANSFORM_FIX_ME
-                               int mval[2];
+                                       int mval[2];
 
-                               getmouseco_sc(mval);
-                               BIF_selectOrientation();
-                               calc_manipulator_stats(curarea);
-                               copy_m3_m4(t->spacemtx, G.vd->twmat);
-                               warp_pointer(mval[0], mval[1]);
+                                       getmouseco_sc(mval);
+                                       BIF_selectOrientation();
+                                       calc_manipulator_stats(curarea);
+                                       copy_m3_m4(t->spacemtx, G.vd->twmat);
+                                       warp_pointer(mval[0], mval[1]);
 #endif
-                       }
-                       else {
-                               t->state = TRANS_CONFIRM;
-                       }
-                       break;
-
-               case MIDDLEMOUSE:
-                       if ((t->flag & T_NO_CONSTRAINT)==0) {
-                               /* exception for switching to dolly, or trackball, in camera view */
-                               if (t->flag & T_CAMERA) {
-                                       if (t->mode==TFM_TRANSLATION)
-                                               setLocalConstraint(t, (CON_AXIS2), "along local Z");
-                                       else if (t->mode==TFM_ROTATION) {
-                                               restoreTransObjects(t);
-                                               initTrackball(t);
-                                       }
                                }
                                else {
-                                       t->modifiers |= MOD_CONSTRAINT_SELECT;
-                                       if (t->con.mode & CON_APPLY) {
-                                               stopConstraint(t);
+                                       t->state = TRANS_CONFIRM;
+                               }
+                               break;
+
+                       case MIDDLEMOUSE:
+                               if ((t->flag & T_NO_CONSTRAINT) == 0) {
+                                       /* exception for switching to dolly, or trackball, in camera view */
+                                       if (t->flag & T_CAMERA) {
+                                               if (t->mode == TFM_TRANSLATION)
+                                                       setLocalConstraint(t, (CON_AXIS2), "along local Z");
+                                               else if (t->mode == TFM_ROTATION) {
+                                                       restoreTransObjects(t);
+                                                       initTrackball(t);
+                                               }
                                        }
                                        else {
-                                               if (event->shift) {
-                                                       initSelectConstraint(t, t->spacemtx);
+                                               t->modifiers |= MOD_CONSTRAINT_SELECT;
+                                               if (t->con.mode & CON_APPLY) {
+                                                       stopConstraint(t);
                                                }
                                                else {
-                                                       /* bit hackish... but it prevents mmb select to print the orientation from menu */
-                                                       strcpy(t->spacename, "global");
-                                                       initSelectConstraint(t, mati);
+                                                       if (event->shift) {
+                                                               initSelectConstraint(t, t->spacemtx);
+                                                       }
+                                                       else {
+                                                               /* bit hackish... but it prevents mmb select to print the orientation from menu */
+                                                               strcpy(t->spacename, "global");
+                                                               initSelectConstraint(t, mati);
+                                                       }
+                                                       postSelectConstraint(t);
                                                }
-                                               postSelectConstraint(t);
                                        }
+                                       t->redraw |= TREDRAW_HARD;
                                }
-                               t->redraw |= TREDRAW_HARD;
-                       }
-                       break;
-               case ESCKEY:
-                       t->state = TRANS_CANCEL;
-                       break;
-               case PADENTER:
-               case RETKEY:
-                       t->state = TRANS_CONFIRM;
-                       break;
-               case GKEY:
-                       /* only switch when... */
-                       if ( ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
-                               resetTransRestrictions(t);
-                               restoreTransObjects(t);
-                               initTranslation(t);
-                               initSnapping(t, NULL); // need to reinit after mode change
-                               t->redraw |= TREDRAW_HARD;
-                       }
-                       break;
-               case SKEY:
-                       /* only switch when... */
-                       if ( ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) {
-                               resetTransRestrictions(t);
-                               restoreTransObjects(t);
-                               initResize(t);
-                               initSnapping(t, NULL); // need to reinit after mode change
-                               t->redraw |= TREDRAW_HARD;
-                       }
-                       break;
-               case RKEY:
-                       /* only switch when... */
-                       if (!(t->options & CTX_TEXTURE)) {
-                               if ( ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) {
-
+                               break;
+                       case ESCKEY:
+                               t->state = TRANS_CANCEL;
+                               break;
+                       case PADENTER:
+                       case RETKEY:
+                               t->state = TRANS_CONFIRM;
+                               break;
+                       case GKEY:
+                               /* only switch when... */
+                               if (ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
                                        resetTransRestrictions(t);
+                                       restoreTransObjects(t);
+                                       initTranslation(t);
+                                       initSnapping(t, NULL); // need to reinit after mode change
+                                       t->redraw |= TREDRAW_HARD;
+                               }
+                               break;
+                       case SKEY:
+                               /* only switch when... */
+                               if (ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) {
+                                       resetTransRestrictions(t);
+                                       restoreTransObjects(t);
+                                       initResize(t);
+                                       initSnapping(t, NULL); // need to reinit after mode change
+                                       t->redraw |= TREDRAW_HARD;
+                               }
+                               break;
+                       case RKEY:
+                               /* only switch when... */
+                               if (!(t->options & CTX_TEXTURE)) {
+                                       if (ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) {
 
-                                       if (t->mode == TFM_ROTATION) {
-                                               restoreTransObjects(t);
-                                               initTrackball(t);
-                                       }
-                                       else {
-                                               restoreTransObjects(t);
-                                               initRotation(t);
+                                               resetTransRestrictions(t);
+
+                                               if (t->mode == TFM_ROTATION) {
+                                                       restoreTransObjects(t);
+                                                       initTrackball(t);
+                                               }
+                                               else {
+                                                       restoreTransObjects(t);
+                                                       initRotation(t);
+                                               }
+                                               initSnapping(t, NULL); // need to reinit after mode change
+                                               t->redraw |= TREDRAW_HARD;
                                        }
-                                       initSnapping(t, NULL); // need to reinit after mode change
+                               }
+                               break;
+                       case CKEY:
+                               if (event->alt) {
+                                       t->flag ^= T_PROP_CONNECTED;
+                                       sort_trans_data_dist(t);
+                                       calculatePropRatio(t);
+                                       t->redraw = 1;
+                               }
+                               else {
+                                       stopConstraint(t);
                                        t->redraw |= TREDRAW_HARD;
                                }
-                       }
-                       break;
-               case CKEY:
-                       if (event->alt) {
-                               t->flag ^= T_PROP_CONNECTED;
-                               sort_trans_data_dist(t);
-                               calculatePropRatio(t);
-                               t->redraw= 1;
-                       }
-                       else {
-                               stopConstraint(t);
-                               t->redraw |= TREDRAW_HARD;
-                       }
-                       break;
-               case XKEY:
-               case YKEY:
-               case ZKEY:
-                       transform_event_xyz_constraint(t, event->type, cmode);
-                       break;
-               case OKEY:
-                       if (t->flag & T_PROP_EDIT && event->shift) {
-                               t->prop_mode = (t->prop_mode + 1) % PROP_MODE_MAX;
-                               calculatePropRatio(t);
-                               t->redraw |= TREDRAW_HARD;
-                       }
-                       break;
-               case PADPLUSKEY:
-                       if (event->alt && t->flag & T_PROP_EDIT) {
-                               t->prop_size *= 1.1f;
-                               if (t->spacetype==SPACE_VIEW3D && t->persp != RV3D_ORTHO)
-                                       t->prop_size= MIN2(t->prop_size, ((View3D *)t->view)->far);
-                               calculatePropRatio(t);
-                       }
-                       t->redraw= 1;
-                       break;
-               case PAGEUPKEY:
-               case WHEELDOWNMOUSE:
-                       if (t->flag & T_AUTOIK) {
-                               transform_autoik_update(t, 1);
-                       }
-                       else view_editmove(event->type);
-                       t->redraw= 1;
-                       break;
-               case PADMINUS:
-                       if (event->alt && t->flag & T_PROP_EDIT) {
-                               t->prop_size*= 0.90909090f;
-                               calculatePropRatio(t);
-                       }
-                       t->redraw= 1;
-                       break;
-               case PAGEDOWNKEY:
-               case WHEELUPMOUSE:
-                       if (t->flag & T_AUTOIK) {
-                               transform_autoik_update(t, -1);
-                       }
-                       else view_editmove(event->type);
-                       t->redraw= 1;
-                       break;
-               default:
-                       handled = 0;
-                       break;
+                               break;
+                       case XKEY:
+                       case YKEY:
+                       case ZKEY:
+                               transform_event_xyz_constraint(t, event->type, cmode);
+                               break;
+                       case OKEY:
+                               if (t->flag & T_PROP_EDIT && event->shift) {
+                                       t->prop_mode = (t->prop_mode + 1) % PROP_MODE_MAX;
+                                       calculatePropRatio(t);
+                                       t->redraw |= TREDRAW_HARD;
+                               }
+                               break;
+                       case PADPLUSKEY:
+                               if (event->alt && t->flag & T_PROP_EDIT) {
+                                       t->prop_size *= 1.1f;
+                                       if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO)
+                                               t->prop_size = MIN2(t->prop_size, ((View3D *)t->view)->far);
+                                       calculatePropRatio(t);
+                               }
+                               t->redraw = 1;
+                               break;
+                       case PAGEUPKEY:
+                       case WHEELDOWNMOUSE:
+                               if (t->flag & T_AUTOIK) {
+                                       transform_autoik_update(t, 1);
+                               }
+                               else view_editmove(event->type);
+                               t->redraw = 1;
+                               break;
+                       case PADMINUS:
+                               if (event->alt && t->flag & T_PROP_EDIT) {
+                                       t->prop_size *= 0.90909090f;
+                                       calculatePropRatio(t);
+                               }
+                               t->redraw = 1;
+                               break;
+                       case PAGEDOWNKEY:
+                       case WHEELUPMOUSE:
+                               if (t->flag & T_AUTOIK) {
+                                       transform_autoik_update(t, -1);
+                               }
+                               else view_editmove(event->type);
+                               t->redraw = 1;
+                               break;
+                       default:
+                               handled = 0;
+                               break;
                }
 
                // Numerical input events
@@ -1138,30 +1138,30 @@ int transformEvent(TransInfo *t, wmEvent *event)
                t->redraw |= handleSnapping(t, event);
 
        }
-       else if (event->val==KM_RELEASE) {
+       else if (event->val == KM_RELEASE) {
                switch (event->type) {
-               case LEFTSHIFTKEY:
-               case RIGHTSHIFTKEY:
-                       t->modifiers &= ~MOD_CONSTRAINT_PLANE;
-                       t->redraw |= TREDRAW_HARD;
-                       break;
-
-               case MIDDLEMOUSE:
-                       if ((t->flag & T_NO_CONSTRAINT)==0) {
-                               t->modifiers &= ~MOD_CONSTRAINT_SELECT;
-                               postSelectConstraint(t);
+                       case LEFTSHIFTKEY:
+                       case RIGHTSHIFTKEY:
+                               t->modifiers &= ~MOD_CONSTRAINT_PLANE;
                                t->redraw |= TREDRAW_HARD;
-                       }
-                       break;
+                               break;
+
+                       case MIDDLEMOUSE:
+                               if ((t->flag & T_NO_CONSTRAINT) == 0) {
+                                       t->modifiers &= ~MOD_CONSTRAINT_SELECT;
+                                       postSelectConstraint(t);
+                                       t->redraw |= TREDRAW_HARD;
+                               }
+                               break;
 //             case LEFTMOUSE:
 //             case RIGHTMOUSE:
 //                     if (WM_modal_tweak_exit(event, t->event_type))
 ////                   if (t->options & CTX_TWEAK)
 //                             t->state = TRANS_CONFIRM;
 //                     break;
-               default:
-                       handled = 0;
-                       break;
+                       default:
+                               handled = 0;
+                               break;
                }
 
                /* confirm transform if launch key is released after mouse move */
@@ -1194,11 +1194,11 @@ int calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], int c
 
        t->mode = TFM_DUMMY;
 
-       initTransInfo(C, t, NULL, NULL);        // 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
+       t->around = centerMode;             // override userdefined mode
 
        if (t->total == 0) {
                success = FALSE;
@@ -1302,7 +1302,7 @@ static void drawArc(float size, float angle_start, float angle_end, int segments
 
        glBegin(GL_LINE_STRIP);
 
-       for ( angle = angle_start; angle < angle_end; angle += delta) {
+       for (angle = angle_start; angle < angle_end; angle += delta) {
                glVertex2f(cosf(angle) * size, sinf(angle) * size);
        }
        glVertex2f(cosf(angle_end) * size, sinf(angle_end) * size);
@@ -1312,35 +1312,35 @@ static void drawArc(float size, float angle_start, float angle_end, int segments
 
 static int helpline_poll(bContext *C)
 {
-       ARegion *ar= CTX_wm_region(C);
+       ARegion *ar = CTX_wm_region(C);
        
-       if (ar && ar->regiontype==RGN_TYPE_WINDOW)
+       if (ar && ar->regiontype == RGN_TYPE_WINDOW)
                return 1;
        return 0;
 }
 
 static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
 {
-       TransInfo *t = (TransInfo*)customdata;
+       TransInfo *t = (TransInfo *)customdata;
 
        if (t->helpline != HLP_NONE && !(t->flag & T_USES_MANIPULATOR)) {
                float vecrot[3], cent[2];
                int mval[2];
 
-               mval[0]= x;
-               mval[1]= y;
+               mval[0] = x;
+               mval[1] = y;
 
                copy_v3_v3(vecrot, t->center);
                if (t->flag & T_EDIT) {
-                       Object *ob= t->obedit;
+                       Object *ob = t->obedit;
                        if (ob) mul_m4_v3(ob->obmat, vecrot);
                }
                else if (t->flag & T_POSE) {
-                       Object *ob=t->poseobj;
+                       Object *ob = t->poseobj;
                        if (ob) mul_m4_v3(ob->obmat, vecrot);
                }
 
-               projectFloatView(t, vecrot, cent);      // no overflow in extreme cases
+               projectFloatView(t, vecrot, cent);  // no overflow in extreme cases
 
                glPushMatrix();
 
@@ -1385,67 +1385,67 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
                                glLineWidth(1.0);
                                break;
                        case HLP_ANGLE:
-                               {
-                                       float dx = t->mval[0] - cent[0], dy = t->mval[1] - cent[1];
-                                       float angle = atan2f(dy, dx);
-                                       float dist = sqrtf(dx*dx + dy*dy);
-                                       float delta_angle = MIN2(15.0f / dist, (float)M_PI/4.0f);
-                                       float spacing_angle = MIN2(5.0f / dist, (float)M_PI/12.0f);
-                                       UI_ThemeColor(TH_WIRE);
+                       {
+                               float dx = t->mval[0] - cent[0], dy = t->mval[1] - cent[1];
+                               float angle = atan2f(dy, dx);
+                               float dist = sqrtf(dx * dx + dy * dy);
+                               float delta_angle = MIN2(15.0f / dist, (float)M_PI / 4.0f);
+                               float spacing_angle = MIN2(5.0f / dist, (float)M_PI / 12.0f);
+                               UI_ThemeColor(TH_WIRE);
 
-                                       setlinestyle(3);
-                                       glBegin(GL_LINE_STRIP);
-                                       glVertex2iv(t->mval);
-                                       glVertex2fv(cent);
-                                       glEnd();
+                               setlinestyle(3);
+                               glBegin(GL_LINE_STRIP);
+                               glVertex2iv(t->mval);
+                               glVertex2fv(cent);
+                               glEnd();
 
-                                       glTranslatef(cent[0] - t->mval[0] + mval[0], cent[1] - t->mval[1] + mval[1], 0);
+                               glTranslatef(cent[0] - t->mval[0] + mval[0], cent[1] - t->mval[1] + mval[1], 0);
 
-                                       setlinestyle(0);
-                                       glLineWidth(3.0);
-                                       drawArc(dist, angle - delta_angle, angle - spacing_angle, 10);
-                                       drawArc(dist, angle + spacing_angle, angle + delta_angle, 10);
+                               setlinestyle(0);
+                               glLineWidth(3.0);
+                               drawArc(dist, angle - delta_angle, angle - spacing_angle, 10);
+                               drawArc(dist, angle + spacing_angle, angle + delta_angle, 10);
 
-                                       glPushMatrix();
+                               glPushMatrix();
 
-                                       glTranslatef(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0);
-                                       glRotatef(RAD2DEGF(angle - delta_angle), 0, 0, 1);
+                               glTranslatef(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0);
+                               glRotatef(RAD2DEGF(angle - delta_angle), 0, 0, 1);
 
-                                       drawArrowHead(DOWN, 5);
+                               drawArrowHead(DOWN, 5);
 
-                                       glPopMatrix();
+                               glPopMatrix();
 
-                                       glTranslatef(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0);
-                                       glRotatef(RAD2DEGF(angle + delta_angle), 0, 0, 1);
+                               glTranslatef(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0);
+                               glRotatef(RAD2DEGF(angle + delta_angle), 0, 0, 1);
 
-                                       drawArrowHead(UP, 5);
+                               drawArrowHead(UP, 5);
 
-                                       glLineWidth(1.0);
-                                       break;
-                               }
-                               case HLP_TRACKBALL:
-                               {
-                                       unsigned char col[3], col2[3];
-                                       UI_GetThemeColor3ubv(TH_GRID, col);
+                               glLineWidth(1.0);
+                               break;
+                       }
+                       case HLP_TRACKBALL:
+                       {
+                               unsigned char col[3], col2[3];
+                               UI_GetThemeColor3ubv(TH_GRID, col);
 
-                                       glTranslatef(mval[0], mval[1], 0);
+                               glTranslatef(mval[0], mval[1], 0);
 
-                                       glLineWidth(3.0);
+                               glLineWidth(3.0);
 
-                                       UI_make_axis_color(col, col2, 'X');
-                                       glColor3ubv((GLubyte *)col2);
+                               UI_make_axis_color(col, col2, 'X');
+                               glColor3ubv((GLubyte *)col2);
 
-                                       drawArrow(RIGHT, 5, 10, 5);
-                                       drawArrow(LEFT, 5, 10, 5);
+                               drawArrow(RIGHT, 5, 10, 5);
+                               drawArrow(LEFT, 5, 10, 5);
 
-                                       UI_make_axis_color(col, col2, 'Y');
-                                       glColor3ubv((GLubyte *)col2);
+                               UI_make_axis_color(col, col2, 'Y');
+                               glColor3ubv((GLubyte *)col2);
 
-                                       drawArrow(UP, 5, 10, 5);
-                                       drawArrow(DOWN, 5, 10, 5);
-                                       glLineWidth(1.0);
-                                       break;
-                               }
+                               drawArrow(UP, 5, 10, 5);
+                               drawArrow(DOWN, 5, 10, 5);
+                               glLineWidth(1.0);
+                               break;
+                       }
                }
 
                glPopMatrix();
@@ -1479,12 +1479,12 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
        PropertyRNA *prop;
 
        // Save back mode in case we're in the generic operator
-       if ((prop= RNA_struct_find_property(op->ptr, "mode"))) {
+       if ((prop = RNA_struct_find_property(op->ptr, "mode"))) {
                RNA_property_enum_set(op->ptr, prop, t->mode);
        }
 
-       if ((prop= RNA_struct_find_property(op->ptr, "value"))) {
-               float *values= (t->flag & T_AUTOVALUES) ? t->auto_values : t->values;
+       if ((prop = RNA_struct_find_property(op->ptr, "value"))) {
+               float *values = (t->flag & T_AUTOVALUES) ? t->auto_values : t->values;
                if (RNA_property_array_check(prop)) {
                        RNA_property_float_set_array(op->ptr, prop, values);
                }
@@ -1494,8 +1494,8 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
        }
 
        /* convert flag to enum */
-       switch (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) {
-               case (T_PROP_EDIT|T_PROP_CONNECTED):
+       switch (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
+               case (T_PROP_EDIT | T_PROP_CONNECTED):
                        proportional = PROP_EDIT_CONNECTED;
                        break;
                case T_PROP_EDIT:
@@ -1604,7 +1604,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
 
        t->state = TRANS_STARTING;
 
-       if ( (prop = RNA_struct_find_property(op->ptr, "texture_space")) && RNA_property_is_set(op->ptr, prop)) {
+       if ((prop = RNA_struct_find_property(op->ptr, "texture_space")) && RNA_property_is_set(op->ptr, prop)) {
                if (RNA_property_boolean_get(op->ptr, prop)) {
                        options |= CTX_TEXTURE;
                }
@@ -1655,7 +1655,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
        else
                unit_m3(t->spacemtx);
 
-       createTransData(C, t);                  // make TransData structs from selection
+       createTransData(C, t);          // make TransData structs from selection
 
        if (t->total == 0) {
                postTrans(C, t);
@@ -1695,114 +1695,114 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
        initMouseInput(t, &t->mouse, t->center2d, t->imval);
 
        switch (mode) {
-       case TFM_TRANSLATION:
-               initTranslation(t);
-               break;
-       case TFM_ROTATION:
-               initRotation(t);
-               break;
-       case TFM_RESIZE:
-               initResize(t);
-               break;
-       case TFM_SKIN_RESIZE:
-               initSkinResize(t);
-               break;
-       case TFM_TOSPHERE:
-               initToSphere(t);
-               break;
-       case TFM_SHEAR:
-               initShear(t);
-               break;
-       case TFM_WARP:
-               initWarp(t);
-               break;
-       case TFM_SHRINKFATTEN:
-               initShrinkFatten(t);
-               break;
-       case TFM_TILT:
-               initTilt(t);
-               break;
-       case TFM_CURVE_SHRINKFATTEN:
-               initCurveShrinkFatten(t);
-               break;
-       case TFM_MASK_SHRINKFATTEN:
-               initMaskShrinkFatten(t);
-               break;
-       case TFM_TRACKBALL:
-               initTrackball(t);
-               break;
-       case TFM_PUSHPULL:
-               initPushPull(t);
-               break;
-       case TFM_CREASE:
-               initCrease(t);
-               break;
-       case TFM_BONESIZE:
-               {       /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */
-                       bArmature *arm= t->poseobj->data;
-                       if (arm->drawtype==ARM_ENVELOPE)
+               case TFM_TRANSLATION:
+                       initTranslation(t);
+                       break;
+               case TFM_ROTATION:
+                       initRotation(t);
+                       break;
+               case TFM_RESIZE:
+                       initResize(t);
+                       break;
+               case TFM_SKIN_RESIZE:
+                       initSkinResize(t);
+                       break;
+               case TFM_TOSPHERE:
+                       initToSphere(t);
+                       break;
+               case TFM_SHEAR:
+                       initShear(t);
+                       break;
+               case TFM_WARP:
+                       initWarp(t);
+                       break;
+               case TFM_SHRINKFATTEN:
+                       initShrinkFatten(t);
+                       break;
+               case TFM_TILT:
+                       initTilt(t);
+                       break;
+               case TFM_CURVE_SHRINKFATTEN:
+                       initCurveShrinkFatten(t);
+                       break;
+               case TFM_MASK_SHRINKFATTEN:
+                       initMaskShrinkFatten(t);
+                       break;
+               case TFM_TRACKBALL:
+                       initTrackball(t);
+                       break;
+               case TFM_PUSHPULL:
+                       initPushPull(t);
+                       break;
+               case TFM_CREASE:
+                       initCrease(t);
+                       break;
+               case TFM_BONESIZE:
+               {   /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */
+                       bArmature *arm = t->poseobj->data;
+                       if (arm->drawtype == ARM_ENVELOPE)
                                initBoneEnvelope(t);
                        else
                                initBoneSize(t);
                }
                break;
-       case TFM_BONE_ENVELOPE:
-               initBoneEnvelope(t);
-               break;
-       case TFM_EDGE_SLIDE:
-               initEdgeSlide(t);
-               break;
-       case TFM_BONE_ROLL:
-               initBoneRoll(t);
-               break;
-       case TFM_TIME_TRANSLATE:
-               initTimeTranslate(t);
-               break;
-       case TFM_TIME_SLIDE:
-               initTimeSlide(t);
-               break;
-       case TFM_TIME_SCALE:
-               initTimeScale(t);
-               break;
-       case TFM_TIME_DUPLICATE:
-               /* same as TFM_TIME_EXTEND, but we need the mode info for later 
-                * so that duplicate-culling will work properly
-                */
-               if (ELEM(t->spacetype, SPACE_IPO, SPACE_NLA))
-                       initTranslation(t);
-               else
-                       initTimeTranslate(t);
-               t->mode = mode;
-               break;
-       case TFM_TIME_EXTEND:
-               /* now that transdata has been made, do like for TFM_TIME_TRANSLATE (for most Animation
-                * Editors because they have only 1D transforms for time values) or TFM_TRANSLATION
-                * (for Graph/NLA Editors only since they uses 'standard' transforms to get 2D movement)
-                * depending on which editor this was called from
-                */
-               if (ELEM(t->spacetype, SPACE_IPO, SPACE_NLA))
-                       initTranslation(t);
-               else
+               case TFM_BONE_ENVELOPE:
+                       initBoneEnvelope(t);
+                       break;
+               case TFM_EDGE_SLIDE:
+                       initEdgeSlide(t);
+                       break;
+               case TFM_BONE_ROLL:
+                       initBoneRoll(t);
+                       break;
+               case TFM_TIME_TRANSLATE:
                        initTimeTranslate(t);
-               break;
-       case TFM_BAKE_TIME:
-               initBakeTime(t);
-               break;
-       case TFM_MIRROR:
-               initMirror(t);
-               break;
-       case TFM_BEVEL:
-               initBevel(t);
-               break;
-       case TFM_BWEIGHT:
-               initBevelWeight(t);
-               break;
-       case TFM_ALIGN:
-               initAlign(t);
-               break;
-       case TFM_SEQ_SLIDE:
-               initSeqSlide(t);
-               break;
+                       break;
+               case TFM_TIME_SLIDE:
+                       initTimeSlide(t);
+                       break;
+               case TFM_TIME_SCALE:
+                       initTimeScale(t);
+                       break;
+               case TFM_TIME_DUPLICATE:
+                       /* same as TFM_TIME_EXTEND, but we need the mode info for later
+                        * so that duplicate-culling will work properly
+                        */
+                       if (ELEM(t->spacetype, SPACE_IPO, SPACE_NLA))
+                               initTranslation(t);
+                       else
+                               initTimeTranslate(t);
+                       t->mode = mode;
+                       break;
+               case TFM_TIME_EXTEND:
+                       /* now that transdata has been made, do like for TFM_TIME_TRANSLATE (for most Animation
+                        * Editors because they have only 1D transforms for time values) or TFM_TRANSLATION
+                        * (for Graph/NLA Editors only since they uses 'standard' transforms to get 2D movement)
+                        * depending on which editor this was called from
+                        */
+                       if (ELEM(t->spacetype, SPACE_IPO, SPACE_NLA))
+                               initTranslation(t);
+                       else
+                               initTimeTranslate(t);
+                       break;
+               case TFM_BAKE_TIME:
+                       initBakeTime(t);
+                       break;
+               case TFM_MIRROR:
+                       initMirror(t);
+                       break;
+               case TFM_BEVEL:
+                       initBevel(t);
+                       break;
+               case TFM_BWEIGHT:
+                       initBevelWeight(t);
+                       break;
+               case TFM_ALIGN:
+                       initAlign(t);
+                       break;
+               case TFM_SEQ_SLIDE:
+                       initSeqSlide(t);
+                       break;
        }
 
        if (t->state == TRANS_CANCEL) {
@@ -1813,13 +1813,13 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
 
        /* overwrite initial values if operator supplied a non-null vector */
        if ((prop = RNA_struct_find_property(op->ptr, "value")) && RNA_property_is_set(op->ptr, prop)) {
-               float values[4]= {0}; /* in case value isn't length 4, avoid uninitialized memory  */
+               float values[4] = {0}; /* in case value isn't length 4, avoid uninitialized memory  */
 
                if (RNA_property_array_check(prop)) {
                        RNA_float_get_array(op->ptr, "value", values);
                }
                else {
-                       values[0]= RNA_float_get(op->ptr, "value");
+                       values[0] = RNA_float_get(op->ptr, "value");
                }
 
                copy_v4_v4(t->values, values);
@@ -1915,11 +1915,11 @@ int transformEnd(bContext *C, TransInfo *t)
                /* handle restoring objects */
                if (t->state == TRANS_CANCEL) {
                        /* exception, edge slide transformed UVs too */
-                       if (t->mode==TFM_EDGE_SLIDE)
+                       if (t->mode == TFM_EDGE_SLIDE)
                                doEdgeSlide(t, 0.0f);
                        
                        exit_code = OPERATOR_CANCELLED;
-                       restoreTransObjects(t); // calls recalcData()
+                       restoreTransObjects(t); // calls recalcData()
                }
                else {
                        exit_code = OPERATOR_FINISHED;
@@ -1943,7 +1943,7 @@ int transformEnd(bContext *C, TransInfo *t)
 //                     if (t->undostr) ED_undo_push(C, t->undostr);
 //                     else ED_undo_push(C, transform_to_undostr(t));
                }
-               t->undostr= NULL;
+               t->undostr = NULL;
 
                viewRedrawForce(C, t);
        }
@@ -1958,31 +1958,31 @@ int transformEnd(bContext *C, TransInfo *t)
 static void protectedTransBits(short protectflag, float *vec)
 {
        if (protectflag & OB_LOCK_LOCX)
-               vec[0]= 0.0f;
+               vec[0] = 0.0f;
        if (protectflag & OB_LOCK_LOCY)
-               vec[1]= 0.0f;
+               vec[1] = 0.0f;
        if (protectflag & OB_LOCK_LOCZ)
-               vec[2]= 0.0f;
+               vec[2] = 0.0f;
 }
 
 static void protectedSizeBits(short protectflag, float *size)
 {
        if (protectflag & OB_LOCK_SCALEX)
-               size[0]= 1.0f;
+               size[0] = 1.0f;
        if (protectflag & OB_LOCK_SCALEY)
-               size[1]= 1.0f;
+               size[1] = 1.0f;
        if (protectflag & OB_LOCK_SCALEZ)
-               size[2]= 1.0f;
+               size[2] = 1.0f;
 }
 
 static void protectedRotateBits(short protectflag, float *eul, float *oldeul)
 {
        if (protectflag & OB_LOCK_ROTX)
-               eul[0]= oldeul[0];
+               eul[0] = oldeul[0];
        if (protectflag & OB_LOCK_ROTY)
-               eul[1]= oldeul[1];
+               eul[1] = oldeul[1];
        if (protectflag & OB_LOCK_ROTZ)
-               eul[2]= oldeul[2];
+               eul[2] = oldeul[2];
 }
 
 
@@ -1991,19 +1991,19 @@ static void protectedRotateBits(short protectflag, float *eul, float *oldeul)
 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)
+       if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0)
                return;
        
        if (protectflag & OB_LOCK_ROT4D) {
                /* axis-angle getting limited as 4D entities that they are... */
                if (protectflag & OB_LOCK_ROTW)
-                       *angle= oldAngle;
+                       *angle = oldAngle;
                if (protectflag & OB_LOCK_ROTX)
-                       axis[0]= oldAxis[0];
+                       axis[0] = oldAxis[0];
                if (protectflag & OB_LOCK_ROTY)
-                       axis[1]= oldAxis[1];
+                       axis[1] = oldAxis[1];
                if (protectflag & OB_LOCK_ROTZ)
-                       axis[2]= oldAxis[2];
+                       axis[2] = oldAxis[2];
        }
        else {
                /* axis-angle get limited with euler... */
@@ -2013,18 +2013,18 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl
                axis_angle_to_eulO(oldeul, EULER_ORDER_DEFAULT, oldAxis, oldAngle);
                
                if (protectflag & OB_LOCK_ROTX)
-                       eul[0]= oldeul[0];
+                       eul[0] = oldeul[0];
                if (protectflag & OB_LOCK_ROTY)
-                       eul[1]= oldeul[1];
+                       eul[1] = oldeul[1];
                if (protectflag & OB_LOCK_ROTZ)
-                       eul[2]= oldeul[2];
+                       eul[2] = oldeul[2];
                
                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_EQF(axis[0], axis[1]) && IS_EQF(axis[1], axis[2])) {
                        /* for now, rotate around y-axis then (so that it simply becomes the roll) */
-                       axis[1]= 1.0f;
+                       axis[1] = 1.0f;
                }
        }
 }
@@ -2033,37 +2033,37 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl
 static void protectedQuaternionBits(short protectflag, float *quat, float *oldquat)
 {
        /* check that protection flags are set */
-       if ((protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ|OB_LOCK_ROTW)) == 0)
+       if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0)
                return;
        
        if (protectflag & OB_LOCK_ROT4D) {
                /* quaternions getting limited as 4D entities that they are... */
                if (protectflag & OB_LOCK_ROTW)
-                       quat[0]= oldquat[0];
+                       quat[0] = oldquat[0];
                if (protectflag & OB_LOCK_ROTX)
-                       quat[1]= oldquat[1];
+                       quat[1] = oldquat[1];
                if (protectflag & OB_LOCK_ROTY)
-                       quat[2]= oldquat[2];
+                       quat[2] = oldquat[2];
                if (protectflag & OB_LOCK_ROTZ)
-                       quat[3]= oldquat[3];
+                       quat[3] = oldquat[3];
        }
        else {
                /* quaternions get limited with euler... (compatibility mode) */
                float eul[3], oldeul[3], nquat[4], noldquat[4];
                float qlen;
 
-               qlen= normalize_qt_qt(nquat, quat);
+               qlen = normalize_qt_qt(nquat, quat);
                normalize_qt_qt(noldquat, oldquat);
 
                quat_to_eul(eul, nquat);
                quat_to_eul(oldeul, noldquat);
 
                if (protectflag & OB_LOCK_ROTX)
-                       eul[0]= oldeul[0];
+                       eul[0] = oldeul[0];
                if (protectflag & OB_LOCK_ROTY)
-                       eul[1]= oldeul[1];
+                       eul[1] = oldeul[1];
                if (protectflag & OB_LOCK_ROTZ)
-                       eul[2]= oldeul[2];
+                       eul[2] = oldeul[2];
 
                eul_to_quat(quat, eul);
 
@@ -2071,7 +2071,9 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu
                mul_qt_fl(quat, qlen);
                
                /* quaternions flip w sign to accumulate rotations correctly */
-               if ( (nquat[0]<0.0f && quat[0]>0.0f) || (nquat[0]>0.0f && quat[0]<0.0f) ) {
+               if ((nquat[0] < 0.0f && quat[0] > 0.0f) ||
+                   (nquat[0] > 0.0f && quat[0] < 0.0f))
+               {
                        mul_qt_fl(quat, -1.0f);
                }
        }
@@ -2082,22 +2084,22 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu
 static void constraintTransLim(TransInfo *t, TransData *td)
 {
        if (td->con) {
-               bConstraintTypeInfo *ctiLoc= get_constraint_typeinfo(CONSTRAINT_TYPE_LOCLIMIT);
-               bConstraintTypeInfo *ctiDist= get_constraint_typeinfo(CONSTRAINT_TYPE_DISTLIMIT);
+               bConstraintTypeInfo *ctiLoc = get_constraint_typeinfo(CONSTRAINT_TYPE_LOCLIMIT);
+               bConstraintTypeInfo *ctiDist = get_constraint_typeinfo(CONSTRAINT_TYPE_DISTLIMIT);
                
-               bConstraintOb cob= {NULL};
+               bConstraintOb cob = {NULL};
                bConstraint *con;
                float ctime = (float)(t->scene->r.cfra);
                
                /* Make a temporary bConstraintOb for using these limit constraints
-                *      - they only care that cob->matrix is correctly set ;-)
+                *  - they only care that cob->matrix is correctly set ;-)
                 *      - current space should be local
                 */
                unit_m4(cob.matrix);
                copy_v3_v3(cob.matrix[3], td->loc);
                
                /* Evaluate valid constraints */
-               for (con= td->con; con; con= con->next) {
+               for (con = td->con; con; con = con->next) {
                        bConstraintTypeInfo *cti = NULL;
                        ListBase targets = {NULL, NULL};
                        float tmat[4][4];
@@ -2108,16 +2110,16 @@ static void constraintTransLim(TransInfo *t, TransData *td)
                        
                        /* only use it if it's tagged for this purpose (and the right type) */
                        if (con->type == CONSTRAINT_TYPE_LOCLIMIT) {
-                               bLocLimitConstraint *data= con->data;
+                               bLocLimitConstraint *data = con->data;
                                
-                               if ((data->flag2 & LIMIT_TRANSFORM)==0)
+                               if ((data->flag2 & LIMIT_TRANSFORM) == 0)
                                        continue;
                                cti = ctiLoc;
                        }
                        else if (con->type == CONSTRAINT_TYPE_DISTLIMIT) {
-                               bDistLimitConstraint *data= con->data;
+                               bDistLimitConstraint *data = con->data;
                                
-                               if ((data->flag & LIMITDIST_TRANSFORM)==0)
+                               if ((data->flag & LIMITDIST_TRANSFORM) == 0)
                                        continue;
                                cti = ctiDist;
                        }
@@ -2160,7 +2162,7 @@ static void constraintTransLim(TransInfo *t, TransData *td)
 static void constraintob_from_transdata(bConstraintOb *cob, TransData *td)
 {
        /* Make a temporary bConstraintOb for use by limit constraints
-        *      - they only care that cob->matrix is correctly set ;-)
+        *  - they only care that cob->matrix is correctly set ;-)
         *      - current space should be local
         */
        memset(cob, 0, sizeof(bConstraintOb));
@@ -2168,8 +2170,8 @@ static void constraintob_from_transdata(bConstraintOb *cob, TransData *td)
                if (td->ext->rotOrder == ROT_MODE_QUAT) {
                        /* quats */
                        /* objects and bones do normalization first too, otherwise
-                        * we don't necessarily end up with a rotation matrix, and
-                        * then conversion back to quat gives a different result */
+                       * we don't necessarily end up with a rotation matrix, and
+                       * then conversion back to quat gives a different result */
                        float quat[4];
                        normalize_qt_qt(quat, td->ext->quat);
                        quat_to_mat4(cob->matrix, quat);
@@ -2188,24 +2190,24 @@ static void constraintob_from_transdata(bConstraintOb *cob, TransData *td)
 static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
 {
        if (td->con) {
-               bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_ROTLIMIT);
+               bConstraintTypeInfo *cti = get_constraint_typeinfo(CONSTRAINT_TYPE_ROTLIMIT);
                bConstraintOb cob;
                bConstraint *con;
                int do_limit = FALSE;
                
                /* Evaluate valid constraints */
-               for (con= td->con; con; con= con->next) {
+               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-Rotation constraints */
                        if (con->type == CONSTRAINT_TYPE_ROTLIMIT) {
-                               bRotLimitConstraint *data= con->data;
+                               bRotLimitConstraint *data = con->data;
                                float tmat[4][4];
                                
                                /* only use it if it's tagged for this purpose */
-                               if ((data->flag2 & LIMIT_TRANSFORM)==0)
+                               if ((data->flag2 & LIMIT_TRANSFORM) == 0)
                                        continue;
 
                                /* skip incompatable spacetypes */
@@ -2258,12 +2260,12 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
 static void constraintSizeLim(TransInfo *t, TransData *td)
 {
        if (td->con && td->ext) {
-               bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_SIZELIMIT);
-               bConstraintOb cob= {NULL};
+               bConstraintTypeInfo *cti = get_constraint_typeinfo(CONSTRAINT_TYPE_SIZELIMIT);
+               bConstraintOb cob = {NULL};
                bConstraint *con;
                
                /* Make a temporary bConstraintOb for using these limit constraints
-                *      - they only care that cob->matrix is correctly set ;-)
+                *  - they only care that cob->matrix is correctly set ;-)
                 *      - current space should be local
                 */
                if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
@@ -2279,18 +2281,18 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
                }
                
                /* Evaluate valid constraints */
-               for (con= td->con; con; con= con->next) {
+               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;
+                               bSizeLimitConstraint *data = con->data;
                                float tmat[4][4];
                                
                                /* only use it if it's tagged for this purpose */
-                               if ((data->flag2 & LIMIT_TRANSFORM)==0)
+                               if ((data->flag2 & LIMIT_TRANSFORM) == 0)
                                        continue;
                                
                                /* do space conversions */
@@ -2381,8 +2383,8 @@ void initWarp(TransInfo *t)
 
        mid_v3_v3v3(t->center, min, max);
 
-       if (max[0] == min[0]) max[0] += 0.1f; /* not optimal, but flipping is better than invalid garbage (i.e. division by zero!) */
-       t->val= (max[0]-min[0])/2.0f; /* t->val is X dimension projected boundbox */
+       if (max[0] == min[0]) max[0] += 0.1f;  /* not optimal, but flipping is better than invalid garbage (i.e. division by zero!) */
+       t->val = (max[0] - min[0]) / 2.0f; /* t->val is X dimension projected boundbox */
 }
 
 int handleEventWarp(TransInfo *t, wmEvent *event)
@@ -2409,7 +2411,7 @@ int Warp(TransInfo *t, const int UNUSED(mval[2]))
        int i;
        char str[50];
        
-       curs= give_cursor(t->scene, t->view);
+       curs = give_cursor(t->scene, t->view);
        /*
         * gcursor is the one used for helpline.
         * It has to be in the same space as the drawing loop
@@ -2469,18 +2471,18 @@ int Warp(TransInfo *t, const int UNUSED(mval[2]))
                mul_m4_v3(t->viewmat, vec);
                sub_v3_v3(vec, t->viewmat[3]);
                
-               dist= vec[0]-cursor[0];
+               dist = vec[0] - cursor[0];
                
                /* t->val is X dimension projected boundbox */
-               phi0= (circumfac*dist/t->val);
+               phi0 = (circumfac * dist / t->val);
                
-               vec[1]= (vec[1]-cursor[1]);
+               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];
+               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];
                
                mul_m4_v3(t->viewinv, loc);
                sub_v3_v3(loc, t->viewinv[3]);
@@ -2533,7 +2535,7 @@ int handleEventShear(TransInfo *t, wmEvent *event)
                // Use customData pointer to signal Shear direction
                if (t->customData == NULL) {
                        initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
-                       t->customData = (void*)1;
+                       t->customData = (void *)1;
                }
                else {
                        initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE);
@@ -2591,7 +2593,7 @@ int Shear(TransInfo *t, const int UNUSED(mval[2]))
        mul_m3_m3m3(tmat, smat, persmat);
        mul_m3_m3m3(totmat, persinv, tmat);
        
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
                
@@ -2654,7 +2656,7 @@ void initResize(TransInfo *t)
 static void headerResize(TransInfo *t, float vec[3], char *str)
 {
        char tvec[60];
-       char *spos= str;
+       char *spos = str;
        if (hasNumInput(&t->num)) {
                outputNumInput(&(t->num), tvec);
        }
@@ -2666,14 +2668,14 @@ static void headerResize(TransInfo *t, float vec[3], char *str)
        
        if (t->con.mode & CON_APPLY) {
                switch (t->num.idx_max) {
-               case 0:
-                       spos += sprintf(spos, "Scale: %s%s %s", &tvec[0], t->con.text, t->proptext);
-                       break;
-               case 1:
-                       spos += sprintf(spos, "Scale: %s : %s%s %s", &tvec[0], &tvec[20], t->con.text, t->proptext);
-                       break;
-               case 2:
-                       spos += sprintf(spos, "Scale: %s : %s : %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
+                       case 0:
+                               spos += sprintf(spos, "Scale: %s%s %s", &tvec[0], t->con.text, t->proptext);
+                               break;
+                       case 1:
+                               spos += sprintf(spos, "Scale: %s : %s%s %s", &tvec[0], &tvec[20], t->con.text, t->proptext);
+                               break;
+                       case 2:
+                               spos += sprintf(spos, "Scale: %s : %s : %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
                }
        }
        else {
@@ -2683,15 +2685,15 @@ static void headerResize(TransInfo *t, float vec[3], char *str)
                        spos += sprintf(spos, "Scale X: %s   Y: %s  Z: %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
        }
        
-       if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) {
+       if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
                spos += sprintf(spos, " Proportional size: %.2f", t->prop_size);
        }
 
        (void)spos;
 }
 
-#define SIGN(a)                (a<-FLT_EPSILON?1:a>FLT_EPSILON?2:3)
-#define VECSIGNFLIP(a, b) ((SIGN(a[0]) & SIGN(b[0]))==0 || (SIGN(a[1]) & SIGN(b[1]))==0 || (SIGN(a[2]) & SIGN(b[2]))==0)
+#define SIGN(a)     (a<-FLT_EPSILON ? 1 : a>FLT_EPSILON ? 2 : 3)
+#define VECSIGNFLIP(a, b) ((SIGN(a[0]) & SIGN(b[0])) == 0 || (SIGN(a[1]) & SIGN(b[1])) == 0 || (SIGN(a[2]) & SIGN(b[2])) == 0)
 
 /* smat is reference matrix, only scaled */
 static void TransMat3ToSize(float mat[][3], float smat[][3], float *size)
@@ -2699,16 +2701,16 @@ static void TransMat3ToSize(float mat[][3], float smat[][3], float *size)
        float vec[3];
        
        copy_v3_v3(vec, mat[0]);
-       size[0]= normalize_v3(vec);
+       size[0] = normalize_v3(vec);
        copy_v3_v3(vec, mat[1]);
-       size[1]= normalize_v3(vec);
+       size[1] = normalize_v3(vec);
        copy_v3_v3(vec, mat[2]);
-       size[2]= normalize_v3(vec);
+       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];
-       if ( VECSIGNFLIP(mat[2], smat[2]) ) size[2]= -size[2];
+       if (VECSIGNFLIP(mat[0], smat[0]) ) size[0] = -size[0];
+       if (VECSIGNFLIP(mat[1], smat[1]) ) size[1] = -size[1];
+       if (VECSIGNFLIP(mat[2], smat[2]) ) size[2] = -size[2];
 }
 
 
@@ -2731,10 +2733,10 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
        
        /* local constraint shouldn't alter center */
        if ((t->around == V3D_LOCAL) &&
-               (   (t->flag & (T_OBJECT|T_POSE)) ||
-                   ((t->flag & T_EDIT) && (t->settings->selectmode & (SCE_SELECT_EDGE|SCE_SELECT_FACE))) ||
-                   (t->obedit && t->obedit->type == OB_ARMATURE))
-               )
+           (   (t->flag & (T_OBJECT | T_POSE)) ||
+               ((t->flag & T_EDIT) && (t->settings->selectmode & (SCE_SELECT_EDGE | SCE_SELECT_FACE))) ||
+               (t->obedit && t->obedit->type == OB_ARMATURE))
+           )
        {
                copy_v3_v3(center, td->center);
        }
@@ -2748,7 +2750,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
        if (td->ext) {
                float fsize[3];
                
-               if (t->flag & (T_OBJECT|T_TEXTURE|T_POSE)) {
+               if (t->flag & (T_OBJECT | T_TEXTURE | T_POSE)) {
                        float obsizemat[3][3];
                        // Reorient the size mat to fit the oriented object.
                        mul_m3_m3m3(obsizemat, tmat, td->axismtx);
@@ -2762,19 +2764,19 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
                
                protectedSizeBits(td->protectflag, fsize);
                
-               if ((t->flag & T_V3D_ALIGN)==0) {       // align mode doesn't resize objects itself
+               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 * (1 + (fsize[0] - 1) * 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];
-                        }
+                       }
                        else {
                                /* Reset val if SINGLESIZE but using a constraint */
                                if (td->flag & TD_SINGLESIZE)
-                                        *td->val = td->ival;
+                                       *td->val = td->ival;
                                
                                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);
@@ -2801,7 +2803,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
        
        mul_v3_fl(vec, td->factor);
        
-       if (t->flag & (T_OBJECT|T_POSE)) {
+       if (t->flag & (T_OBJECT | T_POSE)) {
                mul_m3_v3(td->smtx, vec);
        }
        
@@ -2818,10 +2820,10 @@ int Resize(TransInfo *t, const int 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) {
-               ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1]))/100.0f;
+       if ((t->flag & T_USES_MANIPULATOR) && t->con.mode == 0) {
+               ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1])) / 100.0f;
        }
        else {
                ratio = t->values[0];
@@ -2850,11 +2852,11 @@ int Resize(TransInfo *t, const int mval[2])
                t->con.applySize(t, NULL, mat);
        }
        
-       copy_m3_m3(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++) {
+       for (i = 0, td = t->data; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
                
@@ -2871,7 +2873,7 @@ int Resize(TransInfo *t, const int mval[2])
                if (t->con.applySize)
                        t->con.applySize(t, NULL, mat);
                
-               for (i = 0, td=t->data; i < t->total; i++, td++)
+               for (i = 0, td = t->data; i < t->total; i++, td++)
                        ElementResize(t, td, mat);
        }
        
@@ -2996,7 +2998,7 @@ void initToSphere(TransInfo *t)
        t->flag |= T_NO_CONSTRAINT;
        
        // Calculate average radius
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                t->val += len_v3v3(t->center, td->iloc);
        }
        
@@ -3038,7 +3040,7 @@ int ToSphere(TransInfo *t, const int UNUSED(mval[2]))
        }
        
        
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                float tratio;
                if (td->flag & TD_NOACTION)
                        break;
@@ -3086,7 +3088,7 @@ void initRotation(TransInfo *t)
        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[1] = (float)((5.0 / 180) * M_PI);
        t->snap[2] = t->snap[1] * 0.2f;
        
        t->num.increment = 1.0f;
@@ -3108,8 +3110,8 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
 
        /* local constraint shouldn't alter center */
        if (around == V3D_LOCAL) {
-               if (    (t->flag & (T_OBJECT|T_POSE)) ||
-                   (t->settings->selectmode & (SCE_SELECT_EDGE|SCE_SELECT_FACE)) ||
+               if (    (t->flag & (T_OBJECT | T_POSE)) ||
+                       (t->settings->selectmode & (SCE_SELECT_EDGE | SCE_SELECT_FACE)) ||
                        (t->obedit && t->obedit->type == OB_ARMATURE))
                {
                        center = td->center;
@@ -3136,7 +3138,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                
                if (td->flag & TD_USEQUAT) {
                        mul_serie_m3(fmat, td->mtx, mat, td->smtx, NULL, NULL, NULL, NULL, NULL);
-                       mat3_to_quat(quat, fmat);       // Actual transform
+                       mat3_to_quat(quat, fmat);   // Actual transform
                        
                        if (td->ext->quat) {
                                mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat);
@@ -3168,9 +3170,9 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                if ((td->flag & TD_NO_LOC) == 0) {
                        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
+                       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_v3(vec, center);
                        /* vec now is the location where the object has to be */
@@ -3182,12 +3184,12 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                                /* do nothing */
                        }
                        else if (td->flag & TD_PBONE_LOCAL_MTX_C) {
-                               mul_m3_v3(pmtx, vec);   // To Global space
-                               mul_m3_v3(td->ext->l_smtx, vec);// To Pose space (Local Location)
+                               mul_m3_v3(pmtx, vec);   // To Global space
+                               mul_m3_v3(td->ext->l_smtx, vec); // To Pose space (Local Location)
                        }
                        else {
-                               mul_m3_v3(pmtx, vec);   // To Global space
-                               mul_m3_v3(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);
@@ -3202,7 +3204,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                 * and ElementRotation() might be called in Translation context (with align snapping),
                 * we need to be sure to actually use the *rotation* matrix here...
                 * So no other way than storing it in some dedicated members of td->ext! */
-               if ((t->flag & T_V3D_ALIGN)==0) { /* align mode doesn't rotate objects itself */
+               if ((t->flag & T_V3D_ALIGN) == 0) { /* align mode doesn't rotate objects itself */
                        /* euler or quaternion/axis-angle? */
                        if (td->ext->rotOrder == ROT_MODE_QUAT) {
                                mul_serie_m3(fmat, td->ext->r_mtx, mat, td->ext->r_smtx, NULL, NULL, NULL, NULL, NULL);
@@ -3271,11 +3273,11 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                constraintTransLim(t, td);
                
                /* rotation */
-               if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself
+               if ((t->flag & T_V3D_ALIGN) == 0) { // align mode doesn't rotate objects itself
                        /* euler or quaternion? */
                        if ((td->ext->rotOrder == ROT_MODE_QUAT) || (td->flag & TD_USEQUAT)) {
                                mul_serie_m3(fmat, td->mtx, mat, td->smtx, NULL, NULL, NULL, NULL, NULL);
-                               mat3_to_quat(quat, fmat);       // Actual transform
+                               mat3_to_quat(quat, fmat);   // Actual transform
                                
                                mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat);
                                /* this function works on end result */
@@ -3288,7 +3290,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                                axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle);
                                
                                mul_serie_m3(fmat, td->mtx, mat, td->smtx, NULL, NULL, NULL, NULL, NULL);
-                               mat3_to_quat(quat, fmat);       // Actual transform
+                               mat3_to_quat(quat, fmat);   // Actual transform
                                mul_qt_qtqt(tquat, quat, iquat);
                                
                                quat_to_axis_angle(td->ext->rotAxis, td->ext->rotAngle, tquat);
@@ -3331,7 +3333,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
        
        vec_rot_to_mat3(mat, axis, angle);
        
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                
                if (td->flag & TD_NOACTION)
                        break;
@@ -3353,7 +3355,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
 
 int Rotation(TransInfo *t, const int UNUSED(mval[2]))
 {
-       char str[128], *spos= str;
+       char str[128], *spos = str;
        
        float final;
 
@@ -3378,16 +3380,16 @@ int Rotation(TransInfo *t, const int UNUSED(mval[2]))
                
                outputNumInput(&(t->num), c);
                
-               spos+= sprintf(spos, "Rot: %s %s %s", &c[0], t->con.text, t->proptext);
+               spos += sprintf(spos, "Rot: %s %s %s", &c[0], t->con.text, t->proptext);
 
                /* Clamp between -180 and 180 */
-               final= angle_wrap_rad(DEG2RADF(final));
+               final = angle_wrap_rad(DEG2RADF(final));
        }
        else {
                spos += sprintf(spos, "Rot: %.2f%s %s", RAD2DEGF(final), t->con.text, t->proptext);
        }
        
-       if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) {
+       if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
                spos += sprintf(spos, " Proportional size: %.2f", t->prop_size);
        }
        (void)spos;
@@ -3416,7 +3418,7 @@ void initTrackball(TransInfo *t)
        t->idx_max = 1;
        t->num.idx_max = 1;
        t->snap[0] = 0.0f;
-       t->snap[1] = (float)((5.0/180)*M_PI);
+       t->snap[1] = (float)((5.0 / 180) * M_PI);
        t->snap[2] = t->snap[1] * 0.2f;
 
        t->num.increment = 1.0f;
@@ -3435,7 +3437,7 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
 
        mul_m3_m3m3(mat, smat, totmat);
 
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
 
@@ -3455,7 +3457,7 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
 
 int Trackball(TransInfo *t, const int UNUSED(mval[2]))
 {
-       char str[128], *spos= str;
+       char str[128], *spos = str;
        float axis1[3], axis2[3];
        float mat[3][3], totmat[3][3], smat[3][3];
        float phi[2];
@@ -3486,7 +3488,7 @@ int Trackball(TransInfo *t, const int UNUSED(mval[2]))
                spos += sprintf(spos, "Trackball: %.2f %.2f %s", RAD2DEGF(phi[0]), RAD2DEGF(phi[1]), t->proptext);
        }
 
-       if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) {
+       if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
                spos += sprintf(spos, " Proportional size: %.2f", t->prop_size);
        }
        (void)spos;
@@ -3522,7 +3524,7 @@ void initTranslation(TransInfo *t)
 
        initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
 
-       t->idx_max = (t->flag & T_2D_EDIT)? 1: 2;
+       t->idx_max = (t->flag & T_2D_EDIT) ? 1 : 2;
        t->num.flag = 0;
        t->num.idx_max = t->idx_max;
 
@@ -3550,7 +3552,7 @@ void initTranslation(TransInfo *t)
 
 static void headerTranslation(TransInfo *t, float vec[3], char *str)
 {
-       char *spos= str;
+       char *spos = str;
        char tvec[60];
        char distvec[20];
        char autoik[20];
@@ -3568,10 +3570,10 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str)
 
                dist = len_v3(vec);
                if (!(t->flag & T_2D_EDIT) && t->scene->unit.system) {
-                       int i, do_split= t->scene->unit.flag & USER_UNIT_OPT_SPLIT ? 1:0;
+                       int i, do_split = t->scene->unit.flag & USER_UNIT_OPT_SPLIT ? 1 : 0;
 
-                       for (i=0; i<3; i++)
-                               bUnit_AsString(&tvec[i*20], 20, dvec[i]*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, do_split, 1);
+                       for (i = 0; i < 3; i++)
+                               bUnit_AsString(&tvec[i * 20], 20, dvec[i] * t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, do_split, 1);
                }
                else {
                        sprintf(&tvec[0], "%.4f", dvec[0]);
@@ -3581,33 +3583,33 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str)
        }
 
        if (!(t->flag & T_2D_EDIT) && t->scene->unit.system)
-               bUnit_AsString(distvec, sizeof(distvec), dist*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, 0);
-       else if ( dist > 1e10f || dist < -1e10f )       /* prevent string buffer overflow */
+               bUnit_AsString(distvec, sizeof(distvec), dist * t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, 0);
+       else if (dist > 1e10f || dist < -1e10f)     /* prevent string buffer overflow */
                sprintf(distvec, "%.4e", dist);
        else
                sprintf(distvec, "%.4f", dist);
 
        if (t->flag & T_AUTOIK) {
-               short chainlen= t->settings->autoik_chainlen;
+               short chainlen = t->settings->autoik_chainlen;
 
                if (chainlen)
                        sprintf(autoik, "AutoIK-Len: %d", chainlen);
                else
-                       autoik[0]= '\0';
+                       autoik[0] = '\0';
        }
        else
-               autoik[0]= '\0';
+               autoik[0] = '\0';
 
        if (t->con.mode & CON_APPLY) {
                switch (t->num.idx_max) {
-               case 0:
-                       spos += sprintf(spos, "D: %s (%s)%s %s  %s", &tvec[0], distvec, t->con.text, t->proptext, &autoik[0]);
-                       break;
-               case 1:
-                       spos += sprintf(spos, "D: %s   D: %s (%s)%s %s  %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext, &autoik[0]);
-                       break;
-               case 2:
-                       spos += sprintf(spos, "D: %s   D: %s  D: %s (%s)%s %s  %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]);
+                       case 0:
+                               spos += sprintf(spos, "D: %s (%s)%s %s  %s", &tvec[0], distvec, t->con.text, t->proptext, &autoik[0]);
+                               break;
+                       case 1:
+                               spos += sprintf(spos, "D: %s   D: %s (%s)%s %s  %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext, &autoik[0]);
+                               break;
+                       case 2:
+                               spos += sprintf(spos, "D: %s   D: %s  D: %s (%s)%s %s  %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]);
                }
        }
        else {
@@ -3617,7 +3619,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str)
                        spos += sprintf(spos, "Dx: %s   Dy: %s  Dz: %s (%s)%s %s  %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]);
        }
        
-       if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) {
+       if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
                spos += sprintf(spos, " Proportional size: %.2f", t->prop_size);
        }
        (void)spos;
@@ -3629,7 +3631,7 @@ static void applyTranslation(TransInfo *t, float vec[3])
        float tvec[3];
        int i;
 
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
                
@@ -3733,7 +3735,7 @@ int Translation(TransInfo *t, const int UNUSED(mval[2]))
 void initShrinkFatten(TransInfo *t)
 {
        // If not in mesh edit mode, fallback to Resize
-       if (t->obedit==NULL || t->obedit->type != OB_MESH) {
+       if (t->obedit == NULL || t->obedit->type != OB_MESH) {
                initResize(t);
        }
        else {
@@ -3785,7 +3787,7 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
 
        t->values[0] = distance;
 
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
 
@@ -3818,12 +3820,12 @@ void initTilt(TransInfo *t)
        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[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|T_NO_PROJECT;
+       t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
 }
 
 
@@ -3855,7 +3857,7 @@ int Tilt(TransInfo *t, const int UNUSED(mval[2]))
                sprintf(str, "Tilt: %.2f %s", RAD2DEGF(final), t->proptext);
        }
 
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
 
@@ -3922,7 +3924,7 @@ int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
                sprintf(str, "Shrink/Fatten: %3f", ratio);
        }
 
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
 
@@ -3930,7 +3932,7 @@ int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
                        continue;
 
                if (td->val) {
-                       *td->val= td->ival*ratio;
+                       *td->val = td->ival * ratio;
                        /* apply PET */
                        *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
                        if (*td->val <= 0.0f) *td->val = 0.001f;
@@ -3990,7 +3992,7 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
                sprintf(str, "Shrink/Fatten: %3f", ratio);
        }
 
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
 
@@ -4064,7 +4066,7 @@ int PushPull(TransInfo *t, const int UNUSED(mval[2]))
                t->con.applyRot(t, NULL, axis, NULL);
        }
 
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
 
@@ -4137,28 +4139,28 @@ int handleEventBevel(TransInfo *t, wmEvent *event)
                if (!G.editBMesh) return 0;
 
                switch (event->type) {
-               case MIDDLEMOUSE:
-                       G.editBMesh->options ^= BME_BEVEL_VERT;
-                       t->state = TRANS_CANCEL;
-                       return 1;
-               //case PADPLUSKEY:
-               //      G.editBMesh->options ^= BME_BEVEL_RES;
-               //      G.editBMesh->res += 1;
-               //      if (G.editBMesh->res > 4) {
-               //              G.editBMesh->res = 4;
-               //      }
-               //      t->state = TRANS_CANCEL;
-               //      return 1;
-               //case PADMINUS:
-               //      G.editBMesh->options ^= BME_BEVEL_RES;
-               //      G.editBMesh->res -= 1;
-               //      if (G.editBMesh->res < 0) {
-               //              G.editBMesh->res = 0;
-               //      }
-               //      t->state = TRANS_CANCEL;
-               //      return 1;
-               default:
-                       return 0;
+                       case MIDDLEMOUSE:
+                               G.editBMesh->options ^= BME_BEVEL_VERT;
+                               t->state = TRANS_CANCEL;
+                               return 1;
+                       //case PADPLUSKEY:
+                       //      G.editBMesh->options ^= BME_BEVEL_RES;
+                       //      G.editBMesh->res += 1;
+                       //      if (G.editBMesh->res > 4) {
+                       //              G.editBMesh->res = 4;
+                       //      }
+                       //      t->state = TRANS_CANCEL;
+                       //      return 1;
+                       //case PADMINUS:
+                       //      G.editBMesh->options ^= BME_BEVEL_RES;
+                       //      G.editBMesh->res -= 1;
+                       //      if (G.editBMesh->res < 0) {
+                       //              G.editBMesh->res = 0;
+                       //      }
+                       //      t->state = TRANS_CANCEL;
+                       //      return 1;
+                       default:
+                               return 0;
                }
        }
        return 0;
@@ -4195,7 +4197,7 @@ int Bevel(TransInfo *t, const int UNUSED(mval[2]))
        }
 
        if (distance < 0) distance = -distance;
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                if (td->axismtx[1][0] > 0 && distance > td->axismtx[1][0]) {
                        d = td->axismtx[1][0];
                }
@@ -4229,7 +4231,7 @@ void initBevelWeight(TransInfo *t)
 
        t->num.increment = t->snap[1];
 
-       t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT;
+       t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
 }
 
 int BevelWeight(TransInfo *t, const int UNUSED(mval[2]))
@@ -4267,7 +4269,7 @@ int BevelWeight(TransInfo *t, const int UNUSED(mval[2]))
                        sprintf(str, "Bevel Weight: %.3f %s", weight, t->proptext);
        }
 
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
 
@@ -4302,7 +4304,7 @@ void initCrease(TransInfo *t)
 
        t->num.increment = t->snap[1];
 
-       t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT;
+       t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
 }
 
 int Crease(TransInfo *t, const int UNUSED(mval[2]))
@@ -4340,7 +4342,7 @@ int Crease(TransInfo *t, const int UNUSED(mval[2]))
                        sprintf(str, "Crease: %.3f %s", crease, t->proptext);
        }
 
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
 
@@ -4418,11 +4420,11 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
        }
 
        /* we've tucked the scale in loc */
-       oldy= td->iloc[1];
+       oldy = td->iloc[1];
        size_to_mat3(sizemat, td->iloc);
        mul_m3_m3m3(tmat, tmat, sizemat);
        mat3_to_size(td->loc, tmat);
-       td->loc[1]= oldy;
+       td->loc[1] = oldy;
 }
 
 int BoneSize(TransInfo *t, const int mval[2])
@@ -4435,8 +4437,8 @@ int BoneSize(TransInfo *t, const int mval[2])
        
        // 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) {
-               ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1]))/100.0f;
+       if ((t->flag & T_USES_MANIPULATOR) && t->con.mode == 0) {
+               ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1])) / 100.0f;
        }
        else {
                ratio = t->values[0];
@@ -4457,11 +4459,11 @@ int BoneSize(TransInfo *t, const int mval[2])
                t->con.applySize(t, NULL, mat);
        }
        
-       copy_m3_m3(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++) {
+       for (i = 0; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
                
@@ -4496,7 +4498,7 @@ void initBoneEnvelope(TransInfo *t)
        
        t->num.increment = t->snap[1];
 
-       t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT;
+       t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
 }
 
 int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
@@ -4523,7 +4525,7 @@ int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
                sprintf(str, "Envelope: %3f", ratio);
        }
        
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
                
@@ -4533,9 +4535,9 @@ int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
                if (td->val) {
                        /* if the old/original value was 0.0f, then just use ratio */
                        if (td->ival)
-                               *td->val= td->ival*ratio;
+                               *td->val = td->ival * ratio;
                        else
-                               *td->val= ratio;
+                               *td->val = ratio;
                }
        }
        
@@ -4565,7 +4567,7 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l,
 {
        BMLoop *firstl;
        float a[3] = {0.0f, 0.0f, 0.0f}, n[3] = {0.0f, 0.0f, 0.0f};
-       int i=0;
+       int i = 0;
 
        firstl = l;
        do {
@@ -4823,7 +4825,7 @@ static int createSlideVerts(TransInfo *t)
                                sv->down = BM_edge_other_vert(l->e, v);
                        }
 
-                       v2=v, v = BM_edge_other_vert(e, v);
+                       v2 = v, v = BM_edge_other_vert(e, v);
 
                        e1 = e;
                        e = get_other_edge(v, e);
@@ -4880,8 +4882,8 @@ static int createSlideVerts(TransInfo *t)
                        /* search cross edges for visible edge to the mouse cursor,
                         * then use the shared vertex to calculate screen vector*/
                        dis2 = -1.0f;
-                       for (i=0; i<2; i++) {
-                               v = i?e->v1:e->v2;
+                       for (i = 0; i < 2; i++) {
+                               v = i ? e->v1 : e->v2;
                                BM_ITER_ELEM (e2, &iter2, v, BM_EDGES_OF_VERT) {
                                        if (BM_elem_flag_test(e2, BM_ELEM_SELECT))
                                                continue;
@@ -4923,7 +4925,7 @@ static int createSlideVerts(TransInfo *t)
 
        /*create copies of faces for customdata projection*/
        sv_array = sld->sv;
-       for (i=0; i<sld->totsv; i++, sv_array++) {
+       for (i = 0; i < sld->totsv; i++, sv_array++) {
                BMIter fiter, liter;
                BMFace *f;
                BMLoop *l;
@@ -4999,7 +5001,7 @@ void projectSVData(TransInfo *t, int final)
 
        BLI_smallhash_init(&visit);
        
-       for (i=0, sv = sld->sv; i < sld->totsv; sv++, i++) {
+       for (i = 0, sv = sld->sv; i < sld->totsv; sv++, i++) {
                BMIter fiter;
                BMFace *f;
                
@@ -5065,7 +5067,7 @@ void projectSVData(TransInfo *t, int final)
                                        BMEdge *e_sel;
 
                                        BM_ITER_ELEM (e_sel, &eiter, l->v, BM_EDGES_OF_VERT) {
-                                               if (BM_elem_flag_test(e_sel, BM_ELEM_SELECT)) {;
+                                               if (BM_elem_flag_test(e_sel, BM_ELEM_SELECT)) {
                                                        break;
                                                }
                                        }
@@ -5131,7 +5133,7 @@ void freeSlideTempFaces(SlideData *sld)
                BMFace *copyf;
 
                copyf = BLI_smallhash_iternew(&sld->origfaces, &hiter, NULL);
-               for (; copyf; copyf=BLI_smallhash_iternext(&hiter, NULL)) {
+               for (; copyf; copyf = BLI_smallhash_iternext(&hiter, NULL)) {
                        BM_face_verts_kill(sld->em->bm, copyf);
                }
 
@@ -5152,7 +5154,7 @@ void freeSlideVerts(TransInfo *t)
                LinkNode *look = sld->vertlist;
                GHash *vertgh = sld->vhash;
                while (look) {
-                       sv  = BLI_ghash_lookup(vertgh, (EditVert*)look->link);
+                       sv  = BLI_ghash_lookup(vertgh, (EditVert *)look->link);
                        if (sv != NULL) {
                                sv->up->f &= !SELECT;
                                sv->down->f &= !SELECT;
@@ -5188,7 +5190,7 @@ void initEdgeSlide(TransInfo *t)
        t->handleEvent = handleEventEdgeSlide;
 
        if (!createSlideVerts(t)) {
-               t->state= TRANS_CANCEL;
+               t->state = TRANS_CANCEL;
                return;
        }
        
@@ -5211,7 +5213,7 @@ void initEdgeSlide(TransInfo *t)
 
        t->num.increment = t->snap[1];
 
-       t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT;
+       t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
 }
 
 int handleEventEdgeSlide(struct TransInfo *t, struct wmEvent *event)
@@ -5340,7 +5342,7 @@ static int doEdgeSlide(TransInfo *t, float perc)
        sld->perc = perc;
 
        sv = svlist;
-       for (i=0; i<sld->totsv; i++, sv++) {
+       for (i = 0; i < sld->totsv; i++, sv++) {
                if (sld->is_proportional == FALSE) {
                        TransDataSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
                        float cur_sel = curr_sv->edge_len;
@@ -5405,11 +5407,11 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
                outputNumInput(&(t->num), c);
 
                BLI_snprintf(str, sizeof(str), "Edge Slide: %s (E)ven: %s, (F)lipped: %s",
-                            &c[0], !is_proportional ? "ON" : "OFF", flipped ? "ON" : "OFF" );
+                            &c[0], !is_proportional ? "ON" : "OFF", flipped ? "ON" : "OFF");
        }
        else {
                BLI_snprintf(str, sizeof(str), "Edge Slide: %.2f (E)ven: %s, (F)lipped: %s",
-                            final, !is_proportional ? "ON" : "OFF", flipped ? "ON" : "OFF" );
+                            final, !is_proportional ? "ON" : "OFF", flipped ? "ON" : "OFF");
        }
 
        CLAMP(final, -1.0f, 1.0f);
@@ -5443,12 +5445,12 @@ void initBoneRoll(TransInfo *t)
        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[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|T_NO_PROJECT;
+       t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
 }
 
 int BoneRoll(TransInfo *t, const int UNUSED(mval[2]))
@@ -5523,11 +5525,11 @@ int BakeTime(TransInfo *t, const int mval[2])
 
        if (t->mouse.precision) {
                /* calculate ratio for shiftkey pos, and for total, and blend these for precision */
-               time= (float)(t->center2d[0] - t->mouse.precision_mval[0]) * fac;
-               time+= 0.1f*((float)(t->center2d[0]*fac - mval[0]) -time);
+               time = (float)(t->center2d[0] - t->mouse.precision_mval[0]) * fac;
+               time += 0.1f * ((float)(t->center2d[0] * fac - mval[0]) - time);
        }
        else {
-               time = (float)(t->center2d[0] - mval[0])*fac;
+               time = (float)(t->center2d[0] - mval[0]) * fac;
        }
 
        snapGrid(t, &time);
@@ -5553,7 +5555,7 @@ int BakeTime(TransInfo *t, const int mval[2])
                        sprintf(str, "Time: %.3f %s", time, t->proptext);
        }
 
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                if (td->flag & TD_NOACTION)
                        break;
 
@@ -5612,7 +5614,7 @@ int Mirror(TransInfo *t, const int UNUSED(mval[2]))
 
                sprintf(str, "Mirror%s", t->con.text);
 
-               for (i = 0, td=t->data; i < t->total; i++, td++) {
+               for (i = 0, td = t->data; i < t->total; i++, td++) {
                        if (td->flag & TD_NOACTION)
                                break;
 
@@ -5631,7 +5633,7 @@ int Mirror(TransInfo *t, const int UNUSED(mval[2]))
 
                size_to_mat3(mat, size);
 
-               for (i = 0, td=t->data; i < t->total; i++, td++) {
+               for (i = 0, td = t->data; i < t->total; i++, td++) {
                        if (td->flag & TD_NOACTION)
                                break;
 
@@ -5672,7 +5674,7 @@ int Align(TransInfo *t, const int UNUSED(mval[2]))
        /* saving original center */
        copy_v3_v3(center, t->center);
 
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                float mat[3][3], invmat[3][3];
 
                if (td->flag & TD_NOACTION)
@@ -5682,7 +5684,7 @@ int Align(TransInfo *t, const int UNUSED(mval[2]))
                        continue;
 
                /* around local centers */
-               if (t->flag & (T_OBJECT|T_POSE)) {
+               if (t->flag & (T_OBJECT | T_POSE)) {
                        copy_v3_v3(t->center, td->center);
                }
                else {
@@ -5746,7 +5748,7 @@ static void applySeqSlide(TransInfo *t, float val[2])
        TransData *td = t->data;
        int i;
 
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                float tvec[2];
 
                if (td->flag & TD_NOACTION)
@@ -5803,38 +5805,38 @@ int SeqSlide(TransInfo *t, const int UNUSED(mval[2]))
 // XXX these modifier checks should be keymappable
 static short getAnimEdit_SnapMode(TransInfo *t)
 {
-       short autosnap= SACTSNAP_OFF;
+       short autosnap = SACTSNAP_OFF;
        
        if (t->spacetype == SPACE_ACTION) {
-               SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
+               SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
                
                if (saction)
-                       autosnap= saction->autosnap;
+                       autosnap = saction->autosnap;
        }
        else if (t->spacetype == SPACE_IPO) {
-               SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
+               SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
                
                if (sipo)
-                       autosnap= sipo->autosnap;
+                       autosnap = sipo->autosnap;
        }
        else if (t->spacetype == SPACE_NLA) {
-               SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
+               SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first;
                
                if (snla)
-                       autosnap= snla->autosnap;
+                       autosnap = snla->autosnap;
        }
        else {
-               autosnap= SACTSNAP_OFF;
+               autosnap = SACTSNAP_OFF;
        }
        
        /* toggle autosnap on/off 
-        *      - when toggling on, prefer nearest frame over 1.0 frame increments
+        *  - when toggling on, prefer nearest frame over 1.0 frame increments
         */
        if (t->modifiers & MOD_SNAP_INVERT) {
                if (autosnap)
-                       autosnap= SACTSNAP_OFF;
+                       autosnap = SACTSNAP_OFF;
                else
-                       autosnap= SACTSNAP_FRAME;
+                       autosnap = SACTSNAP_FRAME;
        }
 
        return autosnap;
@@ -5849,19 +5851,19 @@ static short getAnimEdit_DrawTime(TransInfo *t)
        short drawtime;
 
        if (t->spacetype == SPACE_ACTION) {
-               SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
+               SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
                
-               drawtime = (saction->flag & SACTION_DRAWTIME)? 1 : 0;
+               drawtime = (saction->flag & SACTION_DRAWTIME) ? 1 : 0;
        }
        else if (t->spacetype == SPACE_NLA) {
-               SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
+               SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first;
                
-               drawtime = (snla->flag & SNLA_DRAWTIME)? 1 : 0;
+               drawtime = (snla->flag & SNLA_DRAWTIME) ? 1 : 0;
        }
        else if (t->spacetype == SPACE_IPO) {
-               SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
+               SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
                
-               drawtime = (sipo->flag & SIPO_DRAWTIME)? 1 : 0;
+               drawtime = (sipo->flag & SIPO_DRAWTIME) ? 1 : 0;
        }       
        else {
                drawtime = 0;
@@ -5881,23 +5883,23 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d,
 
 #if 0   /* 'do_time' disabled for now */
 
-               const Scene *scene= t->scene;
-               const short do_time= 0; //getAnimEdit_DrawTime(t); // NOTE: this works, but may be confusing behavior given the option's label, hence disabled
-               const double secf= FPS;
+               const Scene *scene = t->scene;
+               const short do_time = 0; //getAnimEdit_DrawTime(t); // NOTE: this works, but may be confusing behavior given the option's label, hence disabled
+               const double secf = FPS;
 #endif
                double val;
                
                /* convert frame to nla-action time (if needed) */
                if (adt)
-                       val= BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
+                       val = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
                else
-                       val= *(td->val);
+                       val = *(td->val);
                
-#if 0  /* 'do_time' disabled for now */
+#if 0   /* 'do_time' disabled for now */
 
                /* do the snapping to nearest frame/second */
                if (do_time) {
-                       val= (float)(floor((val/secf) + 0.5f) * secf);
+                       val = (float)(floor((val / secf) + 0.5f) * secf);
                }
                else
 #endif
@@ -5907,9 +5909,9 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d,
                
                /* convert frame out of nla-action time */
                if (adt)
-                       *(td->val)= BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
+                       *(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
                else
-                       *(td->val)= val;
+                       *(td->val) = val;
        }
        /* snap key to nearest marker? */
        else if (autosnap == SACTSNAP_MARKER) {
@@ -5917,19 +5919,19 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d,
                
                /* convert frame to nla-action time (if needed) */
                if (adt)
-                       val= BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
+                       val = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
                else
-                       val= *(td->val);
+                       val = *(td->val);
                
                /* snap to nearest marker */
                // TODO: need some more careful checks for where data comes from
-               val= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, val);
+               val = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, val);
                
                /* convert frame out of nla-action time */
                if (adt)
-                       *(td->val)= BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
+                       *(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
                else
-                       *(td->val)= val;
+                       *(td->val) = val;
        }
        
        /* if the handles are to be moved too (as side-effect of keyframes moving, to keep the general effect) 
@@ -5980,21 +5982,21 @@ static void headerTimeTranslate(TransInfo *t, char *str)
        }
        else {
                const Scene *scene = t->scene;
-               const short autosnap= getAnimEdit_SnapMode(t);
+               const short autosnap = getAnimEdit_SnapMode(t);
                const short do_time = getAnimEdit_DrawTime(t);
-               const double secf= FPS;
+               const double secf = FPS;
                float val = t->values[0];
                
                /* apply snapping + frame->seconds conversions */
                if (autosnap == SACTSNAP_STEP) {
                        if (do_time)
-                               val= floorf((double)val / secf + 0.5);
+                               val = floorf((double)val / secf + 0.5);
                        else
-                               val= floorf(val + 0.5f);
+                               val = floorf(val + 0.5f);
                }
                else {
                        if (do_time)
-                               val= (float)((double)val / secf);
+                               val = (float)((double)val / secf);
                }
                
                if (autosnap == SACTSNAP_FRAME)
@@ -6013,20 +6015,20 @@ static void applyTimeTranslate(TransInfo *t, float UNUSED(sval))
        Scene *scene = t->scene;
        int i;
 
-       const short do_time= getAnimEdit_DrawTime(t);
-       const double secf= FPS;
+       const short do_time = getAnimEdit_DrawTime(t);
+       const double secf = FPS;
 
-       const short autosnap= getAnimEdit_SnapMode(t);
+       const short autosnap = getAnimEdit_SnapMode(t);
 
        float deltax, val /* , valprev */;
 
        /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
-       for (i = 0 ; i < t->total; i++, td++, td2d++) {
+       for (i = 0; i < t->total; i++, td++, td2d++) {
                /* it is assumed that td->extra is a pointer to the AnimData,
                 * whose active action is where this keyframe comes from
                 * (this is only valid when not in NLA)
                 */
-               AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
+               AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
 
                /* valprev = *td->val; */ /* UNUSED */
 
@@ -6097,7 +6099,7 @@ void initTimeSlide(TransInfo *t)
 {
        /* this tool is only really available in the Action Editor... */
        if (t->spacetype == SPACE_ACTION) {
-               SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
+               SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
 
                /* set flag for drawing stuff */
                saction->flag |= SACTION_MOVING;
@@ -6133,12 +6135,12 @@ static void headerTimeSlide(TransInfo *t, float sval, char *str)
                outputNumInput(&(t->num), tvec);
        }
        else {
-               float minx= *((float *)(t->customData));
-               float maxx= *((float *)(t->customData) + 1);
-               float cval= t->values[0];
+               float minx = *((float *)(t->customData));
+               float maxx = *((float *)(t->customData) + 1);
+               float cval = t->values[0];
                float val;
 
-               val= 2.0f*(cval-sval) / (maxx-minx);
+               val = 2.0f * (cval - sval) / (maxx - minx);
                CLAMP(val, -1.0f, 1.0f);
 
                sprintf(&tvec[0], "%.4f", val);
@@ -6152,43 +6154,43 @@ static void applyTimeSlide(TransInfo *t, float sval)
        TransData *td = t->data;
        int i;
 
-       float minx= *((float *)(t->customData));
-       float maxx= *((float *)(t->customData) + 1);
+       float minx = *((float *)(t->customData));
+       float maxx = *((float *)(t->customData) + 1);
 
        /* set value for drawing black line */
        if (t->spacetype == SPACE_ACTION) {
-               SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
+               SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
                float cvalf = t->values[0];
 
-               saction->timeslide= cvalf;
+               saction->timeslide = cvalf;
        }
 
        /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
-       for (i = 0 ; i < t->total; i++, td++) {
+       for (i = 0; i < t->total; i++, td++) {
                /* it is assumed that td->extra is a pointer to the AnimData,
                 * whose active action is where this keyframe comes from
                 * (this is only valid when not in NLA)
                 */
-               AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
+               AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
                float cval = t->values[0];
 
                /* apply NLA-mapping to necessary values */
                if (adt)
-                       cval= BKE_nla_tweakedit_remap(adt, cval, NLATIME_CONVERT_UNMAP);
+                       cval = BKE_nla_tweakedit_remap(adt, cval, NLATIME_CONVERT_UNMAP);
 
                /* only apply to data if in range */
                if ((sval > minx) && (sval < maxx)) {
-                       float cvalc= CLAMPIS(cval, minx, maxx);
+                       float cvalc = CLAMPIS(cval, minx, maxx);
                        float timefac;
 
                        /* left half? */
                        if (td->ival < sval) {
-                               timefac= (sval - td->ival) / (sval - minx);
-                               *(td->val)= cvalc - timefac * (cvalc - minx);
+                               timefac = (sval - td->ival) / (sval - minx);
+                               *(td->val) = cvalc - timefac * (cvalc - minx);
                        }
                        else {
-                               timefac= (td->ival - sval) / (maxx - sval);
-                               *(td->val)= cvalc + timefac * (maxx - cvalc);
+                               timefac = (td->ival - sval) / (maxx - sval);
+                               *(td->val) = cvalc + timefac * (maxx - cvalc);
                        }
                }
        }
@@ -6198,8 +6200,8 @@ int TimeSlide(TransInfo *t, const int mval[2])
 {
        View2D *v2d = (View2D *)t->view;
        float cval[2], sval[2];
-       float minx= *((float *)(t->customData));
-       float maxx= *((float *)(t->customData) + 1);
+       float minx = *((float *)(t->customData));
+       float maxx = *((float *)(t->customData) + 1);
        char str[200];
 
        /* calculate mouse co-ordinates */
@@ -6211,9 +6213,9 @@ int TimeSlide(TransInfo *t, const int mval[2])
        t->values[0] = cval[0];
 
        /* handle numeric-input stuff */
-       t->vec[0] = 2.0f*(cval[0]-sval[0]) / (maxx-minx);
+       t->vec[0] = 2.0f * (cval[0] - sval[0]) / (maxx - minx);
        applyNumInput(&t->num, &t->vec[0]);
-       t->values[0] = (maxx-minx) * t->vec[0] / 2.0f + sval[0];
+       t->values[0] = (maxx - minx) * t->vec[0] / 2.0f + sval[0];
 
        headerTimeSlide(t, sval[0], str);
        applyTimeSlide(t, sval[0]);
@@ -6286,19 +6288,19 @@ static void applyTimeScale(TransInfo *t)
        TransData2D *td2d = t->data2d;
        int i;
 
-       const short autosnap= getAnimEdit_SnapMode(t);
-       const short do_time= getAnimEdit_DrawTime(t);
-       const double secf= FPS;
+       const short autosnap = getAnimEdit_SnapMode(t);
+       const short do_time = getAnimEdit_DrawTime(t);
+       const double secf = FPS;
 
 
-       for (i = 0 ; i < t->total; i++, td++, td2d++) {
+       for (i = 0; i < t->total; i++, td++, td2d++) {
                /* it is assumed that td->extra is a pointer to the AnimData,
                 * whose active action is where this keyframe comes from
                 * (this is only valid when not in NLA)
                 */
-               AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
-               float startx= CFRA;
-               float fac= t->values[0];
+               AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
+               float startx = CFRA;
+               float fac = t->values[0];
 
                if (autosnap == SACTSNAP_STEP) {
                        if (do_time)
@@ -6309,7 +6311,7 @@ static void applyTimeScale(TransInfo *t)
 
                /* check if any need to apply nla-mapping */
                if (adt)
-                       startx= BKE_nla_tweakedit_remap(adt, startx, NLATIME_CONVERT_UNMAP);
+                       startx = BKE_nla_tweakedit_remap(adt, startx, NLATIME_CONVERT_UNMAP);
 
                /* now, calculate the new value */
                *(td->val) = ((td->ival - startx) * fac) + startx;