Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Bantle <hairbat@yahoo.com>2007-01-01 12:41:10 +0300
committerGeoffrey Bantle <hairbat@yahoo.com>2007-01-01 12:41:10 +0300
commitd48a472fe5f77ed63dc33e2c6f1104af107baef3 (patch)
tree827dbeae6a8f99839bba2abcd45cb10c534c1677 /source/blender/src/drawview.c
parentc96e3e6e7d3c9a9005dea86db635d602bdc383c8 (diff)
-> 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.
Diffstat (limited to 'source/blender/src/drawview.c')
-rw-r--r--source/blender/src/drawview.c23
1 files changed, 17 insertions, 6 deletions
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<nr; b++, distance++) {
- if (*tbuf && *tbuf>=min && *tbuf<max) {
- *dist= (short) sqrt( (float)distance ); // XXX, this distance is wrong - zr
- index = *tbuf - min+1; // messy yah, but indices start at 1
- goto exit;
+ 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]);