Toggle between Connected and Normal PET.
authorMartin Poirier <theeth@yahoo.com>
Thu, 7 Apr 2005 18:28:41 +0000 (18:28 +0000)
committerMartin Poirier <theeth@yahoo.com>
Thu, 7 Apr 2005 18:28:41 +0000 (18:28 +0000)
Alt-C during transform (hotkey subject to change)

No visual clue right now other than what is transformed and it gets resetted everytime (not kept as a global flag).

So, still a lot to do regarding that.

source/blender/src/transform.c
source/blender/src/transform.h
source/blender/src/transform_generics.c

index bac4d59a7ba5b7a8166b86363ce1af8d6797fea0..e7d4b3bc22dcb44424b445cc6250da99f307d8bf 100755 (executable)
@@ -128,15 +128,22 @@ int       LastMode = TFM_TRANSLATION;
 
 /* ************************** Functions *************************** */
 
-static void qsort_trans_data(TransData *head, TransData *tail) {
+static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail) {
        TransData pivot = *head;
        TransData *ihead = head;
        TransData *itail = tail;
+       short connected = t->flag & T_PROP_CONNECTED;
 
        while (head < tail)
        {
-               while ((tail->dist >= pivot.dist) && (head < tail))
-                       tail--;
+               if (connected) {
+                       while ((tail->dist >= pivot.dist) && (head < tail))
+                               tail--;
+               }
+               else {
+                       while ((tail->rdist >= pivot.rdist) && (head < tail))
+                               tail--;
+               }
 
                if (head != tail)
                {
@@ -144,8 +151,14 @@ static void qsort_trans_data(TransData *head, TransData *tail) {
                        head++;
                }
 
-               while ((head->dist <= pivot.dist) && (head < tail))
-                       head++;
+               if (connected) {
+                       while ((head->dist <= pivot.dist) && (head < tail))
+                               head++;
+               }
+               else {
+                       while ((head->rdist <= pivot.rdist) && (head < tail))
+                               head++;
+               }
 
                if (head != tail)
                {
@@ -156,10 +169,10 @@ static void qsort_trans_data(TransData *head, TransData *tail) {
 
        *head = pivot;
        if (ihead < head) {
-               qsort_trans_data(ihead, head-1);
+               qsort_trans_data(t, ihead, head-1);
        }
        if (itail > head) {
-               qsort_trans_data(head+1, itail);
+               qsort_trans_data(t, head+1, itail);
        }
 }
 
@@ -171,7 +184,7 @@ static void sort_trans_data_dist(TransInfo *t) {
                start++;
                i++;
        }
-       qsort_trans_data(start, t->data + t->total - 1);
+       qsort_trans_data(t, start, t->data + t->total - 1);
 }
 
 static void sort_trans_data(TransInfo *t) 
@@ -635,7 +648,7 @@ static void calc_distanceCurveVerts(TransData *head, TransData *tail) {
                        }
                }
                else {
-                       td->dist = 1000000.0f;
+                       td->dist = MAXFLOAT;
                        td->flag |= TD_NOTCONNECTED;
                }
        }
@@ -1059,7 +1072,7 @@ static void createTransEditVerts(TransInfo *t)
                                        }
                                        else {
                                                tob->flag |= TD_NOTCONNECTED;
-                                               tob->dist = 10000000.0f;
+                                               tob->dist = MAXFLOAT;
                                        }
                                }
                                
@@ -1750,8 +1763,16 @@ void Transform(int mode, int context)
                                        Trans.redraw = 1;
                                        break;
                                case CKEY:
-                                       stopConstraint(&Trans);
-                                       Trans.redraw = 1;
+                                       if (G.qual & LR_ALTKEY) {
+                                               Trans.flag ^= T_PROP_CONNECTED;
+                                               sort_trans_data_dist(&Trans);
+                                               calculatePropRatio(&Trans);
+                                               Trans.redraw= 1;
+                                       }
+                                       else {
+                                               stopConstraint(&Trans);
+                                               Trans.redraw = 1;
+                                       }
                                        break;
                                case XKEY:
                                        if ((Trans.flag & T_NO_CONSTRAINT)==0) {
index 30d1bab30eccaf1a7aa0af8e763805e8595e1d1b..1630d29b02bf9422441ca2f3d738c5cfc03eb40f 100755 (executable)
@@ -164,7 +164,8 @@ typedef struct TransInfo {
 #define T_NULL_ONE             512
 #define T_NO_ZERO              1024
 
-#define T_PROP_EDIT            2048
+#define T_PROP_EDIT             2048
+#define T_PROP_CONNECTED 4096
 
 
 /* transinfo->con->mode */
index 1aef46f6448fd211df0e72a71e90271826a2e68c..40c79d64a2731e83f1ebc85191dd4a306e0e3bd3 100755 (executable)
@@ -722,6 +722,7 @@ void calculatePropRatio(TransInfo *t)
        TransData *td = t->data;
        int i;
        float dist;
+       short connected = t->flag & T_PROP_CONNECTED;
        extern int prop_mode;
 
        if (t->flag & T_PROP_EDIT) {
@@ -729,7 +730,11 @@ void calculatePropRatio(TransInfo *t)
                        if (td->flag & TD_SELECTED) {
                                td->factor = 1.0f;
                        }
-                       else if (td->flag & TD_NOTCONNECTED || td->dist > t->propsize) {
+                       else if ((connected && 
+                                               (td->flag & TD_NOTCONNECTED || td->dist > t->propsize))
+                               ||
+                                       (connected == 0 &&
+                                               td->rdist > t->propsize)) {
                                /* 
                                   The elements are sorted according to their dist member in the array,
                                   that means we can stop when it finds one element outside of the propsize.