[Bf-blender-cvs] [ce155ad2f69] master: Correct recent bmesh separate addition

Campbell Barton noreply at git.blender.org
Sat Mar 11 13:23:15 CET 2017


Commit: ce155ad2f699c67bcbc9802c8481556aaa8240e0
Author: Campbell Barton
Date:   Sat Mar 11 23:19:49 2017 +1100
Branches: master
https://developer.blender.org/rBce155ad2f699c67bcbc9802c8481556aaa8240e0

Correct recent bmesh separate addition

- Was setting flag incorrectly to avoid re-use.
- Check edge has loops before accessing.

===================================================================

M	source/blender/bmesh/tools/bmesh_separate.c

===================================================================

diff --git a/source/blender/bmesh/tools/bmesh_separate.c b/source/blender/bmesh/tools/bmesh_separate.c
index 571da2ff94c..04e03664956 100644
--- a/source/blender/bmesh/tools/bmesh_separate.c
+++ b/source/blender/bmesh/tools/bmesh_separate.c
@@ -49,10 +49,10 @@ void BM_mesh_separate_faces(
 	 * - Create an array of faces based on 'filter_fn'.
 	 *   First part of array for match, for non-match.
 	 *
-	 * - Clear all vertex tags, then tag all vertices from 'faces_b'.
+	 * - Enable all vertex tags, then clear all tagged vertices from 'faces_b'.
 	 *
 	 * - Loop over 'faces_a', checking each vertex,
-	 *   splitting out any which are tagged (and therefor shared).
+	 *   splitting out any which aren't tagged (and therefor shared), disabling tags as we go.
 	 */
 
 	BMFace *f;
@@ -95,8 +95,8 @@ void BM_mesh_separate_faces(
 		do {
 			if (!BM_elem_flag_test(l_iter->v, BM_ELEM_TAG)) {
 				BMVert *v = l_iter->v;
-				/* Disable, since we may visit this vertex again on other faces */
-				BM_elem_flag_disable(v, BM_ELEM_TAG);
+				/* Enable, since we may visit this vertex again on other faces */
+				BM_elem_flag_enable(v, BM_ELEM_TAG);
 
 				/* We know the vertex is shared, collect all vertices and split them off. */
 
@@ -105,15 +105,17 @@ void BM_mesh_separate_faces(
 					BMEdge *e_first, *e_iter;
 					e_iter = e_first = l_iter->e;
 					do {
-						BMLoop *l_radial_first, *l_radial_iter;
-						l_radial_first = l_radial_iter = e_iter->l;
-						do {
-							if (l_radial_iter->v == v) {
-								if (filter_fn(l_radial_iter->f, user_data)) {
-									BLI_buffer_append(&loop_split, BMLoop *, l_radial_iter);
+						if (e_iter->l != NULL) {
+							BMLoop *l_radial_first, *l_radial_iter;
+							l_radial_first = l_radial_iter = e_iter->l;
+							do {
+								if (l_radial_iter->v == v) {
+									if (filter_fn(l_radial_iter->f, user_data)) {
+										BLI_buffer_append(&loop_split, BMLoop *, l_radial_iter);
+									}
 								}
-							}
-						} while ((l_radial_iter = l_radial_iter->radial_next) != l_radial_first);
+							} while ((l_radial_iter = l_radial_iter->radial_next) != l_radial_first);
+						}
 					} while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e_first);
 				}




More information about the Bf-blender-cvs mailing list