Fixed constraint center calculation. Much smarter to do it when calculating transform...
authorMartin Poirier <theeth@yahoo.com>
Wed, 16 Mar 2005 21:55:57 +0000 (21:55 +0000)
committerMartin Poirier <theeth@yahoo.com>
Wed, 16 Mar 2005 21:55:57 +0000 (21:55 +0000)
Fixed Extrude constraint. Needed to premul the normal by the object's matrix to but it in global space.

Also, moved the Locking Axis modifier (for constraints) from Alt to Shift. Alt was conflicting with middle mouse button emulation (reported in the test builds forum).

Tilt Transformation.

source/blender/include/BIF_transform.h
source/blender/src/editmesh_tools.c
source/blender/src/space.c
source/blender/src/transform.c
source/blender/src/transform.h
source/blender/src/transform_constraints.c
source/blender/src/transform_generics.c
source/blender/src/transform_generics.h
source/blender/src/transform_numinput.c
source/blender/src/transform_numinput.h

index 07faf2a615d6dfca89aecab8b7b10cb51541aec7..37f4b97ebb06006fdb7207805c50b7fc0915ef2e 100755 (executable)
@@ -46,6 +46,7 @@
 #define TFM_SHEAR                      5
 #define TFM_WARP                       7
 #define TFM_SHRINKFATTEN       8
+#define TFM_TILT                       9
 
 #define TFM_LAMP_ENERGY                10
 
index 51d8c07aedefe5661d61ba89de4bb06b92b5570a..9c88d9142547d075c1817162c48e93e3b0360953 100644 (file)
@@ -568,8 +568,11 @@ void extrude_mesh(void)
                        Transform(TFM_SHRINKFATTEN);
                }
                else {
-                       if(transmode=='n') 
+                       if(transmode=='n') {
+                               Mat4MulVecfl(G.obedit->obmat, nor);
+                               VecSubf(nor, nor, G.obedit->obmat[3]);
                                BIF_setSingleAxisConstraint(nor);
+                       }
                        Transform(TFM_TRANSLATION);
                }
 #else
index 1dee307202513ca5a011ea2f2fe2e2234fb2909a..42f081c55e42c8c4ac614a51a8cfbc0e3d3e0789 100644 (file)
@@ -1550,10 +1550,18 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                                countall();
                                                makeDispList(G.obedit);
                                        }
-                                       else if((G.qual==LR_ALTKEY) && G.obedit->type==OB_CURVE)
-                                               clear_tilt();
-                                       else if((G.qual==0))
-                                               transform('t');
+                                       if (G.obedit->type==OB_CURVE) {
+                                               if (G.qual==LR_ALTKEY) {
+                                                       clear_tilt();
+                                               }
+                                               else if (G.qual==0) {
+#ifdef NEWTRANSFORM
+                                                       Transform(TFM_TILT);
+#else
+                                                       transform('t');
+#endif
+                                               }
+                                       }
                                }
                                else if(G.qual==LR_CTRLKEY) {
                                        make_track();
index fb024d9b05b32f70f1f93b5d504c67d23ed870f8..0a598fd52f8928804f3dad058a2baca4a80edf03 100755 (executable)
@@ -410,6 +410,7 @@ static void createTransPose(void)
        for(i=0; i<Trans.total; i++, td++, tdx++) {
                td->ext= tdx;
                td->tdi = NULL;
+               td->val = NULL;
        }       
        /* recursive fill trans data */
        td= Trans.data;
@@ -452,6 +453,7 @@ static void createTransArmatureVerts(void)
 
                        td->ext = NULL;
                        td->tdi = NULL;
+                       td->val = NULL;
 
                        td++;
                }
@@ -466,6 +468,7 @@ static void createTransArmatureVerts(void)
 
                        td->ext = NULL;
                        td->tdi = NULL;
+                       td->val = NULL;
 
                        td++;
                }
@@ -513,6 +516,7 @@ static void createTransMBallVerts(void)
 
                        td->ext = tx;
                        td->tdi = NULL;
+                       td->val = NULL;
 
                        tx->size = &ml->expx;
                        tx->isize[0] = ml->expx;
@@ -582,6 +586,7 @@ static void createTransCurveVerts(void)
                                                else td->flag= 0;
                                                td->ext = NULL;
                                                td->tdi = NULL;
