[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45789] trunk/blender/source/blender/ editors/mesh: bmesh rip: when there are selected faces call region_to_loop before ripping.

Campbell Barton ideasman42 at gmail.com
Thu Apr 19 18:57:51 CEST 2012


Revision: 45789
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45789
Author:   campbellbarton
Date:     2012-04-19 16:57:50 +0000 (Thu, 19 Apr 2012)
Log Message:
-----------
bmesh rip: when there are selected faces call region_to_loop before ripping. gives better results then previous fix when there are selected faces as apart of an edge selection.

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

Modified: trunk/blender/source/blender/editors/mesh/editmesh_rip.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_rip.c	2012-04-19 16:20:07 UTC (rev 45788)
+++ trunk/blender/source/blender/editors/mesh/editmesh_rip.c	2012-04-19 16:57:50 UTC (rev 45789)
@@ -45,6 +45,7 @@
 #include "BKE_report.h"
 #include "BKE_tessmesh.h"
 
+#include "WM_api.h"
 #include "WM_types.h"
 
 #include "ED_mesh.h"
@@ -339,8 +340,29 @@
 }
 /* --- end 'ripsel' selection handling code --- */
 
+/* return TRUE if the face is...
+*/
+int edbm_rip_edge_is_ripable(BMEdge *e)
+{
+	int tot;
+	BMLoop *l_iter;
+	BMLoop *l_first;
 
+	l_iter = l_first = e->l;
+	/* we could do more checks here, but save for face checks */
+	do {
+		if (!BM_elem_flag_test(l_iter->f, BM_ELEM_HIDDEN)) {
+			if (!BM_elem_flag_test(l_iter->f, BM_ELEM_SELECT)) {
+				return TRUE;
+			}
+			tot++;
+		}
+	} while ((l_iter = l_iter->radial_next) != l_first);
 
+	return tot < 2;
+}
+
+
 /* based on mouse cursor position, it defines how is being ripped */
 static int edbm_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
@@ -362,25 +384,11 @@
 
 	EdgeLoopPair *eloop_pairs;
 
-	/* running in face mode hardly makes sense, if we try to run code below it almost works ok
-	 * but doesnt make sense logically because ripping is supposed to rip an edge apart.
-	 *
-	 * Rather then disable, we can split in this case
-	 */
-	if (em->selectmode == SCE_SELECT_FACE) {
-		EDBM_op_init(em, &bmop, op, "split geom=%hvef use_only_faces=%b", BM_ELEM_SELECT, TRUE);
-		BMO_op_exec(em->bm, &bmop);
-		BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE);
-		BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_ALL, BM_ELEM_SELECT, TRUE);
-		if (!EDBM_op_finish(em, &bmop, op, TRUE)) {
-			return OPERATOR_CANCELLED;
-		}
-		else {
-			return OPERATOR_FINISHED;
-		}
+	/* running in face mode hardly makes sense, so convert to region loop and rip */
+	if (em->bm->totfacesel) {
+		WM_operator_name_call(C, "MESH_OT_region_to_loop", WM_OP_INVOKE_DEFAULT, NULL);
 	}
 
-
 	/* note on selection:
 	 * When calling edge split we operate on tagged edges rather then selected
 	 * this is important because the edges to operate on are extended by one,
@@ -395,7 +403,9 @@
 
 	/* BM_ELEM_SELECT --> BM_ELEM_TAG */
 	BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
-		BM_elem_flag_set(e, BM_ELEM_TAG, BM_elem_flag_test(e, BM_ELEM_SELECT));
+		if (edbm_rip_edge_is_ripable(e)) {
+			BM_elem_flag_set(e, BM_ELEM_TAG, BM_elem_flag_test(e, BM_ELEM_SELECT));
+		}
 	}
 
 	/* handle case of one vert selected.  identify

Modified: trunk/blender/source/blender/editors/mesh/editmesh_select.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_select.c	2012-04-19 16:20:07 UTC (rev 45788)
+++ trunk/blender/source/blender/editors/mesh/editmesh_select.c	2012-04-19 16:57:50 UTC (rev 45789)
@@ -2518,14 +2518,9 @@
 	BMFace *f;
 	BMEdge *e;
 	BMIter iter;
-	ViewContext vc;
-	
-	em_setup_viewcontext(C, &vc);
-	
-	BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
-		BM_elem_flag_disable(e, BM_ELEM_TAG);
-	}
 
+	BM_mesh_elem_hflag_disable_all(em->bm, BM_EDGE, BM_ELEM_TAG, FALSE);
+
 	BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
 		BMLoop *l1, *l2;
 		BMIter liter1, liter2;
@@ -2546,8 +2541,9 @@
 	EDBM_flag_disable_all(em, BM_ELEM_SELECT);
 	
 	BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) {
-		if (BM_elem_flag_test(e, BM_ELEM_TAG) && !BM_elem_flag_test(e, BM_ELEM_HIDDEN))
+		if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
 			BM_edge_select_set(em->bm, e, TRUE);
+		}
 	}
 
 	/* If in face-only select mode, switch to edge select mode so that




More information about the Bf-blender-cvs mailing list