[Bf-blender-cvs] [9ce1135440f] blender-v3.1-release: Cleanup: remove duplicate vertex normal array in SculptSession

Campbell Barton noreply at git.blender.org
Tue Feb 1 05:36:28 CET 2022


Commit: 9ce1135440f2fa69c14d393971fcf6c671f35cc3
Author: Campbell Barton
Date:   Tue Feb 1 13:35:55 2022 +1100
Branches: blender-v3.1-release
https://developer.blender.org/rB9ce1135440f2fa69c14d393971fcf6c671f35cc3

Cleanup: remove duplicate vertex normal array in SculptSession

>From investigating T95185, it's important the normal returned by
SCULPT_vertex_normal_get always match the PBVH normal array.

Since this is always initialized in the PBVH, there is no advantage
in storing the normal array in two places, it only adds the possibility
that changes in the future causing different meshes normals to be used.

Split out from D13975.

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

M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/intern/paint.c
M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 4019c4d62c4..8291be9d7e8 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -499,7 +499,6 @@ typedef struct SculptSession {
 
   /* These are always assigned to base mesh data when using PBVH_FACES and PBVH_GRIDS. */
   struct MVert *mvert;
-  const float (*vert_normals)[3];
   struct MPoly *mpoly;
   struct MLoop *mloop;
 
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 407375c4d22..72210eea71d 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1648,7 +1648,6 @@ static void sculpt_update_object(Depsgraph *depsgraph,
     ss->totvert = me->totvert;
     ss->totpoly = me->totpoly;
     ss->totfaces = me->totpoly;
-    ss->vert_normals = BKE_mesh_vertex_normals_ensure(me);
     ss->mvert = me->mvert;
     ss->mpoly = me->mpoly;
     ss->mloop = me->mloop;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 2725fc1eae4..07e26a3d931 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -178,13 +178,8 @@ void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3])
 {
   switch (BKE_pbvh_type(ss->pbvh)) {
     case PBVH_FACES: {
-      if (ss->shapekey_active || ss->deform_modifiers_active) {
-        const float(*vert_normals)[3] = BKE_pbvh_get_vert_normals(ss->pbvh);
-        copy_v3_v3(no, vert_normals[index]);
-      }
-      else {
-        copy_v3_v3(no, ss->vert_normals[index]);
-      }
+      const float(*vert_normals)[3] = BKE_pbvh_get_vert_normals(ss->pbvh);
+      copy_v3_v3(no, vert_normals[index]);
       break;
     }
     case PBVH_BMESH:



More information about the Bf-blender-cvs mailing list