[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31449] branches/soc-2010-nicolasbishop/ source/blender: Merged GPUDrawFlags into DMDrawFlags, cleaned up DMDrawFlags

Nicholas Bishop nicholasbishop at gmail.com
Thu Aug 19 00:08:46 CEST 2010


Revision: 31449
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31449
Author:   nicholasbishop
Date:     2010-08-19 00:08:45 +0200 (Thu, 19 Aug 2010)

Log Message:
-----------
Merged GPUDrawFlags into DMDrawFlags, cleaned up DMDrawFlags

Modified Paths:
--------------
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c
    branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawmesh.c
    branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawobject.c
    branches/soc-2010-nicolasbishop/source/blender/gpu/GPU_buffers.h
    branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c
    branches/soc-2010-nicolasbishop/source/blender/makesrna/intern/rna_scene.c

Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h	2010-08-18 19:09:30 UTC (rev 31448)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h	2010-08-18 22:08:45 UTC (rev 31449)
@@ -81,11 +81,21 @@
 	DM_TYPE_CCGDM
 } DerivedMeshType;
 
-typedef enum {
-	DM_DRAW_FAST_NAV = 1,
-	DM_DRAW_BACKBUF_SEL = 2,
-	DM_DRAW_USE_COLORS = 4,
-	DM_DRAW_PTEX_TEXELS = 8,
+typedef enum DMDrawFlags {
+	/* fast navigation for multires */
+	DM_DRAW_LOWEST_SUBDIVISION_LEVEL = 1,
+	/* draw mask for sculpt mode */
+	DM_DRAW_PAINT_MASK = 2,
+	/* draw ptex textures */
+	DM_DRAW_PTEX = 4,
+	/* mcol, weight colors, etc. */
+	DM_DRAW_VERTEX_COLORS = 8,
+	/* visually show ptex texel density */
+	DM_DRAW_PTEX_TEXELS = 16,
+	/* mainly for sculpting, use smooth normals */
+	DM_DRAW_FULLY_SMOOTH = 32,
+	/* back-buffer selection mode */
+	DM_DRAW_BACKBUF_SELECTION = 64,
 } DMDrawFlags;
 
 typedef struct DerivedMesh DerivedMesh;

Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c	2010-08-18 19:09:30 UTC (rev 31448)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c	2010-08-18 22:08:45 UTC (rev 31449)
@@ -433,31 +433,23 @@
    false if regular drawing should be used */
 static int cddm_draw_pbvh(DerivedMesh *dm, float (*partial_redraw_planes)[4],
 			  int (*setMaterial)(int, void *attribs),
-			  DMDrawFlags dm_flags)
+			  DMDrawFlags flags)
 {
 	CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
 	MFace *mface = cddm->mface;
 	float (*face_nors)[3];
 
-	if(!(dm_flags & DM_DRAW_BACKBUF_SEL) && cddm->pbvh && cddm->pbvh_draw) {
+	if(!(flags & DM_DRAW_BACKBUF_SELECTION) && cddm->pbvh && cddm->pbvh_draw) {
 		if(dm->numFaceData) {
-			GPUDrawFlags gpu_flags = 0;
-
 			face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL);
 
 			/* should be per face */
 			if(setMaterial && !setMaterial(mface->mat_nr+1, NULL))
 				return 1;
 			if(mface->flag & ME_SMOOTH)
-				gpu_flags |= GPU_DRAW_SMOOTH;
+				flags |= DM_DRAW_FULLY_SMOOTH;
 
-			if(dm_flags & DM_DRAW_USE_COLORS)
-				gpu_flags |= GPU_DRAW_ACTIVE_MCOL;
-
-			if(dm_flags & DM_DRAW_PTEX_TEXELS)
-				gpu_flags |= GPU_DRAW_PTEX_TEXELS;
-
-			BLI_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors, gpu_flags);
+			BLI_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors, flags);
 		}
 
 		return 1;
