replace VECCOPY and QUATCOPY with inline funcs.
[blender.git] / source / blender / editors / transform / transform.c
index eea77e3..9c1d5ad 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -1006,9 +1004,6 @@ int transformEvent(TransInfo *t, wmEvent *event)
                        else view_editmove(event->type);
                        t->redraw= 1;
                        break;
-//             case NDOFMOTION:
-//            viewmoveNDOF(1);
-  //         break;
                default:
                        handled = 0;
                        break;
@@ -1017,43 +1012,6 @@ int transformEvent(TransInfo *t, wmEvent *event)
                // Numerical input events
                t->redraw |= handleNumInput(&(t->num), event);
 
-               // NDof input events
-               switch(handleNDofInput(&(t->ndof), event))
-               {
-                       case NDOF_CONFIRM:
-                               if ((t->options & CTX_NDOF) == 0)
-                               {
-                                       /* Confirm on normal transform only */
-                                       t->state = TRANS_CONFIRM;
-                               }
-                               break;
-                       case NDOF_CANCEL:
-                               if (t->options & CTX_NDOF)
-                               {
-                                       /* Cancel on pure NDOF transform */
-                                       t->state = TRANS_CANCEL;
-                               }
-                               else
-                               {
-                                       /* Otherwise, just redraw, NDof input was cancelled */
-                                       t->redraw |= TREDRAW_HARD;
-                               }
-                               break;
-                       case NDOF_NOMOVE:
-                               if (t->options & CTX_NDOF)
-                               {
-                                       /* Confirm on pure NDOF transform */
-                                       t->state = TRANS_CONFIRM;
-                               }
-                               break;
-                       case NDOF_REFRESH:
-                               t->redraw |= TREDRAW_HARD;
-                               break;
-                       default:
-                               handled = 0;
-                               break;
-               }
-
                // Snapping events
                t->redraw |= handleSnapping(t, event);
 
@@ -1131,7 +1089,7 @@ int calculateTransformCenter(bContext *C, int centerMode, float *vec)
                calculateCenter(t);
 
                // Copy center from constraint center. Transform center can be local
-               VECCOPY(vec, t->con.center);
+               copy_v3_v3(vec, t->con.center);
        }
 
 
@@ -1250,7 +1208,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
                mval[0]= x;
                mval[1]= y;
 
