[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48155] trunk/blender/source/blender/ editors/mesh/editmesh_knife.c: Fixes [#31433] BMesh: Knife tool Angle Constraint function

Nicholas Rishel rishel.nick at gmail.com
Thu Jun 21 10:58:34 CEST 2012


Revision: 48155
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48155
Author:   nicholas_rishel
Date:     2012-06-21 08:58:17 +0000 (Thu, 21 Jun 2012)
Log Message:
-----------
Fixes [#31433] BMesh: Knife tool Angle Constraint function

The problem was that calculating the angle was reliant on previous mouse coordinates, which did not update to match snapped-to vertices and edges.

This solves the issue by updating mouse coordinates in knife_find_closest_edge() and knife_find_closest_vertex(). Additionally, when angle constraints are enabled, edge/vertex snapping is now prevented.

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-06-21 08:07:49 UTC (rev 48154)
+++ trunk/blender/source/blender/editors/mesh/editmesh_knife.c	2012-06-21 08:58:17 UTC (rev 48155)
@@ -1468,6 +1468,8 @@
 
 		if (cure && p) {
 			if (!kcd->ignore_edge_snapping || !(cure->e)) {
+				KnifeVert *edgesnap = NULL;
+
 				if (kcd->snap_midpoints) {
 					mid_v3_v3v3(p, cure->v1->co, cure->v2->co);
 					mid_v3_v3v3(cagep, cure->v1->cageco, cure->v2->cageco);
@@ -1479,6 +1481,13 @@
 					d = len_v3v3(cagep, cure->v1->cageco) / len_v3v3(cure->v1->cageco, cure->v2->cageco);
 					interp_v3_v3v3(p, cure->v1->co, cure->v2->co, d);
 				}
+
+				/* update mouse coordinates to the snapped-to edge's screen coordinates
+				 * this is important for angle snap, which uses the previous mouse position */
+				edgesnap = new_knife_vert(kcd, p, cagep);
+				kcd->cur.mval[0] = (int)edgesnap->sco[0];
+				kcd->cur.mval[1] = (int)edgesnap->sco[1];
+
 			}
 			else {
 				return NULL;
@@ -1557,6 +1566,11 @@
 			if (curv && p) {
 				copy_v3_v3(p, curv->co);
 				copy_v3_v3(cagep, curv->cageco);
+
+				/* update mouse coordinates to the snapped-to vertex's screen coordinates
+				 * this is important for angle snap, which uses the previous mouse position */
+				kcd->cur.mval[0] = (int)curv->sco[0];
+				kcd->cur.mval[1] = (int)curv->sco[1];
 			}
 
 			return curv;
@@ -1617,9 +1631,15 @@
 	kcd->cur.mval[0] = kcd->vc.mval[0];
 	kcd->cur.mval[1] = kcd->vc.mval[1];
 
-	kcd->cur.vert = knife_find_closest_vert(kcd, kcd->cur.co, kcd->cur.cage, &kcd->cur.bmface, &kcd->cur.is_space);
-	if (!kcd->cur.vert) {
-		kcd->cur.edge = knife_find_closest_edge(kcd, kcd->cur.co, kcd->cur.cage, &kcd->cur.bmface, &kcd->cur.is_space);
+	/* if angle snapping is enabled, don't snap to edges/vertices */
+	if (kcd->angle_snapping == ANGLE_FREE) {
+
+		kcd->cur.vert = knife_find_closest_vert(kcd, kcd->cur.co, kcd->cur.cage, &kcd->cur.bmface, &kcd->cur.is_space);
+
+		if (!kcd->cur.vert) {
+			kcd->cur.edge = knife_find_closest_edge(kcd, kcd->cur.co, kcd->cur.cage, &kcd->cur.bmface, &kcd->cur.is_space);
+		}
+
 	}
 
 	/* if no hits are found this would normally default to (0, 0, 0) so instead




More information about the Bf-blender-cvs mailing list