[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41440] branches/bmesh/blender/source/ blender: replace as many uses of BM_Get/ SetIndex as possible with tagging with a temp flag, some uses need index values to be set, so this will need more effort to replace (crazy space and solidify for eg) .

Campbell Barton ideasman42 at gmail.com
Tue Nov 1 13:51:38 CET 2011


Revision: 41440
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41440
Author:   campbellbarton
Date:     2011-11-01 12:51:38 +0000 (Tue, 01 Nov 2011)
Log Message:
-----------
replace as many uses of BM_Get/SetIndex as possible with tagging with a temp flag, some uses need index values to be set, so this will need more effort to replace (crazy space and solidify for eg).

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c
    branches/bmesh/blender/source/blender/bmesh/operators/removedoubles.c
    branches/bmesh/blender/source/blender/editors/mesh/bmesh_select.c
    branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
    branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c
    branches/bmesh/blender/source/blender/editors/mesh/knifetool.c
    branches/bmesh/blender/source/blender/editors/transform/transform.c
    branches/bmesh/blender/source/blender/editors/transform/transform_conversions.c
    branches/bmesh/blender/source/blender/editors/util/crazyspace.c
    branches/bmesh/blender/source/blender/editors/uvedit/uvedit_draw.c
    branches/bmesh/blender/source/blender/editors/uvedit/uvedit_ops.c

Modified: branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c	2011-11-01 11:00:08 UTC (rev 41439)
+++ branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c	2011-11-01 12:51:38 UTC (rev 41440)
@@ -350,8 +350,12 @@
 
 	/* Clear indices of verts & edges */
 	BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
-		BM_SetIndex(v, 0);
+		BM_SetHFlag(v, BM_TMP_TAG);
 	}
+	/* BMESH_TODO, don't abuse vertex index index info */
+
+	/* this is used to count edge users, we can probably
+	 * use bmesh connectivity info here - campbell*/
 	BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) {
 		BM_SetIndex(e, 0);
 	}
@@ -444,8 +448,8 @@
 			else {
 				/* can't do anything useful here!
 				   Set the face index for a vert incase it gets a zero normal */
-				BM_SetIndex(e->v1, -1);
-				BM_SetIndex(e->v2, -1);
+				BM_ClearHFlag(e->v1, BM_TMP_TAG);
+				BM_ClearHFlag(e->v2, BM_TMP_TAG);
 				continue;
 			}
 		}
@@ -472,7 +476,7 @@
 			   edges */
 			BM_Vert_UpdateNormal(bm, v);
 		}
-		else if (normalize_v3(v->no) == 0.0f && BM_GetIndex(v) < 0) {
+		else if (normalize_v3(v->no) == 0.0f && !BM_TestHFlag(v, BM_TMP_TAG)) {
 			/* exceptional case, totally flat. use the normal
 			   of any marked face around the vertex */
 			BM_ITER(f, &fiter, bm, BM_FACES_OF_VERT, v) {

Modified: branches/bmesh/blender/source/blender/bmesh/operators/removedoubles.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/removedoubles.c	2011-11-01 11:00:08 UTC (rev 41439)
+++ branches/bmesh/blender/source/blender/bmesh/operators/removedoubles.c	2011-11-01 12:51:38 UTC (rev 41440)
@@ -123,6 +123,7 @@
 		}
 	}
 
+	/* BMESH_TODO, stop abusing face index here */
 	BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
 		BM_SetIndex(f, 0);
 		BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {

Modified: branches/bmesh/blender/source/blender/editors/mesh/bmesh_select.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmesh_select.c	2011-11-01 11:00:08 UTC (rev 41439)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmesh_select.c	2011-11-01 12:51:38 UTC (rev 41440)
@@ -1217,6 +1217,7 @@
 
 	BLI_smallhash_init(&visithash);
 
+	/* BMESH_TODO this should be valid now, leaving here until we can ensure this - campbell */
 	/* we need the vert */
 	BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
 		BM_SetIndex(v, totvert);
@@ -2203,11 +2204,11 @@
 	sharp = (sharp * M_PI) / 180.0;
 
 	BM_ITER(f, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
-		BM_SetIndex(f, 0);
+		BM_ClearHFlag(f, BM_TMP_TAG);
 	}
 
 	BM_ITER(f, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
-		if (BM_TestHFlag(f, BM_HIDDEN) || !BM_TestHFlag(f, BM_SELECT) || BM_GetIndex(f))
+		if (BM_TestHFlag(f, BM_HIDDEN) || !BM_TestHFlag(f, BM_SELECT) || BM_TestHFlag(f, BM_TMP_TAG))
 			continue;
 
 		BLI_array_empty(stack);
@@ -2222,13 +2223,13 @@
 
 			BM_Select(em->bm, f, 1);
 
-			BM_SetIndex(f, 1);
+			BM_SetHFlag(f, BM_TMP_TAG);
 
 			BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, f) {
 				BM_ITER(l2, &liter2, em->bm, BM_LOOPS_OF_LOOP, l) {
 					float angle;
 
-					if (BM_GetIndex(l2->f) || BM_TestHFlag(l2->f, BM_HIDDEN))
+					if (BM_TestHFlag(l2->f, BM_TMP_TAG) || BM_TestHFlag(l2->f, BM_HIDDEN))
 						continue;
 
 					/* edge has exactly two neighboring faces, check angle */
@@ -2387,7 +2388,7 @@
 	BMIter iter;
 	
 	BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
-		BM_SetIndex(v, 0);
+		BM_ClearHFlag(v, BM_TMP_TAG);
 	}
 	
 	BM_ITER(f, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
@@ -2396,14 +2397,14 @@
 		
 		BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, f) {
 			if (BM_TestHFlag(l->v, BM_SELECT) && !BM_TestHFlag(l->v, BM_HIDDEN)) {
-				BM_SetIndex(l->next->v, 1);
+				BM_SetHFlag(l->next->v, BM_TMP_TAG);
 				BM_Select(em->bm, l->v, 0);
 			}
 		}
 	}
 
 	BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
-		if (BM_GetIndex(v)) {
+		if (BM_TestHFlag(v, BM_TMP_TAG)) {
 			BM_Select(em->bm, v, 1);
 		}
 	}
@@ -2440,7 +2441,7 @@
 	em_setup_viewcontext(C, &vc);
 	
 	BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
-		BM_SetIndex(e, 0);
+		BM_ClearHFlag(e, BM_TMP_TAG);
 	}
 
 	BM_ITER(f, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
@@ -2456,14 +2457,14 @@
 			}
 			
 			if ((tot != totsel && totsel > 0) || (totsel == 1 && tot == 1))
-				BM_SetIndex(l1->e, 1);
+				BM_SetHFlag(l1->e, BM_TMP_TAG);
 		}
 	}
 
 	EDBM_clear_flag_all(em, BM_SELECT);
 	
 	BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
