diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2020-04-20 03:19:42 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2020-04-20 03:19:42 +0300 |
commit | 9776b8a05e7c318a338e5ae859404610bc717947 (patch) | |
tree | 093d902a85ff3e9f5005b16166adc96c840a63b4 /source/blender | |
parent | 251234ad4360632d4fd0f0570ce498fa183cc98f (diff) | |
parent | 28f667c7c46a1855146bba9e555b20c9993d7316 (diff) |
Merge branch 'blender-v2.83-release'
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_paint.h | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pbvh.c | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_filter_mesh.c | 18 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_smooth.c | 5 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_buffers.c | 4 |
6 files changed, 38 insertions, 8 deletions
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index f78a142704b..7822f285c3b 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -294,10 +294,15 @@ typedef struct SculptSession { struct MultiresModifierData *modifier; int level; } multires; + + /* These are always assigned to base mesh data when using PBVH_FACES and PBVH_GRIDS. */ struct MVert *mvert; struct MPoly *mpoly; struct MLoop *mloop; + + /* These contain the vertex and poly counts of the final mesh. */ int totvert, totpoly; + struct KeyBlock *shapekey_active; float *vmask; @@ -306,6 +311,7 @@ typedef struct SculptSession { int *pmap_mem; /* Mesh Face Sets */ + /* Total number of polys of the base mesh. */ int totfaces; int *face_sets; diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 420538061bb..4bbbae7081d 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -1514,9 +1514,12 @@ static void sculpt_update_object( ss->totvert = me_eval->totvert; ss->totpoly = me_eval->totpoly; ss->totfaces = me->totpoly; - ss->mvert = NULL; - ss->mpoly = NULL; - ss->mloop = NULL; + + /* These are assigned to the base mesh in Multires. This is needed because Face Sets operators + * and tools use the Face Sets data from the base mesh when Multires is active. */ + ss->mvert = me->mvert; + ss->mpoly = me->mpoly; + ss->mloop = me->mloop; } else { ss->totvert = me->totvert; @@ -1851,7 +1854,7 @@ static PBVH *build_pbvh_from_ccg(Object *ob, SubdivCCG *subdiv_ccg) subdiv_ccg->grid_flag_mats, subdiv_ccg->grid_hidden); pbvh_show_mask_set(pbvh, ob->sculpt->show_mask); - pbvh_show_face_sets_set(pbvh, false); + pbvh_show_face_sets_set(pbvh, ob->sculpt->show_face_sets); return pbvh; } diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 977e70745a3..33aa20fa1e4 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -2958,7 +2958,7 @@ bool pbvh_has_face_sets(PBVH *bvh) { switch (bvh->type) { case PBVH_GRIDS: - return false; + return (bvh->pdata && CustomData_get_layer(bvh->pdata, CD_SCULPT_FACE_SETS)); case PBVH_FACES: return (bvh->pdata && CustomData_get_layer(bvh->pdata, CD_SCULPT_FACE_SETS)); case PBVH_BMESH: diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c index 4f22ad6a9b0..94b6e0eb864 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c @@ -223,7 +223,16 @@ static void mesh_filter_task_cb(void *__restrict userdata, if (ss->filter_cache->active_face_set != SCULPT_FACE_SET_NONE) { if (!SCULPT_vertex_has_face_set(ss, vd.index, ss->filter_cache->active_face_set)) { - continue; + /* Surface Smooth can't skip the loop for this vertex as it needs to calculate its + * laplacian_disp. This value is accessed from the vertex neighbors when deforming the + * vertices, so it is needed for all vertices even if they are not going to be displaced. + */ + if (filter_type == MESH_FILTER_SURFACE_SMOOTH) { + fade = 0.0f; + } + else { + continue; + } } /* Skip the edges of the face set when relaxing or smoothing. * There is a relax face set option to relax the boundaries independently. */ @@ -429,6 +438,13 @@ static void mesh_filter_surface_smooth_displace_task_cb( if (fade == 0.0f) { continue; } + + if (ss->filter_cache->active_face_set != SCULPT_FACE_SET_NONE) { + if (!SCULPT_vertex_has_face_set(ss, vd.index, ss->filter_cache->active_face_set)) { + continue; + } + } + SCULPT_surface_smooth_displace_step(ss, vd.co, ss->filter_cache->surface_smooth_laplacian_disp, diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.c b/source/blender/editors/sculpt_paint/sculpt_smooth.c index de3211abe08..3a09d52d418 100644 --- a/source/blender/editors/sculpt_paint/sculpt_smooth.c +++ b/source/blender/editors/sculpt_paint/sculpt_smooth.c @@ -315,7 +315,7 @@ static void do_smooth_brush_bmesh_task_cb_ex(void *__restrict userdata, vd.index, tls->thread_id); if (smooth_mask) { - float val = SCULPT_neighbor_mask_average(ss, vd.vert_indices[vd.i]) - *vd.mask; + float val = SCULPT_neighbor_mask_average(ss, vd.index) - *vd.mask; val *= fade * bstrength; *vd.mask += val; CLAMP(*vd.mask, 0.0f, 1.0f); @@ -533,6 +533,9 @@ static void SCULPT_do_surface_smooth_brush_laplacian_task_cb_ex( orig_data.co, alpha); madd_v3_v3fl(vd.co, disp, clamp_f(fade, 0.0f, 1.0f)); + if (vd.mvert) { + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } } BKE_pbvh_vertex_iter_end; } diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 8496bcac693..8b562413ce8 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -691,6 +691,8 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers, { const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0; const bool show_vcol = (update_flags & GPU_PBVH_BUFFERS_SHOW_VCOL) != 0; + const bool show_face_sets = sculpt_face_sets && + (update_flags & GPU_PBVH_BUFFERS_SHOW_SCULPT_FACE_SETS) != 0; bool empty_mask = true; bool default_face_set = true; @@ -738,7 +740,7 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers, uchar face_set_color[4] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, UCHAR_MAX}; - if (subdiv_ccg && sculpt_face_sets) { + if (show_face_sets && subdiv_ccg && sculpt_face_sets) { const int face_index = BKE_subdiv_cgg_grid_to_face_index(subdiv_ccg, grid_index); const int fset = abs(sculpt_face_sets[face_index]); |