[Bf-blender-cvs] [0f0d1f8e2a8] temp_bmesh_multires: Paint brush no long SCULPT_undo_push_node per dab (except for first stroke) for dyntopo. Instead it updates the original vertex color customdata layer.

Joseph Eagar noreply at git.blender.org
Sat Oct 31 03:40:04 CET 2020


Commit: 0f0d1f8e2a82e9b0864b7ba4beb19390e7781c27
Author: Joseph Eagar
Date:   Fri Oct 30 19:37:22 2020 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rB0f0d1f8e2a82e9b0864b7ba4beb19390e7781c27

Paint brush no long SCULPT_undo_push_node per dab (except for first
stroke) for dyntopo.  Instead it updates the original vertex color
customdata layer.

Calling into the undo system destroys threading with dyntopo, as its
undo code is single-threaded.

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

M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/intern/pbvh.c
M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 281444cab95..d8c7d238f49 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -229,6 +229,7 @@ void BKE_pbvh_free(PBVH *pbvh);
 /** update original data, only data whose r_** parameters are passed in will be updated*/
 void BKE_pbvh_bmesh_update_origvert(
     PBVH *pbvh, struct BMVert *v, float **r_co, float **r_no, float **r_color);
+void BKE_pbvh_update_origcolor_bmesh(PBVH *pbvh, PBVHNode *node);
 
 /* Hierarchical Search in the BVH, two methods:
  * - for each hit calling a callback
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 5ce08246275..06ee5250a41 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1424,6 +1424,30 @@ static int pbvh_flush_bb(PBVH *pbvh, PBVHNode *node, int flag)
   return update;
 }
 
+void BKE_pbvh_update_origcolor_bmesh(PBVH *pbvh, PBVHNode *node)
+{
+  PBVHVertexIter vd;
+
+  if (!pbvh->bm || !pbvh->cd_origvcol_offset) {
+    return;
+  }
+
+  int cd_vcol_offset = CustomData_get_offset(&pbvh->bm->vdata, CD_PROP_COLOR);
+
+  if (cd_vcol_offset == -1) {
+    return;
+  }
+
+  BKE_pbvh_vertex_iter_begin(pbvh, node, vd, PBVH_ITER_ALL)
+  {
+    float *c1 = BM_ELEM_CD_GET_VOID_P(vd.bm_vert, pbvh->cd_origvcol_offset);
+    float *c2 = BM_ELEM_CD_GET_VOID_P(vd.bm_vert, cd_vcol_offset);
+
+    copy_v4_v4(c1, c2);
+  }
+  BKE_pbvh_vertex_iter_end;
+}
+
 void BKE_pbvh_update_bounds(PBVH *pbvh, int flag)
 {
   if (!pbvh->nodes) {
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index d4a609c7751..a9324176d15 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5768,7 +5768,15 @@ static void do_brush_action_task_cb(void *__restrict userdata,
     BKE_pbvh_node_mark_update_mask(data->nodes[n]);
   }
   else if (ELEM(data->brush->sculpt_tool, SCULPT_TOOL_PAINT, SCULPT_TOOL_SMEAR)) {
-    SCULPT_undo_push_node(data->ob, data->nodes[n], SCULPT_UNDO_COLOR);
+    //make sure we have at least one undo_color node
+    if (!ss->bm || SCULPT_stroke_is_first_brush_step(ss->cache)) {
+      SCULPT_undo_push_node(data->ob, data->nodes[n], SCULPT_UNDO_COLOR);
+    }
+
+    if (ss->bm) {
+      BKE_pbvh_update_origcolor_bmesh(ss->pbvh, data->nodes[n]);
+    }
+
     BKE_pbvh_node_mark_update_color(data->nodes[n]);
   }
   else {



More information about the Bf-blender-cvs mailing list