[Bf-blender-cvs] [b29a8a5dfe3] master: BMesh: dissolve faces no longer fails when some faces can't dissolve

Campbell Barton noreply at git.blender.org
Mon Jul 5 10:32:41 CEST 2021


Commit: b29a8a5dfe3d6eb2fbbdecd0d5dffb3d709b9b91
Author: Campbell Barton
Date:   Mon Jul 5 13:56:27 2021 +1000
Branches: master
https://developer.blender.org/rBb29a8a5dfe3d6eb2fbbdecd0d5dffb3d709b9b91

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.

===================================================================

M	source/blender/bmesh/operators/bmo_dissolve.c

===================================================================

diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c
index 62eaa690077..c0ce63fb0eb 100644
--- a/source/blender/bmesh/operators/bmo_dissolve.c
+++ b/source/blender/bmesh/operators/bmo_dissolve.c
@@ -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. */
+
+      /* Prevent these faces from being removed. */
+      for (i = 0; i < faces_len; i++) {
+        BMO_face_flag_disable(bm, faces[i], FACE_ORIG);
+      }
     }
-
-    /* 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);
   }
 
   /* 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);



More information about the Bf-blender-cvs mailing list