[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50465] trunk/blender/source/blender/ editors/mesh/editmesh_rip.c: minor improvements to rip

Campbell Barton ideasman42 at gmail.com
Fri Sep 7 08:31:55 CEST 2012


Revision: 50465
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50465
Author:   campbellbarton
Date:     2012-09-07 06:31:54 +0000 (Fri, 07 Sep 2012)
Log Message:
-----------
minor improvements to rip
- rip tool didnt select the best edge to rip for wire verts (no connected faces)
- ripping one vert with 2 edges connected didnt work.

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

Modified: trunk/blender/source/blender/editors/mesh/editmesh_rip.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_rip.c	2012-09-07 05:54:54 UTC (rev 50464)
+++ trunk/blender/source/blender/editors/mesh/editmesh_rip.c	2012-09-07 06:31:54 UTC (rev 50465)
@@ -380,6 +380,7 @@
 	float projectMat[4][4], fmval[3] = {event->mval[0], event->mval[1]};
 	float dist = FLT_MAX;
 	float d;
+	int is_wire;
 
 	BMEditSelection ese;
 	int totboundary_edge = 0;
@@ -403,6 +404,8 @@
 	if (!v)
 		return OPERATOR_CANCELLED;
 
+	is_wire = BM_vert_is_wire(v);
+
 	e2 = NULL;
 
 	if (v->e) {
@@ -430,8 +433,11 @@
 	 * - we cant find an edge - this means we are ripping a faces vert that is connected to other
 	 *   geometry only at the vertex.
 	 * - the boundary edge total is greater then 2,
-	 *   in this case edge split _can_ work but we get far nicer results if we use this special case. */
-	if (totboundary_edge > 2) {
+	 *   in this case edge split _can_ work but we get far nicer results if we use this special case.
+	 * - there are only 2 edges but we are a wire vert. */
+	if ((is_wire == FALSE && totboundary_edge > 2) ||
+	    (is_wire == TRUE  && totboundary_edge > 1))
+	{
 		BMVert **vout;
 		int vout_len;
 
@@ -458,21 +464,40 @@
 
 			dist = FLT_MAX;
 
-			for (i = 0; i < vout_len; i++) {
-				BM_ITER_ELEM (l, &iter, vout[i], BM_LOOPS_OF_VERT) {
-					if (!BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) {
-						float l_mid_co[3];
-						BM_loop_calc_face_tangent(l, l_mid_co);
+			if (is_wire) {
+				for (i = 0; i < vout_len; i++) {
+					BM_ITER_ELEM (e, &iter, vout[i], BM_EDGES_OF_VERT) {
+						if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) {
+							float e_mid_co[3];
+							mid_v3_v3v3(e_mid_co, e->v1->co, e->v2->co);
 
-						/* scale to average of surrounding edge size, only needs to be approx */
-						mul_v3_fl(l_mid_co, (BM_edge_calc_length(l->e) + BM_edge_calc_length(l->prev->e)) / 2.0f);
-						add_v3_v3(l_mid_co, v->co);
+							d = edbm_rip_rip_edgedist(ar, projectMat, v->co, e_mid_co, fmval);
 
-						d = edbm_rip_rip_edgedist(ar, projectMat, v->co, l_mid_co, fmval);
+							if (d < dist) {
+								dist = d;
+								vi_best = i;
+							}
+						}
+					}
+				}
+			}
+			else {
+				for (i = 0; i < vout_len; i++) {
+					BM_ITER_ELEM (l, &iter, vout[i], BM_LOOPS_OF_VERT) {
+						if (!BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) {
+							float l_mid_co[3];
+							BM_loop_calc_face_tangent(l, l_mid_co);
 
-						if (d < dist) {
-							dist = d;
-							vi_best = i;
+							/* scale to average of surrounding edge size, only needs to be approx */
+							mul_v3_fl(l_mid_co, (BM_edge_calc_length(l->e) + BM_edge_calc_length(l->prev->e)) / 2.0f);
+							add_v3_v3(l_mid_co, v->co);
+
+							d = edbm_rip_rip_edgedist(ar, projectMat, v->co, l_mid_co, fmval);
+
+							if (d < dist) {
+								dist = d;
+								vi_best = i;
+							}
 						}
 					}
 				}




More information about the Bf-blender-cvs mailing list