[Bf-blender-cvs] [206f29c] master: Fix T44685 - In grease pencil stroke editing, selecting points is offset by a few pixels
Joshua Leung
noreply at git.blender.org
Sun May 17 16:04:54 CEST 2015
Commit: 206f29c12c59f13f5815701dd7ceeee4ff8d3a64
Author: Joshua Leung
Date: Mon May 18 02:03:15 2015 +1200
Branches: master
https://developer.blender.org/rB206f29c12c59f13f5815701dd7ceeee4ff8d3a64
Fix T44685 - In grease pencil stroke editing, selecting points is offset by a few pixels
The problem was that it was aborting too early after stumbling across a point which
might fit within the bounds required. This commit improves the logic here to solve
this and a few other little bugs like that.
Disclaimer: There are still a few cases where it randomly ends up picking something
way off. However, this only seems to occur very sporadically, so it's hard to say
how bad the problem may be.
===================================================================
M source/blender/editors/gpencil/gpencil_select.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 9d0cb6d..1b66f36 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -775,6 +775,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
bGPDstroke *hit_stroke = NULL;
bGPDspoint *hit_point = NULL;
+ int hit_distance = radius_squared;
/* sanity checks */
if (sa == NULL) {
@@ -797,7 +798,6 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
{
bGPDspoint *pt;
int i;
- int hit_index = -1;
/* firstly, check for hit-point */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
@@ -807,18 +807,19 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
/* do boundbox check first */
if (!ELEM(V2D_IS_CLIPPED, x0, x0)) {
- /* only check if point is inside */
- if (((x0 - mx) * (x0 - mx) + (y0 - my) * (y0 - my)) <= radius_squared) {
- hit_stroke = gps;
- hit_point = pt;
- break;
+ const int pt_distance = ((x0 - mx) * (x0 - mx) + (y0 - my) * (y0 - my));
+
+ /* check if point is inside */
+ if (pt_distance <= radius_squared) {
+ /* only use this point if it is a better match than the current hit - T44685 */
+ if (pt_distance < hit_distance) {
+ hit_stroke = gps;
+ hit_point = pt;
+ hit_distance = pt_distance;
+ }
}
}
}
-
- /* skip to next stroke if nothing found */
- if (hit_index == -1)
- continue;
}
CTX_DATA_END;
More information about the Bf-blender-cvs
mailing list