diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-31 13:51:12 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-31 18:17:03 +0300 |
commit | f87bba0368ea3d0b71559cfae662ae9e3b39ad6f (patch) | |
tree | a51b9512487f41593e905f91123bba1d0147e35e /source/blender/blenkernel/intern/paint.c | |
parent | 151f69a5c214691de0665affcd8a49cecd6dd0aa (diff) |
Fix T62282: multires sculpting does not update smooth normals
It may be good to move the normals update out of the drawing code. But it was
already there for the non-multires sculpt cases, and does not have an obvious
place since we bypass the depsgraph and want to avoid the cost of updating the
normals multiple times when multiple events are handled before a redraw.
Diffstat (limited to 'source/blender/blenkernel/intern/paint.c')
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 441ae311404..f1f49070f1d 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -987,6 +987,21 @@ void BKE_sculptsession_bm_to_me(Object *ob, bool reorder) } } +static void sculptsession_free_pbvh(Object *object) +{ + SculptSession *ss = object->sculpt; + + if (ss && ss->pbvh) { + /* Ensure all normals are updated before freeing the PBVH, because + * we skip updating them for performance when we don't draw the PBVH. */ + Mesh *mesh = object->data; + BKE_pbvh_update_normals(ss->pbvh, mesh->runtime.subdiv_ccg); + + BKE_pbvh_free(ss->pbvh); + ss->pbvh = NULL; + } +} + void BKE_sculptsession_bm_to_me_for_render(Object *object) { if (object && object->sculpt) { @@ -999,11 +1014,6 @@ void BKE_sculptsession_bm_to_me_for_render(Object *object) */ BKE_object_free_derived_caches(object); - if (object->sculpt->pbvh) { - BKE_pbvh_free(object->sculpt->pbvh); - object->sculpt->pbvh = NULL; - } - sculptsession_bm_to_me_update_data_only(object, false); /* In contrast with sculptsession_bm_to_me no need in @@ -1024,9 +1034,8 @@ void BKE_sculptsession_free(Object *ob) BM_mesh_free(ss->bm); } - if (ss->pbvh) { - BKE_pbvh_free(ss->pbvh); - } + sculptsession_free_pbvh(ob); + MEM_SAFE_FREE(ss->pmap); MEM_SAFE_FREE(ss->pmap_mem); if (ss->bm_log) { @@ -1269,10 +1278,7 @@ void BKE_sculpt_update_object_before_eval(Object *ob) /* We free pbvh on changes, except in the middle of drawing a stroke * since it can't deal with changing PVBH node organization, we hope * topology does not change in the meantime .. weak. */ - if (ss->pbvh) { - BKE_pbvh_free(ss->pbvh); - ss->pbvh = NULL; - } + sculptsession_free_pbvh(ob); BKE_sculptsession_free_deformMats(ob->sculpt); |