diff --git a/source/blender/include/BIF_editmesh.h b/source/blender/include/BIF_editmesh.h index 86f84c1e028..ca9f3d6a378 100644 --- a/source/blender/include/BIF_editmesh.h +++ b/source/blender/include/BIF_editmesh.h @@ -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 diff --git a/source/blender/src/edit.c b/source/blender/src/edit.c index 656ecda8eac..a44bbc3af0f 100644 --- a/source/blender/src/edit.c +++ b/source/blender/src/edit.c @@ -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); } } diff --git a/source/blender/src/editface.c b/source/blender/src/editface.c index d89af858f21..781210cd373 100644 --- a/source/blender/src/editface.c +++ b/source/blender/src/editface.c @@ -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) { diff --git a/source/blender/src/editmesh_lib.c b/source/blender/src/editmesh_lib.c index 24727308fb3..6251ba1a650 100644 --- a/source/blender/src/editmesh_lib.c +++ b/source/blender/src/editmesh_lib.c @@ -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) { diff --git a/source/blender/src/transform_generics.c b/source/blender/src/transform_generics.c index a0dde01ba8e..8154929eb17 100644 --- a/source/blender/src/transform_generics.c +++ b/source/blender/src/transform_generics.c @@ -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 */ diff --git a/source/blender/src/transform_manipulator.c b/source/blender/src/transform_manipulator.c index 601d516f26f..5c06aaea890 100644 --- a/source/blender/src/transform_manipulator.c +++ b/source/blender/src/transform_manipulator.c @@ -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) { diff --git a/source/blender/src/transform_orientations.c b/source/blender/src/transform_orientations.c index 5c35a80c43f..301ac8aa248 100644 --- a/source/blender/src/transform_orientations.c +++ b/source/blender/src/transform_orientations.c @@ -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;