-> 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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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,6 +1206,7 @@ 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;
|
||||
|
||||
@@ -1230,11 +1231,21 @@ unsigned int sample_backbuf_rect(short mval[2], int size, unsigned int min, unsi
|
||||
|
||||
for(a=0; a<2; a++) {
|
||||
for(b=0; b<nr; b++, distance++) {
|
||||
if (*tbuf && *tbuf>=min && *tbuf<max) {
|
||||
*dist= (short) sqrt( (float)distance ); // XXX, this distance is wrong - zr
|
||||
if (*tbuf && *tbuf>=min && *tbuf<max) { //we got a hit
|
||||
if(strict){
|
||||
indexok = indextest(*tbuf - min+1);
|
||||
if(indexok){
|
||||
*dist= (short) sqrt( (float)distance );
|
||||
index = *tbuf - min+1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else{
|
||||
*dist= (short) sqrt( (float)distance ); // XXX, this distance is wrong -
|
||||
index = *tbuf - min+1; // messy yah, but indices start at 1
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
tbuf+= (dirvec[rc][0]+dirvec[rc][1]);
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ int facesel_face_pick(Mesh *me, short *mval, unsigned int *index, short rect)
|
||||
/* sample rect to increase changes of selecting, so that when clicking
|
||||
on an edge in the backbuf, we can still select a face */
|
||||
int dist;
|
||||
*index = sample_backbuf_rect(mval, 3, 1, me->totface+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;
|
||||
|
||||
@@ -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,15 +380,13 @@ 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) {
|
||||
@@ -389,6 +395,7 @@ EditVert *findnearestvert(int *dist, short sel, short strict)
|
||||
} 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user