[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51066] trunk/blender/source/blender/ editors: replace most uses of ED_view3d_project_float_noclip() with ED_view3d_project_float_global/object

Campbell Barton ideasman42 at gmail.com
Fri Oct 5 05:58:01 CEST 2012


Revision: 51066
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51066
Author:   campbellbarton
Date:     2012-10-05 03:57:56 +0000 (Fri, 05 Oct 2012)
Log Message:
-----------
replace most uses of ED_view3d_project_float_noclip() with ED_view3d_project_float_global/object

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_mesh.h
    trunk/blender/source/blender/editors/mesh/editmesh_slide.c
    trunk/blender/source/blender/editors/mesh/editmesh_tools.c
    trunk/blender/source/blender/editors/mesh/meshtools.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
    trunk/blender/source/blender/editors/transform/transform.c

Modified: trunk/blender/source/blender/editors/include/ED_mesh.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_mesh.h	2012-10-05 03:20:14 UTC (rev 51065)
+++ trunk/blender/source/blender/editors/include/ED_mesh.h	2012-10-05 03:57:56 UTC (rev 51066)
@@ -174,7 +174,7 @@
 
 
 /* editmesh_tools.c (could be moved) */
-void EMBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct Object *obedit, struct BMEditMesh *em);
+void EMBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEditMesh *em);
 
 
 /* editface.c */

Modified: trunk/blender/source/blender/editors/mesh/editmesh_slide.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_slide.c	2012-10-05 03:20:14 UTC (rev 51065)
+++ trunk/blender/source/blender/editors/mesh/editmesh_slide.c	2012-10-05 03:57:56 UTC (rev 51066)
@@ -381,22 +381,23 @@
 		BMEdge *edge = NULL;
 		
 		float v1_proj[3], v2_proj[3];