-		if (BM_GetIndex(e) && !BM_TestHFlag(e, BM_HIDDEN))
+		if (BM_TestHFlag(e, BM_TMP_TAG) && !BM_TestHFlag(e, BM_HIDDEN))
 			BM_Select_Edge(em->bm, e, 1);
 	}
 
@@ -2560,15 +2561,15 @@
 	BLI_smallhash_init(&visithash);
 	
 	BM_ITER(f, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
-		BM_SetIndex(f, 0);
+		BM_ClearHFlag(f, BM_TMP_TAG);
 	}
 
 	BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
 		if (BM_TestHFlag(e, BM_SELECT)) {
 			BLI_array_append(edges, e);
-			BM_SetIndex(e, 1);
+			BM_SetHFlag(e, BM_TMP_TAG);
 		} else {
-			BM_SetIndex(e, 0);
+			BM_ClearHFlag(e, BM_TMP_TAG);
 		}
 	}
 	
@@ -2583,7 +2584,7 @@
 		
 		e = edges[i];
 		
-		if (!BM_GetIndex(e))
+		if (!BM_TestHFlag(e, BM_TMP_TAG))
 			continue;
 		
 		BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_EDGE, e) {
@@ -2612,9 +2613,9 @@
 			int j;
 			
 			for (j=0; j<tot; j++) {
-				BM_SetIndex(region[j], 1);
+				BM_SetHFlag(region[j], BM_TMP_TAG);
 				BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, region[j]) {
-					BM_SetIndex(l->e, 0);
+					BM_ClearHFlag(l->e, BM_TMP_TAG);
 				}
 			}
 			
