[Bf-blender-cvs] [9a1c47d] master: Attempt to solve T39950,

Antony Riakiotakis noreply at git.blender.org
Mon May 5 20:13:35 CEST 2014


Commit: 9a1c47de444eec6f6f73896aff8712c6847d328f
Author: Antony Riakiotakis
Date:   Mon May 5 21:13:27 2014 +0300
https://developer.blender.org/rB9a1c47de444eec6f6f73896aff8712c6847d328f

Attempt to solve T39950,

Avoid filling up buffers when total buffer triangles are zero.

Better still would be to tag a node as hidden when doing recreation of
the PBVH tree by checking for any visible elements. Original bug report
probably has to do with OpenGL doing something funky but hidden nodes
should be tagged as hidden to completely avoid iterating for painting.
This is to be done in a later commit.

Also some naming cleanup for consistency, GPU_build_pbvh_mesh_buffers to
GPU_build_mesh_pbvh_buffers.

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

M	source/blender/blenkernel/intern/pbvh.c
M	source/blender/gpu/GPU_buffers.h
M	source/blender/gpu/intern/gpu_buffers.c

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

diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 09bf165..17b8f5e 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1037,7 +1037,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
 					break;
 				case PBVH_FACES:
 					node->draw_buffers =
-						GPU_build_pbvh_mesh_buffers(node->face_vert_indices,
+						GPU_build_mesh_pbvh_buffers(node->face_vert_indices,
 					                           bvh->faces, bvh->verts,
 					                           node->prim_indices,
 					                           node->totprim);
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index 6c7945d..096b208 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -166,19 +166,22 @@ bool GPU_buffer_legacy(struct DerivedMesh *dm);
 /* Buffers for non-DerivedMesh drawing */
 typedef struct GPU_PBVH_Buffers GPU_PBVH_Buffers;
 
-GPU_PBVH_Buffers *GPU_build_pbvh_mesh_buffers(int (*face_vert_indices)[4],
+/* build */
+GPU_PBVH_Buffers *GPU_build_mesh_pbvh_buffers(int (*face_vert_indices)[4],
                                     struct MFace *mface, struct MVert *mvert,
                                     int *face_indices, int totface);
 
-void GPU_update_mesh_pbvh_buffers(GPU_PBVH_Buffers *buffers, MVert *mvert,
-                             int *vert_indices, int totvert, const float *vmask,
-                             int (*face_vert_indices)[4], bool show_diffuse_color);
-
 GPU_PBVH_Buffers *GPU_build_grid_pbvh_buffers(int *grid_indices, int totgrid,
                                     unsigned int **grid_hidden, int gridsize);
 
 GPU_PBVH_Buffers *GPU_build_bmesh_pbvh_buffers(int smooth_shading);
 
+/* update */
+
+void GPU_update_mesh_pbvh_buffers(GPU_PBVH_Buffers *buffers, MVert *mvert,
+							 int *vert_indices, int totvert, const float *vmask,
+							 int (*face_vert_indices)[4], bool show_diffuse_color);
+
 void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
                               struct BMesh *bm,
                               struct GSet *bm_faces,
@@ -191,9 +194,11 @@ void GPU_update_grid_pbvh_buffers(GPU_PBVH_Buffers *buffers, struct CCGElem **gr
                              int *grid_indices, int totgrid, const struct CCGKey *key,
                              bool show_diffuse_color);
 
+/* draw */
 void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
                            bool wireframe);
 
+/* debug PBVH draw*/
 void GPU_draw_pbvh_BB(float min[3], float max[3], bool leaf);
 void GPU_end_draw_pbvh_BB(void);
 void GPU_init_draw_pbvh_BB(void);
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 9bf63d2..e33d72e 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -1623,7 +1623,7 @@ void GPU_update_mesh_pbvh_buffers(GPU_PBVH_Buffers *buffers, MVert *mvert,
 	buffers->mvert = mvert;
 }
 
-GPU_PBVH_Buffers *GPU_build_pbvh_mesh_buffers(int (*face_vert_indices)[4],
+GPU_PBVH_Buffers *GPU_build_mesh_pbvh_buffers(int (*face_vert_indices)[4],
                                     MFace *mface, MVert *mvert,
                                     int *face_indices,
                                     int totface)
@@ -1646,6 +1646,16 @@ GPU_PBVH_Buffers *GPU_build_pbvh_mesh_buffers(int (*face_vert_indices)[4],
 			tottri += f->v4 ? 2 : 1;
 	}
 
+	if (tottri == 0) {
+		buffers->tot_tri = 0;
+
+		buffers->mface = mface;
+		buffers->face_indices = face_indices;
+		buffers->totface = 0;
+
+		return buffers;
+	}
+
 	/* An element index buffer is used for smooth shading, but flat
 	 * shading requires separate vertex normals so an index buffer is
 	 * can't be used there. */
@@ -1966,6 +1976,10 @@ GPU_PBVH_Buffers *GPU_build_grid_pbvh_buffers(int *grid_indices, int totgrid,
 	/* Count the number of quads */
 	totquad = gpu_count_grid_quads(grid_hidden, grid_indices, totgrid, gridsize);
 
+	/* totally hidden node, return here to avoid BufferData with zero below. */
+	if (totquad == 0)
+		return buffers;
+
 	if (totquad == fully_visible_totquad) {
 		buffers->index_buf = gpu_get_grid_buffer(gridsize, &buffers->index_type, &buffers->tot_quad);
 		buffers->has_hidden = 0;




More information about the Bf-blender-cvs mailing list