[Bf-blender-cvs] [e60b18d] master: Dyntopo: Delete OpenGL buffers of nodes that do not have any more triangles.

Antony Riakiotakis noreply at git.blender.org
Wed Apr 2 00:41:30 CEST 2014


Commit: e60b18d51d58e327031961970405453becca1653
Author: Antony Riakiotakis
Date:   Wed Apr 2 01:40:05 2014 +0300
https://developer.blender.org/rBe60b18d51d58e327031961970405453becca1653

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.

===================================================================

M	source/blender/gpu/intern/gpu_buffers.c

===================================================================

diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 3882b7c..3d5879b 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -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,




More information about the Bf-blender-cvs mailing list