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:
authorJoshua Leung <aligorith@gmail.com>2015-05-17 17:03:15 +0300
committerJoshua Leung <aligorith@gmail.com>2015-05-17 17:03:39 +0300
commit206f29c12c59f13f5815701dd7ceeee4ff8d3a64 (patch)
tree9d346ae2b076ea0ca08c5dff1f1c395ad983bdcc /source/blender/editors
parent30b45d5591fdd20e5cd5abd0cf3be62622c0b0db (diff)
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.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 9d0cb6d711a..1b66f366b70 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;