Internal refactoring of tracking module, should be no functional changes
[blender.git] / source / blender / editors / transform / transform_conversions.c
index c4db85420ca0712e495e6c0586aeb2c3b1678195..fbc59f4c2cb9a6735281d5637e0fcf803b6c10a4 100644 (file)
@@ -53,6 +53,7 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_movieclip_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_movieclip_types.h"
+#include "DNA_mask_types.h"
 
 #include "MEM_guardedalloc.h"
 
 
 #include "MEM_guardedalloc.h"
 
@@ -87,6 +88,7 @@
 #include "BKE_sequencer.h"
 #include "BKE_tessmesh.h"
 #include "BKE_tracking.h"
 #include "BKE_sequencer.h"
 #include "BKE_tessmesh.h"
 #include "BKE_tracking.h"
+#include "BKE_mask.h"
 
 
 #include "ED_anim_api.h"
 
 
 #include "ED_anim_api.h"
 #include "ED_types.h"
 #include "ED_uvedit.h"
 #include "ED_clip.h"
 #include "ED_types.h"
 #include "ED_uvedit.h"
 #include "ED_clip.h"
+#include "ED_mask.h"
 #include "ED_util.h"  /* for crazyspace correction */
 
 #include "ED_util.h"  /* for crazyspace correction */
 
-#include "WM_api.h"            /* for WM_event_add_notifier to deal with stabilization nodes */
+#include "WM_api.h"  /* for WM_event_add_notifier to deal with stabilization nodes */
 #include "WM_types.h"
 
 #include "UI_view2d.h"
 #include "WM_types.h"
 
 #include "UI_view2d.h"
@@ -159,10 +162,10 @@ static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail, Tra
 
        *head = *temp;
        if (ihead < head) {
 
        *head = *temp;
        if (ihead < head) {
-               qsort_trans_data(t, ihead, head-1, temp);
+               qsort_trans_data(t, ihead, head - 1, temp);
        }
        if (itail > head) {
        }
        if (itail > head) {
-               qsort_trans_data(t, head+1, itail, temp);
+               qsort_trans_data(t, head + 1, itail, temp);
        }
 }
 
        }
 }
 
@@ -214,18 +217,18 @@ static void set_prop_dist(TransInfo *t, short with_dist)
        TransData *tob;
        int a;
 
        TransData *tob;
        int a;
 
-       for (a=0, tob= t->data; a<t->total; a++, tob++) {
+       for (a = 0, tob = t->data; a < t->total; a++, tob++) {
 
 
-               tob->rdist= 0.0f; // init, it was mallocced
+               tob->rdist = 0.0f; // init, it was mallocced
 
 
-               if ((tob->flag & TD_SELECTED)==0) {
+               if ((tob->flag & TD_SELECTED) == 0) {
                        TransData *td;
                        int i;
                        float dist, vec[3];
 
                        tob->rdist = -1.0f; // signal for next loop
 
                        TransData *td;
                        int i;
                        float dist, vec[3];
 
                        tob->rdist = -1.0f; // signal for next loop
 
-                       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_SELECTED) {
                                        sub_v3_v3v3(vec, tob->center, td->center);
                                        mul_m3_v3(tob->mtx, vec);
                                if (td->flag & TD_SELECTED) {
                                        sub_v3_v3v3(vec, tob->center, td->center);
                                        mul_m3_v3(tob->mtx, vec);
@@ -237,7 +240,7 @@ static void set_prop_dist(TransInfo *t, short with_dist)
                                                tob->rdist = dist;
                                        }
                                }
                                                tob->rdist = dist;
                                        }
                                }
-                               else break;     // by definition transdata has selected items in beginning
+                               else break;  // by definition transdata has selected items in beginning
                        }
                        if (with_dist) {
                                tob->dist = tob->rdist;
                        }
                        if (with_dist) {
                                tob->dist = tob->rdist;
@@ -266,16 +269,16 @@ static void createTransTexspace(TransInfo *t)
        }
 
        id = ob->data;
        }
 
        id = ob->data;
-       if (id == NULL || !ELEM3(GS(id->name), ID_ME, ID_CU, ID_MB )) {
+       if (id == NULL || !ELEM3(GS(id->name), ID_ME, ID_CU, ID_MB)) {
                t->total = 0;
                return;
        }
 
        t->total = 1;
                t->total = 0;
                return;
        }
 
        t->total = 1;
-       td= t->data= MEM_callocN(sizeof(TransData), "TransTexspace");
-       td->ext= t->ext= MEM_callocN(sizeof(TransDataExtension), "TransTexspace");
+       td = t->data = MEM_callocN(sizeof(TransData), "TransTexspace");
+       td->ext = t->ext = MEM_callocN(sizeof(TransDataExtension), "TransTexspace");
 
 
-       td->flag= TD_SELECTED;
+       td->flag = TD_SELECTED;
        copy_v3_v3(td->center, ob->obmat[3]);
        td->ob = ob;
 
        copy_v3_v3(td->center, ob->obmat[3]);
        td->ob = ob;
 
@@ -303,7 +306,7 @@ static void createTransEdge(TransInfo *t)
        BMEdge *eed;
        BMIter iter;
        float mtx[3][3], smtx[3][3];
        BMEdge *eed;
        BMIter iter;
        float mtx[3][3], smtx[3][3];
-       int count=0, countsel=0;
+       int count = 0, countsel = 0;
        int propmode = t->flag & T_PROP_EDIT;
 
        BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
        int propmode = t->flag & T_PROP_EDIT;
 
        BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
@@ -323,7 +326,7 @@ static void createTransEdge(TransInfo *t)
                t->total = countsel;
        }
 
                t->total = countsel;
        }
 
-       td= t->data= MEM_callocN(t->total * sizeof(TransData), "TransCrease");
+       td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransCrease");
 
        copy_m3_m4(mtx, t->obedit->obmat);
        invert_m3_m3(smtx, mtx);
 
        copy_m3_m4(mtx, t->obedit->obmat);
        invert_m3_m3(smtx, mtx);
@@ -337,11 +340,11 @@ static void createTransEdge(TransInfo *t)
                        add_v3_v3v3(td->center, eed->v1->co, eed->v2->co);
                        mul_v3_fl(td->center, 0.5f);
 
                        add_v3_v3v3(td->center, eed->v1->co, eed->v2->co);
                        mul_v3_fl(td->center, 0.5f);
 
-                       td->loc= NULL;
+                       td->loc = NULL;
                        if (BM_elem_flag_test(eed, BM_ELEM_SELECT))
                        if (BM_elem_flag_test(eed, BM_ELEM_SELECT))
-                               td->flag= TD_SELECTED;
+                               td->flag = TD_SELECTED;
                        else
                        else
-                               td->flag= 0;
+                               td->flag = 0;
 
 
                        copy_m3_m3(td->smtx, smtx);
 
 
                        copy_m3_m3(td->smtx, smtx);
@@ -366,15 +369,15 @@ static void createTransEdge(TransInfo *t)
 
 static bKinematicConstraint *has_targetless_ik(bPoseChannel *pchan)
 {
 
 static bKinematicConstraint *has_targetless_ik(bPoseChannel *pchan)
 {
-       bConstraint *con= pchan->constraints.first;
+       bConstraint *con = pchan->constraints.first;
 
 
-       for (;con; con= con->next) {
-               if (con->type==CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0f)) {
-                       bKinematicConstraint *data= con->data;
+       for (; con; con = con->next) {
+               if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce != 0.0f)) {
+                       bKinematicConstraint *data = con->data;
 
 
-                       if (data->tar==NULL)
+                       if (data->tar == NULL)
                                return data;
                                return data;
-                       if (data->tar->type==OB_ARMATURE && data->subtarget[0]==0)
+                       if (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)
                                return data;
                }
        }
                                return data;
                }
        }
@@ -385,44 +388,44 @@ static short apply_targetless_ik(Object *ob)
 {
        bPoseChannel *pchan, *parchan, *chanlist[256];
        bKinematicConstraint *data;
 {
        bPoseChannel *pchan, *parchan, *chanlist[256];
        bKinematicConstraint *data;
-       int segcount, apply= 0;
+       int segcount, apply = 0;
 
        /* now we got a difficult situation... we have to find the
         * target-less IK pchans, and apply transformation to the all
         * pchans that were in the chain */
 
 
        /* now we got a difficult situation... we have to find the
         * target-less IK pchans, and apply transformation to the all
         * pchans that were in the chain */
 
-       for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) {
-               data= has_targetless_ik(pchan);
+       for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+               data = has_targetless_ik(pchan);
                if (data && (data->flag & CONSTRAINT_IK_AUTO)) {
 
                        /* fill the array with the bones of the chain (armature.c does same, keep it synced) */
                if (data && (data->flag & CONSTRAINT_IK_AUTO)) {
 
                        /* fill the array with the bones of the chain (armature.c does same, keep it synced) */
-                       segcount= 0;
+                       segcount = 0;
 
                        /* exclude tip from chain? */
                        if (!(data->flag & CONSTRAINT_IK_TIP))
 
                        /* exclude tip from chain? */
                        if (!(data->flag & CONSTRAINT_IK_TIP))
-                               parchan= pchan->parent;
+                               parchan = pchan->parent;
                        else
                        else
-                               parchan= pchan;
+                               parchan = pchan;
 
                        /* Find the chain's root & count the segments needed */
 
                        /* Find the chain's root & count the segments needed */
-                       for (; parchan; parchan=parchan->parent) {
-                               chanlist[segcount]= parchan;
+                       for (; parchan; parchan = parchan->parent) {
+                               chanlist[segcount] = parchan;
                                segcount++;
 
                                segcount++;
 
-                               if (segcount==data->rootbone || segcount>255) break; // 255 is weak
+                               if (segcount == data->rootbone || segcount > 255) break;  // 255 is weak
                        }
                        }
-                       for (;segcount;segcount--) {
+                       for (; segcount; segcount--) {
                                Bone *bone;
                                Bone *bone;
-                               float rmat[4][4]/*, tmat[4][4], imat[4][4]*/;
+                               float rmat[4][4] /*, tmat[4][4], imat[4][4]*/;
 
                                /* pose_mat(b) = pose_mat(b-1) * offs_bone * channel * constraint * IK  */
                                /* we put in channel the entire result of rmat= (channel * constraint * IK) */
                                /* pose_mat(b) = pose_mat(b-1) * offs_bone * rmat  */
                                /* rmat = pose_mat(b) * inv(pose_mat(b-1) * offs_bone ) */
 
 
                                /* pose_mat(b) = pose_mat(b-1) * offs_bone * channel * constraint * IK  */
                                /* we put in channel the entire result of rmat= (channel * constraint * IK) */
                                /* pose_mat(b) = pose_mat(b-1) * offs_bone * rmat  */
                                /* rmat = pose_mat(b) * inv(pose_mat(b-1) * offs_bone ) */
 
-                               parchan= chanlist[segcount-1];
-                               bone= parchan->bone;
-                               bone->flag |= BONE_TRANSFORM;   /* ensures it gets an auto key inserted */
+                               parchan = chanlist[segcount - 1];
+                               bone = parchan->bone;
+                               bone->flag |= BONE_TRANSFORM;   /* ensures it gets an auto key inserted */
 
                                BKE_armature_mat_pose_to_bone(parchan, parchan->pose_mat, rmat);
 
 
                                BKE_armature_mat_pose_to_bone(parchan, parchan->pose_mat, rmat);
 
@@ -433,11 +436,11 @@ static short apply_targetless_ik(Object *ob)
                                        copy_m3_m4(rmat3, rmat);
                                        
                                        /* rotation */
                                        copy_m3_m4(rmat3, rmat);
                                        
                                        /* rotation */
-                                               /* [#22409] is partially caused by this, as slight numeric error introduced during 
-                                                * the solving process leads to locked-axis values changing. However, we cannot modify
-                                                * the values here, or else there are huge discreptancies between IK-solver (interactive)
-                                                * and applied poses.
-                                                */
+                                       /* [#22409] is partially caused by this, as slight numeric error introduced during
+                                        * the solving process leads to locked-axis values changing. However, we cannot modify
+                                        * the values here, or else there are huge discreptancies between IK-solver (interactive)
+                                        * and applied poses.
+                                        */
                                        if (parchan->rotmode > 0)
                                                mat3_to_eulO(parchan->eul, parchan->rotmode, rmat3);
                                        else if (parchan->rotmode == ROT_MODE_AXISANGLE)
                                        if (parchan->rotmode > 0)
                                                mat3_to_eulO(parchan->eul, parchan->rotmode, rmat3);
                                        else if (parchan->rotmode == ROT_MODE_AXISANGLE)
@@ -467,7 +470,7 @@ static short apply_targetless_ik(Object *ob)
 
                        }
 
 
                        }
 
-                       apply= 1;
+                       apply = 1;
                        data->flag &= ~CONSTRAINT_IK_AUTO;
                }
        }
                        data->flag &= ~CONSTRAINT_IK_AUTO;
                }
        }
@@ -477,7 +480,7 @@ static short apply_targetless_ik(Object *ob)
 
 static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, TransData *td)
 {
 
 static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, TransData *td)
 {
-       Bone *bone= pchan->bone;
+       Bone *bone = pchan->bone;
        float pmat[3][3], omat[3][3];
        float cmat[3][3], tmat[3][3];
        float vec[3];
        float pmat[3][3], omat[3][3];
        float cmat[3][3], tmat[3][3];
        float vec[3];
@@ -496,40 +499,40 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
                td->flag |= TD_NO_LOC;
        }
 
                td->flag |= TD_NO_LOC;
        }
 
-       td->protectflag= pchan->protectflag;
+       td->protectflag = pchan->protectflag;
 
        td->loc = pchan->loc;
        copy_v3_v3(td->iloc, pchan->loc);
 
 
        td->loc = pchan->loc;
        copy_v3_v3(td->iloc, pchan->loc);
 
-       td->ext->size= pchan->size;
+       td->ext->size = pchan->size;
        copy_v3_v3(td->ext->isize, pchan->size);
 
        if (pchan->rotmode > 0) {
        copy_v3_v3(td->ext->isize, pchan->size);
 
        if (pchan->rotmode > 0) {
-               td->ext->rot= pchan->eul;
-               td->ext->rotAxis= NULL;
-               td->ext->rotAngle= NULL;
-               td->ext->quat= NULL;
+               td->ext->rot = pchan->eul;
+               td->ext->rotAxis = NULL;
+               td->ext->rotAngle = NULL;
+               td->ext->quat = NULL;
                
                copy_v3_v3(td->ext->irot, pchan->eul);
        }
        else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
                
                copy_v3_v3(td->ext->irot, pchan->eul);
        }
        else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
-               td->ext->rot= NULL;
-               td->ext->rotAxis= pchan->rotAxis;
-               td->ext->rotAngle= &pchan->rotAngle;
-               td->ext->quat= NULL;
+               td->ext->rot = NULL;
+               td->ext->rotAxis = pchan->rotAxis;
+               td->ext->rotAngle = &pchan->rotAngle;
+               td->ext->quat = NULL;
                
                
-               td->ext->irotAngle= pchan->rotAngle;
+               td->ext->irotAngle = pchan->rotAngle;
                copy_v3_v3(td->ext->irotAxis, pchan->rotAxis);
        }
        else {
                copy_v3_v3(td->ext->irotAxis, pchan->rotAxis);
        }
        else {
-               td->ext->rot= NULL;
-               td->ext->rotAxis= NULL;
-               td->ext->rotAngle= NULL;
-               td->ext->quat= pchan->quat;
+               td->ext->rot = NULL;
+               td->ext->rotAxis = NULL;
+               td->ext->rotAngle = NULL;
+               td->ext->quat = pchan->quat;
                
                copy_qt_qt(td->ext->iquat, pchan->quat);
        }
                
                copy_qt_qt(td->ext->iquat, pchan->quat);
        }
-       td->ext->rotOrder= pchan->rotmode;
+       td->ext->rotOrder = pchan->rotmode;
 
 
        /* proper way to get parent transform + own transform + constraints transform */
 
 
        /* proper way to get parent transform + own transform + constraints transform */
@@ -556,11 +559,11 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
                        copy_m3_m4(tmat, pchan->constinv);
                        invert_m3_m3(cmat, tmat);
                        mul_serie_m3(td->mtx, pmat, omat, cmat, NULL, NULL, NULL, NULL, NULL);
                        copy_m3_m4(tmat, pchan->constinv);
                        invert_m3_m3(cmat, tmat);
                        mul_serie_m3(td->mtx, pmat, omat, cmat, NULL, NULL, NULL, NULL, NULL);
-                       mul_serie_m3(td->ext->r_mtx, rpmat, omat, cmat, NULL,NULL,NULL,NULL,NULL);
+                       mul_serie_m3(td->ext->r_mtx, rpmat, omat, cmat, NULL, NULL, NULL, NULL, NULL);
                }
                else {
                }
                else {
-                       mul_serie_m3(td->mtx, pmat, omat, NULL, NULL,NULL,NULL,NULL,NULL);
-                       mul_serie_m3(td->ext->r_mtx, rpmat, omat, NULL, NULL,NULL,NULL,NULL,NULL);
+                       mul_serie_m3(td->mtx, pmat, omat, NULL, NULL, NULL, NULL, NULL, NULL);
+                       mul_serie_m3(td->ext->r_mtx, rpmat, omat, NULL, NULL, NULL, NULL, NULL, NULL);
                }
                invert_m3_m3(td->ext->r_smtx, td->ext->r_mtx);
        }
                }
                invert_m3_m3(td->ext->r_smtx, td->ext->r_mtx);
        }
@@ -585,25 +588,25 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
        mul_m3_m3m3(td->axismtx, omat, pmat);
        normalize_m3(td->axismtx);
 
        mul_m3_m3m3(td->axismtx, omat, pmat);
        normalize_m3(td->axismtx);
 
-       if (t->mode==TFM_BONESIZE) {
-               bArmature *arm= t->poseobj->data;
+       if (t->mode == TFM_BONESIZE) {
+               bArmature *arm = t->poseobj->data;
 
 
-               if (arm->drawtype==ARM_ENVELOPE) {
-                       td->loc= NULL;
-                       td->val= &bone->dist;
-                       td->ival= bone->dist;
+               if (arm->drawtype == ARM_ENVELOPE) {
+                       td->loc = NULL;
+                       td->val = &bone->dist;
+                       td->ival = bone->dist;
                }
                else {
                        // abusive storage of scale in the loc pointer :)
                }
                else {
                        // abusive storage of scale in the loc pointer :)
-                       td->loc= &bone->xwidth;
+                       td->loc = &bone->xwidth;
                        copy_v3_v3(td->iloc, td->loc);
                        copy_v3_v3(td->iloc, td->loc);
-                       td->val= NULL;
+                       td->val = NULL;
                }
        }
 
        /* in this case we can do target-less IK grabbing */
                }
        }
 
        /* in this case we can do target-less IK grabbing */
-       if (t->mode==TFM_TRANSLATION) {
-               bKinematicConstraint *data= has_targetless_ik(pchan);
+       if (t->mode == TFM_TRANSLATION) {
+               bKinematicConstraint *data = has_targetless_ik(pchan);
                if (data) {
                        if (data->flag & CONSTRAINT_IK_TIP) {
                                copy_v3_v3(data->grabtarget, pchan->pose_tail);
                if (data) {
                        if (data->flag & CONSTRAINT_IK_TIP) {
                                copy_v3_v3(data->grabtarget, pchan->pose_tail);
@@ -622,14 +625,14 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
        }
 
        /* store reference to first constraint */
        }
 
        /* store reference to first constraint */
-       td->con= pchan->constraints.first;
+       td->con = pchan->constraints.first;
 }
 
 static void bone_children_clear_transflag(int mode, short around, ListBase *lb)
 {
 }
 
 static void bone_children_clear_transflag(int mode, short around, ListBase *lb)
 {
-       Bone *bone= lb->first;
+       Bone *bone = lb->first;
 
 
-       for ( ; bone;bone= bone->next) {
+       for (; bone; bone = bone->next) {
                if ((bone->flag & BONE_HINGE) && (bone->flag & BONE_CONNECTED)) {
                        bone->flag |= BONE_HINGE_CHILD_TRANSFORM;
                }
                if ((bone->flag & BONE_HINGE) && (bone->flag & BONE_CONNECTED)) {
                        bone->flag |= BONE_HINGE_CHILD_TRANSFORM;
                }
@@ -651,7 +654,7 @@ static void bone_children_clear_transflag(int mode, short around, ListBase *lb)
  * returns total number of bones with BONE_TRANSFORM */
 int count_set_pose_transflags(int *out_mode, short around, Object *ob)
 {
  * returns total number of bones with BONE_TRANSFORM */
 int count_set_pose_transflags(int *out_mode, short around, Object *ob)
 {
-       bArmature *arm= ob->data;
+       bArmature *arm = ob->data;
        bPoseChannel *pchan;
        Bone *bone;
        int mode = *out_mode;
        bPoseChannel *pchan;
        Bone *bone;
        int mode = *out_mode;
@@ -696,7 +699,7 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob)
                                                if (pchan->bone->flag & BONE_HINGE_CHILD_TRANSFORM)
                                                        hastranslation = 1;
                                        }
                                                if (pchan->bone->flag & BONE_HINGE_CHILD_TRANSFORM)
                                                        hastranslation = 1;
                                        }
-                                       else if ((pchan->protectflag & OB_LOCK_LOC)!=OB_LOCK_LOC)
+                                       else if ((pchan->protectflag & OB_LOCK_LOC) != OB_LOCK_LOC)
                                                hastranslation = 1;
                                }
                                else
                                                hastranslation = 1;
                                }
                                else
@@ -717,26 +720,26 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob)
 /* -------- Auto-IK ---------- */
 
 /* adjust pose-channel's auto-ik chainlen */
 /* -------- Auto-IK ---------- */
 
 /* adjust pose-channel's auto-ik chainlen */
-static void pchan_autoik_adjust (bPoseChannel *pchan, short chainlen)
+static void pchan_autoik_adjust(bPoseChannel *pchan, short chainlen)
 {
        bConstraint *con;
 
        /* don't bother to search if no valid constraints */
 {
        bConstraint *con;
 
        /* don't bother to search if no valid constraints */
-       if ((pchan->constflag & (PCHAN_HAS_IK|PCHAN_HAS_TARGET))==0)
+       if ((pchan->constflag & (PCHAN_HAS_IK | PCHAN_HAS_TARGET)) == 0)
                return;
 
        /* check if pchan has ik-constraint */
                return;
 
        /* check if pchan has ik-constraint */
-       for (con= pchan->constraints.first; con; con= con->next) {
-               if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0f)) {
-                       bKinematicConstraint *data= con->data;
+       for (con = pchan->constraints.first; con; con = con->next) {
+               if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce != 0.0f)) {
+                       bKinematicConstraint *data = con->data;
                        
                        /* only accept if a temporary one (for auto-ik) */
                        if (data->flag & CONSTRAINT_IK_TEMP) {
                                /* chainlen is new chainlen, but is limited by maximum chainlen */
                        
                        /* only accept if a temporary one (for auto-ik) */
                        if (data->flag & CONSTRAINT_IK_TEMP) {
                                /* chainlen is new chainlen, but is limited by maximum chainlen */
-                               if ((chainlen==0) || (chainlen > data->max_rootbone))
-                                       data->rootbone= data->max_rootbone;
+                               if ((chainlen == 0) || (chainlen > data->max_rootbone))
+                                       data->rootbone = data->max_rootbone;
                                else
                                else
-                                       data->rootbone= chainlen;
+                                       data->rootbone = chainlen;
                        }
                }
        }
                        }
                }
        }
