Add distance check in lasso generation to get a smoother lasso.

Hopefully this helps with lasso select troubles [#21179].
This commit is contained in:
Nathan Letwory 2010-10-01 08:12:37 +00:00
parent 65b92821e1
commit b85f779355
2 changed files with 15 additions and 5 deletions

@ -284,7 +284,7 @@ int EM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, s
/* yah, opengl doesn't do concave... tsk! */
ED_region_pixelspace(vc->ar);
draw_triangulated(mcords, tot);
draw_triangulated(mcords, tot);
glBegin(GL_LINE_LOOP); /* for zero sized masks, lines */
for(a=0; a<tot; a++) glVertex2s(mcords[a][0], mcords[a][1]);

@ -2435,11 +2435,21 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event)
}
{
short x, y;
short *lasso= gesture->customdata;
lasso += 2 * gesture->points;
lasso[0] = event->x - sx;
lasso[1] = event->y - sy;
gesture->points++;
lasso += (2 * gesture->points - 2);
x = (event->x - sx - lasso[0]);
y = (event->y - sy - lasso[1]);
/* make a simple distance check to get a smoother lasso
add only when at least 2 pixels between this and previous location */
if((x*x+y*y) > 4) {
lasso += 2;
lasso[0] = event->x - sx;
lasso[1] = event->y - sy;
gesture->points++;
}
}
break;