[Bf-blender-cvs] [b52e04f7945] temp_bmesh_multires: * Fix bug in last commit, broke draw brush

Joseph Eagar noreply at git.blender.org
Mon Apr 12 08:39:49 CEST 2021


Commit: b52e04f79451038d5b7910a36a97d94441aabf23
Author: Joseph Eagar
Date:   Sun Apr 11 23:39:25 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rBb52e04f79451038d5b7910a36a97d94441aabf23

* Fix bug in last commit, broke draw brush

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

M	source/blender/blenkernel/intern/pbvh_bmesh.c
M	source/blender/bmesh/intern/bmesh_log.c
M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 80aeaef40f0..ece9b81d8df 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -60,9 +60,7 @@ Topology rake:
 #include "bmesh.h"
 #include "pbvh_intern.h"
 
-//#define DYNTOPO_TIME_LIMIT 0.015
-#define DYNTOPO_RUN_INTERVAL 0.02
-#define DYNTOPO_MAX_ITER 1024
+#define DYNTOPO_MAX_ITER 8192
 
 #define DYNTOPO_USE_HEAP
 
@@ -638,7 +636,8 @@ static BMFace *pbvh_bmesh_face_create(PBVH *pbvh,
                                       BMVert *v_tri[3],
                                       BMEdge *e_tri[3],
                                       const BMFace *f_example,
-                                      bool ensure_verts)
+                                      bool ensure_verts,
+                                      bool log_face)
 {
   PBVHNode *node = &pbvh->nodes[node_index];
 
@@ -664,7 +663,10 @@ static BMFace *pbvh_bmesh_face_create(PBVH *pbvh,
   node->flag &= ~PBVH_FullyHidden;
 
   /* Log the new face */
-  BM_log_face_added(pbvh->bm_log, f);
+  if (log_face) {
+    BM_log_face_added(pbvh->bm_log, f);
+  }
+
   int cd_vert_node = pbvh->cd_vert_node_offset;
 
   if (ensure_verts) {
@@ -673,10 +675,13 @@ static BMFace *pbvh_bmesh_face_create(PBVH *pbvh,
       if (BM_ELEM_CD_GET_INT(l->v, cd_vert_node) == DYNTOPO_NODE_NONE) {
         BLI_table_gset_add(node->bm_unique_verts, l->v);
         BM_ELEM_CD_SET_INT(l->v, cd_vert_node, node_index);
-      } else {
+
+        node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateBB;
+      }
+      else {
         BLI_table_gset_add(node->bm_other_verts, l->v);
       }
-       
+
       l = l->next;
     } while (l != f->l_first);
   }
@@ -2064,7 +2069,7 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx,
     v_tri[1] = v_new;
     v_tri[2] = v_opp;
     bm_edges_from_tri(pbvh->bm, v_tri, e_tri);
-    f_new = pbvh_bmesh_face_create(pbvh, ni, v_tri, e_tri, f_adj, false);
+    f_new = pbvh_bmesh_face_create(pbvh, ni, v_tri, e_tri, f_adj, false, true);
     long_edge_queue_face_add(eq_ctx, f_new);
 
     pbvh_bmesh_copy_facedata(bm, f_new, f_adj);
@@ -2106,7 +2111,7 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx,
     e_tri[2] = e_tri[1]; /* switched */
     e_tri[1] = BM_edge_create(pbvh->bm, v_tri[1], v_tri[2], NULL, BM_CREATE_NO_DOUBLE);
 
-    f_new = pbvh_bmesh_face_create(pbvh, ni, v_tri, e_tri, f_adj, false);
+    f_new = pbvh_bmesh_face_create(pbvh, ni, v_tri, e_tri, f_adj, false, true);
     long_edge_queue_face_add(eq_ctx, f_new);
 
     pbvh_bmesh_copy_facedata(bm, f_new, f_adj);
@@ -2419,7 +2424,7 @@ static void pbvh_bmesh_collapse_edge(PBVH *pbvh,
       PBVHNode *n = pbvh_bmesh_node_from_face(pbvh, f);
       int ni = n - pbvh->nodes;
       bm_edges_from_tri(pbvh->bm, v_tri, e_tri);
-      BMFace *f2 = pbvh_bmesh_face_create(pbvh, ni, v_tri, e_tri, f, false);
+      BMFace *f2 = pbvh_bmesh_face_create(pbvh, ni, v_tri, e_tri, f, false, true);
 
       BMLoop *l2 = f2->l_first;
 
@@ -3404,7 +3409,7 @@ static bool cleanup_valence_3_4(PBVH *pbvh,
 
       BMFace *f1 = NULL;
       if (vs[0] != vs[1] && vs[1] != vs[2] && vs[0] != vs[2]) {
-        f1 = pbvh_bmesh_face_create(pbvh, n, vs, NULL, l->f, true);
+        f1 = pbvh_bmesh_face_create(pbvh, n, vs, NULL, l->f, true, false);
       }
 
       if (val == 4 && vs[0] != vs[2] && vs[2] != vs[3] && vs[0] != vs[3]) {
@@ -3412,19 +3417,23 @@ static bool cleanup_valence_3_4(PBVH *pbvh,
         vs[1] = ls[2]->v;
         vs[2] = ls[3]->v;
 
-        BMFace *f2 = pbvh_bmesh_face_create(pbvh, n, vs, NULL, v->e->l->f, true);
+        BMFace *f2 = pbvh_bmesh_face_create(pbvh, n, vs, NULL, v->e->l->f, true, false);
         SWAP(void *, f2->l_first->prev->head.data, ls[3]->head.data);
 
         CustomData_bmesh_copy_data(
             &pbvh->bm->ldata, &pbvh->bm->ldata, ls[0]->head.data, &f2->l_first->head.data);
         CustomData_bmesh_copy_data(
             &pbvh->bm->ldata, &pbvh->bm->ldata, ls[2]->head.data, &f2->l_first->next->head.data);
+
+        BM_log_face_added(pbvh->bm_log, f2);
       }
 
       if (f1) {
         SWAP(void *, f1->l_first->head.data, ls[0]->head.data);
         SWAP(void *, f1->l_first->next->head.data, ls[1]->head.data);
         SWAP(void *, f1->l_first->prev->head.data, ls[2]->head.data);
+
+        BM_log_face_added(pbvh->bm_log, f1);
       }
 
       BM_vert_kill(pbvh->bm, v);
@@ -3554,7 +3563,11 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
         /* Recursively split nodes that have gotten too many
          * elements */
         if (updatePBVH) {
-          pbvh_bmesh_node_limit_ensure(pbvh, i);
+          if (!pbvh_bmesh_node_limit_ensure(pbvh, i)) {
+            BKE_pbvh_bmesh_node_save_ortri(pbvh->bm, pbvh->nodes + i);
+          }
+        } else {
+          BKE_pbvh_bmesh_node_save_ortri(pbvh->bm, pbvh->nodes + i);
         }
       }
     }
@@ -4030,7 +4043,9 @@ void BKE_pbvh_bmesh_after_stroke(PBVH *pbvh)
 
       /* Recursively split nodes that have gotten too many
        * elements */
-      pbvh_bmesh_node_limit_ensure(pbvh, i);
+      if (!pbvh_bmesh_node_limit_ensure(pbvh, i)) {
+        BKE_pbvh_bmesh_node_save_ortri(pbvh->bm, n);
+      }
     }
   }
 
diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c
index faf29b8af00..cb104e94a8d 100644
--- a/source/blender/bmesh/intern/bmesh_log.c
+++ b/source/blender/bmesh/intern/bmesh_log.c
@@ -539,7 +539,7 @@ static void bm_log_vert_values_swap(BMesh *bm, BMLog *log, GHash *verts, BMLogEn
   }
 }
 
