BMesh: dissolve faces no longer fails when some faces can't dissolve

Previously, any face groups that could not be merged into a face
caused the entire operation to report an error and do nothing.

Now these cases are skipped over, dissolving faces where possible.
This commit is contained in:
Campbell Barton 2021-07-05 13:56:27 +10:00
parent 9075f63e8f
commit b29a8a5dfe
Notes: blender-bot 2024-04-29 13:07:32 +02:00
Referenced by commit 42d0107ee5, Fix crash dissolving overlapping faces
1 changed files with 16 additions and 9 deletions

View File

@ -214,21 +214,29 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
BMFace *f_new = BM_faces_join(bm, faces, faces_len, true);
if (f_new != NULL) {
/* maintain active face */
/* Maintain the active face. */
if (act_face && bm->act_face == NULL) {
bm->act_face = f_new;
}
totface_target -= faces_len - 1;
/* If making the new face failed (e.g. overlapping test)
* un-mark the original faces for deletion. */
BMO_face_flag_disable(bm, f_new, FACE_ORIG);
BMO_face_flag_enable(bm, f_new, FACE_NEW);
}
else {
BMO_error_raise(bm, op, "Could not create merged face");
goto cleanup;
}
/* NOTE: prior to 3.0 this raised an error: "Could not create merged face".
* Change behavior since it's not useful to fail entirely when a single face-group
* can't be merged into one face. Continue with other face groups instead.
*
* This could optionally do a partial merge, where some faces are joined. */
/* if making the new face failed (e.g. overlapping test)
* unmark the original faces for deletion */
BMO_face_flag_disable(bm, f_new, FACE_ORIG);
BMO_face_flag_enable(bm, f_new, FACE_NEW);
/* Prevent these faces from being removed. */
for (i = 0; i < faces_len; i++) {
BMO_face_flag_disable(bm, faces[i], FACE_ORIG);
}
}
}
/* Typically no faces need to be deleted */
@ -253,7 +261,6 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "region.out", BM_FACE, FACE_NEW);
cleanup:
/* free/cleanup */
for (i = 0; i < BLI_array_len(regions); i++) {
MEM_freeN(regions[i].faces);