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.
This commit is contained in:
Campbell Barton 2022-02-01 13:35:55 +11:00
parent 2e4a1a70da
commit 9ce1135440
Notes: blender-bot 2023-05-29 09:17:12 +02:00
Referenced by issue #95843, Undo after remeshing or dyntopo creates a flat shading on normals
3 changed files with 2 additions and 9 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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: