[Bf-blender-cvs] [793135e190c] master: Fix wrong coordinates being read when using the sculpt API

Pablo Dobarro noreply at git.blender.org
Fri Feb 28 16:48:32 CET 2020


Commit: 793135e190c7450d30451617e9b8ae2d5ecec94a
Author: Pablo Dobarro
Date:   Fri Feb 28 15:58:04 2020 +0100
Branches: master
https://developer.blender.org/rB793135e190c7450d30451617e9b8ae2d5ecec94a

Fix wrong coordinates being read when using the sculpt API

The coordinates should be read from the PBVH when using deform modifiers.
This is needed for the cloth brush to work with subdivisions, as it reads the
vertex coordinates using this function when building and updating the
constraints.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D6967

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

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 a26148d11bf..3971b248a2e 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -470,6 +470,8 @@ void BKE_pbvh_parallel_range(const int start,
                              PBVHParallelRangeFunc func,
                              const struct PBVHParallelSettings *settings);
 
+struct MVert *BKE_pbvh_get_verts(const PBVH *bvh);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index efe13fc8817..95e7218a920 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -2885,3 +2885,9 @@ void BKE_pbvh_parallel_range_settings(PBVHParallelSettings *settings,
   memset(settings, 0, sizeof(*settings));
   settings->use_threading = use_threading && totnode > 1;
 }
+
+MVert *BKE_pbvh_get_verts(const PBVH *bvh)
+{
+  BLI_assert(bvh->type == PBVH_FACES);
+  return bvh->verts;
+}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 7c51ddd597a..55ddc82c3f8 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -129,8 +129,15 @@ static int sculpt_vertex_count_get(SculptSession *ss)
 const float *sculpt_vertex_co_get(SculptSession *ss, int index)
 {
   switch (BKE_pbvh_type(ss->pbvh)) {
-    case PBVH_FACES:
-      return ss->mvert[index].co;
+    case PBVH_FACES: {
+      if (ss->shapekey_active || ss->deform_modifiers_active) {
+        const MVert *mverts = BKE_pbvh_get_verts(ss->pbvh);
+        return mverts[index].co;
+      }
+      else {
+        return ss->mvert[index].co;
+      }
+    }
     case PBVH_BMESH:
       return BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index)->co;
     case PBVH_GRIDS: {



More information about the Bf-blender-cvs mailing list