diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-04-27 23:03:49 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-04-27 23:05:06 +0300 |
commit | bfb4dcaa1a7ec5bfd2b25cf7aa5b6173d6c53358 (patch) | |
tree | 351733360f03cc1505a409e14873161c582afb83 /source/blender/blenkernel/intern/pbvh.c | |
parent | f3d5114c41352161d0dad7f30ef6b7dd1f28df85 (diff) |
Fix T97235: PBVH draw cache invalidation bug
The PBVH draw cache wasn't being invalidated in
all cases. It is now invalidated whenever a PBVH
node's draw buffers are freed.
Diffstat (limited to 'source/blender/blenkernel/intern/pbvh.c')
-rw-r--r-- | source/blender/blenkernel/intern/pbvh.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 1fb1570b3ff..e1ab4ccfb0a 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -656,6 +656,7 @@ PBVH *BKE_pbvh_new(void) { PBVH *pbvh = MEM_callocN(sizeof(PBVH), "pbvh"); pbvh->respect_hide = true; + pbvh->draw_cache_invalid = true; return pbvh; } @@ -1368,6 +1369,16 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata, } } +void pbvh_free_draw_buffers(PBVH *pbvh, PBVHNode *node) +{ + if (node->draw_buffers) { + pbvh->draw_cache_invalid = true; + + GPU_pbvh_buffers_free(node->draw_buffers); + node->draw_buffers = NULL; + } +} + static void pbvh_update_draw_buffers(PBVH *pbvh, PBVHNode **nodes, int totnode, int update_flag) { if ((update_flag & PBVH_RebuildDrawBuffers) || ELEM(pbvh->type, PBVH_GRIDS, PBVH_BMESH)) { @@ -1375,8 +1386,7 @@ static void pbvh_update_draw_buffers(PBVH *pbvh, PBVHNode **nodes, int totnode, for (int n = 0; n < totnode; n++) { PBVHNode *node = nodes[n]; if (node->flag & PBVH_RebuildDrawBuffers) { - GPU_pbvh_buffers_free(node->draw_buffers); - node->draw_buffers = NULL; + pbvh_free_draw_buffers(pbvh, node); } else if ((node->flag & PBVH_UpdateDrawBuffers) && node->draw_buffers) { if (pbvh->type == PBVH_GRIDS) { @@ -2779,6 +2789,8 @@ void BKE_pbvh_draw_cb(PBVH *pbvh, int totnode; int update_flag = 0; + pbvh->draw_cache_invalid = false; + /* Search for nodes that need updates. */ if (update_only_visible) { /* Get visible nodes with draw updates. */ @@ -3217,3 +3229,8 @@ void BKE_pbvh_ensure_node_loops(PBVH *pbvh) MEM_SAFE_FREE(visit); } + +bool BKE_pbvh_draw_cache_invalid(const PBVH *pbvh) +{ + return pbvh->draw_cache_invalid; +} |