diff options
Diffstat (limited to 'source/blender/blenkernel/intern/pbvh.c')
-rw-r--r-- | source/blender/blenkernel/intern/pbvh.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 19f28047b80..67988427bd2 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -358,7 +358,7 @@ static void update_vb(PBVH *pbvh, PBVHNode *node, BBC *prim_bbc, int offset, int /* Returns the number of visible quads in the nodes' grids. */ int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden, - int *grid_indices, + const int *grid_indices, int totgrid, int gridsize) { @@ -1325,6 +1325,7 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata, CustomData_get_layer(pbvh->pdata, CD_SCULPT_FACE_SETS), pbvh->face_sets_color_seed, pbvh->face_sets_color_default, + CustomData_get_layer(pbvh->vdata, CD_PROP_COLOR), update_flags); break; case PBVH_BMESH: @@ -1442,6 +1443,10 @@ void BKE_pbvh_update_vertex_data(PBVH *pbvh, int flag) pbvh_update_mask_redraw(pbvh, nodes, totnode, flag); } + if (flag & (PBVH_UpdateColor)) { + /* Do nothing */ + } + if (flag & (PBVH_UpdateVisibility)) { pbvh_update_visibility_redraw(pbvh, nodes, totnode, flag); } @@ -1537,7 +1542,7 @@ static void pbvh_update_visibility_task_cb(void *__restrict userdata, PBVHUpdateData *data = userdata; PBVH *pbvh = data->pbvh; PBVHNode *node = data->nodes[n]; - if (node->flag & PBVH_UpdateMask) { + if (node->flag & PBVH_UpdateVisibility) { switch (BKE_pbvh_type(pbvh)) { case PBVH_FACES: pbvh_faces_node_visibility_update(pbvh, node); @@ -1549,7 +1554,7 @@ static void pbvh_update_visibility_task_cb(void *__restrict userdata, pbvh_bmesh_node_visibility_update(node); break; } - node->flag &= ~PBVH_UpdateMask; + node->flag &= ~PBVH_UpdateVisibility; } } @@ -1729,6 +1734,11 @@ void BKE_pbvh_node_mark_update_mask(PBVHNode *node) node->flag |= PBVH_UpdateMask | PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw; } +void BKE_pbvh_node_mark_update_color(PBVHNode *node) +{ + node->flag |= PBVH_UpdateColor | PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw; +} + void BKE_pbvh_node_mark_update_visibility(PBVHNode *node) { node->flag |= PBVH_UpdateVisibility | PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers | @@ -1762,6 +1772,11 @@ void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden) } } +bool BKE_pbvh_node_fully_hidden_get(PBVHNode *node) +{ + return (node->flag & PBVH_Leaf) && (node->flag & PBVH_FullyHidden); +} + void BKE_pbvh_node_fully_masked_set(PBVHNode *node, int fully_masked) { BLI_assert(node->flag & PBVH_Leaf); @@ -2905,6 +2920,26 @@ void BKE_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***r_array, int *r_tot) *r_tot = tot; } +PBVHColorBufferNode *BKE_pbvh_node_color_buffer_get(PBVHNode *node) +{ + + if (!node->color_buffer.color) { + node->color_buffer.color = MEM_callocN(node->uniq_verts * sizeof(float) * 4, "Color buffer"); + } + return &node->color_buffer; +} + +void BKE_pbvh_node_color_buffer_free(PBVH *pbvh) +{ + PBVHNode **nodes; + int totnode; + BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); + for (int i = 0; i < totnode; i++) { + MEM_SAFE_FREE(nodes[i]->color_buffer.color); + } + MEM_SAFE_FREE(nodes); +} + void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int mode) { struct CCGElem **grids; @@ -2958,6 +2993,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m vi->mask = NULL; if (pbvh->type == PBVH_FACES) { vi->vmask = CustomData_get_layer(pbvh->vdata, CD_PAINT_MASK); + vi->vcol = CustomData_get_layer(pbvh->vdata, CD_PROP_COLOR); } } |