Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-11-01 16:51:38 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-01 16:51:38 +0400
commita1e95e2e1818ffc88aa5079916b1ee51c1e585f0 (patch)
treedb3fa5a5d78e74fbe81ab3da72e17540fa932bd5
parent63eb94e5045950a8759623e70fe05b4bee309850 (diff)
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).
-rw-r--r--source/blender/bmesh/operators/extrudeops.c12
-rw-r--r--source/blender/bmesh/operators/removedoubles.c1
-rw-r--r--source/blender/editors/mesh/bmesh_select.c35
-rw-r--r--source/blender/editors/mesh/bmesh_tools.c46
-rw-r--r--source/blender/editors/mesh/bmeshutils.c3
-rwxr-xr-xsource/blender/editors/mesh/knifetool.c3
-rw-r--r--source/blender/editors/transform/transform.c21
-rw-r--r--source/blender/editors/transform/transform_conversions.c24
-rw-r--r--source/blender/editors/util/crazyspace.c7
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c38
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c47
11 files changed, 136 insertions, 101 deletions
diff --git a/source/blender/bmesh/operators/extrudeops.c b/source/blender/bmesh/operators/extrudeops.c
index 8674d561b63..53086c272f8 100644
--- a/source/blender/bmesh/operators/extrudeops.c
+++ b/source/blender/bmesh/operators/extrudeops.c
@@ -350,8 +350,12 @@ static void calc_solidify_normals(BMesh *bm)
/* 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 @@ static void calc_solidify_normals(BMesh *bm)
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 @@ static void calc_solidify_normals(BMesh *bm)
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) {
diff --git a/source/blender/bmesh/operators/removedoubles.c b/source/blender/bmesh/operators/removedoubles.c
index b4c99c9ce9a..2233d9d4533 100644
--- a/source/blender/bmesh/operators/removedoubles.c
+++ b/source/blender/bmesh/operators/removedoubles.c
@@ -123,6 +123,7 @@ void bmesh_weldverts_exec(BMesh *bm, BMOperator *op)
}
}
+ /* 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) {
diff --git a/source/blender/editors/mesh/bmesh_select.c b/source/blender/editors/mesh/bmesh_select.c
index aa4461bc3ef..0122fe2b230 100644
--- a/source/blender/editors/mesh/bmesh_select.c
+++ b/source/blender/editors/mesh/bmesh_select.c
@@ -1217,6 +1217,7 @@ static int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, B
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 @@ static int select_linked_flat_faces_exec(bContext *C, wmOperator *op)
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 @@ static int select_linked_flat_faces_exec(bContext *C, wmOperator *op)
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 @@ static int select_next_loop(bContext *C, wmOperator *UNUSED(op))
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 @@ static int select_next_loop(bContext *C, wmOperator *UNUSED(op))
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 @@ static int region_to_loop(bContext *C, wmOperator *UNUSED(op))
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 @@ static int region_to_loop(bContext *C, wmOperator *UNUSED(op))
}
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 @@ static int loop_find_regions(BMEditMesh *em, int selbigger)
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 @@ static int loop_find_regions(BMEditMesh *em, int selbigger)
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 @@ static int loop_find_regions(BMEditMesh *em, int selbigger)
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 @@ static int loop_to_region(bContext *C, wmOperator *op)
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);
}
}
diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c
index e2e89578bee..4522cae5353 100644
--- a/source/blender/editors/mesh/bmesh_tools.c
+++ b/source/blender/editors/mesh/bmesh_tools.c
@@ -1517,7 +1517,12 @@ void EDBM_reveal_mesh(BMEditMesh *em)
/* 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 @@ void EDBM_reveal_mesh(BMEditMesh *em)
}
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 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
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 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
} 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 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
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 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
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 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
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 @@ static int select_mirror_exec(bContext *C, wmOperator *op)
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);
diff --git a/source/blender/editors/mesh/bmeshutils.c b/source/blender/editors/mesh/bmeshutils.c
index 5d960c91bd9..72091db7abb 100644
--- a/source/blender/editors/mesh/bmeshutils.c
+++ b/source/blender/editors/mesh/bmeshutils.c
@@ -624,7 +624,8 @@ UvVertMap *EDBM_make_uv_vert_map(BMEditMesh *em, int selected, int do_face_idx_a
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) {
diff --git a/source/blender/editors/mesh/knifetool.c b/source/blender/editors/mesh/knifetool.c
index 5d28cb72126..1fd3366ecd5 100755
--- a/source/blender/editors/mesh/knifetool.c
+++ b/source/blender/editors/mesh/knifetool.c
@@ -1395,7 +1395,8 @@ static void knifenet_fill_faces(knifetool_opdata *kcd)
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);
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index c730aac55b3..72a07f1b3c9 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -4384,10 +4384,13 @@ static int createSlideVerts(TransInfo *t)
j = 0;
BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
if (BM_TestHFlag(v, BM_SELECT)) {
- BM_SetIndex(v, 1);
+ BM_SetHFlag(v, BM_TMP_TAG);
BLI_smallhash_insert(&table, (uintptr_t)v, SET_INT_IN_POINTER(j));
j += 1;
- } else BM_SetIndex(v, 0);
+ }
+ else {
+ BM_ClearHFlag(v, BM_TMP_TAG);
+ }
}
if (!j)
@@ -4399,7 +4402,7 @@ static int createSlideVerts(TransInfo *t)
while (1) {
v = NULL;
BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
- if (BM_GetIndex(v))
+ if (BM_TestHFlag(v, BM_TMP_TAG))
break;
}
@@ -4426,13 +4429,13 @@ static int createSlideVerts(TransInfo *t)
numsel += 1;
- if (!BM_GetIndex(BM_OtherEdgeVert(e, v)))
+ if (!BM_TestHFlag(BM_OtherEdgeVert(e, v), BM_TMP_TAG))
break;
v = BM_OtherEdgeVert(e, v);
} while (e != first->e);
- BM_SetIndex(v, 0);
+ BM_ClearHFlag(v, BM_TMP_TAG);
l1 = l2 = l = NULL;
l1 = e->l;
@@ -4488,8 +4491,8 @@ static int createSlideVerts(TransInfo *t)
sub_v3_v3v3(sv->downvec, BM_OtherEdgeVert(l->e, v)->co, v->co);
}
- BM_SetIndex(v, 0);
- BM_SetIndex(v2, 0);
+ BM_ClearHFlag(v, BM_TMP_TAG);
+ BM_ClearHFlag(v2, BM_TMP_TAG);
j += 2;
break;
@@ -4500,8 +4503,8 @@ static int createSlideVerts(TransInfo *t)
j += 1;
- BM_SetIndex(v, 0);
- BM_SetIndex(v2, 0);
+ BM_ClearHFlag(v, BM_TMP_TAG);
+ BM_ClearHFlag(v2, BM_TMP_TAG);
} while (e != first->e && l1);
}
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 95f1bf3d8e7..a3115156e6f 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -2091,10 +2091,10 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
if(selectmode & SCE_SELECT_VERTEX) {
BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) {
if (BM_Selected(bm, eve)) {
- BM_SetIndex(eve, SELECT);
+ BM_SetHFlag(eve, BM_TMP_TAG);
}
else {
- BM_SetIndex(eve, 0);
+ BM_ClearHFlag(eve, BM_TMP_TAG);
}
}
}
@@ -2102,20 +2102,20 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
BMEdge *eed;
eve = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);
- for( ; eve; eve=BMIter_Step(&iter)) BM_SetIndex(eve, 0);
+ for( ; eve; eve=BMIter_Step(&iter)) BM_ClearHFlag(eve, BM_TMP_TAG);
eed = BMIter_New(&iter, bm, BM_EDGES_OF_MESH, NULL);
for( ; eed; eed=BMIter_Step(&iter)) {
if (BM_Selected(bm, eed)) {
- BM_SetIndex(eed->v1, SELECT);
- BM_SetIndex(eed->v2, SELECT);
+ BM_SetHFlag(eed->v1, BM_TMP_TAG);
+ BM_SetHFlag(eed->v2, BM_TMP_TAG);
}
}
}
else {
BMFace *efa;
eve = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);
- for( ; eve; eve=BMIter_Step(&iter)) BM_SetIndex(eve, 0);
+ for( ; eve; eve=BMIter_Step(&iter)) BM_ClearHFlag(eve, BM_TMP_TAG);
efa = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL);
for( ; efa; efa=BMIter_Step(&iter)) {
@@ -2125,7 +2125,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
l = BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, efa);
for (; l; l=BMIter_Step(&liter)) {
- BM_SetIndex(l->v, SELECT);
+ BM_SetHFlag(l->v, BM_TMP_TAG);
}
}
}
@@ -2138,7 +2138,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
for(a=0; eve; eve=BMIter_Step(&iter), a++) {
BLI_array_growone(selstate);
- if(BM_GetIndex(eve)) {
+ if (BM_TestHFlag(eve, BM_TMP_TAG)) {
selstate[a] = 1;
countsel++;
}
@@ -2189,7 +2189,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
if(totleft > 0) {
mappedcos= crazyspace_get_mapped_editverts(t->scene, t->obedit);
quats= MEM_mallocN( (t->total)*sizeof(float)*4, "crazy quats");
- crazyspace_set_quats_editmesh(em, (float*)defcos, mappedcos, quats);
+ crazyspace_set_quats_editmesh(em, (float*)defcos, mappedcos, quats); /* BMESH_TODO, abuses vertex index, should use an int array */
if(mappedcos)
MEM_freeN(mappedcos);
}
@@ -2491,11 +2491,11 @@ static void createTransUVs(bContext *C, TransInfo *t)
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
if(!uvedit_face_visible(scene, ima, efa, tf)) {
- BM_SetIndex(efa, 0);
+ BM_ClearHFlag(efa, BM_TMP_TAG);
continue;
}
- BM_SetIndex(efa, 1);
+ BM_SetHFlag(efa, BM_TMP_TAG);
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
if (uvedit_uv_selected(em, scene, l))
countsel++;
@@ -2521,7 +2521,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
td2d= t->data2d;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if (!BM_GetIndex(efa))
+ if (!BM_TestHFlag(efa, BM_TMP_TAG))
continue;
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c
index b3dbd6f6085..f4e1773db49 100644
--- a/source/blender/editors/util/crazyspace.c
+++ b/source/blender/editors/util/crazyspace.c
@@ -145,7 +145,8 @@ void crazyspace_set_quats_editmesh(BMEditMesh *em, float *origcos, float *mapped
float *v1, *v2, *v3, *co1, *co2, *co3;
int *vert_table = MEM_callocN(sizeof(int)*em->bm->totvert, "vert_table");
int index = 0;
-
+
+ /* BMESH_TODO this should be valid now, leaving here until we can ensure this - campbell */
BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
BM_SetIndex(v, index);
index++;
@@ -177,7 +178,9 @@ void crazyspace_set_quats_editmesh(BMEditMesh *em, float *origcos, float *mapped
break; /*just do one corner*/
}
}
-
+
+ /* BMESH_TODO, don't overwrite invalid index info! */
+
index = 0;
BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
if (vert_table[index] != 0)
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 1d56740f91e..048bb17b183 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -207,12 +207,12 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
totuvarea += poly_uv_area(tf_uv, efa->len);
if(uvedit_face_visible(scene, ima, efa, tf)) {
- BM_SetIndex(efa, 1);
+ BM_SetHFlag(efa, BM_TMP_TAG);
}
else {
if(tf == activetf)
activetf= NULL;
- BM_SetIndex(efa, 0);
+ BM_ClearHFlag(efa, BM_TMP_TAG);
}
}
@@ -221,7 +221,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
col[1] = col[2] = 0.0;
glColor3fv(col);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if(BM_GetIndex(efa)) {
+ if(BM_TestHFlag(efa, BM_TMP_TAG)) {
glBegin(GL_POLYGON);
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -233,7 +233,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
}
else {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if(BM_GetIndex(efa)) {
+ if(BM_TestHFlag(efa, BM_TMP_TAG)) {
area = BM_face_area(efa) / totarea;
BLI_array_empty(tf_uv);
@@ -535,7 +535,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
if(uvedit_face_visible(scene, ima, efa, tf)) {
- BM_SetIndex(efa, 1);
+ BM_SetHFlag(efa, BM_TMP_TAG);
if(tf==activetf) continue; /* important the temp boolean is set above */
if(uvedit_face_selected(scene, em, efa))
@@ -553,7 +553,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
else {
if(tf == activetf)
activetf= NULL;
- BM_SetIndex(efa, 0);
+ BM_ClearHFlag(efa, BM_TMP_TAG);
}
}
glDisable(GL_BLEND);
@@ -565,12 +565,12 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
if(uvedit_face_visible(scene, ima, efa, tf)) {
- BM_SetIndex(efa, 1);
+ BM_SetHFlag(efa, BM_TMP_TAG);
}
else {
if(tf == activetf)
activetf= NULL;
- BM_SetIndex(efa, 0);
+ BM_ClearHFlag(efa, BM_TMP_TAG);
}
}
@@ -608,7 +608,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
switch(sima->dt_uv) {
case SI_UVDT_DASH:
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if (!BM_GetIndex(efa))
+ if (!BM_TestHFlag(efa, BM_TMP_TAG))
continue;
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
@@ -649,7 +649,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
else glColor3f(0.0f, 0.0f, 0.0f);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if (!BM_GetIndex(efa))
+ if (!BM_TestHFlag(efa, BM_TMP_TAG))
continue;
glBegin(GL_LINE_LOOP);
@@ -665,7 +665,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
cpack(0x0);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if (!BM_GetIndex(efa))
+ if (!BM_TestHFlag(efa, BM_TMP_TAG))
continue;
glBegin(GL_LINE_LOOP);
@@ -688,7 +688,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
glShadeModel(GL_SMOOTH);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if (!BM_GetIndex(efa))
+ if (!BM_TestHFlag(efa, BM_TMP_TAG))
continue;
glBegin(GL_LINE_LOOP);
@@ -706,7 +706,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
}
else {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if (!BM_GetIndex(efa))
+ if (!BM_TestHFlag(efa, BM_TMP_TAG))
continue;
glBegin(GL_LINES);
@@ -728,7 +728,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
else {
/* no nice edges */
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if (!BM_GetIndex(efa))
+ if (!BM_TestHFlag(efa, BM_TMP_TAG))
continue;
glBegin(GL_LINE_LOOP);
@@ -761,7 +761,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
bglBegin(GL_POINTS);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if (!BM_GetIndex(efa))
+ if (!BM_TestHFlag(efa, BM_TMP_TAG))
continue;
if(!uvedit_face_selected(scene, em, efa)) {
@@ -776,7 +776,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
bglBegin(GL_POINTS);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if (!BM_GetIndex(efa))
+ if (!BM_TestHFlag(efa, BM_TMP_TAG))
continue;
if(uvedit_face_selected(scene, em, efa)) {
@@ -797,7 +797,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
bglBegin(GL_POINTS);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if (!BM_GetIndex(efa))
+ if (!BM_TestHFlag(efa, BM_TMP_TAG))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -815,7 +815,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
bglBegin(GL_POINTS);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if (!BM_GetIndex(efa))
+ if (!BM_TestHFlag(efa, BM_TMP_TAG))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -833,7 +833,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
bglBegin(GL_POINTS);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if (!BM_GetIndex(efa))
+ if (!BM_TestHFlag(efa, BM_TMP_TAG))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index f54d2366050..72f49ebabe8 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -608,6 +608,7 @@ static void find_nearest_uv_edge(Scene *scene, Image *ima, BMEditMesh *em, float
mindist= 1e10f;
memset(hit, 0, sizeof(*hit));
+ /* BMESH_TODO this should be valid now, leaving here until we can ensure this - campbell */
eve = BMIter_New(&iter, em->bm, BM_VERTS_OF_MESH, NULL);
for (i=0; eve; eve=BMIter_Step(&iter), i++) {
BM_SetIndex(eve, i);
@@ -936,6 +937,7 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit
EDBM_init_index_arrays(em, 0, 0, 1);
vmap= EDBM_make_uv_vert_map(em, 0, 0, limit);
+ /* BMESH_TODO this should be valid now, leaving here until we can ensure this - campbell */
count = 0;
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
BM_SetIndex(eve, count);
@@ -949,7 +951,10 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit
}
BMO_ClearFlag(em->bm, efa, EFA_F1_FLAG);
+
+ /* BMESH_TODO this should be valid now, leaving here until we can ensure this - campbell */
BM_SetIndex(efa, count);
+
count++;
}
@@ -1592,6 +1597,7 @@ static int stitch_exec(bContext *C, wmOperator *op)
UVVertAverage *uv_average, *uvav;
int count;
+ /* BMESH_TODO this should be valid now, leaving here until we can ensure this - campbell */
// index and count verts
count=0;
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
@@ -1990,7 +1996,8 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
/* (de)select sticky uv nodes */
if(sticky != SI_STICKY_DISABLE) {
BMVert *ev;
-
+
+ /* BMESH_TODO this should be valid now, leaving here until we can ensure this - campbell */
a = 0;
BM_ITER(ev, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
BM_SetIndex(ev, a);
@@ -2371,13 +2378,14 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje
* in the loop and select all MLoopUV's that use a touched vert. */
BMVert *eve;
- BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL)
- BM_SetIndex(eve, 0);
+ BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
+ BM_ClearHFlag(eve, BM_TMP_TAG);
+ }
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if(BM_GetIndex(efa)) {
+ if (BM_TestHFlag(efa, BM_TMP_TAG)) {
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
- BM_SetIndex(l->v, 1);
+ BM_SetHFlag(l->v, BM_TMP_TAG);
}
}
}
@@ -2387,7 +2395,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje
/* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
- if (BM_GetIndex(l->v)) {
+ if (BM_TestHFlag(l->v, BM_TMP_TAG)) {
if (select)
uvedit_uv_select(em, scene, l);
else
@@ -2421,7 +2429,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje
efa = BMIter_New(&iter, em->bm, BM_FACES_OF_MESH, NULL);
for (efa_index=0; efa; efa=BMIter_Step(&iter), efa_index++) {
- if(BM_GetIndex(efa)) {
+ if (BM_TestHFlag(efa, BM_TMP_TAG)) {
/* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -2468,7 +2476,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje
}
else { /* SI_STICKY_DISABLE or ts->uv_flag & UV_SYNC_SELECTION */
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if(BM_GetIndex(efa)) {
+ if (BM_TestHFlag(efa, BM_TMP_TAG)) {
if(select)
uvedit_face_select(scene, em, efa);
else
@@ -2523,13 +2531,13 @@ static int border_select_exec(bContext *C, wmOperator *op)
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
/* assume not touched */
- BM_SetIndex(efa, 0);
+ BM_ClearHFlag(efa, BM_TMP_TAG);
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
if(uvedit_face_visible(scene, ima, efa, tf)) {
poly_uv_center(em, efa, cent);
if(BLI_in_rctf(&rectf, cent[0], cent[1])) {
- BM_SetIndex(efa, 1);
+ BM_SetHFlag(efa, BM_TMP_TAG);
change = 1;
}
}
@@ -2813,7 +2821,11 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe
int count = 0;
float *coords;
short *usercount, users;
-
+
+ /* BMESH_TODO - stop setting the index, bad juju
+ * not totally simple because 3 states and because the count is not
+ * based on the global vertex index :S - campbell */
+
/* set all verts to -1 : an unused index*/
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL)
BM_SetIndex(eve, -1);
@@ -2823,10 +2835,10 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
if(!uvedit_face_visible(scene, ima, efa, tface)) {
- BM_SetIndex(efa, 0);
+ BM_ClearHFlag(efa, BM_TMP_TAG);
continue;
} else {
- BM_SetIndex(efa, 1);
+ BM_SetHFlag(efa, BM_TMP_TAG);
}
change = 1;
@@ -2843,7 +2855,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe
/* add all UV coords from visible, unselected UV coords as well as counting them to average later */
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if (!BM_GetIndex(efa))
+ if (!BM_TestHFlag(efa, BM_TMP_TAG))
continue;
tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
@@ -2870,7 +2882,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe
/* copy the averaged unselected UVs back to the selected UVs */
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if (!BM_GetIndex(efa))
+ if (!BM_TestHFlag(efa, BM_TMP_TAG))
continue;
tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
@@ -3185,15 +3197,10 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op))
BMEditMesh *em= ((Mesh*)obedit->data)->edit_btmesh;
BMFace *efa;
BMLoop *l;
- BMVert *v;
BMIter iter, liter;
MLoopUV *luv;
int facemode= sima ? sima->flag & SI_SELACTFACE : 0;
int stickymode= sima ? (sima->sticky != SI_STICKY_DISABLE) : 1;
-
- BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
- BM_SetIndex(v, BM_TestHFlag(v, BM_SELECT));
- }
/* call the mesh function if we are in mesh sync sel */
if(ts->uv_flag & UV_SYNC_SELECTION) {