[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37250] branches/soc-2011-onion: merged 30096, 30196, 30694

Jason Wilkins Jason.A.Wilkins at gmail.com
Mon Jun 6 16:27:27 CEST 2011


Revision: 37250
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37250
Author:   jwilkins
Date:     2011-06-06 14:27:26 +0000 (Mon, 06 Jun 2011)
Log Message:
-----------
merged 30096, 30196, 30694

** jwilkins:
** multiple patches here because first revision did not compile on windows without the additional fixes
** found bug in this build that causes wrap overlay to be drawn incorrectly when masks are enabled, has certainly been a problem since masks were added
** I do not really like the GPU draw flags introduced in these patches, it is something that is just begging to be more general, since its simplicity was so easily strained by the wrap overlay
** however, I'll withhold fixing the wrap overlay / mask bug until I see how the GPUDrawFlag feature evolves

Revision: 30096
Author: nicholasbishop
Date: 5:55:57 PM, Wednesday, July 07, 2010
Message:
Some more changes for improving non-sculpt paint modes:

?\226?\128?\162 Add face customdata to the pbvh
?\226?\128?\162 Return more data from BLI_pbvh_node_get_faces
?\226?\128?\162 Add some drawing flags for the pbvh/VBO drawing code
?\226?\128?\162 Some initial support for drawing mesh colors (not used yet)
?\226?\128?\162 Abstracted sculpt's get_location a bit so it can be used for other types of paint strokes
?\226?\128?\162 Moved and renamed unproject_brush_radius so other paint modes can use it
?\226?\128?\162 There should be no visible changes from this commit

Revision: 30196
Author: nicholasbishop
Date: 9:30:18 PM, Saturday, July 10, 2010
Message:
Changed glew include from "" to <>
----
Modified : /branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c

Revision: 30694
Author: nicholasbishop
Date: 1:32:57 PM, Saturday, July 24, 2010
Message:
== PBVH ==

* Moved glShadeModel from pbvh.c to gpu_buffers.c, also fixes bad include of glew

Modified Paths:
--------------
    branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h
    branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2011-onion/source/blender/editors/space_view3d/drawobject.c
    branches/soc-2011-onion/source/blender/gpu/GPU_buffers.h
    branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.c

Property Changed:
----------------
    branches/soc-2011-onion/
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c


Property changes on: branches/soc-2011-onion
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29913,30093
/trunk/blender:36833-37206
   + /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29913,30093,30096,30196,30694
/trunk/blender:36833-37206

Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c	2011-06-06 13:35:43 UTC (rev 37249)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c	2011-06-06 14:27:26 UTC (rev 37250)
@@ -242,7 +242,8 @@
 		cddm->pbvh = BLI_pbvh_new();
 		cddm->pbvh_draw = can_pbvh_draw(ob, dm);
 		BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert,
-				    &me->vdata, me->totface, me->totvert,
+				    &me->vdata, &me->fdata, me->totface,
+				    me->totvert,
 				    ss ? &ss->hidden_areas : NULL);
 
 		if(ss->modifiers_active && ob->derivedDeform) {
@@ -486,15 +487,16 @@
 
 	if(cddm->pbvh && cddm->pbvh_draw) {
 		if(dm->numFaceData) {
+			GPUDrawFlags drawflags = 0;
 			float (*face_nors)[3] = CustomData_get_layer(&dm->faceData, CD_NORMAL);
 
 			/* should be per face */
 			if(!setMaterial(mface->mat_nr+1, NULL))
 				return;
+			if(mface->flag & ME_SMOOTH)
+				drawflags |= GPU_DRAW_SMOOTH;
 
-			glShadeModel((mface->flag & ME_SMOOTH)? GL_SMOOTH: GL_FLAT);
-			BLI_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors, (mface->flag & ME_SMOOTH));
-			glShadeModel(GL_FLAT);
+			BLI_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors, drawflags);
 		}
 
 		return;

Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c	2011-06-06 13:35:43 UTC (rev 37249)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c	2011-06-06 14:27:26 UTC (rev 37250)
@@ -66,6 +66,7 @@
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
+#include "gpu_buffers.h"
 #include "GPU_draw.h"
 #include "GPU_extensions.h"
 #include "GPU_material.h"
@@ -1317,13 +1318,15 @@
 
 	if(ccgdm->pbvh && ccgdm->multires.mmd && !fast) {
 		if(dm->numFaceData) {
+			GPUDrawFlags drawflags = 0;
+
 			/* should be per face */
 			if(!setMaterial(faceFlags[1]+1, NULL))
 				return;
+			if(faceFlags[0] & ME_SMOOTH)
+				drawflags |= GPU_DRAW_SMOOTH;
 
-			glShadeModel((faceFlags[0] & ME_SMOOTH)? GL_SMOOTH: GL_FLAT);
-			BLI_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL, (faceFlags[0] & ME_SMOOTH));
-			glShadeModel(GL_FLAT);
+			BLI_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL, drawflags);
 		}
 
 		return;
