small changes to iterator, preparing for bigger changes.

- renamed flag to layer
- added define to make dummy layer args easier to tell apart from flags
This commit is contained in:
Campbell Barton 2011-11-24 00:14:13 +00:00
parent ea93a492e3
commit 052d892207
8 changed files with 24 additions and 21 deletions

@ -19,19 +19,19 @@ typedef struct BMWalker {
void *(*yield)(struct BMWalker *walker);
int structsize;
BMWOrder order;
int flag;
int layer;
BMesh *bm;
BLI_mempool *worklist;
ListBase states;
int restrictflag;
short restrictflag;
GHash *visithash;
int depth;
} BMWalker;
/*initialize a walker. searchmask restricts some (not all) walkers to
elements with a specific tool flag set. flags is specific to each walker.*/
void BMW_Init(struct BMWalker *walker, BMesh *bm, int type, int searchmask, int flags);
void BMW_Init(struct BMWalker *walker, BMesh *bm, int type, short searchmask, int layer);
void *BMW_Begin(BMWalker *walker, void *start);
void *BMW_Step(struct BMWalker *walker);
void BMW_End(struct BMWalker *walker);
@ -91,4 +91,7 @@ enum {
BMW_MAXWALKERS
};
/* use with BMW_Init, so as not to confuse with restrict flags */
#define BMW_NIL_LAY 0
#endif

