[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25312] branches/sculpt25/source/blender: Sculpt Branch:

Brecht Van Lommel brecht at blender.org
Fri Dec 11 15:16:19 CET 2009


Revision: 25312
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25312
Author:   blendix
Date:     2009-12-11 15:16:17 +0100 (Fri, 11 Dec 2009)

Log Message:
-----------
Sculpt Branch:
* Added detection if VBO extension is supported.
* Redraw other 3d views after sculpting.
* Fix brush sometimes punching through mesh with very small polygons,
  added an extra epsilon to the ray-triangle intersection.

Modified Paths:
--------------
    branches/sculpt25/source/blender/blenlib/BLI_pbvh.h
    branches/sculpt25/source/blender/blenlib/intern/pbvh.c
    branches/sculpt25/source/blender/editors/sculpt_paint/sculpt.c
    branches/sculpt25/source/blender/gpu/intern/gpu_buffers.c

Modified: branches/sculpt25/source/blender/blenlib/BLI_pbvh.h
===================================================================
--- branches/sculpt25/source/blender/blenlib/BLI_pbvh.h	2009-12-11 13:54:56 UTC (rev 25311)
+++ branches/sculpt25/source/blender/blenlib/BLI_pbvh.h	2009-12-11 14:16:17 UTC (rev 25312)
@@ -88,9 +88,9 @@
 
 	PBVH_UpdateNormals = 2,
 	PBVH_UpdateBB = 4,
-	PBVH_UpdateOriginalBB = 4,
-	PBVH_UpdateDrawBuffers = 8,
-	PBVH_UpdateRedraw = 16
+	PBVH_UpdateOriginalBB = 8,
+	PBVH_UpdateDrawBuffers = 16,
+	PBVH_UpdateRedraw = 32
 } PBVHNodeFlags;
 
 void BLI_pbvh_node_mark_update(PBVHNode *node);

Modified: branches/sculpt25/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/sculpt25/source/blender/blenlib/intern/pbvh.c	2009-12-11 13:54:56 UTC (rev 25311)
+++ branches/sculpt25/source/blender/blenlib/intern/pbvh.c	2009-12-11 14:16:17 UTC (rev 25312)
@@ -1142,8 +1142,8 @@
 	{	
 		float dist = FLT_MAX;
 			
-		if(!isect_ray_tri_v3(ray_start, ray_normal, t0, t1, t2,
-					 &dist, NULL))
+		if(!isect_ray_tri_threshold_v3(ray_start, ray_normal, t0, t1, t2,
+					 &dist, NULL, 0.001f))
 			dist = FLT_MAX;
 
 		if(dist >= 0 && dist < *fdist) {
@@ -1232,32 +1232,26 @@
 	return hit;
 }
 
-#if 0
-static int nodes_drawn = 0;
-static int is_partial = 0;
-/* XXX: Just a temporary replacement for the real drawing code */
-static void draw_partial_cb(PBVHNode *node, void *data)
+//#include <GL/glew.h>
 
+void BLI_pbvh_node_draw(PBVHNode *node, void *data)
+{
+#if 0
 	/* XXX: Just some quick code to show leaf nodes in different colors */
-	/*float col[3]; int i;
-	if(is_partial) {
+	float col[3]; int i;
+
+	if(0) { //is_partial) {
 		col[0] = (rand() / (float)RAND_MAX); col[1] = col[2] = 0.6;
 	}
 	else {
-		srand((long long)data_v);
+		srand((long long)node);
 		for(i = 0; i < 3; ++i)
 			col[i] = (rand() / (float)RAND_MAX) * 0.3 + 0.7;
 	}
 	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, col);
 
-	glColor3f(1, 0, 0);*/
-	GPU_draw_buffers(BLI_pbvh_node_get_draw_buffers(node));
-	++nodes_drawn;
-}
+	glColor3f(1, 0, 0);
 #endif
-
-void BLI_pbvh_node_draw(PBVHNode *node, void *data)
-{
 	GPU_draw_buffers(node->draw_buffers);
 }
 

Modified: branches/sculpt25/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/sculpt25/source/blender/editors/sculpt_paint/sculpt.c	2009-12-11 13:54:56 UTC (rev 25311)
+++ branches/sculpt25/source/blender/editors/sculpt_paint/sculpt.c	2009-12-11 14:16:17 UTC (rev 25312)
@@ -2054,6 +2054,8 @@
 		BLI_pbvh_update(ss->tree, PBVH_UpdateOriginalBB, NULL);
 
 		if(ss->refkb) sculpt_key_to_mesh(ss->refkb, ob);
+
+		WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
 	}
 }
 

Modified: branches/sculpt25/source/blender/gpu/intern/gpu_buffers.c
===================================================================
--- branches/sculpt25/source/blender/gpu/intern/gpu_buffers.c	2009-12-11 13:54:56 UTC (rev 25311)
+++ branches/sculpt25/source/blender/gpu/intern/gpu_buffers.c	2009-12-11 14:16:17 UTC (rev 25312)
@@ -457,10 +457,12 @@
 	/* Count the number of triangles */
 	for(i = 0, tottri = 0; i < totface; ++i)
 		tottri += mface[face_indices[i]].v4 ? 2 : 1;
+	
+	if(GL_ARB_vertex_buffer_object)
+		glGenBuffersARB(1, &buffers->index_buf);
 
 	if(buffers->index_buf) {
 		/* Generate index buffer object */
-		glGenBuffersARB(1, &buffers->index_buf);
 		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf);
 		glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
 				 sizeof(unsigned short) * tottri * 3, NULL, GL_STATIC_DRAW_ARB);
@@ -503,7 +505,7 @@
 		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
 	}
 
-	if(buffers->vert_buf)
+	if(buffers->index_buf)
 		glGenBuffersARB(1, &buffers->vert_buf);
 	GPU_update_mesh_buffers(buffers, mvert, vert_indices, totvert);
 
@@ -567,7 +569,9 @@
 	totquad= (gridsize-1)*(gridsize-1)*totgrid;
 
 	/* Generate index buffer object */
-	glGenBuffersARB(1, &buffers->index_buf);
+	if(GL_ARB_vertex_buffer_object)
+		glGenBuffersARB(1, &buffers->index_buf);
+
 	if(buffers->index_buf) {
 		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf);
 





More information about the Bf-blender-cvs mailing list