[Bf-blender-cvs] [775bddc] bmesh-boolean-experiment: Boolean: checking index of faces wasn't reliable to tell the mesh it came from

Campbell Barton noreply at git.blender.org
Fri Nov 27 06:17:05 CET 2015


Commit: 775bddc29762095f7e9252b86d222eef30120834
Author: Campbell Barton
Date:   Fri Nov 27 16:09:46 2015 +1100
Branches: bmesh-boolean-experiment
https://developer.blender.org/rB775bddc29762095f7e9252b86d222eef30120834

Boolean: checking index of faces wasn't reliable to tell the mesh it came from

When faces are split, the index is set to -1

Use free flag instead.

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

M	source/blender/modifiers/intern/MOD_boolean.c

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

diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index fd9b327..db795c9 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -146,19 +146,15 @@ static DerivedMesh *get_quick_derivedMesh(DerivedMesh *derivedData, DerivedMesh
 
 #ifdef USE_BMESH
 
-struct BMIsectUserData {
-	int face_tot_first_mesh;
-};
+/* has no meaning for faces, do this so we can tell which face is which */
+#define BM_FACE_TAG BM_ELEM_DRAW
 
 /**
  * Compare selected/unselected.
  */
-static int bm_face_isect_pair(BMFace *f, void *user_data)
+static int bm_face_isect_pair(BMFace *f, void *UNUSED(user_data))
 {
-	struct BMIsectUserData *data = user_data;
-
-	// return (f->mat_nr == 0);  /* quick test */
-	return (BM_elem_index_get(f) < data->face_tot_first_mesh);
+	return BM_elem_flag_test_bool(f, BM_FACE_TAG);
 }
 
 static DerivedMesh *applyModifier(
@@ -198,14 +194,10 @@ static DerivedMesh *applyModifier(
 				int tottri;
 				BMLoop *(*looptris)[3];
 
-				struct BMIsectUserData user_data = {0};
-
 				looptris = MEM_mallocN(sizeof(*looptris) * looptris_tot, __func__);
 
 				BM_bmesh_calc_tessellation(bm, looptris, &tottri);
 
-				user_data.face_tot_first_mesh = dm_other->getNumPolys(dm_other);
-
 				/* postpone this until after tessellating
 				 * so we can use the original normals before the vertex are moved */
 				{
@@ -240,6 +232,7 @@ static DerivedMesh *applyModifier(
 					BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
 						mul_transposed_mat3_m4_v3(nmat, efa->no);
 						normalize_v3(efa->no);
+						BM_elem_flag_enable(efa, BM_FACE_TAG);  /* temp tag to test which side split faces are from */
 						if (++i == i_faces_end) {
 							break;
 						}
@@ -253,7 +246,7 @@ static DerivedMesh *applyModifier(
 				BM_mesh_intersect(
 				        bm,
 				        looptris, tottri,
-				        bm_face_isect_pair, &user_data,
+				        bm_face_isect_pair, NULL,
 				        false, true, false,
 				        bmd->operation,
 				        bmd->threshold);




More information about the Bf-blender-cvs mailing list