[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53559] trunk/blender/source/blender/ editors/mesh/editmesh_knife.c: Fix knife cut bug #33625, failure to cut in otho mode sometimes.

Howard Trickey howard.trickey at gmail.com
Fri Jan 4 16:06:40 CET 2013


Revision: 53559
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53559
Author:   howardt
Date:     2013-01-04 15:06:34 +0000 (Fri, 04 Jan 2013)
Log Message:
-----------
Fix knife cut bug #33625, failure to cut in otho mode sometimes.
Problem was that the code to limit the front and back planes
for better precision assumed line would have center near origin.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/mesh/editmesh_knife.c

Modified: trunk/blender/source/blender/editors/mesh/editmesh_knife.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_knife.c	2013-01-04 14:51:02 UTC (rev 53558)
+++ trunk/blender/source/blender/editors/mesh/editmesh_knife.c	2013-01-04 15:06:34 UTC (rev 53559)
@@ -1315,7 +1315,7 @@
 	//copy_m4_m4(mats->projection, kcd->vc.rv3d->winmat);
 }
 
-/* Calculate maximum excursion (doubled) from (0,0,0) of mesh */
+/* Calculate maximum excursion from (0,0,0) of mesh */
 static void calc_ortho_extent(KnifeTool_OpData *kcd)
 {
 	BMIter iter;
@@ -1328,9 +1328,20 @@
 		for (i = 0; i < 3; i++)
 			max_xyz = max_ff(max_xyz, fabs(v->co[i]));
 	}
-	kcd->ortho_extent = 2 * max_xyz;
+	kcd->ortho_extent = max_xyz;
 }
 
+/* Clip the line (v1, v2) to planes perpendicular to it and distances d from
+ * the closest point on the line to the origin */
+static void clip_to_ortho_planes(float v1[3], float v2[3], float d) {
+	float closest[3];
+	const float origin[3] = {0.0f, 0.0f, 0.0f};
+
+	closest_to_line_v3(closest, origin, v1, v2);
+	dist_ensure_v3_v3fl(v1, closest, d);
+	dist_ensure_v3_v3fl(v2, closest, d);
+}
+
 /* Finds visible (or all, if cutting through) edges that intersects the current screen drag line */
 static void knife_find_line_hits(KnifeTool_OpData *kcd)
 {
@@ -1375,8 +1386,8 @@
 	if (kcd->is_ortho) {
 		if (kcd->ortho_extent == 0.0f)
 			calc_ortho_extent(kcd);
-		limit_dist_v3(v1, v3, kcd->ortho_extent + 10.0f);
-		limit_dist_v3(v2, v4, kcd->ortho_extent + 10.0f);
+		clip_to_ortho_planes(v1, v3, kcd->ortho_extent + 10.0f);
+		clip_to_ortho_planes(v2, v4, kcd->ortho_extent + 10.0f);
 	}
 
 	BLI_smallhash_init(ehash);




More information about the Bf-blender-cvs mailing list