diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-06-29 17:41:00 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-06-29 18:18:11 +0300 |
commit | d140e70c496122915eb5c05aba83153e2e0d7998 (patch) | |
tree | 1e589247d69da64aa7b0e7802319237ec050b5d6 /source/blender/editors/gpencil/gpencil_select.c | |
parent | 147bd16ed1bb3415b30408b0eab110d0854eadd2 (diff) | |
parent | 295d0c52a26730edc6d4ed1276e4051cce006be5 (diff) |
Merge branch 'master' into temp-ghash-experimentstemp-ghash-experiments
Note that 'store hash' feature was removed for now - to complex to maintain (conflicts)
and relatively easy to re-add if we ever really want this one day.
Conflicts:
source/blender/blenlib/BLI_ghash.h
source/blender/blenlib/intern/BLI_ghash.c
source/blender/blenlib/intern/hash_mm2a.c
source/blender/bmesh/tools/bmesh_region_match.c
tests/gtests/blenlib/BLI_ghash_performance_test.cc
tests/gtests/blenlib/BLI_ghash_test.cc
tests/gtests/blenlib/CMakeLists.txt
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_select.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_select.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 9ba77a4244e..1b66f366b70 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -35,28 +35,16 @@ #include "MEM_guardedalloc.h" -#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_lasso.h" #include "BLI_utildefines.h" #include "DNA_gpencil_types.h" -#include "DNA_object_types.h" -#include "DNA_scene_types.h" #include "DNA_screen_types.h" -#include "DNA_space_types.h" -#include "DNA_view3d_types.h" #include "BKE_context.h" -#include "BKE_curve.h" -#include "BKE_depsgraph.h" -#include "BKE_global.h" #include "BKE_gpencil.h" -#include "BKE_library.h" -#include "BKE_object.h" #include "BKE_report.h" -#include "BKE_scene.h" -#include "BKE_screen.h" #include "UI_interface.h" @@ -69,8 +57,6 @@ #include "UI_view2d.h" #include "ED_gpencil.h" -#include "ED_view3d.h" -#include "ED_keyframing.h" #include "gpencil_intern.h" @@ -789,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) { @@ -811,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++) { @@ -821,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; |