[Bf-blender-cvs] [80befca6e59] blender2.8: Manipulator: only check for highlight once
Campbell Barton
noreply at git.blender.org
Wed Jul 26 12:42:10 CEST 2017
Commit: 80befca6e59be69e278b765911d8c5591abd9af6
Author: Campbell Barton
Date: Wed Jul 26 20:49:57 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB80befca6e59be69e278b765911d8c5591abd9af6
Manipulator: only check for highlight once
Was doing 2x lookups which is OK for click-select
but this runs on mouse-move and can become slow.
May enable this again if highlighting logic changes.
Also scale hotspot by pixelsize.
===================================================================
M source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
===================================================================
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
index e626d8be54d..376cf6928bd 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
@@ -452,7 +452,7 @@ static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible
static int manipulator_find_intersected_3d_intern(
ListBase *visible_manipulators, const bContext *C, const int co[2],
- const float hotspot)
+ const int hotspot)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
@@ -462,10 +462,8 @@ static int manipulator_find_intersected_3d_intern(
GLuint buffer[MAXPICKBUF];
short hits;
const bool do_passes = GPU_select_query_check_active();
- rect.xmin = co[0] - hotspot;
- rect.xmax = co[0] + hotspot;
- rect.ymin = co[1] - hotspot;
- rect.ymax = co[1] + hotspot;
+
+ BLI_rcti_init_pt_radius(&rect, co, hotspot);
ED_view3d_draw_setup_view(CTX_wm_window(C), C, CTX_data_scene(C), ar, v3d, NULL, NULL, &rect);
@@ -499,26 +497,39 @@ static wmManipulator *manipulator_find_intersected_3d(
int *r_part)
{
wmManipulator *result = NULL;
- const float hotspot = 14.0f;
- int ret;
+ int hit = -1;
+
+ int hotspot_radii[] = {
+ 3 * U.pixelsize,
+#if 0 /* We may want to enable when selection doesn't run on mousemove! */
+ 7 * U.pixelsize,
+#endif
+ };
*r_part = 0;
/* set up view matrices */
view3d_operator_needs_opengl(C);
- ret = manipulator_find_intersected_3d_intern(visible_manipulators, C, co, 0.5f * hotspot);
-
- if (ret != -1) {
- LinkData *link;
- int retsec;
- retsec = manipulator_find_intersected_3d_intern(visible_manipulators, C, co, 0.2f * hotspot);
+ hit = -1;
- if (retsec != -1)
- ret = retsec;
+ for (int i = 0; i < ARRAY_SIZE(hotspot_radii); i++) {
+ hit = manipulator_find_intersected_3d_intern(visible_manipulators, C, co, hotspot_radii[i]);
+ if (hit != -1) {
+ break;
+ }
+ }
- link = BLI_findlink(visible_manipulators, ret >> 8);
- *r_part = ret & 255;
- result = link->data;
+ if (hit != -1) {
+ LinkData *link = BLI_findlink(visible_manipulators, hit >> 8);
+ if (link != NULL) {
+ *r_part = hit & 255;
+ result = link->data;
+ }
+ else {
+ /* All manipulators should use selection ID they're given as part of the callback,
+ * if they don't it will attempt tp lookup non-existing index. */
+ BLI_assert(0);
+ }
}
return result;
More information about the Bf-blender-cvs
mailing list