Sculpt: Upload white for color attributes in multires in sculpt

Even if multires in sculpt mode doesn't yet support color
attributes, we should at least upload white color to avoid
making everything black.

Also fixed a bug where multires PBVHs didn't have access to
their CustomData attribute layout, which PBVH draw needs.
This commit is contained in:
Joseph Eagar 2022-09-30 15:19:10 -07:00
parent 1eba76d8ed
commit 5b0485fd77
4 changed files with 27 additions and 3 deletions

View File

@ -265,7 +265,8 @@ void BKE_pbvh_build_grids(PBVH *pbvh,
struct CCGKey *key,
void **gridfaces,
struct DMFlagMat *flagmats,
unsigned int **grid_hidden);
unsigned int **grid_hidden,
struct Mesh *me);
/**
* Build a PBVH from a BMesh.
*/

View File

@ -2240,7 +2240,8 @@ static PBVH *build_pbvh_from_ccg(Object *ob, SubdivCCG *subdiv_ccg, bool respect
&key,
(void **)subdiv_ccg->grid_faces,
subdiv_ccg->grid_flag_mats,
subdiv_ccg->grid_hidden);
subdiv_ccg->grid_hidden,
base_mesh);
pbvh_show_mask_set(pbvh, ob->sculpt->show_mask);
pbvh_show_face_sets_set(pbvh, ob->sculpt->show_face_sets);
return pbvh;

View File

@ -663,7 +663,8 @@ void BKE_pbvh_build_grids(PBVH *pbvh,
CCGKey *key,
void **gridfaces,
DMFlagMat *flagmats,
BLI_bitmap **grid_hidden)
BLI_bitmap **grid_hidden,
Mesh *me)
{
const int gridsize = key->grid_size;
@ -676,6 +677,14 @@ void BKE_pbvh_build_grids(PBVH *pbvh,
pbvh->grid_hidden = grid_hidden;
pbvh->leaf_limit = max_ii(LEAF_LIMIT / (gridsize * gridsize), 1);
/* We need the base mesh attribute layout for PBVH draw. */
pbvh->vdata = &me->vdata;
pbvh->ldata = &me->ldata;
pbvh->pdata = &me->pdata;
/* We also need the base mesh for PBVH draw. */
pbvh->mesh = me;
BB cb;
BB_reset(&cb);

View File

@ -345,6 +345,19 @@ struct PBVHBatches {
GPU_vertbuf_attr_get_raw_data(vbo.vert_buf, 0, &access);
switch (vbo.type) {
case CD_PROP_COLOR:
case CD_PROP_BYTE_COLOR: {
/* TODO: Implement color support for multires similar to the mesh cache
* extractor code. For now just upload white.
*/
const ushort4 white(USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX);
foreach_grids(
[&](int /*x*/, int /*y*/, int /*grid_index*/, CCGElem * /*elems*/[4], int /*i*/) {
*static_cast<ushort4 *>(GPU_vertbuf_raw_step(&access)) = white;
});
break;
}
case CD_PBVH_CO_TYPE:
foreach_grids([&](int /*x*/, int /*y*/, int /*grid_index*/, CCGElem *elems[4], int i) {
float *co = CCG_elem_co(&args->ccg_key, elems[i]);