@@ -745,7 +748,7 @@ static void pchan_autoik_adjust (bPoseChannel *pchan, short chainlen)
 /* change the chain-length of auto-ik */
 void transform_autoik_update(TransInfo *t, short mode)
 {
 /* change the chain-length of auto-ik */
 void transform_autoik_update(TransInfo *t, short mode)
 {
-       short *chainlen= &t->settings->autoik_chainlen;
+       short *chainlen = &t->settings->autoik_chainlen;
        bPoseChannel *pchan;
 
        /* mode determines what change to apply to chainlen */
        bPoseChannel *pchan;
 
        /* mode determines what change to apply to chainlen */
@@ -763,7 +766,7 @@ void transform_autoik_update(TransInfo *t, short mode)
                return;
 
        /* apply to all pose-channels */
                return;
 
        /* apply to all pose-channels */
-       for (pchan=t->poseobj->pose->chanbase.first; pchan; pchan=pchan->next) {
+       for (pchan = t->poseobj->pose->chanbase.first; pchan; pchan = pchan->next) {
                pchan_autoik_adjust(pchan, *chainlen);
        }
 }
                pchan_autoik_adjust(pchan, *chainlen);
        }
 }
@@ -775,17 +778,17 @@ static void pose_grab_with_ik_clear(Object *ob)
        bPoseChannel *pchan;
        bConstraint *con, *next;
 
        bPoseChannel *pchan;
        bConstraint *con, *next;
 
-       for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+       for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
                /* clear all temporary lock flags */
                /* clear all temporary lock flags */
-               pchan->ikflag &= ~(BONE_IK_NO_XDOF_TEMP|BONE_IK_NO_YDOF_TEMP|BONE_IK_NO_ZDOF_TEMP);
+               pchan->ikflag &= ~(BONE_IK_NO_XDOF_TEMP | BONE_IK_NO_YDOF_TEMP | BONE_IK_NO_ZDOF_TEMP);
                
                
-               pchan->constflag &= ~(PCHAN_HAS_IK|PCHAN_HAS_TARGET);
+               pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_TARGET);
                
                /* remove all temporary IK-constraints added */
                
                /* remove all temporary IK-constraints added */
-               for (con= pchan->constraints.first; con; con= next) {
-                       next= con->next;
-                       if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
-                               data= con->data;
+               for (con = pchan->constraints.first; con; con = next) {
+                       next = con->next;
+                       if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
+                               data = con->data;
                                if (data->flag & CONSTRAINT_IK_TEMP) {
                                        BLI_remlink(&pchan->constraints, con);
                                        MEM_freeN(con->data);
                                if (data->flag & CONSTRAINT_IK_TEMP) {
                                        BLI_remlink(&pchan->constraints, con);
                                        MEM_freeN(con->data);
@@ -793,7 +796,7 @@ static void pose_grab_with_ik_clear(Object *ob)
                                        continue;
                                }
                                pchan->constflag |= PCHAN_HAS_IK;
                                        continue;
                                }
                                pchan->constflag |= PCHAN_HAS_IK;
-                               if (data->tar==NULL || (data->tar->type==OB_ARMATURE && data->subtarget[0]==0))
+                               if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0))
                                        pchan->constflag |= PCHAN_HAS_TARGET;
                        }
                }
                                        pchan->constflag |= PCHAN_HAS_TARGET;
                        }
                }
@@ -812,21 +815,21 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
                return 0;
 
        /* Rule: not if there's already an IK on this channel */
                return 0;
 
        /* Rule: not if there's already an IK on this channel */
-       for (con= pchan->constraints.first; con; con= con->next) {
-               if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
-                       data= con->data;
+       for (con = pchan->constraints.first; con; con = con->next) {
+               if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
+                       data = con->data;
                        
                        
-                       if (data->tar==NULL || (data->tar->type==OB_ARMATURE && data->subtarget[0]=='\0')) {
+                       if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == '\0')) {
                                /* make reference to constraint to base things off later (if it's the last targetless constraint encountered) */
                                targetless = (bKinematicConstraint *)con->data;
                                
                                /* but, if this is a targetless IK, we make it auto anyway (for the children loop) */
                                /* make reference to constraint to base things off later (if it's the last targetless constraint encountered) */
                                targetless = (bKinematicConstraint *)con->data;
                                
                                /* but, if this is a targetless IK, we make it auto anyway (for the children loop) */
-                               if (con->enforce!=0.0f) {
+                               if (con->enforce != 0.0f) {
                                        data->flag |= CONSTRAINT_IK_AUTO;
                                        
                                        /* if no chain length has been specified, just make things obey standard rotation locks too */
                                        if (data->rootbone == 0) {
                                        data->flag |= CONSTRAINT_IK_AUTO;
                                        
                                        /* if no chain length has been specified, just make things obey standard rotation locks too */
                                        if (data->rootbone == 0) {
-                                               for (; pchan; pchan=pchan->parent) {
+                                               for (; pchan; pchan = pchan->parent) {
                                                        /* here, we set ik-settings for bone from pchan->protectflag */
                                                        // XXX: careful with quats/axis-angle rotations where we're locking 4d components
                                                        if (pchan->protectflag & OB_LOCK_ROTX) pchan->ikflag |= BONE_IK_NO_XDOF_TEMP;
                                                        /* here, we set ik-settings for bone from pchan->protectflag */
                                                        // XXX: careful with quats/axis-angle rotations where we're locking 4d components
                                                        if (pchan->protectflag & OB_LOCK_ROTX) pchan->ikflag |= BONE_IK_NO_XDOF_TEMP;
@@ -839,23 +842,23 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
                                }
                        }
                        
                                }
                        }
                        
-                       if ((con->flag & CONSTRAINT_DISABLE)==0 && (con->enforce!=0.0f))
+                       if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f))
                                return 0;
                }
        }
 
        con = add_pose_constraint(NULL, pchan, "TempConstraint", CONSTRAINT_TYPE_KINEMATIC);
                                return 0;
                }
        }
 
        con = add_pose_constraint(NULL, pchan, "TempConstraint", CONSTRAINT_TYPE_KINEMATIC);
-       pchan->constflag |= (PCHAN_HAS_IK|PCHAN_HAS_TARGET);    /* for draw, but also for detecting while pose solving */
-       data= con->data;
+       pchan->constflag |= (PCHAN_HAS_IK | PCHAN_HAS_TARGET);    /* for draw, but also for detecting while pose solving */
+       data = con->data;
        if (targetless) { 
                /* if exists, use values from last targetless (but disabled) IK-constraint as base */
                *data = *targetless;
        }
        else
        if (targetless) { 
                /* if exists, use values from last targetless (but disabled) IK-constraint as base */
                *data = *targetless;
        }
        else
-               data->flag= CONSTRAINT_IK_TIP;
-       data->flag |= CONSTRAINT_IK_TEMP|CONSTRAINT_IK_AUTO;
+               data->flag = CONSTRAINT_IK_TIP;
+       data->flag |= CONSTRAINT_IK_TEMP | CONSTRAINT_IK_AUTO;
        copy_v3_v3(data->grabtarget, pchan->pose_tail);
        copy_v3_v3(data->grabtarget, pchan->pose_tail);
-       data->rootbone= 0; /* watch-it! has to be 0 here, since we're still on the same bone for the first time through the loop [#25885] */
+       data->rootbone = 0; /* watch-it! has to be 0 here, since we're still on the same bone for the first time through the loop [#25885] */
        
        /* we only include bones that are part of a continual connected chain */
        while (pchan) {
        
        /* we only include bones that are part of a continual connected chain */
        while (pchan) {
@@ -876,7 +879,7 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
        }
 
        /* make a copy of maximum chain-length */
        }
 
        /* make a copy of maximum chain-length */
-       data->max_rootbone= data->rootbone;
+       data->max_rootbone = data->rootbone;
 
        return 1;
 }
 
        return 1;
 }