@@ -853,7 +845,7 @@
 			if(!setDrawOptions || setDrawOptions(userData, orig, &drawSmooth)) {
 				unsigned char *cp = NULL;
 
-				if((flags & DM_DRAW_USE_COLORS) && mc)
+				if((flags & DM_DRAW_VERTEX_COLORS) && mc)
 					cp = (unsigned char *)&mc[i * 4];
 
 				glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
@@ -910,7 +902,7 @@
 		int prevstart = 0;
 		GPU_vertex_setup(dm);
 		GPU_normal_setup(dm);
-		if((flags & DM_DRAW_USE_COLORS) && mc )
+		if((flags & DM_DRAW_VERTEX_COLORS) && mc )
 			GPU_color_setup(dm);
 		if( !GPU_buffer_legacy(dm) ) {
 			int tottri = dm->drawObject->nelements/3;

Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c	2010-08-18 19:09:30 UTC (rev 31448)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c	2010-08-18 22:08:45 UTC (rev 31449)
@@ -1383,22 +1383,22 @@
 
 static int ccgdm_draw_pbvh(DerivedMesh *dm, float (*partial_redraw_planes)[4],
 			   int (*setMaterial)(int, void *attribs),
-			   int fast_navigate, GPUDrawFlags drawflags)
+			   DMDrawFlags flags)
 {
 	CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm;
 	char *faceFlags = ccgdm->faceFlags;
 
 	ccgdm_pbvh_update(ccgdm);
 
-	if(ccgdm->pbvh && ccgdm->multires.mmd && !fast_navigate) {
+	if(ccgdm->pbvh && ccgdm->multires.mmd && !(flags & DM_DRAW_LOWEST_SUBDIVISION_LEVEL)) {
 		if(dm->numFaceData) {
 			/* should be per face */
 			if(setMaterial && !setMaterial(faceFlags[1]+1, NULL))
 				return 1;
 			if(faceFlags[0] & ME_SMOOTH)
-				drawflags |= GPU_DRAW_SMOOTH;
+				flags |= DM_DRAW_FULLY_SMOOTH;
 
-			BLI_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL, drawflags);
+			BLI_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL, flags);
 		}
 
 		return 1;
@@ -1418,10 +1418,10 @@
 	int gridSize = ccgSubSurf_getGridSize(ss);
 	GridKey *gridkey = ccgSubSurf_getGridKey(ss);
 	char *faceFlags = ccgdm->faceFlags;
-	int step = (flags & DM_DRAW_FAST_NAV)? gridSize-1: 1;
+	int step = (flags & DM_DRAW_LOWEST_SUBDIVISION_LEVEL)? gridSize-1: 1;
 
-	if(!(flags & DM_DRAW_BACKBUF_SEL) &&
-	   ccgdm_draw_pbvh(dm, partial_redraw_planes, setMaterial, flags & DM_DRAW_FAST_NAV, 0))
+	if(!(flags & DM_DRAW_BACKBUF_SELECTION) &&
+	   ccgdm_draw_pbvh(dm, partial_redraw_planes, setMaterial, flags))
 		return;
 
 	fi = ccgSubSurf_getFaceIterator(ss);
@@ -1923,14 +1923,13 @@
 	GridKey *gridkey = ccgSubSurf_getGridKey(ss);
 	char *faceFlags = ccgdm->faceFlags;
 	int gridFaces = gridSize - 1, totface;
-	int step = (flags & DM_DRAW_FAST_NAV)? gridSize-1: 1;
+	int step = (flags & DM_DRAW_LOWEST_SUBDIVISION_LEVEL)? gridSize-1: 1;
 
-	if(ccgdm_draw_pbvh(dm, partial_redraw_planes, NULL, (flags & DM_DRAW_FAST_NAV),
-			   (flags & DM_DRAW_USE_COLORS) ? GPU_DRAW_ACTIVE_MCOL : 0))
+	if(ccgdm_draw_pbvh(dm, partial_redraw_planes, NULL, flags))
 		return;
 
-	if(flags & DM_DRAW_USE_COLORS) {
-		if(flags & DM_DRAW_FAST_NAV) {
+	if(flags & DM_DRAW_VERTEX_COLORS) {
+		if(flags & DM_DRAW_LOWEST_SUBDIVISION_LEVEL) {
 			glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
 			glEnable(GL_COLOR_MATERIAL);
 		}
@@ -2058,7 +2057,7 @@
 		}
 	}
 
-	if(flags & DM_DRAW_FAST_NAV)
+	if(flags & DM_DRAW_LOWEST_SUBDIVISION_LEVEL)
 		glDisable(GL_COLOR_MATERIAL);
 }
 static void ccgDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData) {

Modified: branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c	2010-08-18 19:09:30 UTC (rev 31448)
+++ branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c	2010-08-18 22:08:45 UTC (rev 31449)
@@ -1139,7 +1139,7 @@
 	}
 }
 
