[Bf-blender-cvs] [7660218] master: Correct fix for knife interior use, distance needed to be in object-space

Campbell Barton noreply at git.blender.org
Tue May 6 01:32:55 CEST 2014


Commit: 76602182022b15314138dcc488a3a651ac0da021
Author: Campbell Barton
Date:   Tue May 6 09:32:06 2014 +1000
https://developer.blender.org/rB76602182022b15314138dcc488a3a651ac0da021

Correct fix for knife interior use, distance needed to be in object-space

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

M	source/blender/editors/mesh/editmesh_knife.c

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

diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 490603a..366a825 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -1156,37 +1156,30 @@ static void calc_ortho_extent(KnifeTool_OpData *kcd)
  * s in screen projection of p. */
 static bool point_is_visible(KnifeTool_OpData *kcd, const float p[3], const float s[2], bglMats *mats)
 {
-	float p1[3];
 	BMFace *f_hit;
 
 	/* If not cutting through, make sure no face is in front of p */
 	if (!kcd->cut_through) {
 		float dist;
-		float view[3];
+		float view[3], p_ofs[3];
 
 		/* TODO: I think there's a simpler way to get the required raycast ray */
 		ED_view3d_unproject(mats, view, s[0], s[1], 0.0f);
 
+		mul_m4_v3(kcd->ob->imat, view);
+
+		/* make p_ofs a little towards view, so ray doesn't hit p's face. */
+		sub_v3_v3(view, p);
+		dist = normalize_v3(view);
+		madd_v3_v3v3fl(p_ofs, p, view, KNIFE_FLT_EPSBIG * 3.0f);
+
 		/* avoid projecting behind the viewpoint */
 		if (kcd->is_ortho) {
 			dist = FLT_MAX;
 		}
-		else {
-			float p_world[3];
-			mul_v3_m4v3(p_world, kcd->ob->obmat, p);
-			dist = len_v3v3(view, p_world);
-		}
-
-		mul_m4_v3(kcd->ob->imat, view);
-
-		/* make p1 a little towards view, so ray doesn't hit p's face. */
-		copy_v3_v3(p1, p);
-		sub_v3_v3(view, p1);
-		normalize_v3(view);
-		madd_v3_v3fl(p1, view, 3.0f * KNIFE_FLT_EPSBIG);
 
 		/* see if there's a face hit between p1 and the view */
-		f_hit = BKE_bmbvh_ray_cast(kcd->bmbvh, p1, view, KNIFE_FLT_EPS, &dist, NULL, NULL);
+		f_hit = BKE_bmbvh_ray_cast(kcd->bmbvh, p_ofs, view, KNIFE_FLT_EPS, &dist, NULL, NULL);
 		if (f_hit)
 			return false;
 	}




More information about the Bf-blender-cvs mailing list