@@ -885,19 +888,19 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
 static short pose_grab_with_ik_children(bPose *pose, Bone *bone)
 {
        Bone *bonec;
 static short pose_grab_with_ik_children(bPose *pose, Bone *bone)
 {
        Bone *bonec;
-       short wentdeeper=0, added=0;
+       short wentdeeper = 0, added = 0;
 
        /* go deeper if children & children are connected */
 
        /* go deeper if children & children are connected */
-       for (bonec= bone->childbase.first; bonec; bonec= bonec->next) {
+       for (bonec = bone->childbase.first; bonec; bonec = bonec->next) {
                if (bonec->flag & BONE_CONNECTED) {
                if (bonec->flag & BONE_CONNECTED) {
-                       wentdeeper= 1;
-                       added+= pose_grab_with_ik_children(pose, bonec);
+                       wentdeeper = 1;
+                       added += pose_grab_with_ik_children(pose, bonec);
                }
        }
                }
        }
-       if (wentdeeper==0) {
-               bPoseChannel *pchan= BKE_pose_channel_find_name(pose, bone->name);
+       if (wentdeeper == 0) {
+               bPoseChannel *pchan = BKE_pose_channel_find_name(pose, bone->name);
                if (pchan)
                if (pchan)
-                       added+= pose_grab_with_ik_add(pchan);
+                       added += pose_grab_with_ik_add(pchan);
        }
 
        return added;
        }
 
        return added;
@@ -909,30 +912,30 @@ static short pose_grab_with_ik(Object *ob)
        bArmature *arm;
        bPoseChannel *pchan, *parent;
        Bone *bonec;
        bArmature *arm;
        bPoseChannel *pchan, *parent;
        Bone *bonec;
-       short tot_ik= 0;
+       short tot_ik = 0;
 
 
-       if ((ob==NULL) || (ob->pose==NULL) || (ob->mode & OB_MODE_POSE)==0)
+       if ((ob == NULL) || (ob->pose == NULL) || (ob->mode & OB_MODE_POSE) == 0)
                return 0;
 
        arm = ob->data;
 
        /* Rule: allow multiple Bones (but they must be selected, and only one ik-solver per chain should get added) */
                return 0;
 
        arm = ob->data;
 
        /* Rule: allow multiple Bones (but they must be selected, and only one ik-solver per chain should get added) */
-       for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+       for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
                if (pchan->bone->layer & arm->layer) {
                        if (pchan->bone->flag & BONE_SELECTED) {
                                /* Rule: no IK for solitatry (unconnected) bones */
                if (pchan->bone->layer & arm->layer) {
                        if (pchan->bone->flag & BONE_SELECTED) {
                                /* Rule: no IK for solitatry (unconnected) bones */
-                               for (bonec=pchan->bone->childbase.first; bonec; bonec=bonec->next) {
+                               for (bonec = pchan->bone->childbase.first; bonec; bonec = bonec->next) {
                                        if (bonec->flag & BONE_CONNECTED) {
                                                break;
                                        }
                                }
                                        if (bonec->flag & BONE_CONNECTED) {
                                                break;
                                        }
                                }
-                               if ((pchan->bone->flag & BONE_CONNECTED)==0 && (bonec == NULL))
+                               if ((pchan->bone->flag & BONE_CONNECTED) == 0 && (bonec == NULL))
                                        continue;
 
                                /* rule: if selected Bone is not a root bone, it gets a temporal IK */
                                if (pchan->parent) {
                                        /* only adds if there's no IK yet (and no parent bone was selected) */
                                        continue;
 
                                /* rule: if selected Bone is not a root bone, it gets a temporal IK */
                                if (pchan->parent) {
                                        /* only adds if there's no IK yet (and no parent bone was selected) */
-                                       for (parent= pchan->parent; parent; parent= parent->parent) {
+                                       for (parent = pchan->parent; parent; parent = parent->parent) {
                                                if (parent->bone->flag & BONE_SELECTED)
                                                        break;
                                        }
                                                if (parent->bone->flag & BONE_SELECTED)
                                                        break;
                                        }
@@ -958,17 +961,17 @@ static void createTransPose(TransInfo *t, Object *ob)
        bPoseChannel *pchan;
        TransData *td;
        TransDataExtension *tdx;
        bPoseChannel *pchan;
        TransData *td;
        TransDataExtension *tdx;
-       short ik_on= 0;
+       short ik_on = 0;
        int i;
 
        int i;
 
-       t->total= 0;
+       t->total = 0;
 
        /* check validity of state */
 
        /* check validity of state */
-       arm= BKE_armature_from_object(ob);
-       if ((arm==NULL) || (ob->pose==NULL)) return;
+       arm = BKE_armature_from_object(ob);
+       if ((arm == NULL) || (ob->pose == NULL)) return;
 
        if (arm->flag & ARM_RESTPOS) {
 
        if (arm->flag & ARM_RESTPOS) {
-               if (ELEM(t->mode, TFM_DUMMY, TFM_BONESIZE)==0) {
+               if (ELEM(t->mode, TFM_DUMMY, TFM_BONESIZE) == 0) {
                        // XXX use transform operator reports
                        // BKE_report(op->reports, RPT_ERROR, "Can't select linked when sync selection is enabled");
                        return;
                        // XXX use transform operator reports
                        // BKE_report(op->reports, RPT_ERROR, "Can't select linked when sync selection is enabled");
                        return;
@@ -976,8 +979,8 @@ static void createTransPose(TransInfo *t, Object *ob)
        }
 
        /* do we need to add temporal IK chains? */
        }
 
        /* do we need to add temporal IK chains? */
-       if ((arm->flag & ARM_AUTO_IK) && t->mode==TFM_TRANSLATION) {
-               ik_on= pose_grab_with_ik(ob);
+       if ((arm->flag & ARM_AUTO_IK) && t->mode == TFM_TRANSLATION) {
+               ik_on = pose_grab_with_ik(ob);
                if (ik_on) t->flag |= T_AUTOIK;
        }
 
                if (ik_on) t->flag |= T_AUTOIK;
        }
 
@@ -987,26 +990,26 @@ static void createTransPose(TransInfo *t, Object *ob)
        if (t->total == 0) return;
 
        t->flag |= T_POSE;
        if (t->total == 0) return;
 
        t->flag |= T_POSE;
-       t->poseobj= ob; /* we also allow non-active objects to be transformed, in weightpaint */
+       t->poseobj = ob; /* we also allow non-active objects to be transformed, in weightpaint */
 
        /* init trans data */
 
        /* init trans data */
-       td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransPoseBone");
-       tdx = t->ext = MEM_callocN(t->total*sizeof(TransDataExtension), "TransPoseBoneExt");
-       for (i=0; i<t->total; i++, td++, tdx++) {
-               td->ext= tdx;
+       td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransPoseBone");
+       tdx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension), "TransPoseBoneExt");
+       for (i = 0; i < t->total; i++, td++, tdx++) {
+               td->ext = tdx;
                td->val = NULL;
        }
 
        /* use pose channels to fill trans data */
                td->val = NULL;
        }
 
        /* use pose channels to fill trans data */
-       td= t->data;
-       for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+       td = t->data;
+       for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
                if (pchan->bone->flag & BONE_TRANSFORM) {
                        add_pose_transdata(t, pchan, ob, td);
                        td++;
                }
        }
 
                if (pchan->bone->flag & BONE_TRANSFORM) {
                        add_pose_transdata(t, pchan, ob, td);
                        td++;
                }
        }
 
-       if (td != (t->data+t->total)) {
+       if (td != (t->data + t->total)) {
                // XXX use transform operator reports
                // BKE_report(op->reports, RPT_DEBUG, "Bone selection count error");
        }
                // XXX use transform operator reports
                // BKE_report(op->reports, RPT_DEBUG, "Bone selection count error");
        }
@@ -1020,18 +1023,18 @@ static void createTransPose(TransInfo *t, Object *ob)
 static void createTransArmatureVerts(TransInfo *t)
 {
        EditBone *ebo;
 static void createTransArmatureVerts(TransInfo *t)
 {
        EditBone *ebo;
-       bArmature *arm= t->obedit->data;
+       bArmature *arm = t->obedit->data;
        ListBase *edbo = arm->edbo;
        TransData *td;
        float mtx[3][3], smtx[3][3], delta[3], bonemat[3][3];
        
        /* special hack for envelope drawmode and scaling:
        ListBase *edbo = arm->edbo;
        TransData *td;
        float mtx[3][3], smtx[3][3], delta[3], bonemat[3][3];
        
        /* special hack for envelope drawmode and scaling:
-        *      to allow scaling the size of the envelope around single points,
+        *  to allow scaling the size of the envelope around single points,
         *      mode should become TFM_BONE_ENVELOPE in this case
         */
        // TODO: maybe we need a separate hotkey for it, but this is consistent with 2.4x for now
         *      mode should become TFM_BONE_ENVELOPE in this case
         */
        // TODO: maybe we need a separate hotkey for it, but this is consistent with 2.4x for now
-       if ((t->mode == TFM_RESIZE) && (arm->drawtype==ARM_ENVELOPE))
-               t->mode= TFM_BONE_ENVELOPE;
+       if ((t->mode == TFM_RESIZE) && (arm->drawtype == ARM_ENVELOPE))
+               t->mode = TFM_BONE_ENVELOPE;
        
        t->total = 0;
        for (ebo = edbo->first; ebo; ebo = ebo->next) {
        
        t->total = 0;
        for (ebo = edbo->first; ebo; ebo = ebo->next) {
@@ -1058,19 +1061,19 @@ static void createTransArmatureVerts(TransInfo *t)
        copy_m3_m4(mtx, t->obedit->obmat);
        invert_m3_m3(smtx, mtx);
 
        copy_m3_m4(mtx, t->obedit->obmat);
        invert_m3_m3(smtx, mtx);
 
-       td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransEditBone");
+       td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransEditBone");
 
        for (ebo = edbo->first; ebo; ebo = ebo->next) {
 
        for (ebo = edbo->first; ebo; ebo = ebo->next) {
-               ebo->oldlength = ebo->length;   // length==0.0 on extrude, used for scaling radius of bone points
+               ebo->oldlength = ebo->length;   // length==0.0 on extrude, used for scaling radius of bone points
 
                if (EBONE_VISIBLE(arm, ebo) && !(ebo->flag & BONE_EDITMODE_LOCKED)) {
 
                if (EBONE_VISIBLE(arm, ebo) && !(ebo->flag & BONE_EDITMODE_LOCKED)) {
-                       if (t->mode==TFM_BONE_ENVELOPE) {
+                       if (t->mode == TFM_BONE_ENVELOPE) {
                                if (ebo->flag & BONE_ROOTSEL) {
                                if (ebo->flag & BONE_ROOTSEL) {
-                                       td->val= &ebo->rad_head;
-                                       td->ival= *td->val;
+                                       td->val = &ebo->rad_head;
+                                       td->ival = *td->val;
 
                                        copy_v3_v3(td->center, ebo->head);
 
                                        copy_v3_v3(td->center, ebo->head);
-                                       td->flag= TD_SELECTED;
+                                       td->flag = TD_SELECTED;
 
                                        copy_m3_m3(td->smtx, smtx);
                                        copy_m3_m3(td->mtx, mtx);
 
                                        copy_m3_m3(td->smtx, smtx);
                                        copy_m3_m3(td->mtx, mtx);
@@ -1082,10 +1085,10 @@ static void createTransArmatureVerts(TransInfo *t)
                                        td++;
                                }
                                if (ebo->flag & BONE_TIPSEL) {
                                        td++;
                                }
                                if (ebo->flag & BONE_TIPSEL) {
-                                       td->val= &ebo->rad_tail;
-                                       td->ival= *td->val;
+                                       td->val = &ebo->rad_tail;
+                                       td->ival = *td->val;
                                        copy_v3_v3(td->center, ebo->tail);
                                        copy_v3_v3(td->center, ebo->tail);
-                                       td->flag= TD_SELECTED;
+                                       td->flag = TD_SELECTED;
 
                                        copy_m3_m3(td->smtx, smtx);
                                        copy_m3_m3(td->mtx, mtx);
 
                                        copy_m3_m3(td->smtx, smtx);
                                        copy_m3_m3(td->mtx, mtx);
@@ -1098,21 +1101,21 @@ static void createTransArmatureVerts(TransInfo *t)
                                }
 
                        }
                                }
 
                        }
-                       else if (t->mode==TFM_BONESIZE) {
+                       else if (t->mode == TFM_BONESIZE) {
                                if (ebo->flag & BONE_SELECTED) {
                                if (ebo->flag & BONE_SELECTED) {
-                                       if (arm->drawtype==ARM_ENVELOPE) {
-                                               td->loc= NULL;
-                                               td->val= &ebo->dist;
-                                               td->ival= ebo->dist;
+                                       if (arm->drawtype == ARM_ENVELOPE) {
+                                               td->loc = NULL;
+                                               td->val = &ebo->dist;
+                                               td->ival = ebo->dist;
                                        }
                                        else {
                                                // abusive storage of scale in the loc pointer :)
                                        }
                                        else {
                                                // abusive storage of scale in the loc pointer :)
-                                               td->loc= &ebo->xwidth;
+                                               td->loc = &ebo->xwidth;
                                                copy_v3_v3(td->iloc, td->loc);
                                                copy_v3_v3(td->iloc, td->loc);
-                                               td->val= NULL;
+                                               td->val = NULL;
                                        }
                                        copy_v3_v3(td->center, ebo->head);
                                        }
                                        copy_v3_v3(td->center, ebo->head);
-                                       td->flag= TD_SELECTED;
+                                       td->flag = TD_SELECTED;
 
                                        /* use local bone matrix */
                                        sub_v3_v3v3(delta, ebo->tail, ebo->head);
 
                                        /* use local bone matrix */
                                        sub_v3_v3v3(delta, ebo->tail, ebo->head);
@@ -1129,14 +1132,14 @@ static void createTransArmatureVerts(TransInfo *t)
                                        td++;
                                }
                        }
                                        td++;
                                }
                        }
-                       else if (t->mode==TFM_BONE_ROLL) {
+                       else if (t->mode == TFM_BONE_ROLL) {
                                if (ebo->flag & BONE_SELECTED) {
                                if (ebo->flag & BONE_SELECTED) {
-                                       td->loc= NULL;
-                                       td->val= &(ebo->roll);
-                                       td->ival= ebo->roll;
+                                       td->loc = NULL;
+                                       td->val = &(ebo->roll);
+                                       td->ival = ebo->roll;
 
                                        copy_v3_v3(td->center, ebo->head);
 
                                        copy_v3_v3(td->center, ebo->head);
-                                       td->flag= TD_SELECTED;
+                                       td->flag = TD_SELECTED;
 
                                        td->ext = NULL;
                                        td->ob = t->obedit;
 
                                        td->ext = NULL;
                                        td->ob = t->obedit;
@@ -1147,11 +1150,11 @@ static void createTransArmatureVerts(TransInfo *t)
                        else {
                                if (ebo->flag & BONE_TIPSEL) {
                                        copy_v3_v3(td->iloc, ebo->tail);
                        else {
                                if (ebo->flag & BONE_TIPSEL) {
                                        copy_v3_v3(td->iloc, ebo->tail);
-                                       copy_v3_v3(td->center, (t->around==V3D_LOCAL) ? ebo->head : td->iloc);
-                                       td->loc= ebo->tail;
-                                       td->flag= TD_SELECTED;
+                                       copy_v3_v3(td->center, (t->around == V3D_LOCAL) ? ebo->head : td->iloc);
+                                       td->loc = ebo->tail;
+                                       td->flag = TD_SELECTED;
                                        if (ebo->flag & BONE_EDITMODE_LOCKED)
                                        if (ebo->flag & BONE_EDITMODE_LOCKED)
-                                               td->protectflag = OB_LOCK_LOC|OB_LOCK_ROT|OB_LOCK_SCALE;
+                                               td->protectflag = OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE;
 
                                        copy_m3_m3(td->smtx, smtx);
                                        copy_m3_m3(td->mtx, mtx);
 
                                        copy_m3_m3(td->smtx, smtx);
                                        copy_m3_m3(td->mtx, mtx);
@@ -1172,10 +1175,10 @@ static void createTransArmatureVerts(TransInfo *t)
                                if (ebo->flag & BONE_ROOTSEL) {
                                        copy_v3_v3(td->iloc, ebo->head);
                                        copy_v3_v3(td->center, td->iloc);
                                if (ebo->flag & BONE_ROOTSEL) {
                                        copy_v3_v3(td->iloc, ebo->head);
                                        copy_v3_v3(td->center, td->iloc);
-                                       td->loc= ebo->head;
-                                       td->flag= TD_SELECTED;
+                                       td->loc = ebo->head;
+                                       td->flag = TD_SELECTED;
                                        if (ebo->flag & BONE_EDITMODE_LOCKED)
                                        if (ebo->flag & BONE_EDITMODE_LOCKED)
-                                               td->protectflag = OB_LOCK_LOC|OB_LOCK_ROT|OB_LOCK_SCALE;
+                                               td->protectflag = OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE;
 
                                        copy_m3_m3(td->smtx, smtx);
                                        copy_m3_m3(td->mtx, mtx);
 
                                        copy_m3_m3(td->smtx, smtx);
                                        copy_m3_m3(td->mtx, mtx);
@@ -1200,40 +1203,40 @@ static void createTransArmatureVerts(TransInfo *t)
 
 static void createTransMBallVerts(TransInfo *t)
 {
 
 static void createTransMBallVerts(TransInfo *t)
 {
-       MetaBall *mb = (MetaBall*)t->obedit->data;
+       MetaBall *mb = (MetaBall *)t->obedit->data;
        MetaElem *ml;
        TransData *td;
        TransDataExtension *tx;
        float mtx[3][3], smtx[3][3];
        MetaElem *ml;
        TransData *td;
        TransDataExtension *tx;
        float mtx[3][3], smtx[3][3];
-       int count=0, countsel=0;
+       int count = 0, countsel = 0;
        int propmode = t->flag & T_PROP_EDIT;
 
        /* count totals */
        int propmode = t->flag & T_PROP_EDIT;
 
        /* count totals */
-       for (ml= mb->editelems->first; ml; ml= ml->next) {
+       for (ml = mb->editelems->first; ml; ml = ml->next) {
                if (ml->flag & SELECT) countsel++;
                if (propmode) count++;
        }
 
        /* note: in prop mode we need at least 1 selected */
                if (ml->flag & SELECT) countsel++;
                if (propmode) count++;
        }
 
        /* note: in prop mode we need at least 1 selected */
-       if (countsel==0) return;
+       if (countsel == 0) return;
 
        if (propmode) t->total = count;
        else t->total = countsel;
 
 
        if (propmode) t->total = count;
        else t->total = countsel;
 
-       td = t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(MBall EditMode)");
-       tx = t->ext = MEM_callocN(t->total*sizeof(TransDataExtension), "MetaElement_TransExtension");
+       td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(MBall EditMode)");
+       tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension), "MetaElement_TransExtension");
 
        copy_m3_m4(mtx, t->obedit->obmat);
        invert_m3_m3(smtx, mtx);
 
 
        copy_m3_m4(mtx, t->obedit->obmat);
        invert_m3_m3(smtx, mtx);
 
-       for (ml= mb->editelems->first; ml; ml= ml->next) {
+       for (ml = mb->editelems->first; ml; ml = ml->next) {
                if (propmode || (ml->flag & SELECT)) {
                if (propmode || (ml->flag & SELECT)) {
-                       td->loc= &ml->x;
+                       td->loc = &ml->x;
                        copy_v3_v3(td->iloc, td->loc);
                        copy_v3_v3(td->center, td->loc);
 
                        copy_v3_v3(td->iloc, td->loc);
                        copy_v3_v3(td->center, td->loc);
 
-                       if (ml->flag & SELECT) td->flag= TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE;
-                       else td->flag= TD_USEQUAT;
+                       if (ml->flag & SELECT) td->flag = TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE;
+                       else td->flag = TD_USEQUAT;
 
                        copy_m3_m3(td->smtx, smtx);
                        copy_m3_m3(td->mtx, mtx);
 
                        copy_m3_m3(td->smtx, smtx);
                        copy_m3_m3(td->mtx, mtx);
@@ -1273,7 +1276,7 @@ static void createTransMBallVerts(TransInfo *t)
 static void calc_distanceCurveVerts(TransData *head, TransData *tail)
 {
        TransData *td, *td_near = NULL;
 static void calc_distanceCurveVerts(TransData *head, TransData *tail)
 {
        TransData *td, *td_near = NULL;
-       for (td = head; td<=tail; td++) {
+       for (td = head; td <= tail; td++) {
                if (td->flag & TD_SELECTED) {
                        td_near = td;
                        td->dist = 0.0f;
                if (td->flag & TD_SELECTED) {
                        td_near = td;
                        td->dist = 0.0f;
@@ -1281,8 +1284,8 @@ static void calc_distanceCurveVerts(TransData *head, TransData *tail)
                else if (td_near) {
                        float dist;
                        dist = len_v3v3(td_near->center, td->center);
                else if (td_near) {
                        float dist;
                        dist = len_v3v3(td_near->center, td->center);
-                       if (dist < (td-1)->dist) {
-                               td->dist = (td-1)->dist;
+                       if (dist < (td - 1)->dist) {
+                               td->dist = (td - 1)->dist;
                        }
                        else {
                                td->dist = dist;
                        }
                        else {
                                td->dist = dist;
@@ -1294,7 +1297,7 @@ static void calc_distanceCurveVerts(TransData *head, TransData *tail)
                }
        }
        td_near = NULL;
                }
        }
        td_near = NULL;
-       for (td = tail; td>=head; td--) {
+       for (td = tail; td >= head; td--) {
                if (td->flag & TD_SELECTED) {
                        td_near = td;
                        td->dist = 0.0f;
                if (td->flag & TD_SELECTED) {
                        td_near = td;
                        td->dist = 0.0f;
@@ -1302,10 +1305,10 @@ static void calc_distanceCurveVerts(TransData *head, TransData *tail)
                else if (td_near) {
                        float dist;
                        dist = len_v3v3(td_near->center, td->center);
                else if (td_near) {
                        float dist;
                        dist = len_v3v3(td_near->center, td->center);
-                       if (td->flag & TD_NOTCONNECTED || dist < td->dist || (td+1)->dist < td->dist) {
+                       if (td->flag & TD_NOTCONNECTED || dist < td->dist || (td + 1)->dist < td->dist) {
                                td->flag &= ~TD_NOTCONNECTED;
                                td->flag &= ~TD_NOTCONNECTED;
-                               if (dist < (td+1)->dist) {
-                                       td->dist = (td+1)->dist;
+                               if (dist < (td + 1)->dist) {
+                                       td->dist = (td + 1)->dist;
                                }
                                else {
                                        td->dist = dist;
                                }
                                else {
                                        td->dist = dist;
@@ -1330,44 +1333,44 @@ static TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, struc
 
 static void createTransCurveVerts(bContext *C, TransInfo *t)
 {
 
 static void createTransCurveVerts(bContext *C, TransInfo *t)
 {
-       Object *obedit= CTX_data_edit_object(C);
-       Curve *cu= obedit->data;
+       Object *obedit = CTX_data_edit_object(C);
+       Curve *cu = obedit->data;
        TransData *td = NULL;
        TransData *td = NULL;
-         Nurb *nu;
+       Nurb *nu;
        BezTriple *bezt;
        BPoint *bp;
        float mtx[3][3], smtx[3][3];
        int a;
        BezTriple *bezt;
        BPoint *bp;
        float mtx[3][3], smtx[3][3];
        int a;
-       int count=0, countsel=0;
+       int count = 0, countsel = 0;
        int propmode = t->flag & T_PROP_EDIT;
        short hide_handles = (cu->drawflag & CU_HIDE_HANDLES);
        ListBase *nurbs;
 
        /* to be sure */
        int propmode = t->flag & T_PROP_EDIT;
        short hide_handles = (cu->drawflag & CU_HIDE_HANDLES);
        ListBase *nurbs;
 
        /* to be sure */
-       if (cu->editnurb==NULL) return;
+       if (cu->editnurb == NULL) return;
 
        /* count total of vertices, check identical as in 2nd loop for making transdata! */
 
        /* count total of vertices, check identical as in 2nd loop for making transdata! */
-       nurbs= BKE_curve_editNurbs_get(cu);
-       for (nu= nurbs->first; nu; nu= nu->next) {
+       nurbs = BKE_curve_editNurbs_get(cu);
+       for (nu = nurbs->first; nu; nu = nu->next) {
                if (nu->type == CU_BEZIER) {
                if (nu->type == CU_BEZIER) {
-                       for (a=0, bezt= nu->bezt; a<nu->pntsu; a++, bezt++) {
-                               if (bezt->hide==0) {
+                       for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
+                               if (bezt->hide == 0) {
                                        if (hide_handles) {
                                        if (hide_handles) {
-                                               if (bezt->f2 & SELECT) countsel+=3;
-                                               if (propmode) count+= 3;
+                                               if (bezt->f2 & SELECT) countsel += 3;
+                                               if (propmode) count += 3;
                                        }
                                        else {
                                                if (bezt->f1 & SELECT) countsel++;
                                                if (bezt->f2 & SELECT) countsel++;
                                                if (bezt->f3 & SELECT) countsel++;
                                        }
                                        else {
                                                if (bezt->f1 & SELECT) countsel++;
                                                if (bezt->f2 & SELECT) countsel++;
                                                if (bezt->f3 & SELECT) countsel++;
-                                               if (propmode) count+= 3;
+                                               if (propmode) count += 3;
                                        }
                                }
                        }
                }
                else {
                                        }
                                }
                        }
                }
                else {
-                       for (a= nu->pntsu*nu->pntsv, bp= nu->bp; a>0; a--, bp++) {
-                               if (bp->hide==0) {
+                       for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
+                               if (bp->hide == 0) {
                                        if (propmode) count++;
                                        if (bp->f1 & SELECT) countsel++;
                                }
                                        if (propmode) count++;
                                        if (bp->f1 & SELECT) countsel++;
                                }
@@ -1375,38 +1378,38 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
                }
        }
        /* note: in prop mode we need at least 1 selected */
                }
        }
        /* note: in prop mode we need at least 1 selected */
-       if (countsel==0) return;
+       if (countsel == 0) return;
 
        if (propmode) t->total = count;
        else t->total = countsel;
 
        if (propmode) t->total = count;
        else t->total = countsel;
-       t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Curve EditMode)");
+       t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Curve EditMode)");
 
        copy_m3_m4(mtx, t->obedit->obmat);
        invert_m3_m3(smtx, mtx);
 
        td = t->data;
 
        copy_m3_m4(mtx, t->obedit->obmat);
        invert_m3_m3(smtx, mtx);
 
        td = t->data;
-       for (nu= nurbs->first; nu; nu= nu->next) {
+       for (nu = nurbs->first; nu; nu = nu->next) {
                if (nu->type == CU_BEZIER) {
                        TransData *head, *tail;
                        head = tail = td;
                if (nu->type == CU_BEZIER) {
                        TransData *head, *tail;
                        head = tail = td;
-                       for (a=0, bezt= nu->bezt; a<nu->pntsu; a++, bezt++) {
-                               if (bezt->hide==0) {
+                       for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
+                               if (bezt->hide == 0) {
                                        TransDataCurveHandleFlags *hdata = NULL;
 
                                        TransDataCurveHandleFlags *hdata = NULL;
 
-                                       if (            propmode ||
-                                                       ((bezt->f2 & SELECT) && hide_handles) ||
-                                                       ((bezt->f1 & SELECT) && hide_handles == 0)
-                                         ) {
+                                       if (propmode ||
+                                           ((bezt->f2 & SELECT) && hide_handles) ||
+                                           ((bezt->f1 & SELECT) && hide_handles == 0))
+                                       {
                                                copy_v3_v3(td->iloc, bezt->vec[0]);
                                                copy_v3_v3(td->iloc, bezt->vec[0]);
-                                               td->loc= bezt->vec[0];
-                                               copy_v3_v3(td->center, bezt->vec[(hide_handles || bezt->f2 & SELECT) ? 1:0]);
+                                               td->loc = bezt->vec[0];
+                                               copy_v3_v3(td->center, bezt->vec[(hide_handles || bezt->f2 & SELECT) ? 1 : 0]);
                                                if (hide_handles) {
                                                if (hide_handles) {
-                                                       if (bezt->f2 & SELECT) td->flag= TD_SELECTED;
-                                                       else td->flag= 0;
+                                                       if (bezt->f2 & SELECT) td->flag = TD_SELECTED;
+                                                       else td->flag = 0;
                                                }
                                                else {
                                                }
                                                else {
-                                                       if (bezt->f1 & SELECT) td->flag= TD_SELECTED;
-                                                       else td->flag= 0;
+                                                       if (bezt->f1 & SELECT) td->flag = TD_SELECTED;
+                                                       else td->flag = 0;
                                                }
                                                td->ext = NULL;
                                                td->val = NULL;
                                                }
                                                td->ext = NULL;
                                                td->val = NULL;
@@ -1424,17 +1427,17 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
                                        /* This is the Curve Point, the other two are handles */
                                        if (propmode || (bezt->f2 & SELECT)) {
                                                copy_v3_v3(td->iloc, bezt->vec[1]);
                                        /* This is the Curve Point, the other two are handles */
                                        if (propmode || (bezt->f2 & SELECT)) {
                                                copy_v3_v3(td->iloc, bezt->vec[1]);
-                                               td->loc= bezt->vec[1];
+                                               td->loc = bezt->vec[1];
                                                copy_v3_v3(td->center, td->loc);
                                                copy_v3_v3(td->center, td->loc);
-                                               if (bezt->f2 & SELECT) td->flag= TD_SELECTED;
-                                               else td->flag= 0;
+                                               if (bezt->f2 & SELECT) td->flag = TD_SELECTED;
+                                               else td->flag = 0;
                                                td->ext = NULL;
 
                                                td->ext = NULL;
 
-                                               if (t->mode==TFM_CURVE_SHRINKFATTEN) { /* || t->mode==TFM_RESIZE) {*/ /* TODO - make points scale */
+                                               if (t->mode == TFM_CURVE_SHRINKFATTEN) { /* || t->mode==TFM_RESIZE) {*/ /* TODO - make points scale */
                                                        td->val = &(bezt->radius);
                                                        td->ival = bezt->radius;
                                                }
                                                        td->val = &(bezt->radius);
                                                        td->ival = bezt->radius;
                                                }
-                                               else if (t->mode==TFM_TILT) {
+                                               else if (t->mode == TFM_TILT) {
                                                        td->val = &(bezt->alfa);
                                                        td->ival = bezt->alfa;
                                                }
                                                        td->val = &(bezt->alfa);
                                                        td->ival = bezt->alfa;
                                                }
@@ -1445,35 +1448,35 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
                                                copy_m3_m3(td->smtx, smtx);
                                                copy_m3_m3(td->mtx, mtx);
 
                                                copy_m3_m3(td->smtx, smtx);
                                                copy_m3_m3(td->mtx, mtx);
 
-                                               if ((bezt->f1&SELECT)==0 && (bezt->f3&SELECT)==0)
-                                               /* If the middle is selected but the sides arnt, this is needed */
-                                               if (hdata==NULL) { /* if the handle was not saved by the previous handle */
-                                                       hdata = initTransDataCurveHandles(td, bezt);
-                                               }
+                                               if ((bezt->f1 & SELECT) == 0 && (bezt->f3 & SELECT) == 0)
+                                                       /* If the middle is selected but the sides arnt, this is needed */
+                                                       if (hdata == NULL) { /* if the handle was not saved by the previous handle */
+                                                               hdata = initTransDataCurveHandles(td, bezt);
+                                                       }
 
                                                td++;
                                                count++;
                                                tail++;
                                        }
 
                                                td++;
                                                count++;
                                                tail++;
                                        }
-                                       if (            propmode ||
-                                                       ((bezt->f2 & SELECT) && hide_handles) ||
-                                                       ((bezt->f3 & SELECT) && hide_handles == 0)
-                                         ) {
+                                       if (propmode ||
+                                           ((bezt->f2 & SELECT) && hide_handles) ||
+                                           ((bezt->f3 & SELECT) && hide_handles == 0))
+                                       {
                                                copy_v3_v3(td->iloc, bezt->vec[2]);
                                                copy_v3_v3(td->iloc, bezt->vec[2]);
-                                               td->loc= bezt->vec[2];
-                                               copy_v3_v3(td->center, bezt->vec[(hide_handles || bezt->f2 & SELECT) ? 1:2]);
+                                               td->loc = bezt->vec[2];
+                                               copy_v3_v3(td->center, bezt->vec[(hide_handles || bezt->f2 & SELECT) ? 1 : 2]);
                                                if (hide_handles) {
                                                if (hide_handles) {
-                                                       if (bezt->f2 & SELECT) td->flag= TD_SELECTED;
-                                                       else td->flag= 0;
+                                                       if (bezt->f2 & SELECT) td->flag = TD_SELECTED;
+                                                       else td->flag = 0;
                                                }
                                                else {
                                                }
                                                else {
-                                                       if (bezt->f3 & SELECT) td->flag= TD_SELECTED;
-                                                       else td->flag= 0;
+                                                       if (bezt->f3 & SELECT) td->flag = TD_SELECTED;
+                                                       else td->flag = 0;
                                                }
                                                td->ext = NULL;
                                                td->val = NULL;
 
                                                }
                                                td->ext = NULL;
                                                td->val = NULL;
 
-                                               if (hdata==NULL) { /* if the handle was not saved by the previous handle */
+                                               if (hdata == NULL) { /* if the handle was not saved by the previous handle */
                                                        hdata = initTransDataCurveHandles(td, bezt);
                                                }
 
                                                        hdata = initTransDataCurveHandles(td, bezt);
                                                }
 
@@ -1486,12 +1489,12 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
                                        }
                                }
                                else if (propmode && head != tail) {
                                        }
                                }
                                else if (propmode && head != tail) {
-                                       calc_distanceCurveVerts(head, tail-1);
+                                       calc_distanceCurveVerts(head, tail - 1);
                                        head = tail;
                                }
                        }
                        if (propmode && head != tail)
                                        head = tail;
                                }
                        }
                        if (propmode && head != tail)
-                               calc_distanceCurveVerts(head, tail-1);
+                               calc_distanceCurveVerts(head, tail - 1);
 
                        /* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandles
                         * but for now just don't change handle types */
 
                        /* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandles
                         * but for now just don't change handle types */
@@ -1503,17 +1506,17 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
                else {
                        TransData *head, *tail;
                        head = tail = td;
                else {
                        TransData *head, *tail;
                        head = tail = td;
-                       for (a= nu->pntsu*nu->pntsv, bp= nu->bp; a>0; a--, bp++) {
-                               if (bp->hide==0) {
+                       for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
+                               if (bp->hide == 0) {
                                        if (propmode || (bp->f1 & SELECT)) {
                                                copy_v3_v3(td->iloc, bp->vec);
                                        if (propmode || (bp->f1 & SELECT)) {
                                                copy_v3_v3(td->iloc, bp->vec);
-                                               td->loc= bp->vec;
+                                               td->loc = bp->vec;
                                                copy_v3_v3(td->center, td->loc);
                                                copy_v3_v3(td->center, td->loc);
-                                               if (bp->f1 & SELECT) td->flag= TD_SELECTED;
-                                               else td->flag= 0;
+                                               if (bp->f1 & SELECT) td->flag = TD_SELECTED;
+                                               else td->flag = 0;
                                                td->ext = NULL;
 
                                                td->ext = NULL;
 
-                                               if (t->mode==TFM_CURVE_SHRINKFATTEN || t->mode==TFM_RESIZE) {
+                                               if (t->mode == TFM_CURVE_SHRINKFATTEN || t->mode == TFM_RESIZE) {
                                                        td->val = &(bp->radius);
                                                        td->ival = bp->radius;
                                                }
                                                        td->val = &(bp->radius);
                                                        td->ival = bp->radius;
                                                }
@@ -1531,12 +1534,12 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
                                        }
                                }
                                else if (propmode && head != tail) {
                                        }
                                }
                                else if (propmode && head != tail) {
-                                       calc_distanceCurveVerts(head, tail-1);
+                                       calc_distanceCurveVerts(head, tail - 1);
                                        head = tail;
                                }
                        }
                        if (propmode && head != tail)
                                        head = tail;
                                }
                        }
                        if (propmode && head != tail)
-                               calc_distanceCurveVerts(head, tail-1);
+                               calc_distanceCurveVerts(head, tail - 1);
                }
        }
 }
                }
        }
 }
@@ -1545,30 +1548,30 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
 
 static void createTransLatticeVerts(TransInfo *t)
 {
 
 static void createTransLatticeVerts(TransInfo *t)
 {
-       Lattice *latt = ((Lattice*)t->obedit->data)->editlatt->latt;
+       Lattice *latt = ((Lattice *)t->obedit->data)->editlatt->latt;
        TransData *td = NULL;
        BPoint *bp;
        float mtx[3][3], smtx[3][3];
        int a;
        TransData *td = NULL;
        BPoint *bp;
        float mtx[3][3], smtx[3][3];
        int a;
-       int count=0, countsel=0;
+       int count = 0, countsel = 0;
        int propmode = t->flag & T_PROP_EDIT;
 
        bp = latt->def;
        a  = latt->pntsu * latt->pntsv * latt->pntsw;
        while (a--) {
        int propmode = t->flag & T_PROP_EDIT;
 
        bp = latt->def;
        a  = latt->pntsu * latt->pntsv * latt->pntsw;
        while (a--) {
-               if (bp->hide==0) {
+               if (bp->hide == 0) {
                        if (bp->f1 & SELECT) countsel++;
                        if (propmode) count++;
                }
                bp++;
        }
 
                        if (bp->f1 & SELECT) countsel++;
                        if (propmode) count++;
                }
                bp++;
        }
 
-        /* note: in prop mode we need at least 1 selected */
-       if (countsel==0) return;
+       /* note: in prop mode we need at least 1 selected */
+       if (countsel == 0) return;
 
        if (propmode) t->total = count;
        else t->total = countsel;
 
        if (propmode) t->total = count;
        else t->total = countsel;
-       t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Lattice EditMode)");
+       t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Lattice EditMode)");
 
        copy_m3_m4(mtx, t->obedit->obmat);
        invert_m3_m3(smtx, mtx);
 
        copy_m3_m4(mtx, t->obedit->obmat);
        invert_m3_m3(smtx, mtx);
@@ -1578,12 +1581,12 @@ static void createTransLatticeVerts(TransInfo *t)
        a  = latt->pntsu * latt->pntsv * latt->pntsw;
        while (a--) {
                if (propmode || (bp->f1 & SELECT)) {
        a  = latt->pntsu * latt->pntsv * latt->pntsw;
        while (a--) {
                if (propmode || (bp->f1 & SELECT)) {
-                       if (bp->hide==0) {
+                       if (bp->hide == 0) {
                                copy_v3_v3(td->iloc, bp->vec);
                                copy_v3_v3(td->iloc, bp->vec);
-                               td->loc= bp->vec;
+                               td->loc = bp->vec;
                                copy_v3_v3(td->center, td->loc);
                                copy_v3_v3(td->center, td->loc);
-                               if (bp->f1 & SELECT) td->flag= TD_SELECTED;
-                               else td->flag= 0;
+                               if (bp->f1 & SELECT) td->flag = TD_SELECTED;
+                               else td->flag = 0;
                                copy_m3_m3(td->smtx, smtx);
                                copy_m3_m3(td->mtx, mtx);
 
                                copy_m3_m3(td->smtx, smtx);
                                copy_m3_m3(td->mtx, mtx);
 
@@ -1616,7 +1619,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
        int count = 0, hasselected = 0;
        int propmode = t->flag & T_PROP_EDIT;
 
        int count = 0, hasselected = 0;
        int propmode = t->flag & T_PROP_EDIT;
 
-       if (edit==NULL || t->settings->particle.selectmode==SCE_SELECT_PATH) return;
+       if (edit == NULL || t->settings->particle.selectmode == SCE_SELECT_PATH) return;
 
        psys = edit->psys;
 
 
        psys = edit->psys;
 
@@ -1625,19 +1628,19 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
 
        base->flag |= BA_HAS_RECALC_DATA;
 
 
        base->flag |= BA_HAS_RECALC_DATA;
 
-       for (i=0, point=edit->points; i<edit->totpoint; i++, point++) {
+       for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
                point->flag &= ~PEP_TRANSFORM;
                point->flag &= ~PEP_TRANSFORM;
-               transformparticle= 0;
-
-               if ((point->flag & PEP_HIDE)==0) {
-                       for (k=0, key=point->keys; k<point->totkey; k++, key++) {
-                               if ((key->flag&PEK_HIDE)==0) {
-                                       if (key->flag&PEK_SELECT) {
-                                               hasselected= 1;
-                                               transformparticle= 1;
+               transformparticle = 0;
+
+               if ((point->flag & PEP_HIDE) == 0) {
+                       for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
+                               if ((key->flag & PEK_HIDE) == 0) {
+                                       if (key->flag & PEK_SELECT) {
+                                               hasselected = 1;
+                                               transformparticle = 1;
                                        }
                                        else if (propmode)
                                        }
                                        else if (propmode)
-                                               transformparticle= 1;
+                                               transformparticle = 1;
                                }
                        }
                }
                                }
                        }
                }
@@ -1648,8 +1651,8 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
                }
        }
 
                }
        }
 
-        /* note: in prop mode we need at least 1 selected */
-       if (hasselected==0) return;
+       /* note: in prop mode we need at least 1 selected */
+       if (hasselected == 0) return;
 
        t->total = count;
        td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Particle Mode)");
 
        t->total = count;
        td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Particle Mode)");
@@ -1663,7 +1666,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
 
        invert_m4_m4(ob->imat, ob->obmat);
 
 
        invert_m4_m4(ob->imat, ob->obmat);
 
-       for (i=0, point=edit->points; i<edit->totpoint; i++, point++) {
+       for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
                TransData *head, *tail;
                head = tail = td;
 
                TransData *head, *tail;
                head = tail = td;
 
@@ -1672,7 +1675,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
                if (psys && !(psys->flag & PSYS_GLOBAL_HAIR))
                        psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + i, mat);
 
                if (psys && !(psys->flag & PSYS_GLOBAL_HAIR))
                        psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + i, mat);
 
-               for (k=0, key=point->keys; k<point->totkey; k++, key++) {
+               for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
                        if (key->flag & PEK_USE_WCO) {
                                copy_v3_v3(key->world_co, key->co);
                                mul_m4_v3(mat, key->world_co);
                        if (key->flag & PEK_USE_WCO) {
                                copy_v3_v3(key->world_co, key->co);
                                mul_m4_v3(mat, key->world_co);
@@ -1693,7 +1696,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
                        unit_m3(td->smtx);
 
                        /* don't allow moving roots */
                        unit_m3(td->smtx);
 
                        /* don't allow moving roots */
-                       if (k==0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR)))
+                       if (k == 0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR)))
                                td->protectflag |= OB_LOCK_LOC;
 
                        td->ob = ob;
                                td->protectflag |= OB_LOCK_LOC;
 
                        td->ob = ob;
@@ -1703,7 +1706,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
                                td->ival = *(key->time);
                                /* abuse size and quat for min/max values */
                                td->flag |= TD_NO_EXT;
                                td->ival = *(key->time);
                                /* abuse size and quat for min/max values */
                                td->flag |= TD_NO_EXT;
-                               if (k==0) tx->size = NULL;
+                               if (k == 0) tx->size = NULL;
                                else tx->size = (key - 1)->time;
 
                                if (k == point->totkey - 1) tx->quat = NULL;
                                else tx->size = (key - 1)->time;
 
                                if (k == point->totkey - 1) tx->quat = NULL;
@@ -1738,15 +1741,15 @@ void flushTransParticles(TransInfo *t)
 
        /* we do transform in world space, so flush world space position
         * back to particle local space (only for hair particles) */
 
        /* we do transform in world space, so flush world space position
         * back to particle local space (only for hair particles) */
-       td= t->data;
-       for (i=0, point=edit->points; i<edit->totpoint; i++, point++, td++) {
+       td = t->data;
+       for (i = 0, point = edit->points; i < edit->totpoint; i++, point++, td++) {
                if (!(point->flag & PEP_TRANSFORM)) continue;
 
                if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
                        psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + i, mat);
                        invert_m4_m4(imat, mat);
 
                if (!(point->flag & PEP_TRANSFORM)) continue;
 
                if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
                        psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + i, mat);
                        invert_m4_m4(imat, mat);
 
-                       for (k=0, key=point->keys; k<point->totkey; k++, key++) {
+                       for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
                                copy_v3_v3(co, key->world_co);
                                mul_m4_v3(imat, co);
 
                                copy_v3_v3(co, key->world_co);
                                mul_m4_v3(imat, co);
 
@@ -1768,7 +1771,7 @@ void flushTransParticles(TransInfo *t)
 /* ********************* mesh ****************** */
 
 /* proportional distance based on connectivity  */
 /* ********************* mesh ****************** */
 
 /* proportional distance based on connectivity  */
-#define THRESHOLDFACTOR (1.0f-0.0001f)
+#define THRESHOLDFACTOR (1.0f - 0.0001f)
 
 /* I did this wrong, it should be a breadth-first search
  * but instead it's a depth-first search, fudged
 
 /* I did this wrong, it should be a breadth-first search
  * but instead it's a depth-first search, fudged
@@ -1778,10 +1781,10 @@ static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[][3], f
 {
        BMVert **queue = NULL;
        float *dqueue = NULL;
 {
        BMVert **queue = NULL;
        float *dqueue = NULL;
-       int *tots = MEM_callocN(sizeof(int)*em->bm->totvert, "tots editmesh_set_connectivity_distance");
+       int *tots = MEM_callocN(sizeof(int) * em->bm->totvert, "tots editmesh_set_connectivity_distance");
        BLI_array_declare(queue);
        BLI_array_declare(dqueue);
        BLI_array_declare(queue);
        BLI_array_declare(dqueue);
-       SmallHash svisit, *visit=&svisit;
+       SmallHash svisit, *visit = &svisit;
        BMVert *v;
        BMIter viter;
        int i, start;
        BMVert *v;
        BMIter viter;
        int i, start;
@@ -1793,7 +1796,7 @@ static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[][3], f
        BLI_smallhash_init(visit);
 
        BM_ITER_MESH (v, &viter, em->bm, BM_VERTS_OF_MESH) {
        BLI_smallhash_init(visit);
 
        BM_ITER_MESH (v, &viter, em->bm, BM_VERTS_OF_MESH) {
-               if (BM_elem_flag_test(v, BM_ELEM_SELECT)==0 || BM_elem_flag_test(v, BM_ELEM_HIDDEN))
+               if (BM_elem_flag_test(v, BM_ELEM_SELECT) == 0 || BM_elem_flag_test(v, BM_ELEM_HIDDEN))
                        continue;
                        
                
                        continue;
                        
                
@@ -1846,7 +1849,7 @@ static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[][3], f
 
        BLI_smallhash_release(visit);
        
 
        BLI_smallhash_release(visit);
        
-       for (i=0; i<em->bm->totvert; i++) {
+       for (i = 0; i < em->bm->totvert; i++) {
                if (tots[i])
                        dists[i] /= (float)tots[i];
        }
                if (tots[i])
                        dists[i] /= (float)tots[i];
        }
@@ -1857,7 +1860,7 @@ static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[][3], f
 }
 
 /* loop-in-a-loop I know, but we need it! (ton) */
 }
 
 /* loop-in-a-loop I know, but we need it! (ton) */
- static void get_face_center(float cent_r[3], BMVert *eve)
+static void get_face_center(float cent_r[3], BMVert *eve)
 
 {
        BMFace *efa;
 
 {
        BMFace *efa;
@@ -1885,7 +1888,8 @@ static void get_edge_center(float cent_r[3], BMVert *eve)
 }
 
 /* way to overwrite what data is edited with transform */
 }
 
 /* way to overwrite what data is edited with transform */
-static void VertsToTransData(TransInfo *t, TransData *td, BMEditMesh *em, BMVert *eve, float *bweight)
+static void VertsToTransData(TransInfo *t, TransData *td, TransDataExtension *tx,
+                             BMEditMesh *em, BMVert *eve, float *bweight)
 {
        td->flag = 0;
        //if (key)
 {
        td->flag = 0;
        //if (key)
@@ -1895,7 +1899,7 @@ static void VertsToTransData(TransInfo *t, TransData *td, BMEditMesh *em, BMVert
 
        copy_v3_v3(td->center, td->loc);
 
 
        copy_v3_v3(td->center, td->loc);
 
-       if (t->around==V3D_LOCAL) {
+       if (t->around == V3D_LOCAL) {
                if (em->selectmode & SCE_SELECT_FACE)
                        get_face_center(td->center, eve);
                else if (em->selectmode & SCE_SELECT_EDGE)
                if (em->selectmode & SCE_SELECT_FACE)
                        get_face_center(td->center, eve);
                else if (em->selectmode & SCE_SELECT_EDGE)
@@ -1905,12 +1909,12 @@ static void VertsToTransData(TransInfo *t, TransData *td, BMEditMesh *em, BMVert
 
        // Setting normals
        copy_v3_v3(td->axismtx[2], eve->no);
 
        // Setting normals
        copy_v3_v3(td->axismtx[2], eve->no);
-       td->axismtx[0][0]               =
-               td->axismtx[0][1]       =
-               td->axismtx[0][2]       =
-               td->axismtx[1][0]       =
-               td->axismtx[1][1]       =
-               td->axismtx[1][2]       = 0.0f;
+       td->axismtx[0][0]        =
+           td->axismtx[0][1]    =
+           td->axismtx[0][2]    =
+           td->axismtx[1][0]    =
+           td->axismtx[1][1]    =
+           td->axismtx[1][2]    = 0.0f;
 
        td->ext = NULL;
        td->val = NULL;
 
        td->ext = NULL;
        td->val = NULL;
@@ -1919,21 +1923,32 @@ static void VertsToTransData(TransInfo *t, TransData *td, BMEditMesh *em, BMVert
                td->val = bweight;
                td->ival = bweight ? *(bweight) : 1.0f;
        }
                td->val = bweight;
                td->ival = bweight ? *(bweight) : 1.0f;
        }
+       else if (t->mode == TFM_SKIN_RESIZE) {
+               MVertSkin *vs = CustomData_bmesh_get(&em->bm->vdata,
+                                                    eve->head.data,
+                                                    CD_MVERT_SKIN);
+               /* skin node size */
+               td->ext = tx;
+               copy_v3_v3(tx->isize, vs->radius);
+               tx->size = vs->radius;
+               td->val = vs->radius;
+       }
 }
 
 static void createTransEditVerts(bContext *C, TransInfo *t)
 {
        ToolSettings *ts = CTX_data_tool_settings(C);
        TransData *tob = NULL;
 }
 
 static void createTransEditVerts(bContext *C, TransInfo *t)
 {
        ToolSettings *ts = CTX_data_tool_settings(C);
        TransData *tob = NULL;
+       TransDataExtension *tx = NULL;
        BMEditMesh *em = BMEdit_FromObject(t->obedit);
        BMesh *bm = em->bm;
        BMVert *eve;
        BMIter iter;
        BMVert *eve_act = NULL;
        BMEditMesh *em = BMEdit_FromObject(t->obedit);
        BMesh *bm = em->bm;
        BMVert *eve;
        BMIter iter;
        BMVert *eve_act = NULL;
-       float *mappedcos = NULL, *quats= NULL;
+       float *mappedcos = NULL, *quats = NULL;
        float mtx[3][3], smtx[3][3], (*defmats)[3][3] = NULL, (*defcos)[3] = NULL;
        float mtx[3][3], smtx[3][3], (*defmats)[3][3] = NULL, (*defcos)[3] = NULL;
-       float *dists=NULL;
-       int count=0, countsel=0, a, totleft;
+       float *dists = NULL;
+       int count = 0, countsel = 0, a, totleft;
        int propmode = (t->flag & T_PROP_EDIT) ? (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) : 0;
        int mirror = 0;
        char *selstate = NULL;
        int propmode = (t->flag & T_PROP_EDIT) ? (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) : 0;
        int mirror = 0;
        char *selstate = NULL;
@@ -1962,10 +1977,10 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
                BMEdge *eed;
 
                eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
                BMEdge *eed;
 
                eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
-               for ( ; eve; eve=BM_iter_step(&iter)) BM_elem_flag_disable(eve, BM_ELEM_TAG);
+               for (; eve; eve = BM_iter_step(&iter)) BM_elem_flag_disable(eve, BM_ELEM_TAG);
 
                eed = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL);
 
                eed = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL);
-               for ( ; eed; eed=BM_iter_step(&iter)) {
+               for (; eed; eed = BM_iter_step(&iter)) {
                        if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
                                BM_elem_flag_enable(eed->v1, BM_ELEM_TAG);
                                BM_elem_flag_enable(eed->v2, BM_ELEM_TAG);
                        if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
                                BM_elem_flag_enable(eed->v1, BM_ELEM_TAG);
                                BM_elem_flag_enable(eed->v2, BM_ELEM_TAG);
@@ -1975,16 +1990,16 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
        else {
                BMFace *efa;
                eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
        else {
                BMFace *efa;
                eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
-               for ( ; eve; eve=BM_iter_step(&iter)) BM_elem_flag_disable(eve, BM_ELEM_TAG);
+               for (; eve; eve = BM_iter_step(&iter)) BM_elem_flag_disable(eve, BM_ELEM_TAG);
 
                efa = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL);
 
                efa = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL);
-               for ( ; efa; efa=BM_iter_step(&iter)) {
+               for (; efa; efa = BM_iter_step(&iter)) {
                        if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
                                BMIter liter;
                                BMLoop *l;
 
                                l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, efa);
                        if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
                                BMIter liter;
                                BMLoop *l;
 
                                l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, efa);
-                               for (; l; l=BM_iter_step(&liter)) {
+                               for (; l; l = BM_iter_step(&liter)) {
                                        BM_elem_flag_enable(l->v, BM_ELEM_TAG);
                                }
                        }
                                        BM_elem_flag_enable(l->v, BM_ELEM_TAG);
                                }
                        }
@@ -1996,7 +2011,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
         * verts*/
        selstate = MEM_callocN(sizeof(*selstate) * bm->totvert, __func__);
        eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
         * verts*/
        selstate = MEM_callocN(sizeof(*selstate) * bm->totvert, __func__);
        eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
-       for (a=0; eve; eve=BM_iter_step(&iter), a++) {
+       for (a = 0; eve; eve = BM_iter_step(&iter), a++) {
                if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
                        if (BM_elem_flag_test(eve, BM_ELEM_TAG)) {
                                selstate[a] = 1;
                if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
                        if (BM_elem_flag_test(eve, BM_ELEM_TAG)) {
                                selstate[a] = 1;
@@ -2029,7 +2044,11 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
        }
        else t->total = countsel;
 
        }
        else t->total = countsel;
 
-       tob= t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Mesh EditMode)");
+       tob = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mesh EditMode)");
+       if (t->mode == TFM_SKIN_RESIZE) {
+               tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension),
+                                         "TransObData ext");
+       }
 
        copy_m3_m4(mtx, t->obedit->obmat);
        invert_m3_m3(smtx, mtx);
 
        copy_m3_m4(mtx, t->obedit->obmat);
        invert_m3_m3(smtx, mtx);
@@ -2039,19 +2058,19 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
        }
 
        /* detect CrazySpace [tm] */
        }
 
        /* detect CrazySpace [tm] */
-       if (modifiers_getCageIndex(t->scene, t->obedit, NULL, 1)>=0) {
+       if (modifiers_getCageIndex(t->scene, t->obedit, NULL, 1) >= 0) {
                if (modifiers_isCorrectableDeformed(t->obedit)) {
                        /* check if we can use deform matrices for modifier from the
                         * start up to stack, they are more accurate than quats */
                if (modifiers_isCorrectableDeformed(t->obedit)) {
                        /* check if we can use deform matrices for modifier from the
                         * start up to stack, they are more accurate than quats */
-                       totleft= editbmesh_get_first_deform_matrices(t->scene, t->obedit, em, &defmats, &defcos);
+                       totleft = editbmesh_get_first_deform_matrices(t->scene, t->obedit, em, &defmats, &defcos);
 
                        /* if we still have more modifiers, also do crazyspace
                         * correction with quats, relative to the coordinates after
                         * the modifiers that support deform matrices (defcos) */
                        if (totleft > 0) {
 
                        /* if we still have more modifiers, also do crazyspace
                         * correction with quats, relative to the coordinates after
                         * the modifiers that support deform matrices (defcos) */
                        if (totleft > 0) {
-                               mappedcos= crazyspace_get_mapped_editverts(t->scene, t->obedit);
-                               quats= MEM_mallocN((t->total)*sizeof(float)*4, "crazy quats");
-                               crazyspace_set_quats_editmesh(em, (float*)defcos, mappedcos, quats); /* BMESH_TODO, abuses vertex index, should use an int array */
+                               mappedcos = crazyspace_get_mapped_editverts(t->scene, t->obedit);
+                               quats = MEM_mallocN((t->total) * sizeof(float) * 4, "crazy quats");
+                               crazyspace_set_quats_editmesh(em, (float *)defcos, mappedcos, quats); /* BMESH_TODO, abuses vertex index, should use an int array */
                                if (mappedcos)
                                        MEM_freeN(mappedcos);
                        }
                                if (mappedcos)
                                        MEM_freeN(mappedcos);
                        }
@@ -2064,8 +2083,8 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
        /* find out which half we do */
        if (mirror) {
                eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
        /* find out which half we do */
        if (mirror) {
                eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
-               for (a=0; eve; eve=BM_iter_step(&iter), a++) {
-                       if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && selstate[a] && eve->co[0]!=0.0f) {
+               for (a = 0; eve; eve = BM_iter_step(&iter), a++) {
+                       if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && selstate[a] && eve->co[0] != 0.0f) {
                                if (eve->co[0] < 0.0f) {
                                        t->mirror = -1;
                                        mirror = -1;
                                if (eve->co[0] < 0.0f) {
                                        t->mirror = -1;
                                        mirror = -1;
@@ -2076,12 +2095,14 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
        }
 
        eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
        }
 
        eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
-       for (a=0; eve; eve=BM_iter_step(&iter), a++) {
+       for (a = 0; eve; eve = BM_iter_step(&iter), a++) {
                if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
                        if (propmode || selstate[a]) {
                                float *bweight = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_BWEIGHT);
                                
                if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
                        if (propmode || selstate[a]) {
                                float *bweight = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_BWEIGHT);
                                
-                               VertsToTransData(t, tob, em, eve, bweight);
+                               VertsToTransData(t, tob, tx, em, eve, bweight);
+                               if (tx)
+                                       tx++;
 
                                /* selected */
                                if (selstate[a]) tob->flag |= TD_SELECTED;
 
                                /* selected */
                                if (selstate[a]) tob->flag |= TD_SELECTED;
@@ -2105,11 +2126,11 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
 
                                        /* use both or either quat and defmat correction */
                                        if (quats && BM_elem_index_get(eve) != -1) {
 
                                        /* use both or either quat and defmat correction */
                                        if (quats && BM_elem_index_get(eve) != -1) {
-                                               quat_to_mat3(qmat, quats + 4*BM_elem_index_get(eve));
+                                               quat_to_mat3(qmat, quats + 4 * BM_elem_index_get(eve));
 
                                                if (defmats)
                                                        mul_serie_m3(mat, mtx, qmat, defmats[a],
 
                                                if (defmats)
                                                        mul_serie_m3(mat, mtx, qmat, defmats[a],
-                                                               NULL, NULL, NULL, NULL, NULL);
+                                                                    NULL, NULL, NULL, NULL, NULL);
                                                else
                                                        mul_m3_m3m3(mat, mtx, qmat);
                                        }
                                                else
                                                        mul_m3_m3m3(mat, mtx, qmat);
                                        }
@@ -2127,8 +2148,8 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
                                }
 
                                /* Mirror? */
                                }
 
                                /* Mirror? */
-                               if ((mirror>0 && tob->iloc[0]>0.0f) || (mirror<0 && tob->iloc[0]<0.0f)) {
-                                       BMVert *vmir= EDBM_verts_mirror_get(em, eve); //t->obedit, em, eve, tob->iloc, a);
+                               if ((mirror > 0 && tob->iloc[0] > 0.0f) || (mirror < 0 && tob->iloc[0] < 0.0f)) {
+                                       BMVert *vmir = EDBM_verts_mirror_get(em, eve); //t->obedit, em, eve, tob->iloc, a);
                                        if (vmir && vmir != eve) {
                                                tob->extra = vmir;
                                        }
                                        if (vmir && vmir != eve) {
                                                tob->extra = vmir;
                                        }
@@ -2140,7 +2161,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
        
        if (mirror != 0) {
                tob = t->data;
        
        if (mirror != 0) {
                tob = t->data;
-               for (a = 0; a < t->total; a++, tob++ ) {
+               for (a = 0; a < t->total; a++, tob++) {
                        if (ABS(tob->loc[0]) <= 0.00001f) {
                                tob->flag |= TD_MIRROR_EDGE;
                        }
                        if (ABS(tob->loc[0]) <= 0.00001f) {
                                tob->flag |= TD_MIRROR_EDGE;
                        }
@@ -2171,16 +2192,15 @@ void flushTransNodes(TransInfo *t)
        TransData2D *td;
 
        /* flush to 2d vector from internally used 3d vector */
        TransData2D *td;
 
        /* flush to 2d vector from internally used 3d vector */
-       for (a=0, td= t->data2d; a<t->total; a++, td++) {
-               td->loc2d[0]= td->loc[0];
-               td->loc2d[1]= td->loc[1];
+       for (a = 0, td = t->data2d; a < t->total; a++, td++) {
+               td->loc2d[0] = td->loc[0];
+               td->loc2d[1] = td->loc[1];
        }
        
        /* handle intersection with noodles */
        }
        
        /* handle intersection with noodles */
-       if (t->total==1) {
+       if (t->total == 1) {
                ED_node_link_intersect_test(t->sa, 1);
        }
                ED_node_link_intersect_test(t->sa, 1);
        }
-       
 }
 
 /* *** SEQUENCE EDITOR *** */
 }
 
 /* *** SEQUENCE EDITOR *** */
@@ -2192,11 +2212,11 @@ void flushTransNodes(TransInfo *t)
 
 void flushTransSeq(TransInfo *t)
 {
 
 void flushTransSeq(TransInfo *t)
 {
-       ListBase *seqbasep= BKE_sequencer_editing_get(t->scene, FALSE)->seqbasep; /* Editing null check already done */
+       ListBase *seqbasep = BKE_sequencer_editing_get(t->scene, FALSE)->seqbasep; /* Editing null check already done */
        int a, new_frame, old_start;
        int a, new_frame, old_start;
-       TransData *td= NULL;
-       TransData2D *td2d= NULL;
-       TransDataSeq *tdsq= NULL;
+       TransData *td = NULL;
+       TransData2D *td2d = NULL;
+       TransDataSeq *tdsq = NULL;
        Sequence *seq;
 
 
        Sequence *seq;
 
 
@@ -2204,43 +2224,43 @@ void flushTransSeq(TransInfo *t)
        /* prevent updating the same seq twice
         * if the transdata order is changed this will mess up
         * but so will TransDataSeq */
        /* prevent updating the same seq twice
         * if the transdata order is changed this will mess up
         * but so will TransDataSeq */
-       Sequence *seq_prev= NULL;
+       Sequence *seq_prev = NULL;
 
        /* flush to 2d vector from internally used 3d vector */
 
        /* flush to 2d vector from internally used 3d vector */
-       for (a=0, td= t->data, td2d= t->data2d; a<t->total; a++, td++, td2d++) {
-               tdsq= (TransDataSeq *)td->extra;
-               seq= tdsq->seq;
+       for (a = 0, td = t->data, td2d = t->data2d; a < t->total; a++, td++, td2d++) {
+               tdsq = (TransDataSeq *)td->extra;
+               seq = tdsq->seq;
                old_start = seq->start;
                old_start = seq->start;
-               new_frame= (int)floor(td2d->loc[0] + 0.5f);
+               new_frame = (int)floor(td2d->loc[0] + 0.5f);
 
                switch (tdsq->sel_flag) {
 
                switch (tdsq->sel_flag) {
-               case SELECT:
+                       case SELECT:
 #ifdef SEQ_TX_NESTED_METAS
 #ifdef SEQ_TX_NESTED_METAS
-                       if ((seq->depth != 0 || seq_tx_test(seq))) /* for meta's, their children move */
-                               seq->start= new_frame - tdsq->start_offset;
+                               if ((seq->depth != 0 || seq_tx_test(seq))) /* for meta's, their children move */
+                                       seq->start = new_frame - tdsq->start_offset;
 #else
 #else
-                       if (seq->type != SEQ_META && (seq->depth != 0 || seq_tx_test(seq))) /* for meta's, their children move */
-                               seq->start= new_frame - tdsq->start_offset;
+                               if (seq->type != SEQ_TYPE_META && (seq->depth != 0 || seq_tx_test(seq))) /* for meta's, their children move */
+                                       seq->start = new_frame - tdsq->start_offset;
 #endif
 #endif
-                       if (seq->depth==0) {
-                               seq->machine= (int)floor(td2d->loc[1] + 0.5f);
-                               CLAMP(seq->machine, 1, MAXSEQ);
-                       }
-                       break;
-               case SEQ_LEFTSEL: /* no vertical transform  */
-                       seq_tx_set_final_left(seq, new_frame);
-                       seq_tx_handle_xlimits(seq, tdsq->flag&SEQ_LEFTSEL, tdsq->flag&SEQ_RIGHTSEL);
-                       seq_single_fix(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */
-                       break;
-               case SEQ_RIGHTSEL: /* no vertical transform  */
-                       seq_tx_set_final_right(seq, new_frame);
-                       seq_tx_handle_xlimits(seq, tdsq->flag&SEQ_LEFTSEL, tdsq->flag&SEQ_RIGHTSEL);
-                       seq_single_fix(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */
-                       break;
+                               if (seq->depth == 0) {
+                                       seq->machine = (int)floor(td2d->loc[1] + 0.5f);
+                                       CLAMP(seq->machine, 1, MAXSEQ);
+                               }
+                               break;
+                       case SEQ_LEFTSEL: /* no vertical transform  */
+                               seq_tx_set_final_left(seq, new_frame);
+                               seq_tx_handle_xlimits(seq, tdsq->flag & SEQ_LEFTSEL, tdsq->flag & SEQ_RIGHTSEL);
+                               seq_single_fix(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */
+                               break;
+                       case SEQ_RIGHTSEL: /* no vertical transform  */
+                               seq_tx_set_final_right(seq, new_frame);
+                               seq_tx_handle_xlimits(seq, tdsq->flag & SEQ_LEFTSEL, tdsq->flag & SEQ_RIGHTSEL);
+                               seq_single_fix(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */
+                               break;
                }
 
                if (seq != seq_prev) {
                }
 
                if (seq != seq_prev) {
-                       if (seq->depth==0) {
+                       if (seq->depth == 0) {
                                /* Calculate this strip and all nested strips
                                 * children are ALWAYS transformed first
                                 * so we don't need to do this in another loop. */
                                /* Calculate this strip and all nested strips
                                 * children are ALWAYS transformed first
                                 * so we don't need to do this in another loop. */
@@ -2253,7 +2273,7 @@ void flushTransSeq(TransInfo *t)
                        if (tdsq->sel_flag == SELECT)
                                seq_offset_animdata(t->scene, seq, seq->start - old_start);
                }
                        if (tdsq->sel_flag == SELECT)
                                seq_offset_animdata(t->scene, seq, seq->start - old_start);
                }
-               seq_prev= seq;
+               seq_prev = seq;
        }
 
 
        }
 
 
@@ -2262,7 +2282,7 @@ void flushTransSeq(TransInfo *t)
 
                /* calc all meta's then effects [#27953] */
                for (seq = seqbasep->first; seq; seq = seq->next) {
 
                /* calc all meta's then effects [#27953] */
                for (seq = seqbasep->first; seq; seq = seq->next) {
-                       if (seq->type == SEQ_META && seq->flag & SELECT) {
+                       if (seq->type == SEQ_TYPE_META && seq->flag & SELECT) {
                                calc_sequence(t->scene, seq);
                        }
                }
                                calc_sequence(t->scene, seq);
                        }
                }
@@ -2275,14 +2295,14 @@ void flushTransSeq(TransInfo *t)
 
        /* need to do the overlap check in a new loop otherwise adjacent strips
         * will not be updated and we'll get false positives */
 
        /* need to do the overlap check in a new loop otherwise adjacent strips
         * will not be updated and we'll get false positives */
-       seq_prev= NULL;
-       for (a=0, td= t->data, td2d= t->data2d; a<t->total; a++, td++, td2d++) {
+       seq_prev = NULL;
+       for (a = 0, td = t->data, td2d = t->data2d; a < t->total; a++, td++, td2d++) {
 
 
-               tdsq= (TransDataSeq *)td->extra;
-               seq= tdsq->seq;
+               tdsq = (TransDataSeq *)td->extra;
+               seq = tdsq->seq;
 
                if (seq != seq_prev) {
 
                if (seq != seq_prev) {
-                       if (seq->depth==0) {
+                       if (seq->depth == 0) {
                                /* test overlap, displayes red outline */
                                seq->flag &= ~SEQ_OVERLAP;
                                if (seq_test_overlap(seqbasep, seq)) {
                                /* test overlap, displayes red outline */
                                seq->flag &= ~SEQ_OVERLAP;
                                if (seq_test_overlap(seqbasep, seq)) {
@@ -2290,7 +2310,7 @@ void flushTransSeq(TransInfo *t)
                                }
                        }
                }
                                }
                        }
                }
-               seq_prev= seq;
+               seq_prev = seq;
        }
 }
 
        }
 }
 
@@ -2306,8 +2326,8 @@ static void UVsToTransData(SpaceImage *sima, TransData *td, TransData2D *td2d, f
         * proportional editing to be consistent with the stretched uv coords
         * that are displayed. this also means that for display and numinput,
         * and when the the uv coords are flushed, these are converted each time */
         * proportional editing to be consistent with the stretched uv coords
         * that are displayed. this also means that for display and numinput,
         * and when the the uv coords are flushed, these are converted each time */
-       td2d->loc[0] = uv[0]*aspx;
-       td2d->loc[1] = uv[1]*aspy;
+       td2d->loc[0] = uv[0] * aspx;
+       td2d->loc[1] = uv[1] * aspy;
        td2d->loc[2] = 0.0f;
        td2d->loc2d = uv;
 
        td2d->loc[2] = 0.0f;
        td2d->loc2d = uv;
 
@@ -2319,14 +2339,14 @@ static void UVsToTransData(SpaceImage *sima, TransData *td, TransData2D *td2d, f
        memset(td->axismtx, 0, sizeof(td->axismtx));
        td->axismtx[2][2] = 1.0f;
 
        memset(td->axismtx, 0, sizeof(td->axismtx));
        td->axismtx[2][2] = 1.0f;
 
-       td->ext= NULL; td->val= NULL;
+       td->ext = NULL; td->val = NULL;
 
        if (selected) {
                td->flag |= TD_SELECTED;
 
        if (selected) {
                td->flag |= TD_SELECTED;
-               td->dist= 0.0;
+               td->dist = 0.0;
        }
        else {
        }
        else {
-               td->dist= MAXFLOAT;
+               td->dist = MAXFLOAT;
        }
        unit_m3(td->mtx);
        unit_m3(td->smtx);
        }
        unit_m3(td->mtx);
        unit_m3(td->smtx);
@@ -2345,14 +2365,14 @@ static void createTransUVs(bContext *C, TransInfo *t)
        BMFace *efa;
        BMLoop *l;
        BMIter iter, liter;
        BMFace *efa;
        BMLoop *l;
        BMIter iter, liter;
-       int count=0, countsel=0;
+       int count = 0, countsel = 0;
        int propmode = t->flag & T_PROP_EDIT;
 
        if (!ED_space_image_show_uvedit(sima, t->obedit)) return;
 
        /* count */
        BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
        int propmode = t->flag & T_PROP_EDIT;
 
        if (!ED_space_image_show_uvedit(sima, t->obedit)) return;
 
        /* count */
        BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
-               tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
+               tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
 
                if (!uvedit_face_visible_test(scene, ima, efa, tf)) {
                        BM_elem_flag_disable(efa, BM_ELEM_TAG);
 
                if (!uvedit_face_visible_test(scene, ima, efa, tf)) {
                        BM_elem_flag_disable(efa, BM_ELEM_TAG);
@@ -2369,20 +2389,20 @@ static void createTransUVs(bContext *C, TransInfo *t)
                }
        }
 
                }
        }
 
-        /* note: in prop mode we need at least 1 selected */
-       if (countsel==0) return;
+       /* note: in prop mode we need at least 1 selected */
+       if (countsel == 0) return;
 
 
-       t->total= (propmode)? count: countsel;
-       t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(UV Editing)");
+       t->total = (propmode) ? count : countsel;
+       t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(UV Editing)");
        /* for each 2d uv coord a 3d vector is allocated, so that they can be
         * treated just as if they were 3d verts */
        /* for each 2d uv coord a 3d vector is allocated, so that they can be
         * treated just as if they were 3d verts */
-       t->data2d= MEM_callocN(t->total*sizeof(TransData2D), "TransObData2D(UV Editing)");
+       t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransObData2D(UV Editing)");
 
        if (sima->flag & SI_CLIP_UV)
                t->flag |= T_CLIP_UV;
 
 
        if (sima->flag & SI_CLIP_UV)
                t->flag |= T_CLIP_UV;
 
-       td= t->data;
-       td2d= t->data2d;
+       td = t->data;
+       td2d = t->data2d;
 
        BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
                if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
 
        BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
                if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
@@ -2410,17 +2430,17 @@ void flushTransUVs(TransInfo *t)
 
        ED_space_image_uv_aspect(sima, &aspx, &aspy);
        ED_space_image_size(sima, &width, &height);
 
        ED_space_image_uv_aspect(sima, &aspx, &aspy);
        ED_space_image_size(sima, &width, &height);
-       invx= 1.0f/aspx;
-       invy= 1.0f/aspy;
+       invx = 1.0f / aspx;
+       invy = 1.0f / aspy;
 
        /* flush to 2d vector from internally used 3d vector */
 
        /* flush to 2d vector from internally used 3d vector */
-       for (a=0, td= t->data2d; a<t->total; a++, td++) {
-               td->loc2d[0]= td->loc[0]*invx;
-               td->loc2d[1]= td->loc[1]*invy;
+       for (a = 0, td = t->data2d; a < t->total; a++, td++) {
+               td->loc2d[0] = td->loc[0] * invx;
+               td->loc2d[1] = td->loc[1] * invy;
 
                if ((sima->flag & SI_PIXELSNAP) && (t->state != TRANS_CANCEL)) {
 
                if ((sima->flag & SI_PIXELSNAP) && (t->state != TRANS_CANCEL)) {
-                       td->loc2d[0]= (float)floor(width*td->loc2d[0] + 0.5f)/width;
-                       td->loc2d[1]= (float)floor(height*td->loc2d[1] + 0.5f)/height;
+                       td->loc2d[0] = (float)floor(width * td->loc2d[0] + 0.5f) / width;
+                       td->loc2d[1] = (float)floor(height * td->loc2d[1] + 0.5f) / height;
                }
        }
 }
                }
        }
 }
@@ -2428,46 +2448,46 @@ void flushTransUVs(TransInfo *t)
 int clipUVTransform(TransInfo *t, float *vec, int resize)
 {
        TransData *td;
 int clipUVTransform(TransInfo *t, float *vec, int resize)
 {
        TransData *td;
-       int a, clipx=1, clipy=1;
+       int a, clipx = 1, clipy = 1;
        float aspx, aspy, min[2], max[2];
 
        ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
        float aspx, aspy, min[2], max[2];
 
        ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
-       min[0]= min[1]= 0.0f;
-       max[0]= aspx; max[1]= aspy;
+       min[0] = min[1] = 0.0f;
+       max[0] = aspx; max[1] = aspy;
 
 
-       for (a=0, td= t->data; a<t->total; a++, td++) {
+       for (a = 0, td = t->data; a < t->total; a++, td++) {
                DO_MINMAX2(td->loc, min, max);
        }
 
        if (resize) {
                DO_MINMAX2(td->loc, min, max);
        }
 
        if (resize) {
-               if (min[0] < 0.0f && t->center[0] > 0.0f && t->center[0] < aspx*0.5f)
-                       vec[0] *= t->center[0]/(t->center[0] - min[0]);
+               if (min[0] < 0.0f && t->center[0] > 0.0f && t->center[0] < aspx * 0.5f)
+                       vec[0] *= t->center[0] / (t->center[0] - min[0]);
                else if (max[0] > aspx && t->center[0] < aspx)
                else if (max[0] > aspx && t->center[0] < aspx)
-                       vec[0] *= (t->center[0] - aspx)/(t->center[0] - max[0]);
+                       vec[0] *= (t->center[0] - aspx) / (t->center[0] - max[0]);
                else
                else
-                       clipx= 0;
+                       clipx = 0;
 
 
-               if (min[1] < 0.0f && t->center[1] > 0.0f && t->center[1] < aspy*0.5f)
-                       vec[1] *= t->center[1]/(t->center[1] - min[1]);
+               if (min[1] < 0.0f && t->center[1] > 0.0f && t->center[1] < aspy * 0.5f)
+                       vec[1] *= t->center[1] / (t->center[1] - min[1]);
                else if (max[1] > aspy && t->center[1] < aspy)
                else if (max[1] > aspy && t->center[1] < aspy)
-                       vec[1] *= (t->center[1] - aspy)/(t->center[1] - max[1]);
+                       vec[1] *= (t->center[1] - aspy) / (t->center[1] - max[1]);
                else
                else
-                       clipy= 0;
+                       clipy = 0;
        }
        else {
                if (min[0] < 0.0f)
                        vec[0] -= min[0];
                else if (max[0] > aspx)
        }
        else {
                if (min[0] < 0.0f)
                        vec[0] -= min[0];
                else if (max[0] > aspx)
-                       vec[0] -= max[0]-aspx;
+                       vec[0] -= max[0] - aspx;
                else
                else
-                       clipx= 0;
+                       clipx = 0;
 
                if (min[1] < 0.0f)
                        vec[1] -= min[1];
                else if (max[1] > aspy)
 
                if (min[1] < 0.0f)
                        vec[1] -= min[1];
                else if (max[1] > aspy)
-                       vec[1] -= max[1]-aspy;
+                       vec[1] -= max[1] - aspy;
                else
                else
-                       clipy= 0;
+                       clipy = 0;
        }
 
        return (clipx || clipy);
        }
 
        return (clipx || clipy);
@@ -2492,7 +2512,7 @@ static short FrameOnMouseSide(char side, float frame, float cframe)
 
 static void createTransNlaData(bContext *C, TransInfo *t)
 {
 
 static void createTransNlaData(bContext *C, TransInfo *t)
 {
-       Scene *scene= t->scene;
+       Scene *scene = t->scene;
        SpaceNla *snla = NULL;
        TransData *td = NULL;
        TransDataNla *tdn = NULL;
        SpaceNla *snla = NULL;
        TransData *td = NULL;
        TransDataNla *tdn = NULL;
@@ -2502,7 +2522,7 @@ static void createTransNlaData(bContext *C, TransInfo *t)
        bAnimListElem *ale;
        int filter;
        
        bAnimListElem *ale;
        int filter;
        
-       int count=0;
+       int count = 0;
        
        /* determine what type of data we are operating on */
        if (ANIM_animdata_get_context(C, &ac) == 0)
        
        /* determine what type of data we are operating on */
        if (ANIM_animdata_get_context(C, &ac) == 0)
@@ -2510,7 +2530,7 @@ static void createTransNlaData(bContext *C, TransInfo *t)
        snla = (SpaceNla *)ac.sl;
        
        /* filter data */
        snla = (SpaceNla *)ac.sl;
        
        /* filter data */
-       filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
+       filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
        
        /* which side of the current frame should be allowed */
        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
        
        /* which side of the current frame should be allowed */
@@ -2519,7 +2539,7 @@ static void createTransNlaData(bContext *C, TransInfo *t)
                float xmouse, ymouse;
                
                UI_view2d_region_to_view(&ac.ar->v2d, t->imval[0], t->imval[1], &xmouse, &ymouse);
                float xmouse, ymouse;
                
                UI_view2d_region_to_view(&ac.ar->v2d, t->imval[0], t->imval[1], &xmouse, &ymouse);
-               t->frame_side= (xmouse > CFRA) ? 'R' : 'L';
+               t->frame_side = (xmouse > CFRA) ? 'R' : 'L';
        }
        else {
                /* normal transform - both sides of current frame are considered */
        }
        else {
                /* normal transform - both sides of current frame are considered */
@@ -2527,15 +2547,15 @@ static void createTransNlaData(bContext *C, TransInfo *t)
        }
        
        /* loop 1: count how many strips are selected (consider each strip as 2 points) */
        }
        
        /* loop 1: count how many strips are selected (consider each strip as 2 points) */
-       for (ale= anim_data.first; ale; ale= ale->next) {
-               NlaTrack *nlt= (NlaTrack *)ale->data;
+       for (ale = anim_data.first; ale; ale = ale->next) {
+               NlaTrack *nlt = (NlaTrack *)ale->data;
                NlaStrip *strip;
                
                /* make some meta-strips for chains of selected strips */
                BKE_nlastrips_make_metas(&nlt->strips, 1);
                
                /* only consider selected strips */
                NlaStrip *strip;
                
                /* make some meta-strips for chains of selected strips */
                BKE_nlastrips_make_metas(&nlt->strips, 1);
                
                /* only consider selected strips */
-               for (strip= nlt->strips.first; strip; strip= strip->next) {
+               for (strip = nlt->strips.first; strip; strip = strip->next) {
                        // TODO: we can make strips have handles later on...
                        /* transition strips can't get directly transformed */
                        if (strip->type != NLASTRIP_TYPE_TRANSITION) {
                        // TODO: we can make strips have handles later on...
                        /* transition strips can't get directly transformed */
                        if (strip->type != NLASTRIP_TYPE_TRANSITION) {
@@ -2555,24 +2575,24 @@ static void createTransNlaData(bContext *C, TransInfo *t)
        }
        
        /* allocate memory for data */
        }
        
        /* allocate memory for data */
-       t->total= count;
+       t->total = count;
        
        
-       t->data= MEM_callocN(t->total*sizeof(TransData), "TransData(NLA Editor)");
-       td= t->data;
-       t->customData= MEM_callocN(t->total*sizeof(TransDataNla), "TransDataNla (NLA Editor)");
-       tdn= t->customData;
+       t->data = MEM_callocN(t->total * sizeof(TransData), "TransData(NLA Editor)");
+       td = t->data;
+       t->customData = MEM_callocN(t->total * sizeof(TransDataNla), "TransDataNla (NLA Editor)");
+       tdn = t->customData;
        t->flag |= T_FREE_CUSTOMDATA;
        
        /* loop 2: build transdata array */
        t->flag |= T_FREE_CUSTOMDATA;
        
        /* loop 2: build transdata array */
-       for (ale= anim_data.first; ale; ale= ale->next) {
+       for (ale = anim_data.first; ale; ale = ale->next) {
                /* only if a real NLA-track */
                if (ale->type == ANIMTYPE_NLATRACK) {
                        AnimData *adt = ale->adt;
                /* only if a real NLA-track */
                if (ale->type == ANIMTYPE_NLATRACK) {
                        AnimData *adt = ale->adt;
-                       NlaTrack *nlt= (NlaTrack *)ale->data;
+                       NlaTrack *nlt = (NlaTrack *)ale->data;
                        NlaStrip *strip;
                        
                        /* only consider selected strips */
                        NlaStrip *strip;
                        
                        /* only consider selected strips */
-                       for (strip= nlt->strips.first; strip; strip= strip->next) {
+                       for (strip = nlt->strips.first; strip; strip = strip->next) {
                                // TODO: we can make strips have handles later on...
                                /* transition strips can't get directly transformed */
                                if (strip->type != NLASTRIP_TYPE_TRANSITION) {
                                // TODO: we can make strips have handles later on...
                                /* transition strips can't get directly transformed */
                                if (strip->type != NLASTRIP_TYPE_TRANSITION) {
@@ -2582,37 +2602,37 @@ static void createTransNlaData(bContext *C, TransInfo *t)
                                                 *      - td structs are transform-elements operated on by the transform system
                                                 *        and represent a single handle. The storage/pointer used (val or loc) depends on
                                                 *        whether we're scaling or transforming. Ultimately though, the handles
                                                 *      - td structs are transform-elements operated on by the transform system
                                                 *        and represent a single handle. The storage/pointer used (val or loc) depends on
                                                 *        whether we're scaling or transforming. Ultimately though, the handles
-                                                *        the td writes to will simply be a dummy in tdn
+                                                *    the td writes to will simply be a dummy in tdn
                                                 *      - for each strip being transformed, a single tdn struct is used, so in some
                                                 *        cases, there will need to be 1 of these tdn elements in the array skipped...
                                                 */
                                                float center[3], yval;
                                                
                                                /* firstly, init tdn settings */
                                                 *      - for each strip being transformed, a single tdn struct is used, so in some
                                                 *        cases, there will need to be 1 of these tdn elements in the array skipped...
                                                 */
                                                float center[3], yval;
                                                
                                                /* firstly, init tdn settings */
-                                               tdn->id= ale->id;
-                                               tdn->oldTrack= tdn->nlt= nlt;
-                                               tdn->strip= strip;
-                                               tdn->trackIndex= BLI_findindex(&adt->nla_tracks, nlt);
-                                               
-                                               yval= (float)(tdn->trackIndex * NLACHANNEL_STEP(snla));
-                                               
-                                               tdn->h1[0]= strip->start;
-                                               tdn->h1[1]= yval;
-                                               tdn->h2[0]= strip->end;
-                                               tdn->h2[1]= yval;
-                                               
-                                               center[0]= (float)CFRA;
-                                               center[1]= yval;
-                                               center[2]= 0.0f;
+                                               tdn->id = ale->id;
+                                               tdn->oldTrack = tdn->nlt = nlt;
+                                               tdn->strip = strip;
+                                               tdn->trackIndex = BLI_findindex(&adt->nla_tracks, nlt);
+
+                                               yval = (float)(tdn->trackIndex * NLACHANNEL_STEP(snla));
+
+                                               tdn->h1[0] = strip->start;
+                                               tdn->h1[1] = yval;
+                                               tdn->h2[0] = strip->end;
+                                               tdn->h2[1] = yval;
+
+                                               center[0] = (float)CFRA;
+                                               center[1] = yval;
+                                               center[2] = 0.0f;
                                                
                                                /* set td's based on which handles are applicable */
                                                if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA)) {
                                                        /* just set tdn to assume that it only has one handle for now */
                                                
                                                /* set td's based on which handles are applicable */
                                                if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA)) {
                                                        /* just set tdn to assume that it only has one handle for now */
-                                                       tdn->handle= -1;
+                                                       tdn->handle = -1;
                                                        
                                                        /* now, link the transform data up to this data */
                                                        if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) {
                                                        
                                                        /* now, link the transform data up to this data */
                                                        if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) {
-                                                               td->loc= tdn->h1;
+                                                               td->loc = tdn->h1;
                                                                copy_v3_v3(td->iloc, tdn->h1);
                                                                
                                                                /* store all the other gunk that is required by transform */
                                                                copy_v3_v3(td->iloc, tdn->h1);
                                                                
                                                                /* store all the other gunk that is required by transform */
@@ -2620,30 +2640,30 @@ static void createTransNlaData(bContext *C, TransInfo *t)
                                                                memset(td->axismtx, 0, sizeof(td->axismtx));
                                                                td->axismtx[2][2] = 1.0f;
                                                                
                                                                memset(td->axismtx, 0, sizeof(td->axismtx));
                                                                td->axismtx[2][2] = 1.0f;
                                                                
-                                                               td->ext= NULL; td->val= NULL;
+                                                               td->ext = NULL; td->val = NULL;
                                                                
                                                                td->flag |= TD_SELECTED;
                                                                
                                                                td->flag |= TD_SELECTED;
-                                                               td->dist= 0.0f;
+                                                               td->dist = 0.0f;
                                                                
                                                                unit_m3(td->mtx);
                                                                unit_m3(td->smtx);
                                                        }
                                                        else {
                                                                /* time scaling only needs single value */
                                                                
                                                                unit_m3(td->mtx);
                                                                unit_m3(td->smtx);
                                                        }
                                                        else {
                                                                /* time scaling only needs single value */
-                                                               td->val= &tdn->h1[0];
-                                                               td->ival= tdn->h1[0];
+                                                               td->val = &tdn->h1[0];
+                                                               td->ival = tdn->h1[0];
                                                        }
                                                        
                                                        }
                                                        
-                                                       td->extra= tdn;
+                                                       td->extra = tdn;
                                                        td++;
                                                }
                                                if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) {
                                                        /* if tdn is already holding the start handle, then we're doing both, otherwise, only end */
                                                        td++;
                                                }
                                                if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) {
                                                        /* if tdn is already holding the start handle, then we're doing both, otherwise, only end */
-                                                       tdn->handle= (tdn->handle) ? 2 : 1;
+                                                       tdn->handle = (tdn->handle) ? 2 : 1;
                                                        
                                                        /* now, link the transform data up to this data */
                                                        if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) {
                                                        
                                                        /* now, link the transform data up to this data */
                                                        if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) {
-                                                               td->loc= tdn->h2;
+                                                               td->loc = tdn->h2;
                                                                copy_v3_v3(td->iloc, tdn->h2);
                                                                
                                                                /* store all the other gunk that is required by transform */
                                                                copy_v3_v3(td->iloc, tdn->h2);
                                                                
                                                                /* store all the other gunk that is required by transform */
@@ -2651,21 +2671,21 @@ static void createTransNlaData(bContext *C, TransInfo *t)
                                                                memset(td->axismtx, 0, sizeof(td->axismtx));
                                                                td->axismtx[2][2] = 1.0f;
                                                                
                                                                memset(td->axismtx, 0, sizeof(td->axismtx));
                                                                td->axismtx[2][2] = 1.0f;
                                                                
-                                                               td->ext= NULL; td->val= NULL;
+                                                               td->ext = NULL; td->val = NULL;
                                                                
                                                                td->flag |= TD_SELECTED;
                                                                
                                                                td->flag |= TD_SELECTED;
-                                                               td->dist= 0.0f;
+                                                               td->dist = 0.0f;
                                                                
                                                                unit_m3(td->mtx);
                                                                unit_m3(td->smtx);
                                                        }
                                                        else {
                                                                /* time scaling only needs single value */
                                                                
                                                                unit_m3(td->mtx);
                                                                unit_m3(td->smtx);
                                                        }
                                                        else {
                                                                /* time scaling only needs single value */
-                                                               td->val= &tdn->h2[0];
-                                                               td->ival= tdn->h2[0];
+                                                               td->val = &tdn->h2[0];
+                                                               td->ival = tdn->h2[0];
                                                        }
                                                        
                                                        }
                                                        
-                                                       td->extra= tdn;
+                                                       td->extra = tdn;
                                                        td++;
                                                }
                                                
                                                        td++;
                                                }
                                                
@@ -2693,11 +2713,11 @@ static void createTransNlaData(bContext *C, TransInfo *t)
  * It also makes sure gp-frames are still stored in chronological order after
  * transform.
  */
  * It also makes sure gp-frames are still stored in chronological order after
  * transform.
  */
-static void posttrans_gpd_clean (bGPdata *gpd)
+static void posttrans_gpd_clean(bGPdata *gpd)
 {
        bGPDlayer *gpl;
        
 {
        bGPDlayer *gpl;
        
-       for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
+       for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
                ListBase sel_buffer = {NULL, NULL};
                bGPDframe *gpf, *gpfn;
                bGPDframe *gfs, *gfsn;
                ListBase sel_buffer = {NULL, NULL};
                bGPDframe *gpf, *gpfn;
                bGPDframe *gfs, *gfsn;
@@ -2705,9 +2725,9 @@ static void posttrans_gpd_clean (bGPdata *gpd)
                /* loop 1: loop through and isolate selected gp-frames to buffer
                 * (these need to be sorted as they are isolated)
                 */
                /* loop 1: loop through and isolate selected gp-frames to buffer
                 * (these need to be sorted as they are isolated)
                 */
-               for (gpf= gpl->frames.first; gpf; gpf= gpfn) {
-                       short added= 0;
-                       gpfn= gpf->next;
+               for (gpf = gpl->frames.first; gpf; gpf = gpfn) {
+                       short added = 0;
+                       gpfn = gpf->next;
                        
                        if (gpf->flag & GP_FRAME_SELECT) {
                                BLI_remlink(&gpl->frames, gpf);
                        
                        if (gpf->flag & GP_FRAME_SELECT) {
                                BLI_remlink(&gpl->frames, gpf);
@@ -2716,11 +2736,11 @@ static void posttrans_gpd_clean (bGPdata *gpd)
                                 * - go backwards as most frames will still be in order,
                                 *   so doing it this way will be faster
                                 */
                                 * - go backwards as most frames will still be in order,
                                 *   so doing it this way will be faster
                                 */
-                               for (gfs= sel_buffer.last; gfs; gfs= gfs->prev) {
+                               for (gfs = sel_buffer.last; gfs; gfs = gfs->prev) {
                                        /* if current (gpf) occurs after this one in buffer, add! */
                                        if (gfs->framenum < gpf->framenum) {
                                                BLI_insertlinkafter(&sel_buffer, gfs, gpf);
                                        /* if current (gpf) occurs after this one in buffer, add! */
                                        if (gfs->framenum < gpf->framenum) {
                                                BLI_insertlinkafter(&sel_buffer, gfs, gpf);
-                                               added= 1;
+                                               added = 1;
                                                break;
                                        }
                                }
                                                break;
                                        }
                                }
@@ -2735,19 +2755,19 @@ static void posttrans_gpd_clean (bGPdata *gpd)
                
                /* if all were selected (i.e. gpl->frames is empty), then just transfer sel-buf over */
                if (gpl->frames.first == NULL) {
                
                /* if all were selected (i.e. gpl->frames is empty), then just transfer sel-buf over */
                if (gpl->frames.first == NULL) {
-                       gpl->frames.first= sel_buffer.first;
-                       gpl->frames.last= sel_buffer.last;
+                       gpl->frames.first = sel_buffer.first;
+                       gpl->frames.last = sel_buffer.last;
                        
                        continue;
                }
                
                /* loop 2: remove duplicates of frames in buffers */
                        
                        continue;
                }
                
                /* loop 2: remove duplicates of frames in buffers */
-               for (gpf= gpl->frames.first; gpf && sel_buffer.first; gpf= gpfn) {
-                       gpfn= gpf->next;
+               for (gpf = gpl->frames.first; gpf && sel_buffer.first; gpf = gpfn) {
+                       gpfn = gpf->next;
                        
                        /* loop through sel_buffer, emptying stuff from front of buffer if ok */
                        
                        /* loop through sel_buffer, emptying stuff from front of buffer if ok */
-                       for (gfs= sel_buffer.first; gfs && gpf; gfs= gfsn) {
-                               gfsn= gfs->next;
+                       for (gfs = sel_buffer.first; gfs && gpf; gfs = gfsn) {
+                               gfsn = gfs->next;
                                
                                /* if this buffer frame needs to go before current, add it! */
                                if (gfs->framenum < gpf->framenum) {
                                
                                /* if this buffer frame needs to go before current, add it! */
                                if (gfs->framenum < gpf->framenum) {
@@ -2768,8 +2788,8 @@ static void posttrans_gpd_clean (bGPdata *gpd)
                }
                
                /* if anything is still in buffer, append to end */
                }
                
                /* if anything is still in buffer, append to end */
-               for (gfs= sel_buffer.first; gfs; gfs= gfsn) {
-                       gfsn= gfs->next;
+               for (gfs = sel_buffer.first; gfs; gfs = gfsn) {
+                       gfsn = gfs->next;
                        
                        BLI_remlink(&sel_buffer, gfs);
                        BLI_addtail(&gpl->frames, gfs);
                        
                        BLI_remlink(&sel_buffer, gfs);
                        BLI_addtail(&gpl->frames, gfs);
@@ -2777,21 +2797,114 @@ static void posttrans_gpd_clean (bGPdata *gpd)
        }
 }
 
        }
 }
 
+
+/* Called by special_aftertrans_update to make sure selected gp-frames replace
+ * any other gp-frames which may reside on that frame (that are not selected).
+ * It also makes sure sorted are still stored in chronological order after
+ * transform.
+ */
+static void posttrans_mask_clean(Mask *mask)
+{
+       MaskLayer *masklay;
+
+       for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+               ListBase sel_buffer = {NULL, NULL};
+               MaskLayerShape *masklay_shape, *masklay_shape_new;
+               MaskLayerShape *masklay_shape_sort, *masklay_shape_sort_new;
+
+               /* loop 1: loop through and isolate selected gp-frames to buffer
+                * (these need to be sorted as they are isolated)
+                */
+               for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape_new) {
+                       short added = 0;
+                       masklay_shape_new = masklay_shape->next;
+
+                       if (masklay_shape->flag & GP_FRAME_SELECT) {
+                               BLI_remlink(&masklay->splines_shapes, masklay_shape);
+
+                               /* find place to add them in buffer
+                                * - go backwards as most frames will still be in order,
+                                *   so doing it this way will be faster
+                                */
+                               for (masklay_shape_sort = sel_buffer.last; masklay_shape_sort; masklay_shape_sort = masklay_shape_sort->prev) {
+                                       /* if current (masklay_shape) occurs after this one in buffer, add! */
+                                       if (masklay_shape_sort->frame < masklay_shape->frame) {
+                                               BLI_insertlinkafter(&sel_buffer, masklay_shape_sort, masklay_shape);
+                                               added = 1;
+                                               break;
+                                       }
+                               }
+                               if (added == 0)
+                                       BLI_addhead(&sel_buffer, masklay_shape);
+                       }
+               }
+
+               /* error checking: it is unlikely, but may be possible to have none selected */
+               if (sel_buffer.first == NULL)
+                       continue;
+
+               /* if all were selected (i.e. masklay->splines_shapes is empty), then just transfer sel-buf over */
+               if (masklay->splines_shapes.first == NULL) {
+                       masklay->splines_shapes.first = sel_buffer.first;
+                       masklay->splines_shapes.last = sel_buffer.last;
+
+                       continue;
+               }
+
+               /* loop 2: remove duplicates of splines_shapes in buffers */
+               for (masklay_shape = masklay->splines_shapes.first; masklay_shape && sel_buffer.first; masklay_shape = masklay_shape_new) {
+                       masklay_shape_new = masklay_shape->next;
+
+                       /* loop through sel_buffer, emptying stuff from front of buffer if ok */
+                       for (masklay_shape_sort = sel_buffer.first; masklay_shape_sort && masklay_shape; masklay_shape_sort = masklay_shape_sort_new) {
+                               masklay_shape_sort_new = masklay_shape_sort->next;
+
+                               /* if this buffer frame needs to go before current, add it! */
+                               if (masklay_shape_sort->frame < masklay_shape->frame) {
+                                       /* transfer buffer frame to splines_shapes list (before current) */
+                                       BLI_remlink(&sel_buffer, masklay_shape_sort);
+                                       BLI_insertlinkbefore(&masklay->splines_shapes, masklay_shape, masklay_shape_sort);
+                               }
+                               /* if this buffer frame is on same frame, replace current with it and stop */
+                               else if (masklay_shape_sort->frame == masklay_shape->frame) {
+                                       /* transfer buffer frame to splines_shapes list (before current) */
+                                       BLI_remlink(&sel_buffer, masklay_shape_sort);
+                                       BLI_insertlinkbefore(&masklay->splines_shapes, masklay_shape, masklay_shape_sort);
+
+                                       /* get rid of current frame */
+                                       BKE_mask_layer_shape_unlink(masklay, masklay_shape);
+                               }
+                       }
+               }
+
+               /* if anything is still in buffer, append to end */
+               for (masklay_shape_sort = sel_buffer.first; masklay_shape_sort; masklay_shape_sort = masklay_shape_sort_new) {
+                       masklay_shape_sort_new = masklay_shape_sort->next;
+
+                       BLI_remlink(&sel_buffer, masklay_shape_sort);
+                       BLI_addtail(&masklay->splines_shapes, masklay_shape_sort);
+               }
+
+               /* NOTE: this is the only difference to grease pencil code above */
+               BKE_mask_layer_shape_sort(masklay);
+       }
+}
+
 /* Called during special_aftertrans_update to make sure selected keyframes replace
  * any other keyframes which may reside on that frame (that is not selected).
  */
 /* Called during special_aftertrans_update to make sure selected keyframes replace
  * any other keyframes which may reside on that frame (that is not selected).
  */
-static void posttrans_fcurve_clean (FCurve *fcu, const short use_handle)
+static void posttrans_fcurve_clean(FCurve *fcu, const short use_handle)
 {
 {
-       float *selcache;        /* cache for frame numbers of selected frames (fcu->totvert*sizeof(float)) */
-       int len, index, i;      /* number of frames in cache, item index */
+       float *selcache;    /* cache for frame numbers of selected frames (fcu->totvert*sizeof(float)) */
+       int len, index, i;  /* number of frames in cache, item index */
 
        /* allocate memory for the cache */
        // TODO: investigate using BezTriple columns instead?
 
        /* allocate memory for the cache */
        // TODO: investigate using BezTriple columns instead?
-       if (fcu->totvert == 0 || fcu->bezt==NULL)
+       if (fcu->totvert == 0 || fcu->bezt == NULL)
                return;
                return;
-       selcache= MEM_callocN(sizeof(float)*fcu->totvert, "FCurveSelFrameNums");
-       len= 0;
-       index= 0;
+       selcache = MEM_callocN(sizeof(float) * fcu->totvert, "FCurveSelFrameNums");
+       len = 0;
+       index = 0;
 
        /* We do 2 loops, 1 for marking keyframes for deletion, one for deleting
         * as there is no guarantee what order the keyframes are exactly, even though
 
        /* We do 2 loops, 1 for marking keyframes for deletion, one for deleting
         * as there is no guarantee what order the keyframes are exactly, even though
@@ -2800,10 +2913,10 @@ static void posttrans_fcurve_clean (FCurve *fcu, const short use_handle)
 
        /*      Loop 1: find selected keyframes   */
        for (i = 0; i < fcu->totvert; i++) {
 
        /*      Loop 1: find selected keyframes   */
        for (i = 0; i < fcu->totvert; i++) {
-               BezTriple *bezt= &fcu->bezt[i];
+               BezTriple *bezt = &fcu->bezt[i];
                
                if (BEZSELECTED(bezt)) {
                
                if (BEZSELECTED(bezt)) {
-                       selcache[index]= bezt->vec[1][0];
+                       selcache[index] = bezt->vec[1][0];
                        index++;
                        len++;
                }
                        index++;
                        len++;
                }
@@ -2813,12 +2926,12 @@ static void posttrans_fcurve_clean (FCurve *fcu, const short use_handle)
         * (if any keyframes were found, or the whole curve wasn't affected) 
         */
        if ((len) && (len != fcu->totvert)) {
         * (if any keyframes were found, or the whole curve wasn't affected) 
         */
        if ((len) && (len != fcu->totvert)) {
-               for (i= fcu->totvert-1; i >= 0; i--) {
-                       BezTriple *bezt= &fcu->bezt[i];
+               for (i = fcu->totvert - 1; i >= 0; i--) {
+                       BezTriple *bezt = &fcu->bezt[i];
                        
                        if (BEZSELECTED(bezt) == 0) {
                                /* check beztriple should be removed according to cache */
                        
                        if (BEZSELECTED(bezt) == 0) {
                                /* check beztriple should be removed according to cache */
-                               for (index= 0; index < len; index++) {
+                               for (index = 0; index < len; index++) {
                                        if (IS_EQF(bezt->vec[1][0], selcache[index])) {
                                                delete_fcurve_key(fcu, i, 0);
                                                break;
                                        if (IS_EQF(bezt->vec[1][0], selcache[index])) {
                                                delete_fcurve_key(fcu, i, 0);
                                                break;
@@ -2842,21 +2955,21 @@ static void posttrans_fcurve_clean (FCurve *fcu, const short use_handle)
  * any other keyframes which may reside on that frame (that is not selected).
  * remake_action_ipos should have already been called
  */
  * any other keyframes which may reside on that frame (that is not selected).
  * remake_action_ipos should have already been called
  */
-static void posttrans_action_clean (bAnimContext *ac, bAction *act)
+static void posttrans_action_clean(bAnimContext *ac, bAction *act)
 {
        ListBase anim_data = {NULL, NULL};
        bAnimListElem *ale;
        int filter;
 
        /* filter data */
 {
        ListBase anim_data = {NULL, NULL};
        bAnimListElem *ale;
        int filter;
 
        /* filter data */
-       filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
+       filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
        ANIM_animdata_filter(ac, &anim_data, filter, act, ANIMCONT_ACTION);
 
        /* loop through relevant data, removing keyframes as appropriate
        ANIM_animdata_filter(ac, &anim_data, filter, act, ANIMCONT_ACTION);
 
        /* loop through relevant data, removing keyframes as appropriate
-        *      - all keyframes are converted in/out of global time
+        *      - all keyframes are converted in/out of global time
         */
         */
-       for (ale= anim_data.first; ale; ale= ale->next) {
-               AnimData *adt= ANIM_nla_mapping_get(ac, ale);
+       for (ale = anim_data.first; ale; ale = ale->next) {
+               AnimData *adt = ANIM_nla_mapping_get(ac, ale);
                
                if (adt) {
                        ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
                
                if (adt) {
                        ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
@@ -2864,7 +2977,7 @@ static void posttrans_action_clean (bAnimContext *ac, bAction *act)
                        ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
                }
                else
                        ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
                }
                else
-                       posttrans_fcurve_clean(ale->key_data, FALSE); /* only use handles in graph editor */
+                       posttrans_fcurve_clean(ale->key_data, FALSE);  /* only use handles in graph editor */
        }
 
        /* free temp data */
        }
 
        /* free temp data */
@@ -2883,7 +2996,7 @@ static int count_fcurve_keys(FCurve *fcu, char side, float cfra)
                return count;
 
        /* only include points that occur on the right side of cfra */
                return count;
 
        /* only include points that occur on the right side of cfra */
-       for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
+       for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
                if (bezt->f2 & SELECT) {
                        /* no need to adjust the handle selection since they are assumed
                         * selected (like graph editor with SIPO_NOHANDLES) */
                if (bezt->f2 & SELECT) {
                        /* no need to adjust the handle selection since they are assumed
                         * selected (like graph editor with SIPO_NOHANDLES) */
@@ -2906,7 +3019,7 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra)
                return count;
        
        /* only include points that occur on the right side of cfra */
                return count;
        
        /* only include points that occur on the right side of cfra */
-       for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
+       for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
                if (gpf->flag & GP_FRAME_SELECT) {
                        if (FrameOnMouseSide(side, (float)gpf->framenum, cfra))
                                count++;
                if (gpf->flag & GP_FRAME_SELECT) {
                        if (FrameOnMouseSide(side, (float)gpf->framenum, cfra))
                                count++;
@@ -2916,6 +3029,27 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra)
        return count;
 }
 
        return count;
 }
 
+/* fully select selected beztriples, but only include if it's on the right side of cfra */
+static int count_masklayer_frames(MaskLayer *masklay, char side, float cfra)
+{
+       MaskLayerShape *masklayer_shape;
+       int count = 0;
+
+       if (masklay == NULL)
+               return count;
+
+       /* only include points that occur on the right side of cfra */
+       for (masklayer_shape = masklay->splines_shapes.first; masklayer_shape; masklayer_shape = masklayer_shape->next) {
+               if (masklayer_shape->flag & MASK_SHAPE_SELECT) {
+                       if (FrameOnMouseSide(side, (float)masklayer_shape->frame, cfra))
+                               count++;
+               }
+       }
+
+       return count;
+}
+
+
 /* This function assigns the information to transdata */
 static void TimeToTransData(TransData *td, float *time, AnimData *adt)
 {
 /* This function assigns the information to transdata */
 static void TimeToTransData(TransData *td, float *time, AnimData *adt)
 {
@@ -2926,7 +3060,7 @@ static void TimeToTransData(TransData *td, float *time, AnimData *adt)
        /* store the AnimData where this keyframe exists as a keyframe of the
         * active action as td->extra.
         */
        /* store the AnimData where this keyframe exists as a keyframe of the
         * active action as td->extra.
         */
-       td->extra= adt;
+       td->extra = adt;
 }
 
 /* This function advances the address to which td points to, so it must return
 }
 
 /* This function advances the address to which td points to, so it must return
@@ -2945,7 +3079,7 @@ static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FC
        if (ELEM(NULL, fcu, fcu->bezt))
                return td;
 
        if (ELEM(NULL, fcu, fcu->bezt))
                return td;
 
-       for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
+       for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
                /* only add selected keyframes (for now, proportional edit is not enabled) */
                if (bezt->f2 & SELECT) { /* note this MUST match count_fcurve_keys(), so can't use BEZSELECTED() macro */
                        /* only add if on the right 'side' of the current frame */
                /* only add selected keyframes (for now, proportional edit is not enabled) */
                if (bezt->f2 & SELECT) { /* note this MUST match count_fcurve_keys(), so can't use BEZSELECTED() macro */
                        /* only add if on the right 'side' of the current frame */
@@ -2953,7 +3087,7 @@ static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FC
                                TimeToTransData(td, bezt->vec[1], adt);
                                
                                /*set flags to move handles as necessary*/
                                TimeToTransData(td, bezt->vec[1], adt);
                                
                                /*set flags to move handles as necessary*/
-                               td->flag |= TD_MOVEHANDLE1|TD_MOVEHANDLE2;
+                               td->flag |= TD_MOVEHANDLE1 | TD_MOVEHANDLE2;
                                td2d->h1 = bezt->vec[0];
                                td2d->h2 = bezt->vec[2];
                                
                                td2d->h1 = bezt->vec[0];
                                td2d->h2 = bezt->vec[2];
                                
@@ -2973,25 +3107,25 @@ static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FC
 
 /* helper struct for gp-frame transforms (only used here) */
 typedef struct tGPFtransdata {
 
 /* helper struct for gp-frame transforms (only used here) */
 typedef struct tGPFtransdata {
-       float val;                      /* where transdata writes transform */
-       int *sdata;                     /* pointer to gpf->framenum */
+       float val;          /* where transdata writes transform */
+       int *sdata;         /* pointer to gpf->framenum */
 } tGPFtransdata;
 
 /* This function helps flush transdata written to tempdata into the gp-frames  */
 } tGPFtransdata;
 
 /* This function helps flush transdata written to tempdata into the gp-frames  */
-void flushTransGPactionData(TransInfo *t)
+void flushTransIntFrameActionData(TransInfo *t)
 {
        tGPFtransdata *tfd;
        int i;
 
        /* find the first one to start from */
        if (t->mode == TFM_TIME_SLIDE)
 {
        tGPFtransdata *tfd;
        int i;
 
        /* find the first one to start from */
        if (t->mode == TFM_TIME_SLIDE)
-               tfd= (tGPFtransdata *)((float *)(t->customData) + 2);
+               tfd = (tGPFtransdata *)((float *)(t->customData) + 2);
        else
        else
-               tfd= (tGPFtransdata *)(t->customData);
+               tfd = (tGPFtransdata *)(t->customData);
 
        /* flush data! */
        for (i = 0; i < t->total; i++, tfd++) {
 
        /* flush data! */
        for (i = 0; i < t->total; i++, tfd++) {
-               *(tfd->sdata)= (int)floor(tfd->val + 0.5f);
+               *(tfd->sdata) = (int)floor(tfd->val + 0.5f);
        }
 }
 
        }
 }
 
@@ -3002,21 +3136,21 @@ void flushTransGPactionData(TransInfo *t)
  * The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data
  * on the named side are used.
  */
  * The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data
  * on the named side are used.
  */
-static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl, char side, float cfra)
+static int GPLayerToTransData(TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl, char side, float cfra)
 {
        bGPDframe *gpf;
 {
        bGPDframe *gpf;
-       int count= 0;
+       int count = 0;
        
        /* check for select frames on right side of current frame */
        
        /* check for select frames on right side of current frame */
-       for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
+       for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
                if (gpf->flag & GP_FRAME_SELECT) {
                        if (FrameOnMouseSide(side, (float)gpf->framenum, cfra)) {
                                /* memory is calloc'ed, so that should zero everything nicely for us */
                if (gpf->flag & GP_FRAME_SELECT) {
                        if (FrameOnMouseSide(side, (float)gpf->framenum, cfra)) {
                                /* memory is calloc'ed, so that should zero everything nicely for us */
-                               td->val= &tfd->val;
-                               td->ival= (float)gpf->framenum;
+                               td->val = &tfd->val;
+                               td->ival = (float)gpf->framenum;
                                
                                
-                               tfd->val= (float)gpf->framenum;
-                               tfd->sdata= &gpf->framenum;
+                               tfd->val = (float)gpf->framenum;
+                               tfd->sdata = &gpf->framenum;
                                
                                /* advance td now */
                                td++;
                                
                                /* advance td now */
                                td++;
@@ -3029,9 +3163,38 @@ static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl
        return count;
 }
 
        return count;
 }
 
+/* refer to comment above #GPLayerToTransData, this is the same but for masks */
+static int MaskLayerToTransData(TransData *td, tGPFtransdata *tfd, MaskLayer *masklay, char side, float cfra)
+{
+       MaskLayerShape *masklay_shape;
+       int count = 0;
+
+       /* check for select frames on right side of current frame */
+       for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) {
+               if (masklay_shape->flag & MASK_SHAPE_SELECT) {
+                       if (FrameOnMouseSide(side, (float)masklay_shape->frame, cfra)) {
+                               /* memory is calloc'ed, so that should zero everything nicely for us */
+                               td->val = &tfd->val;
+                               td->ival = (float)masklay_shape->frame;
+
+                               tfd->val = (float)masklay_shape->frame;
+                               tfd->sdata = &masklay_shape->frame;
+
+                               /* advance td now */
+                               td++;
+                               tfd++;
+                               count++;
+                       }
+               }
+       }
+
+       return count;
+}
+
+
 static void createTransActionData(bContext *C, TransInfo *t)
 {
 static void createTransActionData(bContext *C, TransInfo *t)
 {
-       Scene *scene= t->scene;
+       Scene *scene = t->scene;
        TransData *td = NULL;
        TransData2D *td2d = NULL;
        tGPFtransdata *tfd = NULL;
        TransData *td = NULL;
        TransData2D *td2d = NULL;
        tGPFtransdata *tfd = NULL;
@@ -3041,7 +3204,7 @@ static void createTransActionData(bContext *C, TransInfo *t)
        bAnimListElem *ale;
        int filter;
        
        bAnimListElem *ale;
        int filter;
        
-       int count=0;
+       int count = 0;
        float cfra;
        
        /* determine what type of data we are operating on */
        float cfra;
        
        /* determine what type of data we are operating on */
@@ -3049,10 +3212,10 @@ static void createTransActionData(bContext *C, TransInfo *t)
                return;
        
        /* filter data */
                return;
        
        /* filter data */
-       if (ac.datatype == ANIMCONT_GPENCIL)
-               filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT);
+       if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
+               filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT);
        else
        else
-               filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
+               filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
        
        /* which side of the current frame should be allowed */
        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
        
        /* which side of the current frame should be allowed */
@@ -3069,8 +3232,8 @@ static void createTransActionData(bContext *C, TransInfo *t)
        }
        
        /* loop 1: fully select ipo-keys and count how many BezTriples are selected */
        }
        
        /* loop 1: fully select ipo-keys and count how many BezTriples are selected */
-       for (ale= anim_data.first; ale; ale= ale->next) {
-               AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
+       for (ale = anim_data.first; ale; ale = ale->next) {
+               AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
                
                /* convert current-frame to action-time (slightly less accurate, especially under
                 * higher scaling ratios, but is faster than converting all points)
                
                /* convert current-frame to action-time (slightly less accurate, especially under
                 * higher scaling ratios, but is faster than converting all points)
@@ -3082,8 +3245,12 @@ static void createTransActionData(bContext *C, TransInfo *t)
                
                if (ale->type == ANIMTYPE_FCURVE)
                        count += count_fcurve_keys(ale->key_data, t->frame_side, cfra);
                
                if (ale->type == ANIMTYPE_FCURVE)
                        count += count_fcurve_keys(ale->key_data, t->frame_side, cfra);
-               else
+               else if (ale->type == ANIMTYPE_GPLAYER)
                        count += count_gplayer_frames(ale->data, t->frame_side, cfra);
                        count += count_gplayer_frames(ale->data, t->frame_side, cfra);
+               else if (ale->type == ANIMTYPE_MASKLAYER)
+                       count += count_masklayer_frames(ale->data, t->frame_side, cfra);
+               else
+                       BLI_assert(0);
        }
        
        /* stop if trying to build list if nothing selected */
        }
        
        /* stop if trying to build list if nothing selected */
@@ -3094,39 +3261,47 @@ static void createTransActionData(bContext *C, TransInfo *t)
        }
        
        /* allocate memory for data */
        }
        
        /* allocate memory for data */
-       t->total= count;
+       t->total = count;
        
        
-       t->data= MEM_callocN(t->total*sizeof(TransData), "TransData(Action Editor)");
-       t->data2d= MEM_callocN(t->total*sizeof(TransData2D), "transdata2d");
-       td= t->data;
+       t->data = MEM_callocN(t->total * sizeof(TransData), "TransData(Action Editor)");
+       t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "transdata2d");
+       td = t->data;
        td2d = t->data2d;
        
        td2d = t->data2d;
        
-       if (ac.datatype == ANIMCONT_GPENCIL) {
+       if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
                if (t->mode == TFM_TIME_SLIDE) {
                if (t->mode == TFM_TIME_SLIDE) {
-                       t->customData= MEM_callocN((sizeof(float)*2)+(sizeof(tGPFtransdata)*count), "TimeSlide + tGPFtransdata");
-                       tfd= (tGPFtransdata *)((float *)(t->customData) + 2);
+                       t->customData = MEM_callocN((sizeof(float) * 2) + (sizeof(tGPFtransdata) * count), "TimeSlide + tGPFtransdata");
+                       tfd = (tGPFtransdata *)((float *)(t->customData) + 2);
                }
                else {
                }
                else {
-                       t->customData= MEM_callocN(sizeof(tGPFtransdata)*count, "tGPFtransdata");
-                       tfd= (tGPFtransdata *)(t->customData);
+                       t->customData = MEM_callocN(sizeof(tGPFtransdata) * count, "tGPFtransdata");
+                       tfd = (tGPFtransdata *)(t->customData);
                }
        }
        else if (t->mode == TFM_TIME_SLIDE)
                }
        }
        else if (t->mode == TFM_TIME_SLIDE)
-               t->customData= MEM_callocN(sizeof(float)*2, "TimeSlide Min/Max");
+               t->customData = MEM_callocN(sizeof(float) * 2, "TimeSlide Min/Max");
        
        /* loop 2: build transdata array */
        
        /* loop 2: build transdata array */
-       for (ale= anim_data.first; ale; ale= ale->next) {
+       for (ale = anim_data.first; ale; ale = ale->next) {
                if (ale->type == ANIMTYPE_GPLAYER) {
                if (ale->type == ANIMTYPE_GPLAYER) {
-                       bGPDlayer *gpl= (bGPDlayer *)ale->data;
+                       bGPDlayer *gpl = (bGPDlayer *)ale->data;
                        int i;
                        
                        i = GPLayerToTransData(td, tfd, gpl, t->frame_side, cfra);
                        td += i;
                        tfd += i;
                }
                        int i;
                        
                        i = GPLayerToTransData(td, tfd, gpl, t->frame_side, cfra);
                        td += i;
                        tfd += i;
                }
+               else if (ale->type == ANIMTYPE_MASKLAYER) {
+                       MaskLayer *masklay = (MaskLayer *)ale->data;
+                       int i;
+
+                       i = MaskLayerToTransData(td, tfd, masklay, t->frame_side, cfra);
+                       td += i;
+                       tfd += i;
+               }
                else {
                else {
-                       AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
-                       FCurve *fcu= (FCurve *)ale->key_data;
+                       AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
+                       FCurve *fcu = (FCurve *)ale->key_data;
                        
                        /* convert current-frame to action-time (slightly less accurate, especially under
                         * higher scaling ratios, but is faster than converting all points)
                        
                        /* convert current-frame to action-time (slightly less accurate, especially under
                         * higher scaling ratios, but is faster than converting all points)
@@ -3136,19 +3311,19 @@ static void createTransActionData(bContext *C, TransInfo *t)
                        else
                                cfra = (float)CFRA;
                        
                        else
                                cfra = (float)CFRA;
                        
-                       td= ActionFCurveToTransData(td, &td2d, fcu, adt, t->frame_side, cfra);
+                       td = ActionFCurveToTransData(td, &td2d, fcu, adt, t->frame_side, cfra);
                }
        }
        
        /* check if we're supposed to be setting minx/maxx for TimeSlide */
        if (t->mode == TFM_TIME_SLIDE) {
                }
        }
        
        /* check if we're supposed to be setting minx/maxx for TimeSlide */
        if (t->mode == TFM_TIME_SLIDE) {
-               float min=999999999.0f, max=-999999999.0f;
+               float min = 999999999.0f, max = -999999999.0f;
                int i;
                
                int i;
                
-               td= t->data;
-               for (i=0; i < count; i++, td++) {
-                       if (min > *(td->val)) min= *(td->val);
-                       if (max < *(td->val)) max= *(td->val);
+               td = t->data;
+               for (i = 0; i < count; i++, td++) {
+                       if (min > *(td->val)) min = *(td->val);
+                       if (max < *(td->val)) max = *(td->val);
                }
                
                if (min == max) {
                }
                
                if (min == max) {
@@ -3174,9 +3349,9 @@ static void createTransActionData(bContext *C, TransInfo *t)
 /* Helper function for createTransGraphEditData, which is responsible for associating
  * source data with transform data
  */
 /* Helper function for createTransGraphEditData, which is responsible for associating
  * source data with transform data
  */
-static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt, BezTriple *bezt, 
-                               int bi, short selected, short ishandle, short intvals, 
-                               float mtx[3][3], float smtx[3][3])
+static void bezt_to_transdata(TransData *td, TransData2D *td2d, AnimData *adt, BezTriple *bezt,
+                              int bi, short selected, short ishandle, short intvals,
+                              float mtx[3][3], float smtx[3][3])
 {
        float *loc = bezt->vec[bi];
        float *cent = bezt->vec[1];
 {
        float *loc = bezt->vec[bi];
        float *cent = bezt->vec[1];
@@ -3229,17 +3404,17 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt,
        memset(td->axismtx, 0, sizeof(td->axismtx));
        td->axismtx[2][2] = 1.0f;
        
        memset(td->axismtx, 0, sizeof(td->axismtx));
        td->axismtx[2][2] = 1.0f;
        
-       td->ext= NULL; td->val= NULL;
+       td->ext = NULL; td->val = NULL;
        
        /* store AnimData info in td->extra, for applying mapping when flushing */
        
        /* store AnimData info in td->extra, for applying mapping when flushing */
-       td->extra= adt;
+       td->extra = adt;
        
        if (selected) {
                td->flag |= TD_SELECTED;
        
        if (selected) {
                td->flag |= TD_SELECTED;
-               td->dist= 0.0f;
+               td->dist = 0.0f;
        }
        else
        }
        else
-               td->dist= MAXFLOAT;
+               td->dist = MAXFLOAT;
        
        if (ishandle)
                td->flag |= TD_NOTIMESNAP;
        
        if (ishandle)
                td->flag |= TD_NOTIMESNAP;
@@ -3254,9 +3429,9 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt,
 static void createTransGraphEditData(bContext *C, TransInfo *t)
 {
        SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
 static void createTransGraphEditData(bContext *C, TransInfo *t)
 {
        SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
-       Scene *scene= t->scene;
-       ARegion *ar= t->ar;
-       View2D *v2d= &ar->v2d;
+       Scene *scene = t->scene;
+       ARegion *ar = t->ar;
+       View2D *v2d = &ar->v2d;
        
        TransData *td = NULL;
        TransData2D *td2d = NULL;
        
        TransData *td = NULL;
        TransData2D *td2d = NULL;
@@ -3267,7 +3442,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
        int filter;
        
        BezTriple *bezt;
        int filter;
        
        BezTriple *bezt;
-       int count=0, i;
+       int count = 0, i;
        float cfra;
        float mtx[3][3], smtx[3][3];
        const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
        float cfra;
        float mtx[3][3], smtx[3][3];
        const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
@@ -3277,11 +3452,11 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
                return;
        
        /* filter data */
                return;
        
        /* filter data */
-       filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
+       filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
        
        /* which side of the current frame should be allowed */
        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
        
        /* which side of the current frame should be allowed */
-               // XXX we still want this mode, but how to get this using standard transform too?
+       // XXX we still want this mode, but how to get this using standard transform too?
        if (t->mode == TFM_TIME_EXTEND) {
                /* only side on which mouse is gets transformed */
                float xmouse, ymouse;
        if (t->mode == TFM_TIME_EXTEND) {
                /* only side on which mouse is gets transformed */
                float xmouse, ymouse;
@@ -3295,9 +3470,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
        }
        
        /* loop 1: count how many BezTriples (specifically their verts) are selected (or should be edited) */
        }
        
        /* loop 1: count how many BezTriples (specifically their verts) are selected (or should be edited) */
-       for (ale= anim_data.first; ale; ale= ale->next) {
-               AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
-               FCurve *fcu= (FCurve *)ale->key_data;
+       for (ale = anim_data.first; ale; ale = ale->next) {
+               AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
+               FCurve *fcu = (FCurve *)ale->key_data;
                
                /* convert current-frame to action-time (slightly less accurate, especially under
                 * higher scaling ratios, but is faster than converting all points)
                
                /* convert current-frame to action-time (slightly less accurate, especially under
                 * higher scaling ratios, but is faster than converting all points)
@@ -3312,11 +3487,11 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
                        continue;
                
                /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse */
                        continue;
                
                /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse */
-               for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
+               for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
                        if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
                        if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
-                               const char sel2= bezt->f2 & SELECT;
-                               const char sel1= use_handle ? bezt->f1 & SELECT : sel2;
-                               const char sel3= use_handle ? bezt->f3 & SELECT : sel2;
+                               const char sel2 = bezt->f2 & SELECT;
+                               const char sel1 = use_handle ? bezt->f1 & SELECT : sel2;
+                               const char sel3 = use_handle ? bezt->f3 & SELECT : sel2;
 
                                if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) {
                                        /* for 'normal' pivots - just include anything that is selected.
 
                                if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) {
                                        /* for 'normal' pivots - just include anything that is selected.
@@ -3356,14 +3531,14 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
        }
        
        /* allocate memory for data */
        }
        
        /* allocate memory for data */
-       t->total= count;
+       t->total = count;
        
        
-       t->data= MEM_callocN(t->total*sizeof(TransData), "TransData (Graph Editor)");
-               /* for each 2d vert a 3d vector is allocated, so that they can be treated just as if they were 3d verts */
-       t->data2d= MEM_callocN(t->total*sizeof(TransData2D), "TransData2D (Graph Editor)");
+       t->data = MEM_callocN(t->total * sizeof(TransData), "TransData (Graph Editor)");
+       /* for each 2d vert a 3d vector is allocated, so that they can be treated just as if they were 3d verts */
+       t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransData2D (Graph Editor)");
        
        
-       td= t->data;
-       td2d= t->data2d;
+       td = t->data;
+       td2d = t->data2d;
        
        /* precompute space-conversion matrices for dealing with non-uniform scaling of Graph Editor */
        unit_m3(mtx);
        
        /* precompute space-conversion matrices for dealing with non-uniform scaling of Graph Editor */
        unit_m3(mtx);
@@ -3380,15 +3555,15 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
                mul_v3_fl(mtx[1], yscale);
                
                /* smtx is global (i.e. view) to data conversion */
                mul_v3_fl(mtx[1], yscale);
                
                /* smtx is global (i.e. view) to data conversion */
-               if (IS_EQF(xscale, 0.0f) == 0) mul_v3_fl(smtx[0], 1.0f/xscale);
-               if (IS_EQF(yscale, 0.0f) == 0) mul_v3_fl(smtx[1], 1.0f/yscale);
+               if (IS_EQF(xscale, 0.0f) == 0) mul_v3_fl(smtx[0], 1.0f / xscale);
+               if (IS_EQF(yscale, 0.0f) == 0) mul_v3_fl(smtx[1], 1.0f / yscale);
        }
        
        /* loop 2: build transdata arrays */
        }
        
        /* loop 2: build transdata arrays */
-       for (ale= anim_data.first; ale; ale= ale->next) {
-               AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
-               FCurve *fcu= (FCurve *)ale->key_data;
-               short intvals= (fcu->flag & FCURVE_INT_VALUES);
+       for (ale = anim_data.first; ale; ale = ale->next) {
+               AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
+               FCurve *fcu = (FCurve *)ale->key_data;
+               short intvals = (fcu->flag & FCURVE_INT_VALUES);
                
                /* convert current-frame to action-time (slightly less accurate, especially under
                 * higher scaling ratios, but is faster than converting all points)
                
                /* convert current-frame to action-time (slightly less accurate, especially under
                 * higher scaling ratios, but is faster than converting all points)
@@ -3402,14 +3577,14 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
                if (fcu->bezt == NULL)
                        continue;
                
                if (fcu->bezt == NULL)
                        continue;
                
-               ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYSEL|ANIM_UNITCONV_SELVERTS);
+               ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS);
                
                /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */
                
                /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */
-               for (i=0, bezt= fcu->bezt; i < fcu->totvert; i++, bezt++) {
+               for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
                        if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
                        if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
-                               const char sel2= bezt->f2 & SELECT;
-                               const char sel1= use_handle ? bezt->f1 & SELECT : sel2;
-                               const char sel3= use_handle ? bezt->f3 & SELECT : sel2;
+                               const char sel2 = bezt->f2 & SELECT;
+                               const char sel1 = use_handle ? bezt->f1 & SELECT : sel2;
+                               const char sel3 = use_handle ? bezt->f3 & SELECT : sel2;
 
                                TransDataCurveHandleFlags *hdata = NULL;
                                /* short h1=1, h2=1; */ /* UNUSED */
 
                                TransDataCurveHandleFlags *hdata = NULL;
                                /* short h1=1, h2=1; */ /* UNUSED */
@@ -3427,7 +3602,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
                                        }
                                        
                                        if (sel3) {
                                        }
                                        
                                        if (sel3) {
-                                               if (hdata==NULL)
+                                               if (hdata == NULL)
                                                        hdata = initTransDataCurveHandles(td, bezt);
                                                bezt_to_transdata(td++, td2d++, adt, bezt, 2, 1, 1, intvals, mtx, smtx);
                                        } 
                                                        hdata = initTransDataCurveHandles(td, bezt);
                                                bezt_to_transdata(td++, td2d++, adt, bezt, 2, 1, 1, intvals, mtx, smtx);
                                        } 
@@ -3464,8 +3639,8 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
                                    ELEM(t->mode, TFM_ROTATION, TFM_RESIZE))
                                {
                                        if (hdata && (sel1) && (sel3)) {
                                    ELEM(t->mode, TFM_ROTATION, TFM_RESIZE))
                                {
                                        if (hdata && (sel1) && (sel3)) {
-                                               bezt->h1= HD_ALIGN;
-                                               bezt->h2= HD_ALIGN;
+                                               bezt->h1 = HD_ALIGN;
+                                               bezt->h2 = HD_ALIGN;
                                        }
                                }
                        }
                                        }
                                }
                        }
@@ -3485,64 +3660,64 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
 /* struct for use in re-sorting BezTriples during Graph Editor transform */
 typedef struct BeztMap {
        BezTriple *bezt;
 /* struct for use in re-sorting BezTriples during Graph Editor transform */
 typedef struct BeztMap {
        BezTriple *bezt;
-       unsigned int oldIndex;          /* index of bezt in fcu->bezt array before sorting */
-       unsigned int newIndex;          /* index of bezt in fcu->bezt array after sorting */
-       short swapHs;                           /* swap order of handles (-1=clear; 0=not checked, 1=swap) */
-       char pipo, cipo;                        /* interpolation of current and next segments */
+       unsigned int oldIndex;      /* index of bezt in fcu->bezt array before sorting */
+       unsigned int newIndex;      /* index of bezt in fcu->bezt array after sorting */
+       short swapHs;               /* swap order of handles (-1=clear; 0=not checked, 1=swap) */
+       char pipo, cipo;            /* interpolation of current and next segments */
 } BeztMap;
 
 
 /* This function converts an FCurve's BezTriple array to a BeztMap array
  * NOTE: this allocates memory that will need to get freed later
  */
 } BeztMap;
 
 
 /* This function converts an FCurve's BezTriple array to a BeztMap array
  * NOTE: this allocates memory that will need to get freed later
  */
-static BeztMap *bezt_to_beztmaps (BezTriple *bezts, int totvert, const short UNUSED(use_handle))
+static BeztMap *bezt_to_beztmaps(BezTriple *bezts, int totvert, const short UNUSED(use_handle))
 {
 {
-       BezTriple *bezt= bezts;
-       BezTriple *prevbezt= NULL;
+       BezTriple *bezt = bezts;
+       BezTriple *prevbezt = NULL;
        BeztMap *bezm, *bezms;
        int i;
        
        /* allocate memory for this array */
        BeztMap *bezm, *bezms;
        int i;
        
        /* allocate memory for this array */
-       if (totvert==0 || bezts==NULL)
+       if (totvert == 0 || bezts == NULL)
                return NULL;
                return NULL;
-       bezm= bezms= MEM_callocN(sizeof(BeztMap)*totvert, "BeztMaps");
+       bezm = bezms = MEM_callocN(sizeof(BeztMap) * totvert, "BeztMaps");
        
        /* assign beztriples to beztmaps */
        
        /* assign beztriples to beztmaps */
-       for (i=0; i < totvert; i++, bezm++, prevbezt=bezt, bezt++) {
-               bezm->bezt= bezt;
+       for (i = 0; i < totvert; i++, bezm++, prevbezt = bezt, bezt++) {
+               bezm->bezt = bezt;
                
                
-               bezm->oldIndex= i;
-               bezm->newIndex= i;
+               bezm->oldIndex = i;
+               bezm->newIndex = i;
                
                
-               bezm->pipo= (prevbezt) ? prevbezt->ipo : bezt->ipo;
-               bezm->cipo= bezt->ipo;
+               bezm->pipo = (prevbezt) ? prevbezt->ipo : bezt->ipo;
+               bezm->cipo = bezt->ipo;
        }
 
        return bezms;
 }
 
 /* This function copies the code of sort_time_ipocurve, but acts on BeztMap structs instead */
        }
 
        return bezms;
 }
 
 /* This function copies the code of sort_time_ipocurve, but acts on BeztMap structs instead */
-static void sort_time_beztmaps (BeztMap *bezms, int totvert, const short UNUSED(use_handle))
+static void sort_time_beztmaps(BeztMap *bezms, int totvert, const short UNUSED(use_handle))
 {
        BeztMap *bezm;
 {
        BeztMap *bezm;
-       int i, ok= 1;
+       int i, ok = 1;
        
        /* keep repeating the process until nothing is out of place anymore */
        while (ok) {
        
        /* keep repeating the process until nothing is out of place anymore */
        while (ok) {
-               ok= 0;
+               ok = 0;
                
                
-               bezm= bezms;
-               i= totvert;
+               bezm = bezms;
+               i = totvert;
                while (i--) {
                        /* is current bezm out of order (i.e. occurs later than next)? */
                        if (i > 0) {
                while (i--) {
                        /* is current bezm out of order (i.e. occurs later than next)? */
                        if (i > 0) {
-                               if (bezm->bezt->vec[1][0] > (bezm+1)->bezt->vec[1][0]) {
+                               if (bezm->bezt->vec[1][0] > (bezm + 1)->bezt->vec[1][0]) {
                                        bezm->newIndex++;
                                        bezm->newIndex++;
-                                       (bezm+1)->newIndex--;
+                                       (bezm + 1)->newIndex--;
                                        
                                        
-                                       SWAP(BeztMap, *bezm, *(bezm+1));
+                                       SWAP(BeztMap, *bezm, *(bezm + 1));
                                        
                                        
-                                       ok= 1;
+                                       ok = 1;
                                }
                        }
                        
                                }
                        }
                        
@@ -3568,7 +3743,7 @@ static void sort_time_beztmaps (BeztMap *bezms, int totvert, const short UNUSED(
 }
 
 /* This function firstly adjusts the pointers that the transdata has to each BezTriple */
 }
 
 /* This function firstly adjusts the pointers that the transdata has to each BezTriple */
-static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totvert, const short UNUSED(use_handle))
+static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totvert, const short UNUSED(use_handle))
 {
        BezTriple *bezts = fcu->bezt;
        BeztMap *bezm;
 {
        BezTriple *bezts = fcu->bezt;
        BeztMap *bezm;
@@ -3581,17 +3756,17 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv
         * pointers have been fixed already, so that we don't override ones that are
         * already done
         */
         * pointers have been fixed already, so that we don't override ones that are
         * already done
         */
-       adjusted= MEM_callocN(t->total, "beztmap_adjusted_map");
+       adjusted = MEM_callocN(t->total, "beztmap_adjusted_map");
        
        /* for each beztmap item, find if it is used anywhere */
        
        /* for each beztmap item, find if it is used anywhere */
-       bezm= bezms;
-       for (i= 0; i < totvert; i++, bezm++) {
+       bezm = bezms;
+       for (i = 0; i < totvert; i++, bezm++) {
                /* loop through transdata, testing if we have a hit
                 * for the handles (vec[0]/vec[2]), we must also check if they need to be swapped...
                 */
                /* loop through transdata, testing if we have a hit
                 * for the handles (vec[0]/vec[2]), we must also check if they need to be swapped...
                 */
-               td2d= t->data2d;
-               td= t->data;
-               for (j= 0; j < t->total; j++, td2d++, td++) {
+               td2d = t->data2d;
+               td = t->data;
+               for (j = 0; j < t->total; j++, td2d++, td++) {
                        /* skip item if already marked */
                        if (adjusted[j] != 0) continue;
                        
                        /* skip item if already marked */
                        if (adjusted[j] != 0) continue;
                        
@@ -3600,26 +3775,26 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv
                         */
                        if (td2d->loc2d == bezm->bezt->vec[0]) {
                                if (bezm->swapHs == 1)
                         */
                        if (td2d->loc2d == bezm->bezt->vec[0]) {
                                if (bezm->swapHs == 1)
-                                       td2d->loc2d= (bezts + bezm->newIndex)->vec[2];
+                                       td2d->loc2d = (bezts + bezm->newIndex)->vec[2];
                                else
                                else
-                                       td2d->loc2d= (bezts + bezm->newIndex)->vec[0];
+                                       td2d->loc2d = (bezts + bezm->newIndex)->vec[0];
                                adjusted[j] = 1;
                        }
                        else if (td2d->loc2d == bezm->bezt->vec[2]) {
                                if (bezm->swapHs == 1)
                                adjusted[j] = 1;
                        }
                        else if (td2d->loc2d == bezm->bezt->vec[2]) {
                                if (bezm->swapHs == 1)
-                                       td2d->loc2d= (bezts + bezm->newIndex)->vec[0];
+                                       td2d->loc2d = (bezts + bezm->newIndex)->vec[0];
                                else
                                else
-                                       td2d->loc2d= (bezts + bezm->newIndex)->vec[2];
+                                       td2d->loc2d = (bezts + bezm->newIndex)->vec[2];
                                adjusted[j] = 1;
                        }
                        else if (td2d->loc2d == bezm->bezt->vec[1]) {
                                adjusted[j] = 1;
                        }
                        else if (td2d->loc2d == bezm->bezt->vec[1]) {
-                               td2d->loc2d= (bezts + bezm->newIndex)->vec[1];
+                               td2d->loc2d = (bezts + bezm->newIndex)->vec[1];
                                        
                                /* if only control point is selected, the handle pointers need to be updated as well */
                                if (td2d->h1)
                                        
                                /* if only control point is selected, the handle pointers need to be updated as well */
                                if (td2d->h1)
-                                       td2d->h1= (bezts + bezm->newIndex)->vec[0];
+                                       td2d->h1 = (bezts + bezm->newIndex)->vec[0];
                                if (td2d->h2)
                                if (td2d->h2)
-                                       td2d->h2= (bezts + bezm->newIndex)->vec[2];
+                                       td2d->h2 = (bezts + bezm->newIndex)->vec[2];
                                        
                                adjusted[j] = 1;
                        }
                                        
                                adjusted[j] = 1;
                        }
@@ -3657,15 +3832,15 @@ void remake_graph_transdata(TransInfo *t, ListBase *anim_data)
        const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
        
        /* sort and reassign verts */
        const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
        
        /* sort and reassign verts */
-       for (ale= anim_data->first; ale; ale= ale->next) {
-               FCurve *fcu= (FCurve *)ale->key_data;
+       for (ale = anim_data->first; ale; ale = ale->next) {
+               FCurve *fcu = (FCurve *)ale->key_data;
                
                if (fcu->bezt) {
                        BeztMap *bezm;
                        
                        /* adjust transform-data pointers */
                        /* note, none of these functions use 'use_handle', it could be removed */
                
                if (fcu->bezt) {
                        BeztMap *bezm;
                        
                        /* adjust transform-data pointers */
                        /* note, none of these functions use 'use_handle', it could be removed */
-                       bezm= bezt_to_beztmaps(fcu->bezt, fcu->totvert, use_handle);
+                       bezm = bezt_to_beztmaps(fcu->bezt, fcu->totvert, use_handle);
                        sort_time_beztmaps(bezm, fcu->totvert, use_handle);
                        beztmap_to_data(t, fcu, bezm, fcu->totvert, use_handle);
                        
                        sort_time_beztmaps(bezm, fcu->totvert, use_handle);
                        beztmap_to_data(t, fcu, bezm, fcu->totvert, use_handle);
                        
@@ -3689,44 +3864,44 @@ void flushTransGraphData(TransInfo *t)
        SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
        TransData *td;
        TransData2D *td2d;
        SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
        TransData *td;
        TransData2D *td2d;
-       Scene *scene= t->scene;
-       double secf= FPS;
+       Scene *scene = t->scene;
+       double secf = FPS;
        int a;
 
        /* flush to 2d vector from internally used 3d vector */
        int a;
 
        /* flush to 2d vector from internally used 3d vector */
-       for (a=0, td= t->data, td2d=t->data2d; a<t->total; a++, td++, td2d++) {
-               AnimData *adt= (AnimData *)td->extra; /* pointers to relevant AnimData blocks are stored in the td->extra pointers */
+       for (a = 0, td = t->data, td2d = t->data2d; a < t->total; a++, td++, td2d++) {
+               AnimData *adt = (AnimData *)td->extra; /* pointers to relevant AnimData blocks are stored in the td->extra pointers */
                
                /* handle snapping for time values
                 *      - we should still be in NLA-mapping timespace
                 *      - only apply to keyframes (but never to handles)
                 */
                
                /* handle snapping for time values
                 *      - we should still be in NLA-mapping timespace
                 *      - only apply to keyframes (but never to handles)
                 */
-               if ((td->flag & TD_NOTIMESNAP)==0) {
+               if ((td->flag & TD_NOTIMESNAP) == 0) {
                        switch (sipo->autosnap) {
                                case SACTSNAP_FRAME: /* snap to nearest frame (or second if drawing seconds) */
                                        if (sipo->flag & SIPO_DRAWTIME)
                        switch (sipo->autosnap) {
                                case SACTSNAP_FRAME: /* snap to nearest frame (or second if drawing seconds) */
                                        if (sipo->flag & SIPO_DRAWTIME)
-                                               td2d->loc[0] = (float)(floorf((td2d->loc[0]/secf) + 0.5f) * secf);
+                                               td2d->loc[0] = floor(((double)td2d->loc[0] / secf) + 0.5) * secf;
                                        else
                                        else
-                                               td2d->loc[0] = (float)(floorf(td2d->loc[0]+0.5f));
+                                               td2d->loc[0] = floor((double)td2d->loc[0] + 0.5);
                                        break;
                                
                                case SACTSNAP_MARKER: /* snap to nearest marker */
                                        break;
                                
                                case SACTSNAP_MARKER: /* snap to nearest marker */
-                                       td2d->loc[0]= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, td2d->loc[0]);
+                                       td2d->loc[0] = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, td2d->loc[0]);
                                        break;
                        }
                }
                                        break;
                        }
                }
-               
+
                /* we need to unapply the nla-mapping from the time in some situations */
                if (adt)
                /* we need to unapply the nla-mapping from the time in some situations */
                if (adt)
-                       td2d->loc2d[0]= BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP);
+                       td2d->loc2d[0] = BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP);
                else
                else
-                       td2d->loc2d[0]= td2d->loc[0];
+                       td2d->loc2d[0] = td2d->loc[0];
                
                /* if int-values only, truncate to integers */
                if (td->flag & TD_INTVALUES)
                
                /* if int-values only, truncate to integers */
                if (td->flag & TD_INTVALUES)
-                       td2d->loc2d[1]= floorf(td2d->loc[1] + 0.5f);
+                       td2d->loc2d[1] = floorf(td2d->loc[1] + 0.5f);
                else
                else
-                       td2d->loc2d[1]= td2d->loc[1];
+                       td2d->loc2d[1] = td2d->loc[1];
                
                if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) {
                        td2d->h1[0] = td2d->ih1[0] + td->loc[0] - td->iloc[0];
                
                if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) {
                        td2d->h1[0] = td2d->ih1[0] + td->loc[0] - td->iloc[0];
@@ -3757,48 +3932,48 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
 
                /* *** Extend Transform *** */
 
 
                /* *** Extend Transform *** */
 
-               Scene * scene= t->scene;
-               int cfra= CFRA;
-               int left= seq_tx_get_final_left(seq, 1);
-               int right= seq_tx_get_final_right(seq, 1);
+               Scene *scene = t->scene;
+               int cfra = CFRA;
+               int left = seq_tx_get_final_left(seq, 1);
+               int right = seq_tx_get_final_right(seq, 1);
 
                if (seq->depth == 0 && ((seq->flag & SELECT) == 0 || (seq->flag & SEQ_LOCK))) {
 
                if (seq->depth == 0 && ((seq->flag & SELECT) == 0 || (seq->flag & SEQ_LOCK))) {
-                       *recursive= 0;
-                       *count= 0;
-                       *flag= 0;
+                       *recursive = FALSE;
+                       *count = 0;
+                       *flag = 0;
                }
                }
-               else if (seq->type ==SEQ_META) {
+               else if (seq->type == SEQ_TYPE_META) {
 
                        /* for meta's we only ever need to extend their children, no matter what depth
                         * just check the meta's are in the bounds */
 
                        /* for meta's we only ever need to extend their children, no matter what depth
                         * just check the meta's are in the bounds */
-                       if (t->frame_side=='R' && right <= cfra)                *recursive= 0;
-                       else if (t->frame_side=='L' && left >= cfra)    *recursive= 0;
-                       else                                                                                    *recursive= 1;
+                       if      (t->frame_side == 'R' && right <= cfra) *recursive = FALSE;
+                       else if (t->frame_side == 'L' && left  >= cfra) *recursive = FALSE;
+                       else *recursive = TRUE;
 
 
-                       *count= 1;
-                       *flag= (seq->flag | SELECT) & ~(SEQ_LEFTSEL|SEQ_RIGHTSEL);
+                       *count = 1;
+                       *flag = (seq->flag | SELECT) & ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
                }
                else {
 
                }
                else {
 
-                       *recursive= 0;  /* not a meta, so no thinking here */
-                       *count= 1;              /* unless its set to 0, extend will never set 2 handles at once */
-                       *flag= (seq->flag | SELECT) & ~(SEQ_LEFTSEL|SEQ_RIGHTSEL);
+                       *recursive = FALSE;  /* not a meta, so no thinking here */
+                       *count = 1;          /* unless its set to 0, extend will never set 2 handles at once */
+                       *flag = (seq->flag | SELECT) & ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
 
 
-                       if (t->frame_side=='R') {
-                               if (right <= cfra)              *count= *flag= 0;       /* ignore */
-                               else if (left > cfra)   ;       /* keep the selection */
-                               else                                    *flag |= SEQ_RIGHTSEL;
+                       if (t->frame_side == 'R') {
+                               if      (right <= cfra) *count = *flag = 0;  /* ignore */
+                               else if (left   > cfra) ;                  /* keep the selection */
+ &nb