From d48a472fe5f77ed63dc33e2c6f1104af107baef3 Mon Sep 17 00:00:00 2001 From: Geoffrey Bantle Date: Mon, 1 Jan 2007 09:41:10 +0000 Subject: [PATCH] -> Fix for bug #5472 Vertex snapping now works with backbuffered selection modes. Previously backbuffer sampling had no way to check whether or not the indices that it retrieved were selected or not. To resolve this I added two optional arguments to sample_backbuf_rect in drawview.c. The first argument tells the function that some additional testing of the retrieved index values needs to be done and the second argument is a pointer to a function to do the testing. findnearestvert() in editmesh_mods.c now makes use of this and passes sample_backbuf_rect() the appropriate argument when being used for vertex snapping. --- source/blender/include/BSE_drawview.h | 2 +- source/blender/src/drawview.c | 23 +++++++++++---- source/blender/src/editface.c | 4 +-- source/blender/src/editmesh_mods.c | 41 ++++++++++++++++++++------- 4 files changed, 50 insertions(+), 20 deletions(-) diff --git a/source/blender/include/BSE_drawview.h b/source/blender/include/BSE_drawview.h index fa0faf2c05f..6e612859173 100644 --- a/source/blender/include/BSE_drawview.h +++ b/source/blender/include/BSE_drawview.h @@ -55,7 +55,7 @@ void backdrawview3d(int test); void check_backbuf(void); unsigned int sample_backbuf(int x, int y); struct ImBuf *read_backbuf(short xmin, short ymin, short xmax, short ymax); -unsigned int sample_backbuf_rect(short mval[2], int size, unsigned int min, unsigned int max, int *dist);; +unsigned int sample_backbuf_rect(short mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict, unsigned int (*indextest)(unsigned int index)); void drawview3dspace(struct ScrArea *sa, void *spacedata); void drawview3d_render(struct View3D *v3d, int winx, int winy); diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index b8e00bbc14b..bfbbcee66fa 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -1198,7 +1198,7 @@ ImBuf *read_backbuf(short xmin, short ymin, short xmax, short ymax) } /* smart function to sample a rect spiralling outside, nice for backbuf selection */ -unsigned int sample_backbuf_rect(short mval[2], int size, unsigned int min, unsigned int max, int *dist) +unsigned int sample_backbuf_rect(short mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict, unsigned int (*indextest)(unsigned int index)) { struct ImBuf *buf; unsigned int *bufmin, *bufmax, *tbuf; @@ -1206,7 +1206,8 @@ unsigned int sample_backbuf_rect(short mval[2], int size, unsigned int min, unsi int a, b, rc, nr, amount, dirvec[4][2]; int distance=0; unsigned int index = 0; - + short indexok = 0; + amount= (size-1)/2; minx = mval[0]-(amount+1); @@ -1230,10 +1231,20 @@ unsigned int sample_backbuf_rect(short mval[2], int size, unsigned int min, unsi for(a=0; a<2; a++) { for(b=0; b=min && *tbuf=min && *tbuftotface+1, &dist); + *index = sample_backbuf_rect(mval, 3, 1, me->totface+1, &dist,0,NULL); } else /* sample only on the exact position */ @@ -163,7 +163,7 @@ static int facesel_edge_pick(Mesh *me, short *mval, unsigned int *index) persp(PERSP_VIEW); } - *index = sample_backbuf_rect(mval, 50, min, max, &dist); + *index = sample_backbuf_rect(mval, 50, min, max, &dist,0,NULL); if (*index == 0) return 0; diff --git a/source/blender/src/editmesh_mods.c b/source/blender/src/editmesh_mods.c index c7b34068b3e..762a9e4fcbd 100644 --- a/source/blender/src/editmesh_mods.c +++ b/source/blender/src/editmesh_mods.c @@ -358,6 +358,14 @@ static void findnearestvert__doClosest(void *userData, EditVert *eve, int x, int } } + + + +static unsigned int findnearestvert__backbufIndextest(unsigned int index){ + EditVert *eve = BLI_findlink(&G.editMesh->verts, index-1); + if(eve && (eve->f & SELECT)) return 0; + return 1; +} /** * findnearestvert * @@ -372,23 +380,22 @@ EditVert *findnearestvert(int *dist, short sel, short strict) short mval[2]; getmouseco_areawin(mval); - - /** - * FIXME - * Strict bypasses the openGL select buffer - * someone with more knowledge of this should fix it -- theeth - */ - if(strict == 0 && G.vd->drawtype>OB_WIRE && (G.vd->flag & V3D_ZBUF_SELECT)) { + if(G.vd->drawtype>OB_WIRE && (G.vd->flag & V3D_ZBUF_SELECT)){ int distance; - unsigned int index = sample_backbuf_rect(mval, 50, em_wireoffs, 0xFFFFFF, &distance); + unsigned int index; + + if(strict) index = sample_backbuf_rect(mval, 50, em_wireoffs, 0xFFFFFF, &distance, strict, findnearestvert__backbufIndextest); + else index = sample_backbuf_rect(mval, 50, em_wireoffs, 0xFFFFFF, &distance, 0, NULL); + EditVert *eve = BLI_findlink(&G.editMesh->verts, index-1); - - if (eve && distance < *dist) { + + if(eve && distance < *dist) { *dist = distance; return eve; } else { return NULL; } + } else { struct { short mval[2], pass, select, strict; int dist, lastIndex, closestIndex; EditVert *closest; } data; @@ -483,7 +490,7 @@ EditEdge *findnearestedge(int *dist) if(G.vd->drawtype>OB_WIRE && (G.vd->flag & V3D_ZBUF_SELECT)) { int distance; - unsigned int index = sample_backbuf_rect(mval, 50, em_solidoffs, em_wireoffs, &distance); + unsigned int index = sample_backbuf_rect(mval, 50, em_solidoffs, em_wireoffs, &distance,0, NULL); EditEdge *eed = BLI_findlink(&G.editMesh->edges, index-1); if (eed && distance<*dist) { @@ -2643,6 +2650,18 @@ void editmesh_mark_sharp(int set) allqueue(REDRAWVIEW3D, 0); } +void BME_Menu() { + short ret; + ret= pupmenu("BME modeller%t|Select Edges of Vert%x1"); + + switch(ret) + { + case 1: + //BME_edges_of_vert(); + break; + } +} + void Edge_Menu() { short ret;