Some random small stuff packed in one commit:
authorMartin Poirier <theeth@yahoo.com>
Wed, 31 Dec 2003 22:44:26 +0000 (22:44 +0000)
committerMartin Poirier <theeth@yahoo.com>
Wed, 31 Dec 2003 22:44:26 +0000 (22:44 +0000)
- Moved a couple of undo_push_mesh after the action has been confirmed (mainly bevel, merge and mirror)

- Split mirror in two functions, interface and functionality

- Simplified the code of the merge function

source/blender/src/edit.c
source/blender/src/editmesh.c
source/blender/src/editobject.c
source/blender/src/space.c

index 998f92f947c0738404012c6c2eab92b958edddbe..a5360e65be4c53cc43725218d484e4c039ab89be 100644 (file)
@@ -1180,22 +1180,18 @@ void mergemenu(void)
 
        event = pupmenu("MERGE %t|At Center%x1|At Cursor%x2");
 
-       switch (event) {
+       if (event==-1) return; /* Return if the menu is closed without any choices */
 
-           case 1: /*Merge at center of selection*/
-                   snap_to_center();
-                   notice("Removed: %d", removedoublesflag(1, doublimit));
-                   allqueue(REDRAWVIEW3D, 0);
-                   countall();
-                   break;
-           case 2: /*Merge at Cursor*/
-                   snap_sel_to_curs();
-                   notice("Removed: %d", removedoublesflag(1, doublimit));
-                   allqueue(REDRAWVIEW3D, 0);
-                   countall();
-                   break;
-       }
+       undo_push_mesh("Merge"); /* The action has been confirmed, push the mesh down the undo pipe */
+
+       if (event==1) 
+               snap_to_center(); /*Merge at Center*/
+       else
+               snap_sel_to_curs(); /*Merge at Cursor*/
 
+       notice("Removed: %d", removedoublesflag(1, doublimit));
+       allqueue(REDRAWVIEW3D, 0);
+       countall();
 }
 
 void delete_context_selected(void) {
index cd7587f9ba72521aa85c0cbd4b3765257d5b3649..53e8a0a80f0157160c17cdf89c22a81fb415d3d7 100644 (file)
@@ -7742,6 +7742,7 @@ void undo_menu_mesh(void)
 }
 
 /******************* BEVEL CODE STARTS HERE ********************/
+
 void bevel_displace_vec(float *midvec, float *v1, float *v2, float *v3, float d, float no[3])
 {
        float a[3], c[3], n_a[3], n_c[3], mid[3], ac, ac2, fac;
@@ -8147,7 +8148,9 @@ void bevel_mesh(float bsize, int allfaces)
        /* tag all faces for shrink*/
        evl= G.edvl.first;
        while (evl) {
-               if (vlakselectedAND(evl, 1)||allfaces) evl->f1= 2;
+               if (vlakselectedAND(evl, 1)||allfaces) {
+                       evl->f1= 2;
+               }
                evl= evl->next;
        }
 
@@ -8524,6 +8527,7 @@ void bevel_menu()
                }       
        }
        if (Canceled==0) {
+               undo_push_mesh("Bevel");
                bevel_mesh_recurs(drawd/fac, recurs, 1);
                righthandfaces(1);
        }
index 47f20c4474f746163b77fb64c5a4ecf2095e2a2c..6db681d9d9fe55f596d4aa541ca526e943934673 100644 (file)
@@ -1577,7 +1577,6 @@ void special_editmenu(void)
                        subdivideflag(1, 0.0, editbutflag | B_SMOOTH);
                        break;
                case 4:
-                       undo_push_mesh("Merge");
                        mergemenu();
                        break;
                case 5:
@@ -1602,7 +1601,6 @@ void special_editmenu(void)
                        vertexsmooth();
                        break;
                case 11:
-                       undo_push_mesh("Bevel");
                        bevel_menu();
                        break;
                }               
@@ -6751,19 +6749,14 @@ void make_displists_by_obdata(void *obdata) {
 /* ******************************************************************** */
 /* Mirror function in Edit Mode */
 
-
-void mirrormenu(void){
-       short mode = 0, axis, a;
+void mirror(short mode) {
+       short axis, a;
        float mat[3][3], imat[3][3], min[3], max[3];
        TransVert *tv;
-       mode=pupmenu("Mirror Axis %t|Global X%x1|       Y%x2|       Z%x3|Local X%x4|      Y%x5|      Z%x6|View X%x7|     Y%x8|     Z%x9|");
-
-       if (G.obedit==0) return;
-       if (mode==-1) return;
 
        make_trans_verts(min, max, 0);
        Mat3CpyMat4(mat, G.obedit->obmat);
-       // Inverting the matrix explicitly, since a 4x4 inverse is not always the same
+       // Inverting the matrix explicitly, since the inverse is not always correct (then why the heck are we keeping it!)
        Mat3Inv(imat, mat);
 
        tv = transvmain;
@@ -6832,7 +6825,7 @@ void mirrormenu(void){
                float viewmat[3][3], iviewmat[3][3];
 
                Mat3CpyMat4(viewmat, G.vd->viewmat);
-       // Inverting the matrix explicitly, since a 4x4 inverse is not always the same
+       // Inverting the matrix explicitly
                Mat3Inv(iviewmat, viewmat);
 
                // axis is mode with an offset
@@ -6883,3 +6876,18 @@ void mirrormenu(void){
 
        tottrans= 0;
 }
+
+void mirrormenu(void){
+       short mode = 0;
+
+       if (G.obedit==0) return;
+
+       mode=pupmenu("Mirror Axis %t|Global X%x1|       Y%x2|       Z%x3|Local X%x4|      Y%x5|      Z%x6|View X%x7|     Y%x8|     Z%x9|");
+
+       if (mode==-1) return; /* return */
+
+       if(G.obedit->type==OB_MESH) undo_push_mesh("Mirror"); /* If it's a mesh, push it down the undo pipe */
+
+       mirror(mode); /* separating functionality from interface | call*/
+}
+
index 14ddb05dfafe92d3895f577bb46b0cf119ba78bb..0c89457a469290a641e0a44856e6018045e3b8ed 100644 (file)
@@ -1130,20 +1130,12 @@ void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                if(G.obedit){
                                        if(G.qual==LR_ALTKEY) {
                                                if(G.obedit->type==OB_MESH) {
-                                                       undo_push_mesh("Merge");
                                                        mergemenu();
-                                                               
                                                        makeDispList(G.obedit);
                                                }
                                        }
                                        else if((G.qual==0)) {
-                                               if(G.obedit->type==OB_MESH) {
-                                                       undo_push_mesh("Mirror");
-                                                       mirrormenu();
-                                               }
-                                               else {
-                                                       mirrormenu();
-                                               }
+                                               mirrormenu();
                                        }
                                }
                                else if((G.qual==0)){