[Bf-blender-cvs] [7b97432] master: Minor cleanup in object select code

Campbell Barton noreply at git.blender.org
Tue Apr 26 06:32:51 CEST 2016


Commit: 7b9743261d3c2ca736988bad92ffae3b559b9d39
Author: Campbell Barton
Date:   Tue Apr 26 14:33:31 2016 +1000
Branches: master
https://developer.blender.org/rB7b9743261d3c2ca736988bad92ffae3b559b9d39

Minor cleanup in object select code

- break when object in hit-buffer.
- don't measure distance to object centers that can't be projected.
- take pixelsize into account for distance pixel distance limit.

===================================================================

M	source/blender/editors/space_view3d/view3d_select.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index e4cc552..bedcf41 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -418,11 +418,12 @@ static void do_lasso_select_objects(ViewContext *vc, const int mcords[][2], cons
 
 	for (base = vc->scene->base.first; base; base = base->next) {
 		if (BASE_SELECTABLE(vc->v3d, base)) { /* use this to avoid un-needed lasso lookups */
-			ED_view3d_project_base(vc->ar, base);
-			if (BLI_lasso_is_point_inside(mcords, moves, base->sx, base->sy, IS_CLIPPED)) {
-				
-				ED_base_object_select(base, select ? BA_SELECT : BA_DESELECT);
-				base->object->flag = base->flag;
+			if (ED_view3d_project_base(vc->ar, base) == V3D_PROJ_RET_OK) {
+				if (BLI_lasso_is_point_inside(mcords, moves, base->sx, base->sy, IS_CLIPPED)) {
+
+					ED_base_object_select(base, select ? BA_SELECT : BA_DESELECT);
+					base->object->flag = base->flag;
+				}
 			}
 			if (vc->obact == base->object && (base->object->mode & OB_MODE_POSE)) {
 				do_lasso_select_pose(vc, base->object, mcords, moves, select);
@@ -1096,21 +1097,22 @@ static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int
 
 		/* two selection methods, the CTRL select uses max dist of 15 */
 		if (buffer) {
-			int a;
-			for (a = 0; a < hits; a++) {
+			for (int a = 0; a < hits; a++) {
 				/* index was converted */
 				if (base->selcol == (buffer[(4 * a) + 3] & ~0xFFFF0000)) {
 					ok = true;
+					break;
 				}
 			}
 		}
 		else {
-			int temp, dist = 15;
-			ED_view3d_project_base(vc->ar, base);
-			
-			temp = abs(base->sx - mval[0]) + abs(base->sy - mval[1]);
-			if (temp < dist)
-				ok = true;
+			const int dist = 15 * U.pixelsize;
+			if (ED_view3d_project_base(vc->ar, base) == V3D_PROJ_RET_OK) {
+				const int delta_px[2] = {base->sx - mval[0], base->sy - mval[1]};
+				if (len_manhattan_v2_int(delta_px) < dist) {
+					ok = true;
+				}
+			}
 		}
 
 		if (ok) {




More information about the Bf-blender-cvs mailing list