-               VECCOPY(vecrot, t->center);
+               copy_v3_v3(vecrot, t->center);
                if(t->flag & T_EDIT) {
                        Object *ob= t->obedit;
                        if(ob) mul_m4_v3(ob->obmat, vecrot);
@@ -1396,16 +1354,20 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
        ToolSettings *ts = CTX_data_tool_settings(C);
        int constraint_axis[3] = {0, 0, 0};
        int proportional = 0;
+       PropertyRNA *prop;
 
-       if (RNA_struct_find_property(op->ptr, "value"))
-       {
-               if (t->flag & T_AUTOVALUES)
-               {
-                       RNA_float_set_array(op->ptr, "value", t->auto_values);
+       // Save back mode in case we're in the generic operator
+       if ((prop= RNA_struct_find_property(op->ptr, "mode"))) {
+               RNA_property_enum_set(op->ptr, prop, t->mode);
+       }
+
+       if ((prop= RNA_struct_find_property(op->ptr, "value"))) {
+               float *values= (t->flag & T_AUTOVALUES) ? t->auto_values : t->values;
+               if (RNA_property_array_check(prop)) {
+                       RNA_property_float_set_array(op->ptr, prop, values);
                }
-               else
-               {
-                       RNA_float_set_array(op->ptr, "value", t->values);
+               else {
+                       RNA_property_float_set(op->ptr, prop, values[0]);
                }
        }
 
@@ -1579,10 +1541,11 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
                {
                        if (kmi->propvalue == TFM_MODAL_SNAP_INV_ON && kmi->val == KM_PRESS)
                        {
-                               if ((ELEM(kmi->type, LEFTCTRLKEY, RIGHTCTRLKEY) && event->ctrl) ||
-                                       (ELEM(kmi->type, LEFTSHIFTKEY, RIGHTSHIFTKEY) && event->shift) ||
-                                       (ELEM(kmi->type, LEFTALTKEY, RIGHTALTKEY) && event->alt) ||
-                                       (kmi->type == OSKEY && event->oskey)) {
+                               if ((ELEM(kmi->type, LEFTCTRLKEY, RIGHTCTRLKEY) &&   event->ctrl)  ||
+                                   (ELEM(kmi->type, LEFTSHIFTKEY, RIGHTSHIFTKEY) && event->shift) ||
+                                   (ELEM(kmi->type, LEFTALTKEY, RIGHTALTKEY) &&     event->alt)   ||
+                                   ((kmi->type == OSKEY) &&                         event->oskey) )
+                               {
                                        t->modifiers |= MOD_SNAP_INVERT;
                                }
                                break;
@@ -1719,9 +1682,16 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
        if (RNA_property_is_set(op->ptr, "value"))
        {
                float values[4]= {0}; /* incase value isn't length 4, avoid uninitialized memory  */
-               RNA_float_get_array(op->ptr, "value", values);
-               QUATCOPY(t->values, values);
-               QUATCOPY(t->auto_values, values);
+               PropertyRNA *prop= RNA_struct_find_property(op->ptr, "value");
+
+               if(RNA_property_array_check(prop)) {
+                       RNA_float_get_array(op->ptr, "value", values);
+               } else {
+                       values[0]= RNA_float_get(op->ptr, "value");
+               }
+
+               copy_v4_v4(t->values, values);
+               copy_v4_v4(t->auto_values, values);
                t->flag |= T_AUTOVALUES;
        }
 
@@ -1951,7 +1921,7 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu
                        quat[3]= oldquat[3];
        }
        else {
-               /* quaternions get limited with euler... (compatability mode) */
+               /* quaternions get limited with euler... (compatibility mode) */
                float eul[3], oldeul[3], nquat[4], noldquat[4];
                float qlen;
 
@@ -1982,22 +1952,27 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu
 
 /* ******************* TRANSFORM LIMITS ********************** */
 
-static void constraintTransLim(TransInfo *UNUSED(t), TransData *td)
+static void constraintTransLim(TransInfo *t, TransData *td)
 {
        if (td->con) {
-               bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_LOCLIMIT);
+               bConstraintTypeInfo *ctiLoc= get_constraint_typeinfo(CONSTRAINT_TYPE_LOCLIMIT);
+               bConstraintTypeInfo *ctiDist= get_constraint_typeinfo(CONSTRAINT_TYPE_DISTLIMIT);
+               
                bConstraintOb cob= {NULL};
                bConstraint *con;
+               float ctime = (float)(t->scene->r.cfra);
                
                /* Make a temporary bConstraintOb for using these limit constraints
                 *      - they only care that cob->matrix is correctly set ;-)
                 *      - current space should be local
                 */
                unit_m4(cob.matrix);
-               VECCOPY(cob.matrix[3], td->loc);
+               copy_v3_v3(cob.matrix[3], td->loc);
                
                /* Evaluate valid constraints */
                for (con= td->con; con; con= con->next) {
+                       bConstraintTypeInfo *cti = NULL;
+                       ListBase targets = {NULL, NULL};
                        float tmat[4][4];
                        
                        /* only consider constraint if enabled */
@@ -2010,7 +1985,17 @@ static void constraintTransLim(TransInfo *UNUSED(t), TransData *td)
                                
                                if ((data->flag2 & LIMIT_TRANSFORM)==0)
                                        continue;
+                               cti = ctiLoc;
+                       }
+                       else if (con->type == CONSTRAINT_TYPE_DISTLIMIT) {
+                               bDistLimitConstraint *data= con->data;
                                
+                               if ((data->flag & LIMITDIST_TRANSFORM)==0)
+                                       continue;
+                               cti = ctiDist;
+                       }
+                       
+                       if (cti) {
                                /* do space conversions */
                                if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
                                        /* just multiply by td->mtx (this should be ok) */
@@ -2022,8 +2007,11 @@ static void constraintTransLim(TransInfo *UNUSED(t), TransData *td)
                                        continue;
                                }
                                
+                               /* get constraint targets if needed */
+                               get_constraint_targets_for_solving(con, &cob, &targets, ctime);
+                               
                                /* do constraint */
-                               cti->evaluate_constraint(con, &cob, NULL);
+                               cti->evaluate_constraint(con, &cob, &targets);
                                
                                /* convert spaces again */
                                if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
@@ -2031,11 +2019,14 @@ static void constraintTransLim(TransInfo *UNUSED(t), TransData *td)
                                        copy_m4_m4(tmat, cob.matrix);
                                        mul_m4_m3m4(cob.matrix, td->smtx, tmat);
                                }
+                               
+                               /* free targets list */
+                               BLI_freelistN(&targets);
                        }
                }
                
                /* copy results from cob->matrix */
-               VECCOPY(td->loc, cob.matrix[3]);
+               copy_v3_v3(td->loc, cob.matrix[3]);
        }
 }
 
@@ -2305,8 +2296,8 @@ int Warp(TransInfo *t, const int UNUSED(mval[2]))
         * It needs to be in view space, but we need to take object's offset
         * into account if in Edit mode.
         */
-       VECCOPY(cursor, curs);
-       VECCOPY(gcursor, cursor);
+       copy_v3_v3(cursor, curs);
+       copy_v3_v3(gcursor, cursor);
        if (t->flag & T_EDIT) {
                sub_v3_v3(cursor, t->obedit->obmat[3]);
                sub_v3_v3(gcursor, t->obedit->obmat[3]);
@@ -2349,7 +2340,7 @@ int Warp(TransInfo *t, const int UNUSED(mval[2]))
                        continue;
                
                /* translate point to center, rotate in such a way that outline==distance */
-               VECCOPY(vec, td->iloc);
+               copy_v3_v3(vec, td->iloc);
                mul_m3_v3(td->mtx, vec);
                mul_m4_v3(t->viewmat, vec);
                sub_v3_v3(vec, t->viewmat[3]);
@@ -2614,27 +2605,18 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
        }
        
        /* local constraint shouldn't alter center */
-       if (t->around == V3D_LOCAL) {
-               if (t->flag & T_OBJECT) {
-                       VECCOPY(center, td->center);
-               }
-               else if (t->flag & T_EDIT) {
-                       
-                       if(t->around==V3D_LOCAL && (t->settings->selectmode & SCE_SELECT_FACE)) {
-                               VECCOPY(center, td->center);
-                       }
-                       else {
-                               VECCOPY(center, t->center);
-                       }
-               }
-               else {
-                       VECCOPY(center, t->center);
-               }
+       if ((t->around == V3D_LOCAL) &&
+               (   (t->flag & (T_OBJECT|T_POSE)) ||
+                   ((t->flag & T_EDIT) && (t->settings->selectmode & SCE_SELECT_FACE)) ||
+                   (t->obedit && t->obedit->type == OB_ARMATURE))
+               )
+       {
+               copy_v3_v3(center, td->center);
        }
        else {
-               VECCOPY(center, t->center);
+               copy_v3_v3(center, t->center);
        }
-       
+
        if (td->ext) {
                float fsize[3];
                
@@ -2732,10 +2714,10 @@ int Resize(TransInfo *t, const int mval[2])
        
        if (t->flag & T_AUTOVALUES)
        {
-               VECCOPY(size, t->auto_values);
+               copy_v3_v3(size, t->auto_values);
        }
        
-       VECCOPY(t->values, size);
+       copy_v3_v3(t->values, size);
        
        size_to_mat3( mat,size);
        
@@ -2886,10 +2868,6 @@ void initRotation(TransInfo *t)
        setInputPostFct(&t->mouse, postInputRotation);
        initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
        
-       t->ndof.axis = 16;
-       /* Scale down and flip input for rotation */
-       t->ndof.factor[0] = -0.2f;
-       
        t->idx_max = 0;
        t->num.idx_max = 0;
        t->snap[0] = 0.0f;
@@ -2911,19 +2889,17 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
        float vec[3], totmat[3][3], smat[3][3];
        float eul[3], fmat[3][3], quat[4];
        float *center = t->center;
-       
+
        /* local constraint shouldn't alter center */
        if (around == V3D_LOCAL) {
-               if (t->flag & (T_OBJECT|T_POSE)) {
+               if (    (t->flag & (T_OBJECT|T_POSE)) ||
+                       (t->settings->selectmode & SCE_SELECT_FACE) ||
+                       (t->obedit && t->obedit->type == OB_ARMATURE))
+               {
                        center = td->center;
                }
-               else {
-                       if(around==V3D_LOCAL && (t->settings->selectmode & SCE_SELECT_FACE)) {
-                               center = td->center;
-                       }
-               }
        }
-       
+
        if (t->flag & T_POINTS) {
                mul_m3_m3m3(totmat, mat, td->mtx);
                mul_m3_m3m3(smat, td->smtx, totmat);
@@ -3037,7 +3013,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                                mul_m3_m3m3(smat, td->smtx, totmat);
                                
                                /* calculate the total rotatation in eulers */
-                               VECCOPY(eul, td->ext->irot);
+                               copy_v3_v3(eul, td->ext->irot);
                                eulO_to_mat3( eulmat,eul, td->ext->rotOrder);
                                
                                /* mat = transform, obmat = bone rotation */
@@ -3047,7 +3023,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                                
                                /* and apply (to end result only) */
                                protectedRotateBits(td->protectflag, eul, td->ext->irot);
-                               VECCOPY(td->ext->rot, eul);
+                               copy_v3_v3(td->ext->rot, eul);
                        }
                        
                        constraintRotLim(t, td);
@@ -3117,7 +3093,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                                
                                /* and apply */
                                protectedRotateBits(td->protectflag, eul, td->ext->irot);
-                               VECCOPY(td->ext->rot, eul);
+                               copy_v3_v3(td->ext->rot, eul);
                        }
                        
                        constraintRotLim(t, td);
@@ -3161,8 +3137,6 @@ int Rotation(TransInfo *t, const int UNUSED(mval[2]))
 
        final = t->values[0];
        
-       applyNDofInput(&t->ndof, &final);
-       
        snapGrid(t, &final);
        
        if ((t->con.mode & CON_APPLY) && t->con.applyRot) {
@@ -3216,11 +3190,6 @@ void initTrackball(TransInfo *t)
 
        initMouseInputMode(t, &t->mouse, INPUT_TRACKBALL);
 
-       t->ndof.axis = 40;
-       /* Scale down input for rotation */
-       t->ndof.factor[0] = 0.2f;
-       t->ndof.factor[1] = 0.2f;
-
        t->idx_max = 1;
        t->num.idx_max = 1;
        t->snap[0] = 0.0f;
@@ -3268,16 +3237,14 @@ int Trackball(TransInfo *t, const int UNUSED(mval[2]))
        float mat[3][3], totmat[3][3], smat[3][3];
        float phi[2];
 
-       VECCOPY(axis1, t->persinv[0]);
-       VECCOPY(axis2, t->persinv[1]);
+       copy_v3_v3(axis1, t->persinv[0]);
+       copy_v3_v3(axis2, t->persinv[1]);
        normalize_v3(axis1);
        normalize_v3(axis2);
 
        phi[0] = t->values[0];
        phi[1] = t->values[1];
 
-       applyNDofInput(&t->ndof, phi);
-
        snapGrid(t, phi);
 
        if (hasNumInput(&t->num)) {
@@ -3322,6 +3289,11 @@ int Trackball(TransInfo *t, const int UNUSED(mval[2]))
 
 void initTranslation(TransInfo *t)
 {
+       if (t->spacetype == SPACE_ACTION) {
+               /* this space uses time translate */
+               t->state = TRANS_CANCEL;
+       }
+
        t->mode = TFM_TRANSLATION;
        t->transform = Translation;
 
@@ -3331,8 +3303,6 @@ void initTranslation(TransInfo *t)
        t->num.flag = 0;
        t->num.idx_max = t->idx_max;
 
-       t->ndof.axis = (t->flag & T_2D_EDIT)? 1|2: 1|2|4;
-
        if(t->spacetype == SPACE_VIEW3D) {
                RegionView3D *rv3d = t->ar->regiondata;
 
@@ -3369,7 +3339,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) {
        else {
                float dvec[3];
 
-               VECCOPY(dvec, vec);
+               copy_v3_v3(dvec, vec);
                applyAspectRatio(t, dvec);
 
                dist = len_v3(vec);
@@ -3399,10 +3369,10 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) {
                if(chainlen)
                        sprintf(autoik, "AutoIK-Len: %d", chainlen);
                else
-                       strcpy(autoik, "");
+                       autoik[0]= '\0';
        }
        else
-               strcpy(autoik, "");
+               autoik[0]= '\0';
 
        if (t->con.mode & CON_APPLY) {
                switch(t->num.idx_max) {
@@ -3476,7 +3446,7 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
                        t->con.applyVec(t, td, vec, tvec, pvec);
                }
                else {
-                       VECCOPY(tvec, vec);
+                       copy_v3_v3(tvec, vec);
                }
                
                mul_m3_v3(td->smtx, tvec);
@@ -3503,11 +3473,10 @@ int Translation(TransInfo *t, const int UNUSED(mval[2]))
                }
                applySnapping(t, t->values);
                t->con.applyVec(t, NULL, t->values, tvec, pvec);
-               VECCOPY(t->values, tvec);
+               copy_v3_v3(t->values, tvec);
                headerTranslation(t, pvec, str);
        }
        else {
-               applyNDofInput(&t->ndof, t->values);
                snapGrid(t, t->values);
                applyNumInput(&t->num, t->values);
                if (hasNumInput(&t->num)) {
@@ -3593,7 +3562,7 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
                if (td->flag & TD_SKIP)
                        continue;
 
-               VECCOPY(vec, td->axismtx[2]);
+               copy_v3_v3(vec, td->axismtx[2]);
                mul_v3_fl(vec, distance);
                mul_v3_fl(vec, td->factor);
 
@@ -3616,10 +3585,6 @@ void initTilt(TransInfo *t)
 
        initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
 
-       t->ndof.axis = 16;
-       /* Scale down and flip input for rotation */
-       t->ndof.factor[0] = -0.2f;
-
        t->idx_max = 0;
        t->num.idx_max = 0;
        t->snap[0] = 0.0f;
@@ -3643,8 +3608,6 @@ int Tilt(TransInfo *t, const int UNUSED(mval[2]))
 
        final = t->values[0];
 
-       applyNDofInput(&t->ndof, &final);
-
        snapGrid(t, &final);
 
        if (hasNumInput(&t->num)) {
@@ -3759,10 +3722,6 @@ void initPushPull(TransInfo *t)
 
        initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
 
-       t->ndof.axis = 4;
-       /* Flip direction */
-       t->ndof.factor[0] = -1.0f;
-
        t->idx_max = 0;
        t->num.idx_max = 0;
        t->snap[0] = 0.0f;
@@ -3783,8 +3742,6 @@ int PushPull(TransInfo *t, const int UNUSED(mval[2]))
 
        distance = t->values[0];
 
-       applyNDofInput(&t->ndof, &distance);
-
        snapGrid(t, &distance);
 
        applyNumInput(&t->num, &distance);
@@ -4301,12 +4258,11 @@ static int createSlideVerts(TransInfo *t)
        LinkNode *edgelist = NULL, *vertlist=NULL, *look;
        GHash *vertgh;
        TransDataSlideVert *tempsv;
-       float vertdist; // XXX, projectMat[4][4];
        int i, j, numsel, numadded=0, timesthrough = 0, vertsel=0;
        /* UV correction vars */
        GHash **uvarray= NULL;
        SlideData *sld = MEM_callocN(sizeof(*sld), "sld");
-       int  uvlay_tot= CustomData_number_of_layers(&em->fdata, CD_MTFACE);
+       const int  uvlay_tot=  (t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) ? CustomData_number_of_layers(&em->fdata, CD_MTFACE) : 0;
        int uvlay_idx;
        TransDataSlideUv *slideuvs=NULL, *suv=NULL, *suv_last=NULL;
        RegionView3D *v3d = t->ar ? t->ar->regiondata : NULL; /* background mode support */
@@ -4566,7 +4522,6 @@ static int createSlideVerts(TransInfo *t)
 
        look = vertlist;
        nearest = NULL;
-       vertdist = -1;
        while(look) {
                tempsv  = BLI_ghash_lookup(vertgh,(EditVert*)look->link);
 
@@ -4649,7 +4604,7 @@ static int createSlideVerts(TransInfo *t)
 
        add_v3_v3(start, end);
        mul_v3_fl(start, 0.5f*(1.0f/totvec));
-       VECCOPY(vec, start);
+       copy_v3_v3(vec, start);
        start[0] = t->mval[0];
        start[1] = t->mval[1];
        add_v3_v3v3(end, start, vec);
@@ -4659,7 +4614,7 @@ static int createSlideVerts(TransInfo *t)
 #define EDGE_SLIDE_MIN 30
        if (len_squared_v2v2(start, end) < (EDGE_SLIDE_MIN * EDGE_SLIDE_MIN)) {
                if(ABS(start[0]-end[0]) + ABS(start[1]-end[1]) < 4.0f) {
-                       /* even more exceptional case, points are ontop of eachother */
+                       /* even more exceptional case, points are ontop of each other */
                        end[0]= start[0];
                        end[1]= start[1] + EDGE_SLIDE_MIN;
                }
@@ -4678,7 +4633,7 @@ static int createSlideVerts(TransInfo *t)
        sld->end[0] = (int) end[0];
        sld->end[1] = (int) end[1];
        
-       if (uvlay_tot) { // XXX && (scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT)) {
+       if (uvlay_tot) {
                int maxnum = 0;
 
                uvarray = MEM_callocN( uvlay_tot * sizeof(GHash *), "SlideUVs Array");
@@ -4717,7 +4672,7 @@ static int createSlideVerts(TransInfo *t)
                                                        uv_new = tf->uv[k];
 
                                                        if (ev->tmp.l) {
-                                                               if (fabs(suv->origuv[0]-uv_new[0]) > 0.0001f || fabs(suv->origuv[1]-uv_new[1]) > 0.0001f) {
+                                                               if (fabsf(suv->origuv[0]-uv_new[0]) > 0.0001f || fabs(suv->origuv[1]-uv_new[1]) > 0.0001f) {
                                                                        ev->tmp.l = -1; /* Tag as invalid */
                                                                        BLI_linklist_free(suv->fuv_list,NULL);
                                                                        suv->fuv_list = NULL;
@@ -4868,8 +4823,6 @@ void initEdgeSlide(TransInfo *t)
 
 int doEdgeSlide(TransInfo *t, float perc)
 {
-       Mesh *me= t->obedit->data;
-       EditMesh *em = me->edit_mesh;
        SlideData *sld = t->customData;
        EditVert *ev, *nearest = sld->nearest;
        EditVert *centerVert, *upVert, *downVert;
@@ -4880,7 +4833,7 @@ int doEdgeSlide(TransInfo *t, float perc)
        int prop=1, flip=0;
        /* UV correction vars */
        GHash **uvarray= sld->uvhash;
-       int  uvlay_tot= CustomData_number_of_layers(&em->fdata, CD_MTFACE);
+       const int  uvlay_tot= sld->uvlay_tot;
        int uvlay_idx;
        TransDataSlideUv *suv;
        float uv_tmp[2];
@@ -4906,7 +4859,7 @@ int doEdgeSlide(TransInfo *t, float perc)
                        tempev = editedge_getOtherVert((perc>=0)?tempsv->up:tempsv->down, ev);
                        interp_v3_v3v3(ev->co, tempsv->origvert.co, tempev->co, fabs(perc));
 
-                       if (uvlay_tot) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
+                       if (uvlay_tot) {
                                for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
                                        suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
                                        if (suv && suv->fuv_list && suv->uv_up && suv->uv_down) {
@@ -4936,7 +4889,7 @@ int doEdgeSlide(TransInfo *t, float perc)
                        if(newlen < 0.0f) {newlen = 0.0;}
                        if(flip == 0) {
                                interp_v3_v3v3(ev->co, editedge_getOtherVert(tempsv->down,ev)->co, editedge_getOtherVert(tempsv->up,ev)->co, fabs(newlen));
-                               if (uvlay_tot) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
+                               if (uvlay_tot) {
                                        /* dont do anything if no UVs */
                                        for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
                                                suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
@@ -4953,7 +4906,7 @@ int doEdgeSlide(TransInfo *t, float perc)
                        } else{
                                interp_v3_v3v3(ev->co, editedge_getOtherVert(tempsv->up,ev)->co, editedge_getOtherVert(tempsv->down,ev)->co, fabs(newlen));
 
-                               if (uvlay_tot) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
+                               if (uvlay_tot) {
                                        /* dont do anything if no UVs */
                                        for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
                                                suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
@@ -5258,7 +5211,7 @@ int Align(TransInfo *t, const int UNUSED(mval[2]))
        int i;
 
        /* saving original center */
-       VECCOPY(center, t->center);
+       copy_v3_v3(center, t->center);
 
        for(i = 0 ; i < t->total; i++, td++)
        {
@@ -5272,11 +5225,11 @@ int Align(TransInfo *t, const int UNUSED(mval[2]))
 
                /* around local centers */
                if (t->flag & (T_OBJECT|T_POSE)) {
-                       VECCOPY(t->center, td->center);
+                       copy_v3_v3(t->center, td->center);
                }
                else {
                        if(t->settings->selectmode & SCE_SELECT_FACE) {
-                               VECCOPY(t->center, td->center);
+                               copy_v3_v3(t->center, td->center);
                        }
                }
 
@@ -5288,7 +5241,7 @@ int Align(TransInfo *t, const int UNUSED(mval[2]))
        }
 
        /* restoring original center */
-       VECCOPY(t->center, center);
+       copy_v3_v3(t->center, center);
 
        recalcData(t);
 
@@ -5309,8 +5262,6 @@ void initSeqSlide(TransInfo *t)
        t->num.flag = 0;
        t->num.idx_max = t->idx_max;
 
-       t->ndof.axis = 1|2;
-
        t->snap[0] = 0.0f;
        t->snap[1] = floor(t->scene->r.frs_sec / t->scene->r.frs_sec_base);
        t->snap[2] = 10.0f;
@@ -5362,10 +5313,9 @@ int SeqSlide(TransInfo *t, const int UNUSED(mval[2]))
                float pvec[3] = {0.0f, 0.0f, 0.0f};
                float tvec[3];
                t->con.applyVec(t, NULL, t->values, tvec, pvec);
-               VECCOPY(t->values, tvec);
+               copy_v3_v3(t->values, tvec);
        }
        else {
-               applyNDofInput(&t->ndof, t->values);
                snapGrid(t, t->values);
                applyNumInput(&t->num, t->values);
        }
@@ -5469,9 +5419,13 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d,
 {
        /* snap key to nearest frame? */
        if (autosnap == SACTSNAP_FRAME) {
+
+#if 0   /* 'doTime' disabled for now */
+
                const Scene *scene= t->scene;
                const short doTime= 0; //getAnimEdit_DrawTime(t); // NOTE: this works, but may be confusing behaviour given the option's label, hence disabled
                const double secf= FPS;
+#endif
                double val;
                
                /* convert frame to nla-action time (if needed) */
@@ -5480,11 +5434,17 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d,
                else
                        val= *(td->val);
                
+#if 0  /* 'doTime' disabled for now */
+
                /* do the snapping to nearest frame/second */
-               if (doTime)
+               if (doTime) {
                        val= (float)( floor((val/secf) + 0.5f) * secf );
+               }
                else
+#endif
+               {
                        val= (float)( floor(val+0.5f) );
+               }
                
                /* convert frame out of nla-action time */
                if (adt)
@@ -5599,7 +5559,7 @@ static void applyTimeTranslate(TransInfo *t, float UNUSED(sval))
 
        const short autosnap= getAnimEdit_SnapMode(t);
 
-       float deltax, val, valprev;
+       float deltax, val /* , valprev */;
 
        /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
        for (i = 0 ; i < t->total; i++, td++, td2d++) {
@@ -5609,7 +5569,7 @@ static void applyTimeTranslate(TransInfo *t, float UNUSED(sval))
                 */
                AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
 
-               valprev = *td->val;
+               /* valprev = *td->val; */ /* UNUSED */
 
                /* check if any need to apply nla-mapping */
                if (adt && t->spacetype != SPACE_SEQ) {
@@ -5783,8 +5743,8 @@ int TimeSlide(TransInfo *t, const int mval[2])
        char str[200];
 
        /* calculate mouse co-ordinates */
-       UI_view2d_region_to_view(v2d, mval[0], mval[0], &cval[0], &cval[1]);
-       UI_view2d_region_to_view(v2d, t->imval[0], t->imval[0], &sval[0], &sval[1]);
+       UI_view2d_region_to_view(v2d, mval[0], mval[1], &cval[0], &cval[1]);
+       UI_view2d_region_to_view(v2d, t->imval[0], t->imval[1], &sval[0], &sval[1]);
 
        /* t->values[0] stores cval[0], which is the current mouse-pointer location (in frames) */
        // XXX Need to be able to repeat this
@@ -5925,54 +5885,3 @@ void BIF_TransformSetUndo(char *UNUSED(str))
        // TRANSFORM_FIX_ME
        //Trans.undostr= str;
 }
-
-
-#if 0 // TRANSFORM_FIX_ME
-static void NDofTransform(void)
-{
-       float fval[7];
-       float maxval = 50.0f; // also serves as threshold
-       int axis = -1;
-       int mode = 0;
-       int i;
-
-       getndof(fval);
-
-       for(i = 0; i < 6; i++)
-       {
-               float val = fabs(fval[i]);
-               if (val > maxval)
-               {
-                       axis = i;
-                       maxval = val;
-               }
-       }
-
-       switch(axis)
-       {
-               case -1:
-                       /* No proper axis found */
-                       break;
-               case 0:
-               case 1:
-               case 2:
-                       mode = TFM_TRANSLATION;
-                       break;
-               case 4:
-                       mode = TFM_ROTATION;
-                       break;
-               case 3:
-               case 5:
-                       mode = TFM_TRACKBALL;
-                       break;
-               default:
-                       printf("ndof: what we are doing here ?");
-       }
-
-       if (mode != 0)
-       {
-               initTransform(mode, CTX_NDOF);
-               Transform();
-       }
-}
-#endif