@ -83,18 +83,18 @@ void *BMW_Begin(BMWalker *walker, void *start)
*
*/
void BMW_Init(BMWalker *walker, BMesh *bm, int type, int searchmask, int flag)
void BMW_Init(BMWalker *walker, BMesh *bm, int type, short searchmask, int layer)
{
memset(walker, 0, sizeof(BMWalker));
walker->flag = flag;
walker->layer = layer;
walker->bm = bm;
walker->restrictflag = searchmask;
walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 1");
if (type >= BMW_MAXWALKERS || type < 0) {
bmesh_error();
fprintf(stderr, "Invalid walker type in BMW_Init; type: %d, searchmask: %d, flag: %d\n", type, searchmask, flag);
fprintf(stderr, "Invalid walker type in BMW_Init; type: %d, searchmask: %d, flag: %d\n", type, searchmask, layer);
}
if (type != BMW_CUSTOM) {

@ -761,7 +761,7 @@ static void *uvedgeWalker_step(BMWalker *walker)
l = lwalk->l;
nl = l->next;
type = walker->bm->ldata.layers[walker->flag].type;
type = walker->bm->ldata.layers[walker->layer].type;
BMW_removestate(walker);
@ -773,8 +773,8 @@ static void *uvedgeWalker_step(BMWalker *walker)
for (i=0; i<2; i++) {
cl = i ? nl : l;
BM_ITER(l2, &liter, walker->bm, BM_LOOPS_OF_VERT, cl->v) {
d1 = CustomData_bmesh_get_layer_n(&walker->bm->ldata,
cl->head.data, walker->flag);
d1 = CustomData_bmesh_get_layer_n(&walker->bm->ldata,
cl->head.data, walker->layer);
rlen = BM_Edge_FaceCount(l2->e);
for (j=0; j<rlen; j++) {
@ -788,7 +788,7 @@ static void *uvedgeWalker_step(BMWalker *walker)
l3 = l2->v != cl->v ? l2->next : l2;
d2 = CustomData_bmesh_get_layer_n(&walker->bm->ldata,
l3->head.data, walker->flag);
l3->head.data, walker->layer);
if (!CustomData_data_equals(type, d1, d2))
continue;

@ -28,7 +28,7 @@ static int UNUSED_FUNCTION(check_hole_in_region)(BMesh *bm, BMFace *f)
/*checks if there are any unmarked boundary edges in the face region*/
BMW_Init(&regwalker, bm, BMW_ISLAND, FACE_MARK, 0);
BMW_Init(&regwalker, bm, BMW_ISLAND, FACE_MARK, BMW_NIL_LAY);
f2 = BMW_Begin(&regwalker, f);
for (; f2; f2=BMW_Step(&regwalker)) {
l2 = BMIter_New(&liter2, bm, BM_LOOPS_OF_FACE, f2);
@ -69,7 +69,7 @@ void dissolvefaces_exec(BMesh *bm, BMOperator *op)
faces = NULL; /*forces different allocation*/
/*yay, walk!*/
BMW_Init(&regwalker, bm, BMW_ISLAND, FACE_MARK, 0);
BMW_Init(&regwalker, bm, BMW_ISLAND, FACE_MARK, BMW_NIL_LAY);
f2 = BMW_Begin(&regwalker, f);
for (; f2; f2=BMW_Step(&regwalker)) {
BLI_array_append(faces, f2);

@ -347,7 +347,7 @@ void bmesh_collapse_exec(BMesh *bm, BMOperator *op)
BMO_Init_Op(bm, &weldop, "weldverts");
BMO_Flag_Buffer(bm, op, "edges", EDGE_MARK, BM_EDGE);
BMW_Init(&walker, bm, BMW_SHELL, EDGE_MARK, 0);
BMW_Init(&walker, bm, BMW_SHELL, EDGE_MARK, BMW_NIL_LAY);
BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
if (!BMO_TestFlag(bm, e, EDGE_MARK))

@ -885,7 +885,7 @@ static void walker_select(BMEditMesh *em, int walkercode, void *start, int selec
BMHeader *h;
BMWalker walker;
BMW_Init(&walker, bm, walkercode, 0, 0);
BMW_Init(&walker, bm, walkercode, 0, BMW_NIL_LAY);
h = BMW_Begin(&walker, start);
for (; h; h=BMW_Step(&walker)) {
if (!select)
@ -1770,7 +1770,7 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event
eed = eve->e;
}
BMW_Init(&walker, em->bm, BMW_SHELL, 0, 0);
BMW_Init(&walker, em->bm, BMW_SHELL, 0, BMW_NIL_LAY);
e = BMW_Begin(&walker, eed->v1);
for (; e; e=BMW_Step(&walker)) {
BM_Select(em->bm, e->v1, sel);
@ -1822,7 +1822,7 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
}
}
BMW_Init(&walker, em->bm, BMW_SHELL, 0, 0);
BMW_Init(&walker, em->bm, BMW_SHELL, 0, BMW_NIL_LAY);
for (i=0; i<tot; i++) {
e = BMW_Begin(&walker, verts[i]);
for (; e; e=BMW_Step(&walker)) {
@ -1978,7 +1978,7 @@ static void walker_deselect_nth(BMEditMesh *em, int nth, int offset, BMHeader *h
}
/* Walk over selected elements starting at active */
BMW_Init(&walker, bm, walktype, BM_SELECT, 0);
BMW_Init(&walker, bm, walktype, BM_SELECT, BMW_NIL_LAY);
BLI_assert(walker.order == BMW_BREADTH_FIRST);
for (h = BMW_Begin(&walker, h_act); h != NULL; h = BMW_Step(&walker)) {
/* Deselect elements that aren't at "nth" depth from active */

@ -1725,7 +1725,7 @@ static int bm_test_exec(bContext *C, wmOperator *UNUSED(op))
}
}
BMW_Init(&walker, em->bm, BMW_UVISLAND, 0);
BMW_Init(&walker, em->bm, BMW_UVISLAND, BMW_NIL_LAY);
BM_ITER(f, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, f) {
@ -3330,7 +3330,7 @@ static int mesh_separate_loose(Main *bmain, Scene *scene, Base *editbase, wmOper
/*Walk from the single vertex, selecting everything connected
to it*/
BMW_Init(&walker, bm, BMW_SHELL, 0, 0);
BMW_Init(&walker, bm, BMW_SHELL, 0, BMW_NIL_LAY);
e = BMW_Begin(&walker, v_seed);
for (; e; e=BMW_Step(&walker)) {
BM_Select(bm, e->v1, 1);

@ -204,7 +204,7 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select)
}
if (select) {
BMW_Init(&walker, em->bm, BMW_EDGERING, 0, 0);
BMW_Init(&walker, em->bm, BMW_EDGERING, 0, BMW_NIL_LAY);
eed = BMW_Begin(&walker, startedge);
for (; eed; eed=BMW_Step(&walker)) {
BM_Select(em->bm, eed, 1);
@ -214,7 +214,7 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select)
return;
}
BMW_Init(&walker, em->bm, BMW_EDGERING, 0, 0);
BMW_Init(&walker, em->bm, BMW_EDGERING, 0, BMW_NIL_LAY);
eed = startedge = BMW_Begin(&walker, startedge);
lastv1 = NULL;
for (lasteed=NULL; eed; eed=BMW_Step(&walker)) {