+                                               td->val = NULL;
 
                                                Mat3CpyMat3(td->smtx, smtx);
                                                Mat3CpyMat3(td->mtx, mtx);
@@ -589,6 +594,7 @@ static void createTransCurveVerts(void)
                                                td++;
                                                count++;
                                        }
+                                       /* THIS IS THE CV, the other two are handles */
                                        if(propmode || (bezt->f2 & 1)) {
                                                VECCOPY(td->iloc, bezt->vec[1]);
                                                td->loc= bezt->vec[1];
@@ -597,6 +603,8 @@ static void createTransCurveVerts(void)
                                                else td->flag= 0;
                                                td->ext = NULL;
                                                td->tdi = NULL;
+                                               td->val = &(bezt->alfa);
+                                               td->ival = bezt->alfa;
 
                                                Mat3CpyMat3(td->smtx, smtx);
                                                Mat3CpyMat3(td->mtx, mtx);
@@ -612,6 +620,7 @@ static void createTransCurveVerts(void)
                                                else td->flag= 0;
                                                td->ext = NULL;
                                                td->tdi = NULL;
+                                               td->val = NULL;
 
                                                Mat3CpyMat3(td->smtx, smtx);
                                                Mat3CpyMat3(td->mtx, mtx);
@@ -633,6 +642,8 @@ static void createTransCurveVerts(void)
                                                else td->flag= 0;
                                                td->ext = NULL;
                                                td->tdi = NULL;
+                                               td->val = &(bp->alfa);
+                                               td->ival = bp->alfa;
 
                                                Mat3CpyMat3(td->smtx, smtx);
                                                Mat3CpyMat3(td->mtx, mtx);
@@ -690,6 +701,7 @@ static void createTransLatticeVerts(void)
 
                                td->ext = NULL;
                                td->tdi = NULL;
+                               td->val = NULL;
 
                                td++;
                                count++;
@@ -717,6 +729,7 @@ static void VertsToTransData(TransData *td, EditVert *eve)
 
        td->ext = NULL;
        td->tdi = NULL;
+       td->val = NULL;
 }
 
 static void createTransEditVerts(void)
@@ -1190,12 +1203,14 @@ static void createTransObject(void)
                                }
                                else {
                                        ObjectToTransData(td, ob);
-                                       td->tdi= NULL;
+                                       td->tdi = NULL;
+                                       td->val = NULL;
                                }
                        }
                        else {
                                ObjectToTransData(td, ob);
-                               td->tdi= NULL;
+                               td->tdi = NULL;
+                               td->val = NULL;
                        }
                        td++;
                        tx++;
@@ -1266,12 +1281,6 @@ void Transform(int mode)
        areawinset(curarea->win);
 
        Mat3One(mati);
-       /* FOR TESTS
-       {
-               float axis[3] = {0.0f, 0.0f, 1.0f};
-               VecRotToMat3(axis, M_PI / 3, mati);
-       }
-       */
 
        /* stupid PET initialisation code */
        /* START */
@@ -1325,6 +1334,9 @@ void Transform(int mode)
        case TFM_SHRINKFATTEN:
                initShrinkFatten(&Trans);
                break;
+       case TFM_TILT:
+               initTilt(&Trans);
+               break;
        }
 
        // Emptying event queue
