[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54164] trunk/blender/source/blender/ editors/transform/transform.c: fix for edge slide bug, when there were no edges to slide along the direction calculated from the face would be wrong half the time (depending on the edge loop direction which is arbitrary).

Campbell Barton ideasman42 at gmail.com
Tue Jan 29 02:23:33 CET 2013


Revision: 54164
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54164
Author:   campbellbarton
Date:     2013-01-29 01:23:33 +0000 (Tue, 29 Jan 2013)
Log Message:
-----------
fix for edge slide bug, when there were no edges to slide along the direction calculated from the face would be wrong half the time (depending on the edge loop direction which is arbitrary).

Modified Paths:
--------------
    trunk/blender/source/blender/editors/transform/transform.c

Modified: trunk/blender/source/blender/editors/transform/transform.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.c	2013-01-29 01:23:29 UTC (rev 54163)
+++ trunk/blender/source/blender/editors/transform/transform.c	2013-01-29 01:23:33 UTC (rev 54164)
@@ -4901,16 +4901,24 @@
 				mul_v3_fl(a, 1.0f / (float)i);
 			}
 			else {
-				float f1[3], f2[3], f3[3];
+				/* When there is no edge to slide along,
+				 * we must slide along the vector defined by the face we're attach to */
+				float e_dir_prev[3], e_dir_next[3], tvec[3];
 
-				sub_v3_v3v3(f1, BM_edge_other_vert(e_prev, v)->co, v->co);
-				sub_v3_v3v3(f2, BM_edge_other_vert(e_next, v)->co, v->co);
+				sub_v3_v3v3(e_dir_prev, BM_edge_other_vert(e_prev, v)->co, v->co);
+				sub_v3_v3v3(e_dir_next, BM_edge_other_vert(e_next, v)->co, v->co);
 
-				cross_v3_v3v3(f3, f1, l->f->no);
-				cross_v3_v3v3(a, f2, l->f->no);
-				negate_v3(a);
+				cross_v3_v3v3(tvec, l->f->no, e_dir_prev);
+				cross_v3_v3v3(a, e_dir_next, l->f->no);
 
-				mid_v3_v3v3(a, a, f3);
+				mid_v3_v3v3(a, a, tvec);
+
+				/* check if we need to flip
+				 * (compare the normal defines by the edges with the face normal) */
+				cross_v3_v3v3(tvec, e_dir_prev, e_dir_next);
+				if (dot_v3v3(tvec, l->f->no) > 0.0f) {
+					negate_v3(a);
+				}
 			}
 
 			copy_v3_v3(vec, a);




More information about the Bf-blender-cvs mailing list