diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2020-04-01 02:03:20 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2020-04-01 02:07:47 +0300 |
commit | da3cb514e52de922148534c660a0b04ee5c43eeb (patch) | |
tree | 82d81dd0be84454a05984fdda9caa79c3b1c2262 /source/blender/blenkernel/intern/pbvh.c | |
parent | 0062813c731ff2a0866d86a2b0558c67b8091f37 (diff) |
Multires: Initial Face Sets support
This implements the Sculpt Mode API functions needed for Face Sets and
visibility management for PBVH_GRIDS. No major changes were needed in
the operators and the sculpt mode code. This implementation stores the
face sets in the base mesh, so faces created in higher subdivision
levels can't be modified individually. Also, we are not checking for
multiple face sets per vertex (that can be added in the future), so
relax tools don't work yet. The rest of the features (paint, undo,
visibility operators..) work as expected.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D7168
Diffstat (limited to 'source/blender/blenkernel/intern/pbvh.c')
-rw-r--r-- | source/blender/blenkernel/intern/pbvh.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 9a4ce8acb11..ac0c9d030cf 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -383,6 +383,25 @@ int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden, return totquad; } +void BKE_pbvh_sync_face_sets_to_grids(PBVH *bvh) +{ + const int gridsize = bvh->gridkey.grid_size; + for (int i = 0; i < bvh->totgrid; i++) { + BLI_bitmap *gh = bvh->grid_hidden[i]; + const int face_index = BKE_subdiv_cgg_grid_to_face_index(bvh->subdiv_ccg, i); + if (!gh && bvh->face_sets[face_index] < 0) { + gh = bvh->grid_hidden[i] = BLI_BITMAP_NEW(bvh->gridkey.grid_area, "partialvis_update_grids"); + } + if (gh) { + for (int y = 0; y < gridsize; y++) { + for (int x = 0; x < gridsize; x++) { + BLI_BITMAP_SET(gh, y * gridsize + x, bvh->face_sets[face_index] < 0); + } + } + } + } +} + static void build_grid_leaf_node(PBVH *bvh, PBVHNode *node) { int totquads = BKE_pbvh_count_grid_quads( @@ -1289,10 +1308,14 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata, switch (bvh->type) { case PBVH_GRIDS: GPU_pbvh_grid_buffers_update(node->draw_buffers, + bvh->subdiv_ccg, bvh->grids, bvh->grid_flag_mats, node->prim_indices, node->totprim, + bvh->face_sets, + bvh->face_sets_color_seed, + bvh->face_sets_color_default, &bvh->gridkey, update_flags); break; @@ -2974,3 +2997,13 @@ MVert *BKE_pbvh_get_verts(const PBVH *bvh) BLI_assert(bvh->type == PBVH_FACES); return bvh->verts; } + +void BKE_pbvh_subdiv_cgg_set(PBVH *bvh, SubdivCCG *subdiv_ccg) +{ + bvh->subdiv_ccg = subdiv_ccg; +} + +void BKE_pbvh_face_sets_set(PBVH *bvh, int *face_sets) +{ + bvh->face_sets = face_sets; +} |