-		float dist = 0;
 		float min_dist = FLT_MAX;
 
 		for (i = 0; i < vso->disk_edges; i++) {
 			edge = vso->edge_frame[i];
 
 			mul_v3_m4v3(v1_proj, vso->obj->obmat, edge->v1->co);
-			ED_view3d_project_float_noclip(vso->active_region, v1_proj, v1_proj);
-
 			mul_v3_m4v3(v2_proj, vso->obj->obmat, edge->v2->co);
-			ED_view3d_project_float_noclip(vso->active_region, v2_proj, v2_proj);
 
-			dist = dist_to_line_segment_v2(mval, v1_proj, v2_proj);
-			if (dist < min_dist) {
-				min_dist = dist;
-				cl_edge = edge;
+			/* we could use ED_view3d_project_float_object here, but for now dont since we dont have the context */
+			if ((ED_view3d_project_float_global(vso->active_region, v1_proj, v1_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) &&
+			    (ED_view3d_project_float_global(vso->active_region, v2_proj, v2_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS))
+			{
+				const float dist = dist_to_line_segment_v2(mval, v1_proj, v2_proj);
+				if (dist < min_dist) {
+					min_dist = dist;
+					cl_edge = edge;
+				}
 			}
 		}
 	}
@@ -448,18 +449,22 @@
 		/* Calculate interpolation value for preview */
 		float t_val;
 
-		float mval_float[] = { (float)event->mval[0], (float)event->mval[1]};
+		float mval_float[2] = { (float)event->mval[0], (float)event->mval[1]};
 		float closest_2d[2];
 
 		other = BM_edge_other_vert(edge, vso->start_vtx);
 
 		/* Project points onto screen and do interpolation in 2D */
 		mul_v3_m4v3(start_vtx_proj, vso->obj->obmat, vso->start_vtx->co);
-		ED_view3d_project_float_noclip(vso->active_region, start_vtx_proj, start_vtx_proj);
-
 		mul_v3_m4v3(edge_other_proj, vso->obj->obmat, other->co);
-		ED_view3d_project_float_noclip(vso->active_region, edge_other_proj, edge_other_proj);
 
+		if ((ED_view3d_project_float_global(vso->active_region, edge_other_proj, edge_other_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) ||
+		    (ED_view3d_project_float_global(vso->active_region, start_vtx_proj, start_vtx_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS))
+		{
+			/* not much we can do here */
+			return;
+		}
+
 		closest_to_line_v2(closest_2d, mval_float, start_vtx_proj, edge_other_proj);
 
 		t_val = line_point_factor_v2(closest_2d, start_vtx_proj, edge_other_proj);
@@ -470,7 +475,7 @@
 		if (edge_len <= 0.0f)
 			edge_len = VTX_SLIDE_SNAP_THRSH;
 
-		edge_len =  (len_v3v3(edge->v1->co, edge->v2->co) * VTX_SLIDE_SNAP_THRSH) / edge_len;
+		edge_len =  (BM_edge_calc_length(edge) * VTX_SLIDE_SNAP_THRSH) / edge_len;
 
 		vso->snap_threshold =  edge_len;
 

Modified: trunk/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_tools.c	2012-10-05 03:20:14 UTC (rev 51065)
+++ trunk/blender/source/blender/editors/mesh/editmesh_tools.c	2012-10-05 03:57:56 UTC (rev 51066)
@@ -153,19 +153,22 @@
 }
 
 
-void EMBM_project_snap_verts(bContext *C, ARegion *ar, Object *obedit, BMEditMesh *em)
+void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
 {
+	Object *obedit = em->ob;
 	BMIter iter;
 	BMVert *eve;
 
+	ED_view3d_init_mats_rv3d(obedit, ar->regiondata);
+
 	BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
 		if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
-			float mval[2], vec[3], no_dummy[3];
+			float mval[2], co_proj[3], no_dummy[3];
 			int dist_dummy;
-			mul_v3_m4v3(vec, obedit->obmat, eve->co);
-			ED_view3d_project_float_noclip(ar, vec, mval);
-			if (snapObjectsContext(C, mval, &dist_dummy, vec, no_dummy, SNAP_NOT_OBEDIT)) {
-				mul_v3_m4v3(eve->co, obedit->imat, vec);
+			if (ED_view3d_project_float_object(ar, eve->co, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+				if (snapObjectsContext(C, mval, &dist_dummy, co_proj, no_dummy, SNAP_NOT_OBEDIT)) {
+					mul_v3_m4v3(eve->co, obedit->imat, co_proj);
+				}
 			}
 		}
 	}
@@ -731,7 +734,10 @@
 	short use_proj;
 	
 	em_setup_viewcontext(C, &vc);
-	
+
+	ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d);
+
+
 	use_proj = ((vc.scene->toolsettings->snap_flag & SCE_SNAP) &&
 	            (vc.scene->toolsettings->snap_mode == SCE_SNAP_MODE_FACE));
 
@@ -760,26 +766,26 @@
 		BM_ITER_MESH (eed, &iter, vc.em->bm, BM_EDGES_OF_MESH) {
 			if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
 				float co1[3], co2[3];
-				mul_v3_m4v3(co1, vc.obedit->obmat, eed->v1->co);
-				mul_v3_m4v3(co2, vc.obedit->obmat, eed->v2->co);
-				ED_view3d_project_float_noclip(vc.ar, co1, co1);
-				ED_view3d_project_float_noclip(vc.ar, co2, co2);
 
-				/* 2D rotate by 90d while adding.
-				 *  (x, y) = (y, -x)
-				 *
-				 * accumulate the screenspace normal in 2D,
-				 * with screenspace edge length weighting the result. */
-				if (line_point_side_v2(co1, co2, mval_f) >= 0.0f) {
-					nor[0] +=  (co1[1] - co2[1]);
-					nor[1] += -(co1[0] - co2[0]);
+				if ((ED_view3d_project_float_object(vc.ar, eed->v1->co, co1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) &&
+				    (ED_view3d_project_float_object(vc.ar, eed->v2->co, co2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS))
+				{
+					/* 2D rotate by 90d while adding.
+					 *  (x, y) = (y, -x)
+					 *
+					 * accumulate the screenspace normal in 2D,
+					 * with screenspace edge length weighting the result. */
+					if (line_point_side_v2(co1, co2, mval_f) >= 0.0f) {
+						nor[0] +=  (co1[1] - co2[1]);
+						nor[1] += -(co1[0] - co2[0]);
+					}
+					else {
+						nor[0] +=  (co2[1] - co1[1]);
+						nor[1] += -(co2[0] - co1[0]);
+					}
+					done = TRUE;
 				}
-				else {
-					nor[0] +=  (co2[1] - co1[1]);
-					nor[1] += -(co2[0] - co1[0]);
-				}
 			}
-			done = TRUE;
 		}
 
 		if (done) {
@@ -836,7 +842,7 @@
 
 			/* also project the source, for retopo workflow */
 			if (use_proj)
-				EMBM_project_snap_verts(C, vc.ar, vc.obedit, vc.em);
+				EMBM_project_snap_verts(C, vc.ar, vc.em);
 		}
 
 		edbm_extrude_edge(vc.obedit, vc.em, BM_ELEM_SELECT, nor);
@@ -869,7 +875,7 @@
 	}
 
 	if (use_proj)
-		EMBM_project_snap_verts(C, vc.ar, vc.obedit, vc.em);
+		EMBM_project_snap_verts(C, vc.ar, vc.em);
 
 	/* This normally happens when pushing undo but modal operators
 	 * like this one don't push undo data until after modal mode is

Modified: trunk/blender/source/blender/editors/mesh/meshtools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/meshtools.c	2012-10-05 03:20:14 UTC (rev 51065)
+++ trunk/blender/source/blender/editors/mesh/meshtools.c	2012-10-05 03:57:56 UTC (rev 51066)
@@ -1237,11 +1237,12 @@
 				const int v_idx = me->mloop[mp->loopstart + fidx].v;
 				dm->getVertCo(dm, v_idx, co);
 				mul_m4_v3(ob->obmat, co);
-				ED_view3d_project_float_noclip(ar, co, sco);
-				len = len_squared_v2v2(mval_f, sco);
-				if (len < len_best) {
-					len_best = len;
-					v_idx_best = v_idx;
+				if (ED_view3d_project_float_global(ar, co, sco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+					len = len_squared_v2v2(mval_f, sco);
+					if (len < len_best) {
+						len_best = len;
+						v_idx_best = v_idx;
+					}
 				}
 			} while (fidx--);
 		}

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2012-10-05 03:20:14 UTC (rev 51065)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2012-10-05 03:57:56 UTC (rev 51066)
@@ -846,20 +846,22 @@
 static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float vert_nor[3],
                                  const float mval[2], const float brush_size_pressure)
 {
-	Brush *brush = paint_brush(&vp->paint);
-	float dist_squared;
-	float vertco[2], delta[2];
+	float vertco[2];
 
-	ED_view3d_project_float_noclip(vc->ar, vert_nor, vertco);
-	sub_v2_v2v2(delta, mval, vertco);
-	dist_squared = dot_v2v2(delta, delta); /* len squared */
-	if (dist_squared > brush_size_pressure * brush_size_pressure) {
-		return 0.0f;
+	if (ED_view3d_project_float_global(vc->ar, vert_nor, vertco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+		float delta[2];
+		float dist_squared;
+
+		sub_v2_v2v2(delta, mval, vertco);
+		dist_squared = dot_v2v2(delta, delta); /* len squared */
+		if (dist_squared <= brush_size_pressure * brush_size_pressure) {
+			Brush *brush = paint_brush(&vp->paint);
+			const float dist = sqrtf(dist_squared);
+			return BKE_brush_curve_strength_clamp(brush, dist, brush_size_pressure);
+		}
 	}
-	else {
-		const float dist = sqrtf(dist_squared);
-		return BKE_brush_curve_strength_clamp(brush, dist, brush_size_pressure);
-	}
+
+	return 0.0f;
 }
 
 static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc,

Modified: trunk/blender/source/blender/editors/transform/transform.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.c	2012-10-05 03:20:14 UTC (rev 51065)
+++ trunk/blender/source/blender/editors/transform/transform.c	2012-10-05 03:57:56 UTC (rev 51066)
@@ -351,7 +351,11 @@
 		case SPACE_VIEW3D:
 		{
 			if (t->ar->regiontype == RGN_TYPE_WINDOW) {
-				ED_view3d_project_float_noclip(t->ar, vec, adr);
+				if (ED_view3d_project_float_global(t->ar, vec, adr, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) {
+					/* XXX, 2.64 and prior did this, weak! */
+					adr[0] = t->ar->winx / 2.0f;
+					adr[1] = t->ar->winy / 2.0f;
+				}
 				return;
 			}
 			break;
@@ -4793,12 +4797,12 @@

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list