[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30847] branches/soc-2010-nicolasbishop/ source/blender: == PBVH ==

Nicholas Bishop nicholasbishop at gmail.com
Wed Jul 28 19:26:57 CEST 2010


Revision: 30847
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30847
Author:   nicholasbishop
Date:     2010-07-28 19:26:56 +0200 (Wed, 28 Jul 2010)

Log Message:
-----------
== PBVH ==

* Some interface cleanups, should be no functional changes

Modified Paths:
--------------
    branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h
    branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_mask.c
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c

Modified: branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h	2010-07-28 17:08:24 UTC (rev 30846)
+++ branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h	2010-07-28 17:26:56 UTC (rev 30847)
@@ -145,7 +145,7 @@
 void BLI_pbvh_get_customdata(PBVH *pbvh, struct CustomData **vdata, struct CustomData **fdata);
 
 void BLI_pbvh_node_get_faces(PBVH *bvh, PBVHNode *node,
-			     struct MFace **faces, struct CustomData **fdata,
+			     struct MFace **faces,
 			     int **face_indices, int **face_vert_indices,
 			     int *totface);
 void BLI_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node,
@@ -154,7 +154,7 @@
 void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node,
 	int *uniquevert, int *totvert);
 void BLI_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node,
-			     int **vert_indices, struct MVert **verts, struct CustomData **vdata);
+			     int **vert_indices, struct MVert **verts);
 
 void BLI_pbvh_node_get_BB(PBVHNode *node, float bb_min[3], float bb_max[3]);
 void BLI_pbvh_node_get_original_BB(PBVHNode *node, float bb_min[3], float bb_max[3]);
@@ -237,7 +237,8 @@
 		\
 		BLI_pbvh_node_get_grids(bvh, node, &grid_indices, &totgrid, NULL, &gridsize, &grids, NULL, &gridkey); \
 		BLI_pbvh_node_num_verts(bvh, node, &uniq_verts, &totvert); \
-		BLI_pbvh_node_get_verts(bvh, node, &vert_indices, &verts, &vi.vdata); \
+		BLI_pbvh_node_get_verts(bvh, node, &vert_indices, &verts); \
+		BLI_pbvh_get_customdata(bvh, &vi.vdata, NULL); \
 		\
 		vi.grids= grids; \
 		vi.grid_indices= grid_indices; \

Modified: branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c	2010-07-28 17:08:24 UTC (rev 30846)
+++ branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c	2010-07-28 17:26:56 UTC (rev 30847)
@@ -1339,11 +1339,10 @@
 	node->flag |= GET_INT_FROM_POINTER(data);
 }
 
-void BLI_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node, int **vert_indices, MVert **verts, CustomData **vdata)
+void BLI_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node, int **vert_indices, MVert **verts)
 {
 	if(vert_indices) *vert_indices= node->vert_indices;
 	if(verts) *verts= bvh->verts;
-	if(vdata) *vdata= bvh->vdata;
 }
 
 void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, int *uniquevert, int *totvert)
