diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-08-24 17:46:42 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-08-24 17:46:59 +0300 |
commit | 0ba3a1a6863a4b5960933df7d5a12d158da5d0d0 (patch) | |
tree | 63658c12166b668d2de3d58882ea0dd8e07c4e96 /source/blender/blenkernel/intern | |
parent | c899f21800533f0d188c505e3909a3e1f2a0c7f2 (diff) |
Sculpt: Optimize Mask Overlay drawing
* Remove support for diffuse color in the pbvh buffers.
* Upload raw data to GPU.
* Only draw nodes that have mask data when drawing the overlay.
This should fix T56466
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/pbvh.c | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 3e7a9b7ce24..00d6fa96856 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -1107,7 +1107,6 @@ void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag) static int pbvh_get_buffers_update_flags(PBVH *bvh) { int update_flags = 0; - update_flags |= bvh->show_diffuse_color ? GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR : 0; update_flags |= bvh->show_mask ? GPU_PBVH_BUFFERS_SHOW_MASK : 0; return update_flags; } @@ -2053,33 +2052,11 @@ bool BKE_pbvh_node_planes_exclude_AABB(PBVHNode *node, void *data) return test_planes_aabb(bb_min, bb_max, data) != ISECT_INSIDE; } -static void pbvh_node_check_diffuse_changed(PBVH *bvh, PBVHNode *node) -{ - if (!node->draw_buffers) - return; - - if (GPU_pbvh_buffers_diffuse_changed(node->draw_buffers, node->bm_faces, bvh->show_diffuse_color)) - node->flag |= PBVH_UpdateDrawBuffers; -} - -/* TODO: not needed anymore in 2.8? */ -#if 0 -static void pbvh_node_check_mask_changed(PBVH *bvh, PBVHNode *node) -{ - if (!node->draw_buffers) { - return; - } - if (GPU_pbvh_buffers_mask_changed(node->draw_buffers, bvh->show_mask)) { - node->flag |= PBVH_UpdateDrawBuffers; - } -} -#endif - struct PBVHNodeDrawCallbackData { - void (*draw_fn)(void *user_data, GPUBatch *batch); void *user_data; bool fast; + bool only_mask; /* Only draw nodes that have mask data. */ }; static void pbvh_node_draw_cb(PBVHNode *node, void *data_v) @@ -2088,8 +2065,11 @@ static void pbvh_node_draw_cb(PBVHNode *node, void *data_v) if (!(node->flag & PBVH_FullyHidden)) { GPUBatch *triangles = GPU_pbvh_buffers_batch_get(node->draw_buffers, data->fast); - if (triangles != NULL) { - data->draw_fn(data->user_data, triangles); + bool show_mask = GPU_pbvh_buffers_has_mask(node->draw_buffers); + if (!data->only_mask || show_mask) { + if (triangles != NULL) { + data->draw_fn(data->user_data, triangles); + } } } } @@ -2098,10 +2078,11 @@ static void pbvh_node_draw_cb(PBVHNode *node, void *data_v) * Version of #BKE_pbvh_draw that runs a callback. */ void BKE_pbvh_draw_cb( - PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast, + PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast, bool only_mask, void (*draw_fn)(void *user_data, GPUBatch *batch), void *user_data) { struct PBVHNodeDrawCallbackData draw_data = { + .only_mask = only_mask, .fast = fast, .draw_fn = draw_fn, .user_data = user_data, @@ -2109,9 +2090,6 @@ void BKE_pbvh_draw_cb( PBVHNode **nodes; int totnode; - for (int a = 0; a < bvh->totnode; a++) - pbvh_node_check_diffuse_changed(bvh, &bvh->nodes[a]); - BKE_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(PBVH_UpdateNormals | PBVH_UpdateDrawBuffers), &nodes, &totnode); |