@@ -2359,7 +2362,7 @@
 		Mesh *me= ob->data;
 		ob->paint->pbvh= ccgdm->pbvh = BLI_pbvh_new();
 		BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert,
-				    &me->vdata, me->totface, me->totvert,
+				    &me->vdata, &me->fdata, me->totface, me->totvert,
 				    ss ? &ss->hidden_areas : NULL);
 	}
 

Modified: branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h	2011-06-06 13:35:43 UTC (rev 37249)
+++ branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h	2011-06-06 14:27:26 UTC (rev 37250)
@@ -68,12 +68,20 @@
 typedef void (*BLI_pbvh_HitCallback)(PBVHNode *node, void *data);
 typedef void (*BLI_pbvh_HitOccludedCallback)(PBVHNode *node, void *data, float* tmin);
 
+/* test AABB against sphere */
+typedef struct {
+	float *center;
+	float radius_squared;
+	int original;
+} PBVHSearchSphereData;
+int BLI_pbvh_search_sphere_cb(PBVHNode *node, void *data);
+
 /* Building */
 
 PBVH *BLI_pbvh_new(void);
 void BLI_pbvh_build_mesh(PBVH *bvh, struct MFace *faces, struct MVert *verts,
-			 struct CustomData *vdata, int totface, int totvert,
-			 ListBase *hidden_areas);
+			 struct CustomData *vdata, struct CustomData *fdata,
+			 int totface, int totvert, ListBase *hidden_areas);
 void BLI_pbvh_build_grids(PBVH *bvh, struct DMGridData **grids,
 			  struct DMGridAdjacency *gridadj, int totgrid,
 			  int gridsize, struct GridKey *gridkey, void **gridfaces,
@@ -106,7 +114,7 @@
 
 void BLI_pbvh_node_draw(PBVHNode *node, void *data);
 int BLI_pbvh_node_planes_contain_AABB(PBVHNode *node, void *data);
-void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3], int smooth);
+void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3], int flags);
 
 /* Node Access */
 
@@ -137,7 +145,9 @@
 void BLI_pbvh_node_set_flags(PBVHNode *node, void *data);
 
 void BLI_pbvh_node_get_faces(PBVH *bvh, PBVHNode *node,
-			     int **face_indices, int *totnode);
+			     struct MFace **faces, struct CustomData **fdata,
+			     int **face_indices, int **face_vert_indices,
+			     int *totface);
 void BLI_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node,
 	int **grid_indices, int *totgrid, int *maxgrid, int *gridsize,
 	struct DMGridData ***griddata, struct DMGridAdjacency **gridadj, struct GridKey **gridkey);
@@ -325,9 +335,9 @@
 PBVHProxyNode* BLI_pbvh_node_add_proxy(PBVH* bvh, PBVHNode* node);
 void BLI_pbvh_gather_proxies(PBVH* pbvh, PBVHNode*** nodes,  int* totnode);
 
-void BLI_pbvh_draw_nodes_in_sphere(PBVH *bvh, float location[3], float radius);
-void BLI_pbvh_gather_nodes_in_sphere(PBVH *bvh, float location[3], float radius, PBVHNode ***nodes, int *totnode);
-void BLI_pbvh_node_array_draw(PBVH *bvh, PBVHNode **nodes, int totnode);
+void BLI_pbvh_draw_nodes_in_sphere(PBVH *bvh, float center[3], float radius, int flags);
+void BLI_pbvh_gather_nodes_in_sphere(PBVH *bvh, float center[3], float radius, PBVHNode ***nodes, int *totnode);
+void BLI_pbvh_node_array_draw(PBVH *bvh, PBVHNode **nodes, int totnode, int flags);
 
 //void BLI_pbvh_node_BB_reset(PBVHNode* node);
 //void BLI_pbvh_node_BB_expand(PBVHNode* node, float co[3]);

Modified: branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c	2011-06-06 13:35:43 UTC (rev 37249)
+++ branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c	2011-06-06 14:27:26 UTC (rev 37250)
@@ -45,6 +45,7 @@
 
 #include <limits.h>
 
+
 static void pbvh_free_nodes(PBVH *bvh);
 
 #define LEAF_LIMIT 10000
@@ -139,6 +140,9 @@
 	/* Used by both mesh and grid type */
 	CustomData *vdata;
 
+	/* For vertex paint */
+	CustomData *fdata;
+
 	/* Only used during BVH build and update,
 	   don't need to remain valid after */
 	BLI_bitmap vert_bitmap;
@@ -170,8 +174,33 @@
 	int stackspace;
 } PBVHIter;
 