@@ -2650,7 +2651,7 @@
 	EDBM_clear_flag_all(em, BM_SELECT);
 	
 	BM_ITER(f, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
-		if (BM_GetIndex(f) && !BM_TestHFlag(f, BM_HIDDEN)) {
+		if (BM_TestHFlag(f, BM_TMP_TAG) && !BM_TestHFlag(f, BM_HIDDEN)) {
 			BM_Select_Face(em->bm, f, 1);
 		}
 	}

Modified: branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c	2011-11-01 11:00:08 UTC (rev 41439)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c	2011-11-01 12:51:38 UTC (rev 41440)
@@ -1517,7 +1517,12 @@
 	/* Use index field to remember what was hidden before all is revealed. */
 	for (i=0; i<3; i++) {
 		BM_ITER(ele, &iter, em->bm, types[i], NULL) {
-			BM_SetIndex(ele, BM_TestHFlag(ele, BM_HIDDEN) ? 1 : 0);
+			if (BM_TestHFlag(ele, BM_HIDDEN)) {
+				BM_SetHFlag(ele, BM_TMP_TAG);
+			}
+			else {
+				BM_ClearHFlag(ele, BM_TMP_TAG);
+			}
 		}
 	}
 
@@ -1531,7 +1536,7 @@
 		}
 
 		BM_ITER(ele, &iter, em->bm, types[i], NULL) {
-			if (BM_GetIndex(ele)) {
+			if (BM_TestHFlag(ele, BM_TMP_TAG)) {
 				BM_Select(em->bm, ele, 1);
 			}
 		}
@@ -2374,9 +2379,12 @@
 	ED_view3d_ob_project_mat_get(rv3d, obedit, projectMat);
 
 	BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
-		if (BM_TestHFlag(e, BM_SELECT))
-			BM_SetIndex(e, 1);
-		else BM_SetIndex(e, 0);
+		if (BM_TestHFlag(e, BM_SELECT)) {
+			BM_SetHFlag(e, BM_TMP_TAG);
+		}
+		else {
+			BM_ClearHFlag(e, BM_TMP_TAG);
+		}
 	}
 
 	/*handle case of one vert selected.  identify
@@ -2425,12 +2433,12 @@
 		} else if (BM_Edge_FaceCount(e2) == 2) {
 			l = e2->l;
 			e = BM_OtherFaceLoop(e2, l->f, v)->e;
-			BM_SetIndex(e, 1);
+			BM_SetHFlag(e, BM_TMP_TAG);
 			BM_Select(bm, e, 1);
 			
 			l = e2->l->radial_next;
 			e = BM_OtherFaceLoop(e2, l->f, v)->e;
-			BM_SetIndex(e, 1);
+			BM_SetHFlag(e, BM_TMP_TAG);
 			BM_Select(bm, e, 1);
 		}
 
@@ -2441,7 +2449,7 @@
 			e2 = NULL;
 			i = 0;
 			BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) {
-				if (BM_GetIndex(e)) {
+				if (BM_TestHFlag(e, BM_TMP_TAG)) {
 					e2 = e;
 					i++;
 				}
@@ -2509,9 +2517,12 @@
 	BMO_HeaderFlag_Buffer(bm, &bmop, side?"edgeout2":"edgeout1", BM_SELECT, BM_EDGE);
 
 	BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
-		if (BM_TestHFlag(e, BM_SELECT))
-			BM_SetIndex(e, 1);
-		else BM_SetIndex(e, 0);
+		if (BM_TestHFlag(e, BM_SELECT)) {
+			BM_SetHFlag(e, BM_TMP_TAG);
+		}
+		else {
+			BM_ClearHFlag(e, BM_TMP_TAG);
+		}
 	}
 
 	/*constrict edge selection again*/
@@ -2519,7 +2530,7 @@
 		e2 = NULL;
 		i = 0;
 		BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) {
-			if (BM_GetIndex(e)) {
+			if (BM_TestHFlag(e, BM_TMP_TAG)) {
 				e2 = e;
 				i++;
 			}
@@ -3923,16 +3934,19 @@
 	float mirror_co[3];
 
 	BM_ITER(v1, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
-		if (!BM_TestHFlag(v1, BM_SELECT) || BM_TestHFlag(v1, BM_HIDDEN))
-			BM_SetIndex(v1, 0);
-		else BM_SetIndex(v1, 1);
+		if (!BM_TestHFlag(v1, BM_SELECT) || BM_TestHFlag(v1, BM_HIDDEN)) {
+			BM_ClearHFlag(v1, BM_TMP_TAG);
+		}
+		else {
+			BM_SetHFlag(v1, BM_TMP_TAG);
+		}
 	}
 
 	if (!extend)
 		EDBM_clear_flag_all(em, BM_SELECT);
 
 	BM_ITER(v1, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
-		if (!BM_GetIndex(v1) || BM_TestHFlag(v1, BM_HIDDEN))
+		if (!BM_TestHFlag(v1, BM_TMP_TAG) || BM_TestHFlag(v1, BM_HIDDEN))
 			continue;
 
 		copy_v3_v3(mirror_co, v1->co);

Modified: branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c	2011-11-01 11:00:08 UTC (rev 41439)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c	2011-11-01 12:51:38 UTC (rev 41440)
@@ -624,7 +624,8 @@
 	
 	if (do_face_idx_array)
 		EDBM_init_index_arrays(em, 0, 0, 1);
-	
+
+	/* BMESH_TODO this should be valid now, leaving here until we can ensure this - campbell */
 	/* we need the vert */
 	totverts=0;
 	BM_ITER(ev, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {

Modified: branches/bmesh/blender/source/blender/editors/mesh/knifetool.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/knifetool.c	2011-11-01 11:00:08 UTC (rev 41439)
+++ branches/bmesh/blender/source/blender/editors/mesh/knifetool.c	2011-11-01 12:51:38 UTC (rev 41440)
@@ -1395,7 +1395,8 @@
 	
 	BMO_push(bm, NULL);
 	bmesh_begin_edit(bm, BMOP_UNTAN_MULTIRES);
-	
+
+	/* BMESH_TODO this should be valid now, leaving here until we can ensure this - campbell */
 	i = 0;
 	BM_ITER(f, &bmiter, bm, BM_FACES_OF_MESH, NULL) {
 		BM_SetIndex(f, i);

Modified: branches/bmesh/blender/source/blender/editors/transform/transform.c

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list