Merge branch 'blender-v2.83-release'

This commit is contained in:
Pablo Dobarro
2020-04-20 02:19:42 +02:00
8 changed files with 40 additions and 10 deletions

View File

@@ -294,10 +294,15 @@ typedef struct SculptSession {
struct MultiresModifierData *modifier; struct MultiresModifierData *modifier;
int level; int level;
} multires; } multires;
/* These are always assigned to base mesh data when using PBVH_FACES and PBVH_GRIDS. */
struct MVert *mvert; struct MVert *mvert;
struct MPoly *mpoly; struct MPoly *mpoly;
struct MLoop *mloop; struct MLoop *mloop;
/* These contain the vertex and poly counts of the final mesh. */
int totvert, totpoly; int totvert, totpoly;
struct KeyBlock *shapekey_active; struct KeyBlock *shapekey_active;
float *vmask; float *vmask;
@@ -306,6 +311,7 @@ typedef struct SculptSession {
int *pmap_mem; int *pmap_mem;
/* Mesh Face Sets */ /* Mesh Face Sets */
/* Total number of polys of the base mesh. */
int totfaces; int totfaces;
int *face_sets; int *face_sets;

View File

@@ -1514,9 +1514,12 @@ static void sculpt_update_object(
ss->totvert = me_eval->totvert; ss->totvert = me_eval->totvert;
ss->totpoly = me_eval->totpoly; ss->totpoly = me_eval->totpoly;
ss->totfaces = me->totpoly; ss->totfaces = me->totpoly;
ss->mvert = NULL;
ss->mpoly = NULL; /* These are assigned to the base mesh in Multires. This is needed because Face Sets operators
ss->mloop = NULL; * 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 { else {
ss->totvert = me->totvert; 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_flag_mats,
subdiv_ccg->grid_hidden); subdiv_ccg->grid_hidden);
pbvh_show_mask_set(pbvh, ob->sculpt->show_mask); 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; return pbvh;
} }

View File

@@ -2958,7 +2958,7 @@ bool pbvh_has_face_sets(PBVH *bvh)
{ {
switch (bvh->type) { switch (bvh->type) {
case PBVH_GRIDS: case PBVH_GRIDS:
return false; return (bvh->pdata && CustomData_get_layer(bvh->pdata, CD_SCULPT_FACE_SETS));
case PBVH_FACES: case PBVH_FACES:
return (bvh->pdata && CustomData_get_layer(bvh->pdata, CD_SCULPT_FACE_SETS)); return (bvh->pdata && CustomData_get_layer(bvh->pdata, CD_SCULPT_FACE_SETS));
case PBVH_BMESH: case PBVH_BMESH:

View File

@@ -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 (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)) { 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. /* Skip the edges of the face set when relaxing or smoothing.
* There is a relax face set option to relax the boundaries independently. */ * 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) { if (fade == 0.0f) {
continue; 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, SCULPT_surface_smooth_displace_step(ss,
vd.co, vd.co,
ss->filter_cache->surface_smooth_laplacian_disp, ss->filter_cache->surface_smooth_laplacian_disp,

View File

@@ -315,7 +315,7 @@ static void do_smooth_brush_bmesh_task_cb_ex(void *__restrict userdata,
vd.index, vd.index,
tls->thread_id); tls->thread_id);
if (smooth_mask) { 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; val *= fade * bstrength;
*vd.mask += val; *vd.mask += val;
CLAMP(*vd.mask, 0.0f, 1.0f); 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, orig_data.co,
alpha); alpha);
madd_v3_v3fl(vd.co, disp, clamp_f(fade, 0.0f, 1.0f)); 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; BKE_pbvh_vertex_iter_end;
} }

View File

@@ -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_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0;
const bool show_vcol = (update_flags & GPU_PBVH_BUFFERS_SHOW_VCOL) != 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 empty_mask = true;
bool default_face_set = 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}; 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 face_index = BKE_subdiv_cgg_grid_to_face_index(subdiv_ccg, grid_index);
const int fset = abs(sculpt_face_sets[face_index]); const int fset = abs(sculpt_face_sets[face_index]);