transform manipulator didnt follow the active face in some cases, also rotate about...
authorCampbell Barton <ideasman42@gmail.com>
Sun, 11 May 2008 19:58:46 +0000 (19:58 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 11 May 2008 19:58:46 +0000 (19:58 +0000)
as a rotation
axis (this is quite useful)

source/blender/include/BIF_editmesh.h
source/blender/src/edit.c
source/blender/src/editface.c
source/blender/src/editmesh_lib.c
source/blender/src/transform_generics.c
source/blender/src/transform_manipulator.c
source/blender/src/transform_orientations.c

index 86f84c1e0284bdd4a01e39b1a4dca0368f381c4b..ca9f3d6a378f4cd9a7e6baf8812f1c3f263ff19a 100644 (file)
@@ -260,5 +260,6 @@ int EM_vertColorCheck(void); /* can we edit colors for this mesh?*/
 
 void EM_set_actFace(struct EditFace *efa);
 struct EditFace * EM_get_actFace(int sloppy);
+int EM_get_actSelection(struct EditSelection *ese);
 
 #endif
index 656ecda8eace6135104c505586f6037931372474..a44bbc3af0fbc7e93fe1765131cd72584795eceb 100644 (file)
@@ -1530,35 +1530,11 @@ void snap_curs_to_active()
                if (G.obedit->type == OB_MESH)
                {
                        /* check active */
-                       if (G.editMesh->selected.last) {
-                               EditSelection *ese = G.editMesh->selected.last;
-                               if ( ese->type == EDITVERT ) {
-                                       EditVert *eve = (EditVert *)ese->data;
-                                       VECCOPY(curs, eve->co);
-                               }
-                               else if ( ese->type == EDITEDGE ) {
-                                       EditEdge *eed = (EditEdge *)ese->data;
-                                       VecAddf(curs, eed->v1->co, eed->v2->co);
-                                       VecMulf(curs, 0.5f);
-                               }
-                               else if ( ese->type == EDITFACE ) {
-                                       EditFace *efa = (EditFace *)ese->data;
-                                       
-                                       if (efa->v4)
-                                       {
-                                               VecAddf(curs, efa->v1->co, efa->v2->co);
-                                               VecAddf(curs, curs, efa->v3->co);
-                                               VecAddf(curs, curs, efa->v4->co);
-                                               VecMulf(curs, 0.25f);
-                                       }
-                                       else
-                                       {
-                                               VecAddf(curs, efa->v1->co, efa->v2->co);
-                                               VecAddf(curs, curs, efa->v3->co);
-                                               VecMulf(curs, 1/3.0f);
-                                       }
-                               }
+                       EditSelection ese;
+                       if (EM_get_actSelection(&ese)) {
+                               EM_editselection_center(curs, &ese);
                        }
+                       
                        Mat4MulVecfl(G.obedit->obmat, curs);
                }
        }
index d89af858f2123f1ccf17251c64314066c774787a..781210cd3733f5efdb801db38e1a9e83c3e369b5 100644 (file)
@@ -151,33 +151,6 @@ int facesel_face_pick(Mesh *me, short *mval, unsigned int *index, short rect)
        return 1;
 }
 
-#if 0 // not used
-/* returns 0 if not found, otherwise 1 */
-static int facesel_edge_pick(Mesh *me, short *mval, unsigned int *index)
-{
-       int dist;
-       unsigned int min = me->totface + 1;
-       unsigned int max = me->totface + me->totedge + 1;
-
-       if (me->totedge == 0)
-               return 0;
-
-       if (G.vd->flag & V3D_NEEDBACKBUFDRAW) {
-               check_backbuf();
-               persp(PERSP_VIEW);
-       }
-
-       *index = sample_backbuf_rect(mval, 50, min, max, &dist,0,NULL);
-
-       if (*index == 0)
-               return 0;
-
-       (*index)--;
-       
-       return 1;
-}
-#endif
-
 /* only operates on the edit object - this is all thats needed at the moment */
 static void uv_calc_center_vector(float *result, Object *ob, EditMesh *em)
 {
index 24727308fb35908f5dd46aa7446c9e3df5fd50f6..6251ba1a6500009cff9771e2c0935a141f30eada 100644 (file)
@@ -103,6 +103,35 @@ EditFace * EM_get_actFace(int sloppy)
        return NULL;
 }
 