@@ -1360,9 +1372,11 @@ void Transform(int mode)
 
                        if(val) {
                                switch (event){
-                                       // enforce redraw of transform when modifiers are used
+                               /* enforce redraw of transform when modifiers are used */
                                case LEFTCTRLKEY:
                                case RIGHTCTRLKEY:
+                               case LEFTSHIFTKEY:
+                               case RIGHTSHIFTKEY:
                                        Trans.redraw = 1;
                                        break;
                                        
@@ -1401,7 +1415,7 @@ void Transform(int mode)
                                        else if(cmode == 'x') {
                                                if (G.qual == 0)
                                                        setLocalConstraint(&Trans, (CON_AXIS0), "along local X");
-                                               else if (G.qual == LR_ALTKEY)
+                                               else if (G.qual == LR_SHIFTKEY)
                                                        setLocalConstraint(&Trans, (CON_AXIS1|CON_AXIS2), "locking local X");
 
                                                cmode = 'X';
@@ -1409,7 +1423,7 @@ void Transform(int mode)
                                        else {
                                                if (G.qual == 0)
                                                        setConstraint(&Trans, mati, (CON_AXIS0), "along global X");
-                                               else if (G.qual == LR_ALTKEY)
+                                               else if (G.qual == LR_SHIFTKEY)
                                                        setConstraint(&Trans, mati, (CON_AXIS1|CON_AXIS2), "locking global X");
 
                                                cmode = 'x';
@@ -1424,7 +1438,7 @@ void Transform(int mode)
                                        else if(cmode == 'y') {
                                                if (G.qual == 0)
                                                        setLocalConstraint(&Trans, (CON_AXIS1), "along global Y");
-                                               else if (G.qual == LR_ALTKEY)
+                                               else if (G.qual == LR_SHIFTKEY)
                                                        setLocalConstraint(&Trans, (CON_AXIS0|CON_AXIS2), "locking global Y");
 
                                                cmode = 'Y';
@@ -1432,7 +1446,7 @@ void Transform(int mode)
                                        else {
                                                if (G.qual == 0)
                                                        setConstraint(&Trans, mati, (CON_AXIS1), "along local Y");
-                                               else if (G.qual == LR_ALTKEY)
+                                               else if (G.qual == LR_SHIFTKEY)
                                                        setConstraint(&Trans, mati, (CON_AXIS0|CON_AXIS2), "locking local Y");
 
                                                cmode = 'y';
@@ -1447,7 +1461,7 @@ void Transform(int mode)
                                        else if(cmode == 'z') {
                                                if (G.qual == 0)
                                                        setLocalConstraint(&Trans, (CON_AXIS2), "along local Z");
-                                               else if (G.qual == LR_ALTKEY)
+                                               else if (G.qual == LR_SHIFTKEY)
                                                        setLocalConstraint(&Trans, (CON_AXIS0|CON_AXIS1), "locking local Z");
 
                                                cmode = 'Z';
@@ -1455,7 +1469,7 @@ void Transform(int mode)
                                        else {
                                                if (G.qual == 0)
                                                        setConstraint(&Trans, mati, (CON_AXIS2), "along global Z");
-                                               else if (G.qual == LR_ALTKEY)
+                                               else if (G.qual == LR_SHIFTKEY)
                                                        setConstraint(&Trans, mati, (CON_AXIS0|CON_AXIS1), "locking global Z");
 
                                                cmode = 'z';
@@ -1492,6 +1506,13 @@ void Transform(int mode)
                        }
                        else {
                                switch (event){
+                               /* enforce redraw of transform when modifiers are used */
+                               case LEFTCTRLKEY:
+                               case RIGHTCTRLKEY:
+                               case LEFTSHIFTKEY:
+                               case RIGHTSHIFTKEY:
+                                       Trans.redraw = 1;
+                                       break;
                                case MIDDLEMOUSE:
                                        postSelectConstraint(&Trans);
                                        Trans.redraw = 1;
@@ -2390,3 +2411,91 @@ int ShrinkFatten(TransInfo *t, short mval[2])
 
        return 1;
 }
+
+/* ************************** TILT *************************** */
+
+void initTilt(TransInfo *t) 
+{
+       t->idx_max = 0;
+       t->num.idx_max = 0;
+       t->snap[0] = 0.0f;
+       t->snap[1] = G.vd->grid * (float)((5.0/180)*M_PI);
+       t->snap[2] = t->snap[1] * 0.2f;
+       t->fac = 0;
+       t->transform = Tilt;
+}
+
+
+
+int Tilt(TransInfo *t, short mval[2]) 
+{
+       TransData *td = t->data;
+       int i;
+       char str[50];
+
+       float final;
+
+       int dx2 = t->center2d[0] - mval[0];
+       int dy2 = t->center2d[1] - mval[1];
+       float B = (float)sqrt(dx2*dx2+dy2*dy2);
+
+       int dx1 = t->center2d[0] - t->imval[0];
+       int dy1 = t->center2d[1] - t->imval[1];
+       float A = (float)sqrt(dx1*dx1+dy1*dy1);
+
+       int dx3 = mval[0] - t->imval[0];
+       int dy3 = mval[1] - t->imval[1];
+
+       float deler= ((dx1*dx1+dy1*dy1)+(dx2*dx2+dy2*dy2)-(dx3*dx3+dy3*dy3))
+               / (2 * A * B);
+
+       float dphi;
+
+       dphi = saacos(deler);
+       if( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi;
+
+       if(G.qual & LR_SHIFTKEY) t->fac += dphi/30.0f;
+       else t->fac += dphi;
+
+       final = t->fac;
+
+       snapGrid(t, &final);
+
+       t->imval[0] = mval[0];
+       t->imval[1] = mval[1];
+
+       if (hasNumInput(&t->num)) {
+               char c[20];
+
+               applyNumInput(&t->num, &final);
+
+               outputNumInput(&(t->num), c);
+
+               sprintf(str, "Tilt: %s %s", &c[0], t->proptext);
+
+               final *= (float)(M_PI / 180.0);
+       }
+       else {
+               sprintf(str, "Tilt: %.2f %s", 180.0*final/M_PI, t->proptext);
+       }
+
+       for(i = 0 ; i < t->total; i++, td++) {
+               if (td->flag & TD_NOACTION)
+                       break;
+
+               if (td->val) {
+                       *td->val = td->ival + final * td->factor;
+               }
+       }
+
+       recalcData(t);
+
+       headerprint(str);
+
+       force_draw(0);
+
+       helpline (t->center);
+
+       return 1;
+}
+
index 20359cc00ec210b001b4ee9a7dc5fd305b5b5ce6..b69999d4e9414e0be4f332aa1cd2e16dfafc285c 100755 (executable)
@@ -83,7 +83,6 @@ typedef struct TransDataExtension {
     float *size;         /* Size of the data to transform (Faculative)                                     */
     float  isize[3];    /* Initial size                                                                   */
        float  obmat[3][3];      /* Object matrix */  
-
        void *bone;                     /* ARGH! old transform demanded it, added for now (ton) */
 } TransDataExtension;
 
@@ -92,6 +91,8 @@ typedef struct TransData {
        float  factor;       /* Factor of the transformation (for Proportionnal Editing)                       */
     float *loc;          /* Location of the data to transform                                              */
     float  iloc[3];      /* Initial location                                                               */
+       float *val;          /* Value pointer for special transforms */
+       float  ival;         /* Old value*/
     float  center[3];   /* Individual data center                                                         */
     float  mtx[3][3];    /* Transformation matrix from data space to global space                          */
     float  smtx[3][3];   /* Transformation matrix from global space to data space                          */
@@ -135,18 +136,6 @@ typedef struct TransInfo {
 #define NOFRACTION             16
 #define        AFFECTALL               32
 
-/* transinfo->mode */
-#define TFM_REPEAT                     0
-#define TFM_TRANSLATION                1
-#define TFM_ROTATION           2
-#define TFM_RESIZE                     3
-#define TFM_TOSPHERE           4
-#define TFM_SHEAR                      5
-#define TFM_WARP                       7
-#define TFM_SHRINKFATTEN       8
-
-#define TFM_LAMP_ENERGY                10
-
 /* transinfo->flag */
 #define T_OBJECT               1
 #define T_EDIT                 2
@@ -161,12 +150,6 @@ typedef struct TransInfo {
 #define CON_SELECT             16
 #define CON_NOFLIP             32      /* does not reorient vector to face viewport when on */
 
-#define PROP_SHARP             0
-#define PROP_SMOOTH            1
-#define PROP_ROOT              2
-#define PROP_LIN               3
-#define PROP_CONST             4
-
 /* transdata->flag */
 #define TD_SELECTED            1
 #define        TD_NOACTION             2
@@ -195,5 +178,8 @@ int Rotation(TransInfo *t, short mval[2]);
 void initShrinkFatten(TransInfo *t);
 int ShrinkFatten(TransInfo *t, short mval[2]);
 
+void initTilt(TransInfo *t);
+int Tilt(TransInfo *t, short mval[2]);
+
 #endif
 
index 5793ffc69e7ba554d5145e8960725c1612f3d28f..00cacf395029e584f05ca6ded0068d79b8386483 100755 (executable)
@@ -117,7 +117,7 @@ void getConstraintMatrix(TransInfo *t);
 void constraintNumInput(TransInfo *t, float vec[3])
 {
        int mode = t->con.mode;
-       float nval = (t->num.flags & NULLONE)?1.0f:0.0f;
+       float nval = (t->num.flag & NULLONE)?1.0f:0.0f;
 
        if (getConstraintSpaceDimension(t) == 2) {
                if (mode & (CON_AXIS0|CON_AXIS1)) {
@@ -158,7 +158,7 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) {
 
        snapGrid(t, vec);
 
-       if (t->num.flags & NULLONE) {
+       if (t->num.flag & NULLONE) {
                if (!(t->con.mode & CON_AXIS0))
                        vec[0] = 1.0f;
 
@@ -394,6 +394,7 @@ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3]
                Mat3MulMat3(smat, td->axismtx, tmat);
        }
 }
+
 /*
  * Generic callback for constant spacial constraints applied to rotations
  * 
@@ -481,25 +482,25 @@ static void drawObjectConstraint(TransInfo *t) {
        TransData * td = t->data;
 
        if (t->con.mode & CON_AXIS0) {
-               drawLine(td->ob->obmat[3], td->axismtx[0], 255 - 'x');
+               drawLine(td->ob->obmat[3], td->axismtx[0], 'x', DRAWLIGHT);
        }
        if (t->con.mode & CON_AXIS1) {
-               drawLine(td->ob->obmat[3], td->axismtx[1], 255 - 'y');
+               drawLine(td->ob->obmat[3], td->axismtx[1], 'y', DRAWLIGHT);
        }
        if (t->con.mode & CON_AXIS2) {
-               drawLine(td->ob->obmat[3], td->axismtx[2], 255 - 'z');
+               drawLine(td->ob->obmat[3], td->axismtx[2], 'z', DRAWLIGHT);
        }
 
        td++;
        for(i=1;i<t->total;i++,td++) {
                if (t->con.mode & CON_AXIS0) {
-                       drawLine(td->ob->obmat[3], td->axismtx[0], 'x');
+                       drawLine(td->ob->obmat[3], td->axismtx[0], 'x', 0);
                }
                if (t->con.mode & CON_AXIS1) {
-                       drawLine(td->ob->obmat[3], td->axismtx[1], 'y');
+                       drawLine(td->ob->obmat[3], td->axismtx[1], 'y', 0);
                }
                if (t->con.mode & CON_AXIS2) {
-                       drawLine(td->ob->obmat[3], td->axismtx[2], 'z');
+                       drawLine(td->ob->obmat[3], td->axismtx[2], 'z', 0);
                }
        }
 }
@@ -541,11 +542,6 @@ void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[])
        t->con.mode = mode;
        getConstraintMatrix(t);
 
-       VECCOPY(t->con.center, t->center);
-       if (t->flag & T_EDIT) {
-               Mat4MulVecfl(G.obedit->obmat, t->con.center);
-       }
-
        startConstraint(t);
 
        t->con.applyVec = applyAxisConstraintVec;
@@ -570,8 +566,6 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[]) {
                        t->con.mode = mode;
                        getConstraintMatrix(t);
 
-                       VECCOPY(t->con.center, t->center);
-
                        startConstraint(t);
 
                        t->con.drawExtra = drawObjectConstraint;
@@ -599,11 +593,6 @@ void BIF_setSingleAxisConstraint(float vec[3]) {
        t->con.mode = (CON_AXIS0|CON_APPLY);
        getConstraintMatrix(t);
 
-       VECCOPY(t->con.center, t->center);
-       if (t->flag & T_OBJECT) {
-               Mat4MulVecfl(G.obedit->obmat, t->con.center);
-       }
-
        t->con.drawExtra = NULL;
        t->con.applyVec = applyAxisConstraintVec;
        t->con.applySize = applyAxisConstraintSize;
@@ -613,7 +602,6 @@ void BIF_setSingleAxisConstraint(float vec[3]) {
 
 void BIF_drawConstraint(void)
 {
-       //int i = -1;
        TransInfo *t = BIF_GetTransInfo();
        TransCon *tc = &(t->con);
 
@@ -625,19 +613,19 @@ void BIF_drawConstraint(void)
        }
        else {
                if (tc->mode & CON_SELECT) {
-                               drawLine(tc->center, tc->mtx[0], 'x');
-                               drawLine(tc->center, tc->mtx[1], 'y');
-                               drawLine(tc->center, tc->mtx[2], 'z');
+                               drawLine(tc->center, tc->mtx[0], 'x', 0);
+                               drawLine(tc->center, tc->mtx[1], 'y', 0);
+                               drawLine(tc->center, tc->mtx[2], 'z', 0);
                }
 
                if (tc->mode & CON_AXIS0) {
-                       drawLine(tc->center, tc->mtx[0], 255 - 'x');
+                       drawLine(tc->center, tc->mtx[0], 'x', DRAWLIGHT);
                }
                if (tc->mode & CON_AXIS1) {
-                       drawLine(tc->center, tc->mtx[1], 255 - 'y');
+                       drawLine(tc->center, tc->mtx[1], 'y', DRAWLIGHT);
                }
                if (tc->mode & CON_AXIS2) {
-                       drawLine(tc->center, tc->mtx[2], 255 - 'z');
+                       drawLine(tc->center, tc->mtx[2], 'z', DRAWLIGHT);
                }
        }
 }
@@ -783,7 +771,7 @@ void setNearestAxis(TransInfo *t)
        }
 
        if (len[0] < len[1] && len[0] < len[2]) {
-               if (G.qual == LR_ALTKEY) {
+               if (G.qual & LR_SHIFTKEY) {
                        t->con.mode |= (CON_AXIS1|CON_AXIS2);
                        strcpy(t->con.text, " locking global X");
                }
@@ -793,7 +781,7 @@ void setNearestAxis(TransInfo *t)
                }
        }
        else if (len[1] < len[0] && len[1] < len[2]) {
-               if (G.qual == LR_ALTKEY) {
+               if (G.qual & LR_SHIFTKEY) {
                        t->con.mode |= (CON_AXIS0|CON_AXIS2);
                        strcpy(t->con.text, " locking global Y");
                }
@@ -803,7 +791,7 @@ void setNearestAxis(TransInfo *t)
                }
        }
        else if (len[2] < len[1] && len[2] < len[0]) {
-               if (G.qual == LR_ALTKEY) {
+               if (G.qual & LR_SHIFTKEY) {
                        t->con.mode |= (CON_AXIS0|CON_AXIS1);
                        strcpy(t->con.text, " locking global Z");
                }
index 5fe4c2ec09d85639a9f42ea3de2325e300a20f53..7c8e7ecc7ba267bfe50b770e006b5b2f32038a2f 100755 (executable)
@@ -289,21 +289,21 @@ void recalcData(TransInfo *t)
 void initTransModeFlags(TransInfo *t, int mode) 
 {
        t->flag = 0;
-       t->num.flags = 0;
+       t->num.flag = 0;
        t->mode = mode;
        
        switch (mode) {
        case TFM_RESIZE:
-               t->num.flags |= NULLONE;
-               t->num.flags |= AFFECTALL;
+               t->num.flag |= NULLONE;
+               t->num.flag |= AFFECTALL;
                if (!G.obedit) {
                        t->flag |= NOZERO;
-                       t->num.flags |= NOZERO;
+                       t->num.flag |= NOZERO;
                }
                break;
        case TFM_TOSPHERE:
-               t->num.flags |= NULLONE;
-               t->num.flags |= NONEGATIVE;
+               t->num.flag |= NULLONE;
+               t->num.flag |= NONEGATIVE;
                t->flag |= NOCONSTRAINT;
                break;
        case TFM_SHEAR:
@@ -312,7 +312,7 @@ void initTransModeFlags(TransInfo *t, int mode)
        }
 }
 
-void drawLine(float *center, float *dir, char axis)
+void drawLine(float *center, float *dir, char axis, short options)
 {
        extern void make_axis_color(char *col, char *col2, char axis);  // drawview.c
        float v1[3], v2[3], v3[3];
@@ -326,9 +326,8 @@ void drawLine(float *center, float *dir, char axis)
        VecSubf(v2, center, v3);
        VecAddf(v1, center, v3);
 
-       if (axis > 127) {
-               axis = -1 * (axis - 255);
-               col[0] = col[1] = col[2] = 200;
+       if (options & DRAWLIGHT) {
+               col[0] = col[1] = col[2] = 220;
        }
        else {
                BIF_GetThemeColor3ubv(TH_GRID, col);
@@ -473,7 +472,9 @@ void restoreTransObjects(TransInfo *t)
        
        for (td = t->data; td < t->data + t->total; td++) {
                VECCOPY(td->loc, td->iloc);
-               
+               if (td->val) {
+                       *td->val = td->ival;
+               }
                if (td->ext) {
                        if (td->ext->rot) {
                                VECCOPY(td->ext->rot, td->ext->irot);
@@ -623,6 +624,12 @@ void calculateCenter(TransInfo *t)
                break;
        }
 
+       /* setting constraint center */
+       VECCOPY(t->con.center, t->center);
+       if(t->flag & T_EDIT) {
+               Mat4MulVecfl(G.obedit->obmat, t->con.center);
+       }
+
        /* voor panning from cameraview */
        if(t->flag & T_OBJECT) {
                if( G.vd->camera==OBACT && G.vd->persp>1) {
index a957bc3b05928b33c500acd64ac66861efd16ccd..54cbdfaa7f6565076431d1a367e09f205cfba4ef 100755 (executable)
@@ -37,9 +37,12 @@ void recalcData(TransInfo *t);
 
 void initTransModeFlags(TransInfo *t, int mode);
 
-void drawLine(float *center, float *dir, char axis);
+void drawLine(float *center, float *dir, char axis, short options);
 
-void postTrans (TransInfo *t);
+/* DRAWLINE options flags */
+#define DRAWLIGHT      1
+#define DRAWDASHED     2
+#define DRAWBOLD       4
 
 void apply_grid1(float *val, int max_index, float factor);
 void apply_grid2(float *val, int max_index, float factor, float factor2);
@@ -49,6 +52,7 @@ void applyTransObjects(TransInfo *t);
 void restoreTransObjects(TransInfo *t);
 
 void initTrans(TransInfo *t);
+void postTrans (TransInfo *t);
 
 void calculateCenterBound(TransInfo *t);
 void calculateCenterMedian(TransInfo *t);
index c83955f46f777d09ebb549e435c7a859acf45e16..dcf582b41e7412025f2104673542ab001257bb77 100755 (executable)
@@ -67,7 +67,7 @@ void outputNumInput(NumInput *n, char *str)
 
        for (j=0; j<=n->idx_max; j++) {
                /* if AFFECTALL and no number typed and cursor not on number, use first number */
-               if (n->flags & AFFECTALL && n->idx != j && n->ctrl[j] == 0)
+               if (n->flag & AFFECTALL && n->idx != j && n->ctrl[j] == 0)
                        i = 0;
                else
                        i = j;
@@ -125,15 +125,15 @@ void applyNumInput(NumInput *n, float *vec)
        if (hasNumInput(n)) {
                for (j=0; j<=n->idx_max; j++) {
                        /* if AFFECTALL and no number typed and cursor not on number, use first number */
-                       if (n->flags & AFFECTALL && n->idx != j && n->ctrl[j] == 0)
+                       if (n->flag & AFFECTALL && n->idx != j && n->ctrl[j] == 0)
                                i = 0;
                        else
                                i = j;
 
-                       if (n->ctrl[i] == 0 && n->flags & NULLONE) {
+                       if (n->ctrl[i] == 0 && n->flag & NULLONE) {
                                vec[j] = 1.0f;
                        }
-                       else if (n->val[i] == 0.0f && n->flags & NOZERO) {
+                       else if (n->val[i] == 0.0f && n->flag & NOZERO) {
                                vec[j] = 0.0001f;
                        }
                        else {
@@ -165,7 +165,7 @@ char handleNumInput(NumInput *n, unsigned short event)
                break;
        case PERIODKEY:
        case PADPERIOD:
-               if (n->flags & NOFRACTION)
+               if (n->flag & NOFRACTION)
                        break;
 
                switch (n->ctrl[idx])
@@ -179,7 +179,7 @@ char handleNumInput(NumInput *n, unsigned short event)
                }
                break;
        case MINUSKEY:
-               if (n->flags & NONEGATIVE)
+               if (n->flag & NONEGATIVE)
                        break;
 
                if (n->ctrl[idx]) {
index 61e99dd3ac20ba98bf308dfac53d7dd4879e66fe..36114c7cc71aad1b378bbf9499bc4862658dd825 100755 (executable)
@@ -36,7 +36,7 @@
 typedef struct NumInput {
     short  idx;
     short  idx_max;
-    short  flags;        /* Different flags to indicate different behaviors                                */
+    short  flag;        /* Different flags to indicate different behaviors                                */
     float  val[3];       /* Direct value of the input                                                      */
     short  ctrl[3];      /* Control to indicate what to do with the numbers that are typed                 */
 } NumInput ;