From 85098bdb89495896a22bb1739cbe2af1d8343d59 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Sat, 30 May 2020 22:56:04 +0200 Subject: 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 --- source/blender/blenkernel/BKE_pbvh.h | 1 + source/blender/blenkernel/intern/pbvh.c | 6 ++++++ source/blender/editors/sculpt_paint/sculpt.c | 11 +++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 12300c12c80..8fb6f140822 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -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 */ diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 32d9a486a8e..19f28047b80 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -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); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 6e56135ec83..fb82d5d12d6 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -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; } -- cgit v1.2.3