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