+int EM_get_actSelection(EditSelection *ese)
+{
+       EditSelection *ese_last = G.editMesh->selected.last;
+       EditFace *efa = EM_get_actFace(0);
+
+       ese->next = ese->prev = NULL;
+       
+       if (ese_last) {
+               if (ese_last->type == EDITFACE) { /* if there is an active face, use it over the last selected face */
+                       if (efa) {
+                               ese->data = (void *)efa;
+                       } else {
+                               ese->data = ese_last->data;
+                       }
+                       ese->type = EDITFACE;
+               } else {
+                       ese->data = ese_last->data;
+                       ese->type = ese_last->type;
+               }
+       } else if (efa) { /* no */
+               ese->data = (void *)efa;
+               ese->type = EDITFACE;
+       } else {
+               ese->data = NULL;
+               return 0;
+       }
+       return 1;
+}
+
 /* ********* Selection History ************ */
 static int EM_check_selection(void *data)
 {
index a0dde01ba8e551bf58165723b1b5478e8b137dd9..8154929eb172c05898401a086aa7df2fe8ca7c79 100644 (file)
@@ -972,11 +972,12 @@ void calculateCenter(TransInfo *t)
                calculateCenterMedian(t);
                break;
        case V3D_ACTIVE:
+               {
                /* set median, and if if if... do object center */
-               
+               EditSelection ese;
                /* EDIT MODE ACTIVE EDITMODE ELEMENT */
-               if (G.obedit && G.obedit->type == OB_MESH && G.editMesh->selected.last) {
-                       EM_editselection_center(t->center, G.editMesh->selected.last);
+               if (G.obedit && G.obedit->type == OB_MESH && EM_get_actSelection(&ese)) {
+                       EM_editselection_center(t->center, &ese);
                        calculateCenter2D(t);
                        break;
                } /* END EDIT MODE ACTIVE ELEMENT */
@@ -989,6 +990,8 @@ void calculateCenter(TransInfo *t)
                                projectIntView(t, t->center, t->center2d);
                        }
                }
+               
+               }
        }
 
        /* setting constraint center */
index 601d516f26fe7bd12ed2bfe185ea495243d40789..5c06aaea890be358e838a40330630542d67e3562 100644 (file)
@@ -230,11 +230,12 @@ int calc_manipulator_stats(ScrArea *sa)
                if(G.obedit->type==OB_MESH) {
                        EditMesh *em = G.editMesh;
                        EditVert *eve;
+                       EditSelection ese;
                        float vec[3]= {0,0,0};
                        
                        /* USE LAST SELECTE WITH ACTIVE */
-                       if (G.vd->around==V3D_ACTIVE && em->selected.last) {
-                               EM_editselection_center(vec, em->selected.last);
+                       if (G.vd->around==V3D_ACTIVE && EM_get_actSelection(&ese)) {
+                               EM_editselection_center(vec, &ese);
                                calc_tw_center(vec);
                                totsel= 1;
                        } else {
@@ -435,10 +436,10 @@ int calc_manipulator_stats(ScrArea *sa)
                        if(G.obedit) {
                                float mat[3][3];
                                int type;
-
+                               
                                strcpy(t->spacename, "normal");
-                       
-                               type = getTransformOrientation(normal, plane, 0);
+                               
+                               type = getTransformOrientation(normal, plane, (G.vd->around == V3D_ACTIVE));
                                
                                switch (type)
                                {
index 5c35a80c43f94c50ef2f6745b65fe3b6b09f02e1..301ac8aa24835a48fc584a60c565ca80bd724593 100644 (file)
@@ -379,16 +379,16 @@ int getTransformOrientation(float normal[3], float plane[3], int activeOnly)
                {
                        EditMesh *em = G.editMesh;
                        EditVert *eve;
+                       EditSelection ese;
                        float vec[3]= {0,0,0};
                        
                        /* USE LAST SELECTED WITH ACTIVE */
-                       if (activeOnly && em->selected.last)
+                       if (activeOnly && EM_get_actSelection(&ese))
                        {
-                               EditSelection *ese = em->selected.last;
-                               EM_editselection_normal(normal, ese);
-                               EM_editselection_plane(plane, ese);
+                               EM_editselection_normal(normal, &ese);
+                               EM_editselection_plane(plane, &ese);
                                
-                               switch (ese->type)
+                               switch (ese.type)
                                {
                                        case EDITVERT:
                                                result = ORIENTATION_VERT;