Fix T76776: Implement vertex_visibility_get for PBVH_GRIDS

This was missing from when Face Sets were enabled in Multires, so it was
always considering that all vertices in the grids are visible. This
should also fix other unreported bugs.

Reviewed By: sergey

Maniphest Tasks: T76776

Differential Revision: https://developer.blender.org/D7809
This commit is contained in:
Pablo Dobarro 2020-05-30 22:56:04 +02:00
parent 071cc71fb0
commit 85098bdb89
Notes: blender-bot 2023-02-14 08:42:53 +01:00
Referenced by issue #77262, Face Sets From visible doesn't work with multires
Referenced by issue #76776, Face Set From Visible not working correctly with Multires
3 changed files with 16 additions and 2 deletions

View File

@ -229,6 +229,7 @@ void BKE_pbvh_sync_face_sets_to_grids(PBVH *pbvh);
const struct CCGKey *BKE_pbvh_get_grid_key(const PBVH *pbvh);
struct CCGElem **BKE_pbvh_get_grids(const PBVH *pbvh);
BLI_bitmap **BKE_pbvh_get_grid_visibility(const PBVH *pbvh);
int BKE_pbvh_get_grid_num_vertices(const PBVH *pbvh);
/* Only valid for type == PBVH_BMESH */

View File

@ -1698,6 +1698,12 @@ struct CCGElem **BKE_pbvh_get_grids(const PBVH *pbvh)
return pbvh->grids;
}
BLI_bitmap **BKE_pbvh_get_grid_visibility(const PBVH *pbvh)
{
BLI_assert(pbvh->type == PBVH_GRIDS);
return pbvh->grid_hidden;
}
int BKE_pbvh_get_grid_num_vertices(const PBVH *pbvh)
{
BLI_assert(pbvh->type == PBVH_GRIDS);

View File

@ -261,8 +261,15 @@ bool SCULPT_vertex_visible_get(SculptSession *ss, int index)
return !(ss->mvert[index].flag & ME_HIDE);
case PBVH_BMESH:
return !BM_elem_flag_test(BM_vert_at_index(ss->bm, index), BM_ELEM_HIDDEN);
case PBVH_GRIDS:
return true;
case PBVH_GRIDS: {
const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh);
const int grid_index = index / key->grid_area;
const int vertex_index = index - grid_index * key->grid_area;
BLI_bitmap **grid_hidden = BKE_pbvh_get_grid_visibility(ss->pbvh);
if (grid_hidden && grid_hidden[grid_index]) {
return !BLI_BITMAP_TEST(grid_hidden[grid_index], vertex_index);
}
}
}
return true;
}