From 5f63344e849ea6435bfd2de5584389cd18b22aa6 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Wed, 20 May 2020 21:11:35 +0200 Subject: 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 --- source/blender/editors/sculpt_paint/sculpt.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to '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; -- cgit v1.2.3