forked from bartvdbraak/blender
bmesh: dissolve, avoid unnecessary loop in test_extra_verts(), also minor code cleanup.
This commit is contained in:
parent
539d7d460d
commit
8661e820f9
@ -75,7 +75,7 @@ static bool UNUSED_FUNCTION(check_hole_in_region) (BMesh *bm, BMFace *f)
|
||||
void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
|
||||
{
|
||||
BMOIter oiter;
|
||||
BMFace *f, *f2 /* , *nf = NULL */;
|
||||
BMFace *f;
|
||||
BLI_array_declare(faces);
|
||||
BLI_array_declare(regions);
|
||||
BMFace ***regions = NULL;
|
||||
@ -101,7 +101,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
|
||||
|
||||
/* collect region */
|
||||
BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) {
|
||||
|
||||
BMFace *f_iter;
|
||||
if (!BMO_elem_flag_test(bm, f, FACE_MARK)) {
|
||||
continue;
|
||||
}
|
||||
@ -114,15 +114,15 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
|
||||
BMW_FLAG_NOP, /* no need to check BMW_FLAG_TEST_HIDDEN, faces are already marked by the bmo */
|
||||
BMW_NIL_LAY);
|
||||
|
||||
for (f2 = BMW_begin(®walker, f); f2; f2 = BMW_step(®walker)) {
|
||||
BLI_array_append(faces, f2);
|
||||
for (f_iter = BMW_begin(®walker, f); f_iter; f_iter = BMW_step(®walker)) {
|
||||
BLI_array_append(faces, f_iter);
|
||||
}
|
||||
BMW_end(®walker);
|
||||
|
||||
for (i = 0; i < BLI_array_count(faces); i++) {
|
||||
f2 = faces[i];
|
||||
BMO_elem_flag_disable(bm, f2, FACE_MARK);
|
||||
BMO_elem_flag_enable(bm, f2, FACE_ORIG);
|
||||
f_iter = faces[i];
|
||||
BMO_elem_flag_disable(bm, f_iter, FACE_MARK);
|
||||
BMO_elem_flag_enable(bm, f_iter, FACE_ORIG);
|
||||
}
|
||||
|
||||
if (BMO_error_occurred(bm)) {
|
||||
@ -312,34 +312,32 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op)
|
||||
|
||||
static bool test_extra_verts(BMesh *bm, BMVert *v)
|
||||
{
|
||||
BMIter iter, liter, iter2, iter3;
|
||||
BMFace *f, *f2;
|
||||
BMIter fiter, liter, eiter, fiter_sub;
|
||||
BMFace *f;
|
||||
BMLoop *l;
|
||||
BMEdge *e;
|
||||
bool found;
|
||||
|
||||
/* test faces around verts for verts that would be wrongly killed
|
||||
* by dissolve faces. */
|
||||
f = BM_iter_new(&iter, bm, BM_FACES_OF_VERT, v);
|
||||
for ( ; f; f = BM_iter_step(&iter)) {
|
||||
l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, f);
|
||||
for ( ; l; l = BM_iter_step(&liter)) {
|
||||
BM_ITER_ELEM(f, &fiter, v, BM_FACES_OF_VERT) {
|
||||
BM_ITER_ELEM(l, &liter, f, BM_LOOPS_OF_FACE) {
|
||||
if (!BMO_elem_flag_test(bm, l->v, VERT_MARK)) {
|
||||
/* if an edge around a vert is a boundary edge,
|
||||
* then dissolve faces won't destroy it.
|
||||
* also if it forms a boundary with one
|
||||
* of the face region */
|
||||
found = false;
|
||||
e = BM_iter_new(&iter2, bm, BM_EDGES_OF_VERT, l->v);
|
||||
for ( ; e; e = BM_iter_step(&iter2)) {
|
||||
bool found = false;
|
||||
BM_ITER_ELEM(e, &eiter, l->v, BM_EDGES_OF_VERT) {
|
||||
BMFace *f_iter;
|
||||
if (BM_edge_is_boundary(e)) {
|
||||
found = true;
|
||||
}
|
||||
f2 = BM_iter_new(&iter3, bm, BM_FACES_OF_EDGE, e);
|
||||
for ( ; f2; f2 = BM_iter_step(&iter3)) {
|
||||
if (!BMO_elem_flag_test(bm, f2, FACE_MARK)) {
|
||||
found = true;
|
||||
break;
|
||||
else {
|
||||
BM_ITER_ELEM(f_iter, &fiter_sub, e, BM_FACES_OF_EDGE) {
|
||||
if (!BMO_elem_flag_test(bm, f_iter, FACE_MARK)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found == true) {
|
||||
|
Loading…
Reference in New Issue
Block a user