-static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode, GPUDrawFlags flags)
+static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode, DMDrawFlags flags)
 {
 	PBVHNode *node;
 	int n;
@@ -1156,7 +1156,7 @@
 							     node->totprim,
 							     bvh->gridsize,
 							     bvh->gridkey,
-							     flags & GPU_DRAW_SMOOTH);
+							     flags & DM_DRAW_FULLY_SMOOTH);
 			}
 			else {
 				GPU_update_mesh_vert_buffers(node->draw_buffers,
@@ -1171,9 +1171,9 @@
 		
 		if(node->flag & PBVH_UpdateColorBuffers) {
 			if(bvh->grids) {
-				if(flags & GPU_DRAW_ACTIVE_MCOL)
+				if(flags & DM_DRAW_PTEX)
 					GPU_update_grids_ptex(node->draw_buffers, bvh, node);
-				else {
+				else if(flags & DM_DRAW_PAINT_MASK) {
 					GPU_update_grid_color_buffers(node->draw_buffers,
 								      bvh->grids,
 								      node->prim_indices,
@@ -1185,11 +1185,12 @@
 				}
 			}
 			else {
-				if(flags & GPU_DRAW_ACTIVE_MCOL)
+				if(flags & DM_DRAW_PTEX)
 					GPU_update_mesh_ptex(node->draw_buffers, bvh, node);
-				else
+				else if(flags & DM_DRAW_PAINT_MASK) {
 					GPU_update_mesh_color_buffers(node->draw_buffers,
 								      bvh, node, flags);
+				}
 			}
 
 			node->flag &= ~PBVH_UpdateColorBuffers;
@@ -1624,7 +1625,7 @@
 
 typedef struct {
 	PBVH *pbvh;
-	GPUDrawFlags flags;
+	DMDrawFlags flags;
 } PBVHDrawData;
 void BLI_pbvh_node_draw(PBVHNode *node, void *data_v)
 {

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawmesh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawmesh.c	2010-08-18 19:09:30 UTC (rev 31448)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawmesh.c	2010-08-18 22:08:45 UTC (rev 31449)
@@ -647,7 +647,7 @@
 		dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, me->edit_mesh);
 	} else if(faceselect) {
 		if(ob->mode & OB_MODE_WEIGHT_PAINT)
-			dm->drawMappedFaces(dm, NULL, wpaint__setSolidDrawOptions, me, DM_DRAW_USE_COLORS);
+			dm->drawMappedFaces(dm, NULL, wpaint__setSolidDrawOptions, me, DM_DRAW_VERTEX_COLORS);
 		else
 			dm->drawMappedFacesTex(dm, draw_tface_mapped__set_draw, me);
 	}

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawobject.c	2010-08-18 19:09:30 UTC (rev 31448)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawobject.c	2010-08-18 22:08:45 UTC (rev 31449)
@@ -2471,7 +2471,7 @@
 	   (p=paint_get_active(scene))) {
 		/* drop down to a low multires level during navigation */
 		fast_navigate = ((p->flags & PAINT_FAST_NAVIGATE) &&
-				 (rv3d->rflag & RV3D_NAVIGATING))? DM_DRAW_FAST_NAV : 0;
+				 (rv3d->rflag & RV3D_NAVIGATING))? DM_DRAW_LOWEST_SUBDIVISION_LEVEL : 0;
 
 		if(ob->paint && ob->paint->partial_redraw) {
 			if(ar->do_draw & RGN_DRAW_PARTIAL) {
@@ -2540,7 +2540,7 @@
 			/* weight paint in solid mode, special case. focus on making the weights clear
 			 * rather then the shading, this is also forced in wire view */
 			GPU_enable_material(0, NULL);
-			dm->drawMappedFaces(dm, NULL, wpaint__setSolidDrawOptions, me->mface, DM_DRAW_USE_COLORS);
+			dm->drawMappedFaces(dm, NULL, wpaint__setSolidDrawOptions, me->mface, DM_DRAW_VERTEX_COLORS);
 
 			bglPolygonOffset(rv3d->dist, 1.0);
 			glDepthMask(0);	// disable write in zbuffer, selected edge wires show better
@@ -2569,7 +2569,7 @@
 			glEnable(GL_LIGHTING);
 			glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
 
-			dm->drawFacesSolid(dm, paint_redraw_planes, GPU_enable_material, fast_navigate);
+			dm->drawFacesSolid(dm, paint_redraw_planes, GPU_enable_material, fast_navigate|DM_DRAW_PAINT_MASK);
 
 			GPU_disable_material();
 
@@ -2604,7 +2604,7 @@

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list