[Bf-blender-cvs] [3d47323162c] temp_bmesh_multires: Fixed bug with original coordinates/normals not being set when dyntopo pbvh is first built

Joseph Eagar noreply at git.blender.org
Tue Oct 27 09:39:24 CET 2020


Commit: 3d47323162c783898d2b60bc558e3db7e44436e0
Author: Joseph Eagar
Date:   Tue Oct 27 01:38:59 2020 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rB3d47323162c783898d2b60bc558e3db7e44436e0

Fixed bug with original coordinates/normals not being set when
dyntopo pbvh is first built

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

M	source/blender/blenkernel/intern/pbvh_bmesh.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 947b7fa6615..8f47f080e9b 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -2320,6 +2320,28 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
   /* TODO: choose leaf limit better */
   pbvh->leaf_limit = 3000;
 
+  BMIter iter;
+  BMVert *v;
+
+  int cd_vcol_offset = -1;
+  if (cd_origvcol_offset >= 0) {
+    cd_vcol_offset = CustomData_get_offset(&bm->vdata, CD_PROP_COLOR);
+  }
+
+  BM_ITER_MESH(v, &iter, bm, BM_VERTS_OF_MESH) {
+    float *co = BM_ELEM_CD_GET_VOID_P(v, cd_origco_offset);
+    float *no = BM_ELEM_CD_GET_VOID_P(v, cd_origno_offset);
+
+    copy_v3_v3(co, v->co);
+    copy_v3_v3(no, v->no);
+
+    if (cd_origvcol_offset >= 0) {
+      MPropCol *c1 = BM_ELEM_CD_GET_VOID_P(v, cd_vcol_offset);
+      MPropCol *c2 = BM_ELEM_CD_GET_VOID_P(v, cd_origvcol_offset);
+
+      copy_v4_v4(c2->color, c1->color);
+    }
+  }
   if (smooth_shading) {
     pbvh->flags |= PBVH_DYNTOPO_SMOOTH_SHADING;
   }
@@ -2329,7 +2351,6 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
   BMFace **nodeinfo = MEM_mallocN(sizeof(*nodeinfo) * bm->totface, "nodeinfo");
   MemArena *arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "fast PBVH node storage");
 
-  BMIter iter;
   BMFace *f;
   int i;
   BM_ITER_MESH_INDEX (f, &iter, bm, BM_FACES_OF_MESH, i) {
@@ -2351,7 +2372,6 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
   /* Likely this is already dirty. */
   bm->elem_index_dirty |= BM_FACE;
 
-  BMVert *v;
   BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
     BM_ELEM_CD_SET_INT(v, cd_vert_node_offset, DYNTOPO_NODE_NONE);
   }
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 06fc4bb6507..46c23795585 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4057,6 +4057,9 @@ static void do_elastic_deform_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in
   };
 
   TaskParallelSettings settings;
+
+  SCULPT_vertex_random_access_ensure(ss);
+
   BKE_pbvh_parallel_range_settings(&settings, true, totnode);
   BLI_task_parallel_range(0, totnode, &data, do_elastic_deform_brush_task_cb_ex, &settings);
 }



More information about the Bf-blender-cvs mailing list