Dyntopo: Delete OpenGL buffers of nodes that do not have any more

triangles.

It is possible to end up with such nodes using brushes in aggressive
collapse mode. Those nodes should normally be cleaned up, since they can
never be actually reused (adding more geometry to a node requires the
node having some geometry to begin with) but until we support dynamic
nodes, better delete those to avoid binding graphics driver resources.

If such zero elements buffers were used, GL error out of memory would be
reported.
This commit is contained in:
Antonis Ryakiotakis 2014-04-02 01:40:05 +03:00
parent 0a112efcf7
commit e60b18d51d
Notes: blender-bot 2023-02-14 05:28:01 +01:00
Referenced by commit 3a20c056e8, Fix T58920: Dyntopo sculpt and snake hook brush artifacts.
Referenced by issue #65523, Dyntopo + Snake tool produce weird artifacts after grab tool
1 changed files with 13 additions and 0 deletions

View File

@ -2046,6 +2046,19 @@ void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
else
totvert = tottri * 3;
/* some nodes may lose all their vertices/faces. Normally we should delete those but since we don't
* support dynamic nodes yet, just return immediately to avoid opengl errors */
if (!tottri) {
if (buffers->index_buf)
glDeleteBuffersARB(1, &buffers->index_buf);
if (buffers->vert_buf)
glDeleteBuffersARB(1, &buffers->vert_buf);
buffers->vert_buf = 0;
buffers->index_buf = 0;
buffers->tot_tri = 0;
return;
}
/* Initialize vertex buffer */
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,