[Bf-blender-cvs] [106f542ac43] temp_bmesh_multires: Sculpt dyntopo: yet another undo bug

Joseph Eagar noreply at git.blender.org
Tue Aug 17 23:59:24 CEST 2021


Commit: 106f542ac43c92c06cd3fb485ae1ed8c8908ac05
Author: Joseph Eagar
Date:   Tue Aug 17 14:58:37 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rB106f542ac43c92c06cd3fb485ae1ed8c8908ac05

Sculpt dyntopo: yet another undo bug

BKE_pbvh_bmesh_add_face had a branch where it ignored
the log_face argument, leading to corruption in
BMLog.

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

M	source/blender/blenkernel/intern/dyntopo.c
M	source/blender/bmesh/intern/bmesh_log.c

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

diff --git a/source/blender/blenkernel/intern/dyntopo.c b/source/blender/blenkernel/intern/dyntopo.c
index d498818d0ac..013e10d65eb 100644
--- a/source/blender/blenkernel/intern/dyntopo.c
+++ b/source/blender/blenkernel/intern/dyntopo.c
@@ -748,6 +748,10 @@ void BKE_pbvh_bmesh_add_face(PBVH *pbvh, struct BMFace *f, bool log_face, bool f
 
   if (force_tree_walk) {
     bke_pbvh_insert_face(pbvh, f);
+
+    if (log_face) {
+      BM_log_face_added(pbvh->bm_log, f);
+    }
     return;
   }
 
@@ -1462,6 +1466,8 @@ static void short_edge_queue_task_cb(void *__restrict userdata,
 
 static bool check_face_is_tri(PBVH *pbvh, BMFace *f)
 {
+  bool origlen = f->len;
+
   if (f->len == 3) {
     return true;
   }
@@ -1519,7 +1525,12 @@ static bool check_face_is_tri(PBVH *pbvh, BMFace *f)
       }
     }
 
+    if (dbl->link == f) {
+      f = NULL;
+    }
+
     BM_face_kill(pbvh->bm, dbl->link);
+
     MEM_freeN(dbl);
     dbl = next;
   }
@@ -1539,7 +1550,9 @@ static bool check_face_is_tri(PBVH *pbvh, BMFace *f)
     BKE_pbvh_bmesh_add_face(pbvh, f2, true, true);
   }
 
-  BKE_pbvh_bmesh_add_face(pbvh, f, true, true);
+  if (f) {
+    BKE_pbvh_bmesh_add_face(pbvh, f, true, true);
+  }
 
   BLI_array_free(fs);
   BLI_array_free(es);
diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c
index 6d20b273675..83964abfd3a 100644
--- a/source/blender/bmesh/intern/bmesh_log.c
+++ b/source/blender/bmesh/intern/bmesh_log.c
@@ -488,6 +488,11 @@ static void bm_log_verts_unmake_pre(
       continue;
     }
 
+    if (v->head.htype != BM_VERT) {
+      printf("bm_log error; vertex id: %p, type was: %d\n", key, v->head.htype);
+      continue;
+    }
+
     /* Ensure the log has the final values of the vertex before
      * deleting it */
     bm_log_vert_bmvert_copy(log, entry, lv, v, cd_vert_mask_offset, true);
@@ -653,6 +658,10 @@ static void bm_log_faces_restore(
         continue;
       }
 
+      if (v->head.htype != BM_VERT) {
+        printf("bm_log corruption!\n");
+        continue;
+      }
       BLI_array_append(vs_tmp, v);
     }



More information about the Bf-blender-cvs mailing list