+/* Test AABB against sphere */
+int BLI_pbvh_search_sphere_cb(PBVHNode *node, void *data_v)
+{
+	PBVHSearchSphereData *data = data_v;
+	float nearest[3];
+	float t[3], bb_min[3], bb_max[3];
+	int i;
 
+	if(data->original)
+		BLI_pbvh_node_get_original_BB(node, bb_min, bb_max);
+	else
+		BLI_pbvh_node_get_BB(node, bb_min, bb_max);
 
+	for(i = 0; i < 3; ++i) {
+		if(bb_min[i] > data->center[i])
+			nearest[i] = bb_min[i];
+		else if(bb_max[i] < data->center[i])
+			nearest[i] = bb_max[i];
+		else
+			nearest[i] = data->center[i]; 
+	}
+	
+	sub_v3_v3v3(t, data->center, nearest);
+
+	return t[0] * t[0] + t[1] * t[1] + t[2] * t[2] < data->radius_squared;
+}
+
 /* Adapted from:
    http://www.gamedev.net/community/forums/topic.asp?topic_id=512123
    Returns true if the AABB is at least partially within the frustum
@@ -423,6 +452,7 @@
 		node->draw_buffers =
 			GPU_build_mesh_buffers(map, bvh->verts, bvh->faces,
 					bvh->vdata,
+				  bvh->fdata,
 					node->prim_indices,
 					node->totprim, node->vert_indices,
 					node->uniq_verts,
@@ -645,12 +675,14 @@
 
 /* Do a full rebuild with on Mesh data structure */
 void BLI_pbvh_build_mesh(PBVH *bvh, MFace *faces, MVert *verts,
-			 CustomData *vdata, int totface, int totvert,
+			 CustomData *vdata, CustomData *fdata,
+			 int totface, int totvert,
 			 ListBase *hidden_areas)
 {
 	bvh->faces = faces;
 	bvh->verts = verts;
 	bvh->vdata = vdata;
+	bvh->fdata = fdata;
 	bvh->totvert = totvert;
 	bvh->leaf_limit = LEAF_LIMIT;
 
@@ -1119,7 +1151,7 @@
 	}
 }
 
-static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode, int smooth)
+static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode, int flags)
 {
 	PBVHNode *node;
 	int n;
@@ -1136,7 +1168,7 @@
 						   node->totprim,
 						   bvh->gridsize,
 							     bvh->gridkey,
-						   smooth);
+							     flags & GPU_DRAW_SMOOTH);
 			}
 			else {
 				GPU_update_mesh_vert_buffers(node->draw_buffers,
@@ -1157,14 +1189,12 @@
 							      node->totprim,
 							      bvh->gridsize,
 							      bvh->gridkey,
-							      bvh->vdata);
+							      bvh->vdata,
+							      flags);
 	}
 			else {
 				GPU_update_mesh_color_buffers(node->draw_buffers,
-							      bvh->vdata,
-							      node->vert_indices,
-							      node->uniq_verts +
-							      node->face_verts);
+							      bvh, node, flags);
 }
 
 			node->flag &= ~PBVH_UpdateColorBuffers;
@@ -1327,14 +1357,22 @@
 }
 
 void BLI_pbvh_node_get_faces(PBVH *bvh, PBVHNode *node,
-			     int **face_indices, int *totnode)
+			     struct MFace **mface, struct CustomData **fdata,
+			     int **face_indices, int **face_vert_indices,
+			     int *totnode)
 {
 	if(bvh->grids) {
+		if(mface) *mface= NULL;
+		if(fdata) *fdata= NULL;
 		if(face_indices) *face_indices= NULL;
+		if(face_vert_indices) *face_vert_indices= NULL;
 		if(totnode) *totnode= 0;
 	}
 	else {
+		if(mface) *mface= bvh->faces;
+		if(fdata) *fdata= bvh->fdata;
 		if(face_indices) *face_indices= node->prim_indices;
+		if(face_vert_indices) *face_vert_indices= node->face_vert_indices;
 		if(totnode) *totnode= node->totprim;
 	}
 }
@@ -1550,7 +1588,7 @@
 
 //#include <GL/glew.h>
 
-void BLI_pbvh_node_draw(PBVHNode *node, void *UNUSED(data))
+void BLI_pbvh_node_draw(PBVHNode *node, void *data)
 {
 #if 0
 	/* XXX: Just some quick code to show leaf nodes in different colors */
@@ -1568,7 +1606,7 @@
 
 	glColor3f(1, 0, 0);
 #endif
-	GPU_draw_buffers(node->draw_buffers);
+	GPU_draw_buffers(node->draw_buffers, *((GPUDrawFlags*)data));
 }
 
 int BLI_pbvh_node_planes_contain_AABB(PBVHNode *node, void *data)
@@ -1578,9 +1616,9 @@
 	BLI_pbvh_node_get_BB(node, bb_min, bb_max);
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list