[Bf-blender-cvs] [5f63344e849] blender-v2.83-release: Fix PBVH API returning wrong normal when using shape keys and modifiers

Pablo Dobarro noreply at git.blender.org
Tue May 26 20:41:03 CEST 2020


Commit: 5f63344e849ea6435bfd2de5584389cd18b22aa6
Author: Pablo Dobarro
Date:   Wed May 20 21:11:35 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB5f63344e849ea6435bfd2de5584389cd18b22aa6

Fix PBVH API returning wrong normal when using shape keys and modifiers

The implementation of this function should match the one in
SCULPT_vertex_co_get. This does not solve the issue when sculpting with
modifiers active but I think this code is wrong

Reviewed By: sergey, brecht

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

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

M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index d2dda1be1e7..8443608cfa5 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -156,9 +156,16 @@ const float *SCULPT_vertex_co_get(SculptSession *ss, int index)
 void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3])
 {
   switch (BKE_pbvh_type(ss->pbvh)) {
-    case PBVH_FACES:
-      normal_short_to_float_v3(no, ss->mvert[index].no);
-      return;
+    case PBVH_FACES: {
+      if (ss->shapekey_active || ss->deform_modifiers_active) {
+        const MVert *mverts = BKE_pbvh_get_verts(ss->pbvh);
+        normal_short_to_float_v3(no, mverts[index].no);
+      }
+      else {
+        normal_short_to_float_v3(no, ss->mvert[index].no);
+      }
+      break;
+    }
     case PBVH_BMESH:
       copy_v3_v3(no, BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index)->no);
       break;



More information about the Bf-blender-cvs mailing list