-static void bm_log_face_values_swap(BMLog *log, GHash *faces, BMLogEntry *entry)
+__attribute__ ((optnone)) static void bm_log_face_values_swap(BMLog *log, GHash *faces, BMLogEntry *entry)
 {
   GHashIterator gh_iter;
   GHASH_ITER (gh_iter, faces) {
@@ -1053,7 +1053,7 @@ void BM_log_entry_drop(BMLogEntry *entry)
 /* Undo one BMLogEntry
  *
  * Has no effect if there's nothing left to undo */
-static void bm_log_undo_intern(BMesh *bm, BMLog *log, BMLogEntry *entry)
+__attribute__((optnone)) static void bm_log_undo_intern(BMesh *bm, BMLog *log, BMLogEntry *entry)
 {
   bm->elem_index_dirty |= BM_VERT | BM_EDGE | BM_FACE;
   bm->elem_table_dirty |= BM_VERT | BM_EDGE | BM_FACE;
@@ -1206,8 +1206,7 @@ void BM_log_vert_added(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
 
 /* Log a face before it is modified
  *
- * This is intended to handle only header flags and we always
- * assume face has been added before
+ * We always assume face has been added before
  */
 void BM_log_face_modified(BMLog *log, BMFace *f)
 {
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 590fa3633d0..f0b9685303c 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2341,7 +2341,8 @@ typedef struct AreaNormalCenterTLSData {
   int count_co[2];
 } AreaNormalCenterTLSData;
 
-static void calc_area_normal_and_center_task_cb(void *__restrict userdata,
+__attribute__((optnone)) static void calc_area_normal_and_center_task_cb(
+    void *__restrict userdata,
                                                 const int n,
                                                 const TaskParallelTLS *__restrict tls)
 {
@@ -2607,7 +2608,7 @@ void SCULPT_calc_area_normal(
 }
 
 /* Expose 'calc_area_normal' externally. */
-bool SCULPT_pbvh_calc_area_normal(const Brush *brush,
+__attribute__((optnone)) bool SCULPT_pbvh_calc_area_normal(const Brush *brush,
                                   Object *ob,
                                   PBVHNode **nodes,
                                   int totnode,
@@ -3120,7 +3121,7 @@ static PBVHNode **sculpt_pbvh_gather_generic(Object *ob,
 }
 
 /* Calculate primary direction of movement for many brushes. */
-static void calc_sculpt_normal(
+__attribute__ ((optnone)) static void calc_sculpt_normal(
     Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float r_area_no[3])
 {
   const Brush *brush = BKE_paint_brush(&sd->paint);
@@ -3686,7 +3687,7 @@ static void do_displacement_smear_brush(Sculpt *sd, Object *ob, PBVHNode **nodes
 
 /** \} */
 
-static void do_draw_brush_task_cb_ex(void *__restrict userdata,
+__attribute__ ((optnone)) static void do_draw_brush_task_cb_ex(void *__restrict userdata,
                                      const int n,
                                      const TaskParallelTLS *__restrict tls)
 {



More information about the Bf-blender-cvs mailing list