[Bf-blender-cvs] [57dba73] master: View3d: take pixelsize into account for selection distance

Campbell Barton noreply at git.blender.org
Tue Mar 11 07:16:44 CET 2014


Commit: 57dba739176153e052d77611ff0e554f05984686
Author: Campbell Barton
Date:   Tue Mar 11 15:34:19 2014 +1100
https://developer.blender.org/rB57dba739176153e052d77611ff0e554f05984686

View3d: take pixelsize into account for selection distance

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

M	source/blender/editors/curve/editcurve.c
M	source/blender/editors/include/ED_view3d.h
M	source/blender/editors/mesh/editmesh_loopcut.c
M	source/blender/editors/mesh/editmesh_path.c
M	source/blender/editors/mesh/editmesh_select.c
M	source/blender/editors/object/object_lattice.c
M	source/blender/editors/physics/particle_edit.c
M	source/blender/editors/space_view3d/view3d_select.c

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

diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 2bd9bba..e50ba2c 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -3613,7 +3613,7 @@ static short findnearestNurbvert(ViewContext *vc, short sel, const int mval[2],
 	/* return 0 1 2: handlepunt */
 	struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; float dist; int hpoint, select; float mval_fl[2]; } data = {NULL};
 
-	data.dist = 100;
+	data.dist = ED_view3d_select_dist_px();
 	data.hpoint = 0;
 	data.select = sel;
 	data.mval_fl[0] = mval[0];
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 0aff3b8..adeb271 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -269,6 +269,8 @@ bool ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], con
 #define MAXPICKBUF      10000
 short view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigned int bufsize, rcti *input);
 
+/* view3d_select.c */
+float ED_view3d_select_dist_px(void);
 void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc);
 void view3d_operator_needs_opengl(const struct bContext *C);
 void view3d_region_operator_needs_opengl(struct wmWindow *win, struct ARegion *ar);
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index bc42819..9a02a97 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -440,7 +440,7 @@ static void loopcut_update_edge(RingSelOpData *lcd, BMEdge *e, const int preview
 
 static void loopcut_mouse_move(RingSelOpData *lcd, const int previewlines)
 {
-	float dist = 75.0f;
+	float dist = ED_view3d_select_dist_px();
 	BMEdge *e = EDBM_edge_find_nearest(&lcd->vc, &dist);
 	loopcut_update_edge(lcd, e, previewlines);
 }
diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c
index 3e64c22..a6e4f50 100644
--- a/source/blender/editors/mesh/editmesh_path.c
+++ b/source/blender/editors/mesh/editmesh_path.c
@@ -88,7 +88,7 @@ static bool mouse_mesh_shortest_path_vert(ViewContext *vc)
 	BMEditMesh *em = vc->em;
 	BMesh *bm = em->bm;
 	BMVert *v_dst;
-	float dist = 75.0f;
+	float dist = ED_view3d_select_dist_px();
 	const bool use_length = true;
 
 	v_dst = EDBM_vert_find_nearest(vc, &dist, false, false);
@@ -253,7 +253,7 @@ static bool mouse_mesh_shortest_path_edge(ViewContext *vc)
 	BMEditMesh *em = vc->em;
 	BMesh *bm = em->bm;
 	BMEdge *e_dst;
-	float dist = 75.0f;
+	float dist = ED_view3d_select_dist_px();
 	const bool use_length = true;
 
 	e_dst = EDBM_edge_find_nearest(vc, &dist);
@@ -377,7 +377,7 @@ static bool mouse_mesh_shortest_path_face(ViewContext *vc)
 	BMEditMesh *em = vc->em;
 	BMesh *bm = em->bm;
 	BMFace *f_dst;
-	float dist = 75.0f;
+	float dist = ED_view3d_select_dist_px();
 	const bool use_length = true;
 
 	f_dst = EDBM_face_find_nearest(vc, &dist);
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 41546e7..37267d1 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -649,7 +649,7 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist)
 static int unified_findnearest(ViewContext *vc, BMVert **r_eve, BMEdge **r_eed, BMFace **r_efa)
 {
 	BMEditMesh *em = vc->em;
-	float dist = 75.0f;
+	float dist = ED_view3d_select_dist_px();
 	
 	*r_eve = NULL;
 	*r_eed = NULL;
@@ -1191,7 +1191,7 @@ static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool de
 	bool select = true;
 	bool select_clear = false;
 	bool select_cycle = true;
-	float dist = 50.0f;
+	float dist = ED_view3d_select_dist_px() * 0.6666f;
 	float mvalf[2];
 
 	em_setup_viewcontext(C, &vc);
diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c
index 8d12809..196e912 100644
--- a/source/blender/editors/object/object_lattice.c
+++ b/source/blender/editors/object/object_lattice.c
@@ -867,7 +867,7 @@ static BPoint *findnearestLattvert(ViewContext *vc, const int mval[2], int sel)
 	/* return 0 1 2: handlepunt */
 	struct { BPoint *bp; float dist; int select; float mval_fl[2]; } data = {NULL};
 
-	data.dist = 100;
+	data.dist = ED_view3d_select_dist_px();
 	data.select = sel;
 	data.mval_fl[0] = mval[0];
 	data.mval_fl[1] = mval[1];
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index f634a51..2fb131d 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -915,6 +915,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
 	int index;
 	float *vec, *nor, dvec[3], dot, dist_1st=0.0f;
 	float hairimat[4][4], hairmat[4][4];
+	const float dist = ED_view3d_select_dist_px();
 
 	if (edit==NULL || edit->psys==NULL || (pset->flag & PE_DEFLECT_EMITTER)==0 || (edit->psys->flag & PSYS_GLOBAL_HAIR))
 		return;
@@ -935,7 +936,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
 		LOOP_KEYS {
 			if (k==0) {
 				dist_1st = len_v3v3((key+1)->co, key->co);
-				dist_1st *= 0.75f * pset->emitterdist;
+				dist_1st *= dist * pset->emitterdist;
 			}
 			else {
 				index= BLI_kdtree_find_nearest(edit->emitter_field, key->co, NULL, NULL);
@@ -1446,7 +1447,7 @@ int PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselec
 
 	PE_set_view3d_data(C, &data);
 	data.mval= mval;
-	data.rad= 75.0f;
+	data.rad = ED_view3d_select_dist_px();
 
 	/* 1 = nearest only */
 	if (extend)
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 47f30e3..de15162 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -98,6 +98,11 @@
 
 #include "view3d_intern.h"  /* own include */
 
+float ED_view3d_select_dist_px(void)
+{
+	return 75.0f * U.pixelsize;
+}
+
 /* TODO: should return whether there is valid context to continue */
 void view3d_set_viewcontext(bContext *C, ViewContext *vc)
 {
@@ -1380,7 +1385,7 @@ static bool mouse_select(bContext *C, const int mval[2],
 	Scene *scene = CTX_data_scene(C);
 	Base *base, *startbase = NULL, *basact = NULL, *oldbasact = NULL;
 	bool is_obedit;
-	float dist = 100.0f;
+	float dist = ED_view3d_select_dist_px() * 1.3333f;
 	int retval = false;
 	short hits;
 	const float mval_fl[2] = {(float)mval[0], (float)mval[1]};




More information about the Bf-blender-cvs mailing list