@@ -1359,20 +1358,18 @@
 }
 
 void BLI_pbvh_node_get_faces(PBVH *bvh, PBVHNode *node,
-			     struct MFace **mface, struct CustomData **fdata,
+			     MFace **mface,
 			     int **face_indices, int **face_vert_indices,
 			     int *totnode)
 {
 	if(bvh->grids) {
 		if(mface) *mface= NULL;
-		if(fdata) *fdata= bvh->fdata;
 		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;

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_mask.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_mask.c	2010-07-28 17:08:24 UTC (rev 30846)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_mask.c	2010-07-28 17:26:56 UTC (rev 30847)
@@ -303,7 +303,7 @@
 			if(ss) // TODO
 				sculpt_undo_push_node(ob, nodes[n]);
 
-			BLI_pbvh_node_get_faces(pbvh, nodes[n], &mface, NULL,
+			BLI_pbvh_node_get_faces(pbvh, nodes[n], &mface,
 						&face_indices, NULL, &totface);
 
 			for(i = 0; i < totface; ++i) {

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c	2010-07-28 17:08:24 UTC (rev 30846)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c	2010-07-28 17:26:56 UTC (rev 30847)
@@ -1944,32 +1944,24 @@
 	int n;
 
 	for(n = 0; n < totnode; ++n) {
-		DerivedMesh *dm;
-		ListBase *fmap;
-
-		MVert *mvert;
-		MFace *mface;
 		CustomData *vdata = NULL;
 		CustomData *fdata = NULL;
-		int *face_indices, totface;
 
-		DMGridData **grids;
-		GridKey *gridkey;
-		int *grid_indices, totgrid, gridsize;
+		BLI_pbvh_get_customdata(pbvh, &vdata, &fdata);
 
-		BLI_pbvh_node_get_verts(pbvh, nodes[n], NULL, &mvert, &vdata);
+		if(BLI_pbvh_uses_grids(pbvh)) {
+			DMGridData **grids;
+			GridKey *gridkey;
+			int *grid_indices, totgrid, gridsize;
+			int active;
+			
+			BLI_pbvh_node_get_grids(pbvh, nodes[n], &grid_indices,
+						&totgrid, NULL, &gridsize, &grids,
+						NULL, &gridkey);
 
-		BLI_pbvh_node_get_faces(pbvh, nodes[n], &mface, &fdata,
-					&face_indices, NULL, &totface);
+			active = vpaint_find_gridkey_active_layer(fdata,
+								  gridkey);
 
-		BLI_pbvh_node_get_grids(pbvh, nodes[n], &grid_indices,
-					&totgrid, NULL, &gridsize, &grids,
-					NULL, &gridkey);
-
-		if(grids) {
-			int active = vpaint_find_gridkey_active_layer(fdata,
-								      gridkey);
-
 			if(active != -1) {
 				if(blur) {
 					vpaint_nodes_grids_smooth(brush, stroke,
@@ -1995,23 +1987,36 @@
 				}
 			}
 		}
-		else if(blur) {
-			dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
-			fmap = dm->getFaceMap ? dm->getFaceMap(ob, dm) : NULL;
+		else {
+			MVert *mvert;
+			MFace *mface;
+			int *face_indices, totface;
 
-			vpaint_nodes_faces_smooth(brush, stroke,
-						  pbvh, nodes[n],
-						  mface, fdata,
-						  fmap, center,
-						  radius, radius*radius);
+			BLI_pbvh_node_get_verts(pbvh, nodes[n], NULL, &mvert);
+			BLI_pbvh_node_get_faces(pbvh, nodes[n], &mface,
+						&face_indices, NULL, &totface);
+
+			if(blur) {
+				DerivedMesh *dm;
+				ListBase *fmap;
+
+				dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
+				fmap = dm->getFaceMap ? dm->getFaceMap(ob, dm) : NULL;
+
+				vpaint_nodes_faces_smooth(brush, stroke,
+							  pbvh, nodes[n],
+							  mface, fdata,
+							  fmap, center,
+							  radius, radius*radius);
+			}				
+			else {
+				vpaint_nodes_faces(brush, stroke,
+						   mface, mvert,
+						   vdata, fdata,
+						   face_indices, totface,
+						   center, radius);
+			}
 		}
-		else {
-			vpaint_nodes_faces(brush, stroke,
-					   mface, mvert,
-					   vdata, fdata,
-					   face_indices, totface,
-					   center, radius);
-		}
 
 		BLI_pbvh_node_set_flags(nodes[n],
 			SET_INT_IN_POINTER(PBVH_UpdateColorBuffers|
@@ -2101,24 +2106,25 @@
 	if(paint_stroke_get_location(C, stroke,
 				     vpaint_color_one_face_raycast_cb,
 				     &hit_data, hit_loc, mouse, 0)) {
-		DMGridData **grids;
-		GridKey *gridkey;
-		MFace *mface;
+		PBVH *pbvh = vc->obact->paint->pbvh;
 		CustomData *fdata;
-		int *face_indices, *grid_indices, gridsize;
 
-		BLI_pbvh_node_get_faces(vc->obact->paint->pbvh, hit_data.node,
-					&mface, &fdata, &face_indices,
-					NULL, NULL);
-		BLI_pbvh_node_get_grids(vc->obact->paint->pbvh, hit_data.node,
-					&grid_indices,
-					NULL, NULL, &gridsize, &grids,
-					NULL, &gridkey);
+		BLI_pbvh_get_customdata(pbvh, NULL, &fdata);
 
-		if(grids) {
-			int active = vpaint_find_gridkey_active_layer(fdata,
-								      gridkey);
+		if(BLI_pbvh_uses_grids(pbvh)) {
+			DMGridData **grids;
+			GridKey *gridkey;
+			int *grid_indices, gridsize;
+			int active;
 
+			BLI_pbvh_node_get_grids(pbvh, hit_data.node,
+						&grid_indices,
+						NULL, NULL, &gridsize, &grids,
+						NULL, &gridkey);
+
+			active = vpaint_find_gridkey_active_layer(fdata,
+								  gridkey);
+
 			if(active != -1) {
 				vpaint_color_single_gridelem(brush,
 					grids,
@@ -2130,6 +2136,13 @@
 			}
 		}
 		else {
+			MFace *mface;
+			int *face_indices;
+
+			BLI_pbvh_node_get_faces(pbvh, hit_data.node,
+						&mface, &face_indices,
+						NULL, NULL);
+
 			vpaint_color_single_face(brush, mface, fdata,
 				 face_indices,
 				 hit_data.hit_index);

Modified: branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c	2010-07-28 17:08:24 UTC (rev 30846)
+++ branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c	2010-07-28 17:26:56 UTC (rev 30847)
@@ -506,9 +506,10 @@
 	if(!buffers->vert_buf)
 		return;
 
+	BLI_pbvh_get_customdata(bvh, &vdata, &fdata);
 	BLI_pbvh_node_num_verts(bvh, node, NULL, &totvert);
-	BLI_pbvh_node_get_verts(bvh, node, &vert_indices, NULL, &vdata);
-	BLI_pbvh_node_get_faces(bvh, node, &mface, &fdata, &face_indices,
+	BLI_pbvh_node_get_verts(bvh, node, &vert_indices, NULL);
+	BLI_pbvh_node_get_faces(bvh, node, &mface, &face_indices,
 				&face_vert_indices, &totface);
 	
 	mcol_totlayer = CustomData_number_of_layers(fdata, CD_MCOL);
@@ -959,8 +960,8 @@
 		int totface, *face_indices;
 		int j, mcol_totlayer, pmask_totlayer;
 
-		BLI_pbvh_node_get_verts(pbvh, node, NULL, &mvert, NULL);
-		BLI_pbvh_node_get_faces(pbvh, node, &mface, NULL, &face_indices, NULL, &totface);
+		BLI_pbvh_node_get_verts(pbvh, node, NULL, &mvert);
+		BLI_pbvh_node_get_faces(pbvh, node, &mface, &face_indices, NULL, &totface);
 
 		if(mcol_first_layer)
 			mcol_totlayer = CustomData_number_of_layers(fdata, CD_MCOL);





More information about the Bf-blender-cvs mailing list