[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51553] trunk/blender/source/blender/ editors/mesh/editmesh_knife.c: Fix knife sensitivity issue (#30637): better calculation of how

Howard Trickey howard.trickey at gmail.com
Tue Oct 23 20:17:52 CEST 2012


Revision: 51553
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51553
Author:   howardt
Date:     2012-10-23 18:17:51 +0000 (Tue, 23 Oct 2012)
Log Message:
-----------
Fix knife sensitivity issue (#30637): better calculation of how
to clamp distances in ortho mode.

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	2012-10-23 17:58:46 UTC (rev 51552)
+++ trunk/blender/source/blender/editors/mesh/editmesh_knife.c	2012-10-23 18:17:51 UTC (rev 51553)
@@ -181,6 +181,7 @@
 	char select_result;  /* set on initialization */
 
 	short is_ortho;
+	float ortho_extent;
 	float clipsta, clipend;
 
 	enum {
@@ -1311,6 +1312,22 @@
 	//copy_m4_m4(mats->projection, kcd->vc.rv3d->winmat);
 }
 
+/* Calculate maximum excursion (doubled) from (0,0,0) of mesh */
+static void calc_ortho_extent(KnifeTool_OpData *kcd)
+{
+	BMIter iter;
+	BMVert *v;
+	BMesh* bm = kcd->em->bm;
+	float max_xyz = 0.0f;
+	int i;
+
+	BM_ITER_MESH(v, &iter, bm, BM_VERTS_OF_MESH) {
+		for (i = 0; i < 3; i++)
+			max_xyz = max_ff(max_xyz, fabs(v->co[i]));
+	}
+	kcd->ortho_extent = 2 * max_xyz;
+}
+
 /* Finds visible (or all, if cutting through) edges that intersects the current screen drag line */
 static void knife_find_line_hits(KnifeTool_OpData *kcd)
 {
@@ -1353,8 +1370,10 @@
 	 * (which may involve using doubles everywhere!),
 	 * limit the distance between these points */
 	if (kcd->is_ortho) {
-		limit_dist_v3(v1, v3, 200.0f);
-		limit_dist_v3(v2, v4, 200.0f);
+		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);
 	}
 
 	BLI_smallhash_init(ehash);




More information about the Bf-blender-cvs mailing list