replace VECCOPY and QUATCOPY with inline funcs.
[blender.git] / source / blender / editors / transform / transform.c
index c8b9572..9c1d5ad 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -1358,6 +1356,11 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
        int proportional = 0;
        PropertyRNA *prop;
 
+       // 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)) {
@@ -1538,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;
@@ -1686,8 +1690,8 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
                        values[0]= RNA_float_get(op->ptr, "value");
                }
 
-               QUATCOPY(t->values, values);
-               QUATCOPY(t->auto_values, values);
+               copy_v4_v4(t->values, values);
+               copy_v4_v4(t->auto_values, values);
                t->flag |= T_AUTOVALUES;
        }
 
@@ -1917,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;
 
@@ -2601,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) {
-                       copy_v3_v3(center, td->center);
-               }
-               else if (t->flag & T_EDIT) {
-                       
-                       if(t->around==V3D_LOCAL && (t->settings->selectmode & SCE_SELECT_FACE)) {
-                               copy_v3_v3(center, td->center);
-                       }
-                       else {
-                               copy_v3_v3(center, t->center);
-                       }
-               }
-               else {
-                       copy_v3_v3(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 {
                copy_v3_v3(center, t->center);
        }
-       
+
        if (td->ext) {
                float fsize[3];
                
@@ -2894,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);
@@ -3296,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;
 
@@ -4260,7 +4258,6 @@ 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;
@@ -4525,7 +4522,6 @@ static int createSlideVerts(TransInfo *t)
 
        look = vertlist;
        nearest = NULL;
-       vertdist = -1;
        while(look) {
                tempsv  = BLI_ghash_lookup(vertgh,(EditVert*)look->link);
 
@@ -5563,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++) {
@@ -5573,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) {