[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29400] trunk/blender/source/blender/ blenkernel/intern: Fixed bug #21348, Hide selection in Edit Mode not working with some modifiers (VBOs)

Nicholas Bishop nicholasbishop at gmail.com
Fri Jun 11 09:57:44 CEST 2010


Revision: 29400
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29400
Author:   nicholasbishop
Date:     2010-06-11 09:57:43 +0200 (Fri, 11 Jun 2010)

Log Message:
-----------
Fixed bug #21348, Hide selection in Edit Mode not working with some modifiers (VBOs)

Was actually a couple bugs:
* VBO bug was that hidden faces weren't being skipped correctly. Fixed that and rewrote this bit of VBO drawing code more clearly (less duplication, less unecessary state, and comments even)
* Second bug was that CCGDerivedMesh wasn't outputing ORIGINDEX data for faces. (it's not doing it for edges or verts either, but I don't know that we need it to.) At any rate, we do need this data for faces so that additional DerivedMeshes on top of subsurf know what faces in the editmesh are hidden.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c
    trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c

Modified: trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c	2010-06-11 03:08:27 UTC (rev 29399)
+++ trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c	2010-06-11 07:57:43 UTC (rev 29400)
@@ -853,48 +853,42 @@
 		}
 	}
 	else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
-		int state = 1;
-		int prevstate = 1;
 		int prevstart = 0;
 		GPU_vertex_setup(dm);
 		GPU_normal_setup(dm);
 		if( useColors && mc )
 			GPU_color_setup(dm);
 		if( !GPU_buffer_legacy(dm) ) {
+			int tottri = dm->drawObject->nelements/3;
 			glShadeModel(GL_SMOOTH);
-			for( i = 0; i < dm->drawObject->nelements/3; i++ ) {
+
+			for( i = 0; i < tottri; i++ ) {
 				int actualFace = dm->drawObject->faceRemap[i];
 				int drawSmooth = (mf[actualFace].flag & ME_SMOOTH);
-				int dontdraw = 0;
+				int draw = 1;
+
 				if(index) {
 					orig = index[actualFace];
 					if(setDrawOptions && orig == ORIGINDEX_NONE)
-						dontdraw = 1;
+						draw = 0;
 				}
 				else
 					orig = actualFace;
-				if( dontdraw ) {
-					state = 0;
+
+				if(setDrawOptions && !setDrawOptions(userData, orig, &drawSmooth))
+					draw = 0;
+
+				/* Goal is to draw as long of a contiguous triangle
+				   array as possible, so draw when we hit either an
+				   invisible triangle or at the end of the array */
+				if(!draw || i == tottri - 1) {
+					if(prevstart != i)
+						/* Add one to the length (via `draw')
+						   if we're drawing at the end of the array */
+						glDrawArrays(GL_TRIANGLES,prevstart*3, (i-prevstart+draw)*3);
+					prevstart = i + 1;
 				}
-				else {
-					if(!setDrawOptions || setDrawOptions(userData, orig, &drawSmooth)) {
-						state = 1;
-					}
-					else {
-						state = 0;
-					}
-				}
-				if( prevstate != state && prevstate == 1 ) {
-					if( i-prevstart > 0 ) {
-						glDrawArrays(GL_TRIANGLES,prevstart*3,(i-prevstart)*3);
-					}
-					prevstart = i;
-				}
-				prevstate = state;
 			}
-			if(state==1) {
-				glDrawArrays(GL_TRIANGLES,prevstart*3,dm->drawObject->nelements-prevstart*3);
-			}
 			glShadeModel(GL_FLAT);
 		}
 		GPU_buffer_unbind();

Modified: trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c	2010-06-11 03:08:27 UTC (rev 29399)
+++ trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c	2010-06-11 07:57:43 UTC (rev 29400)
@@ -2328,6 +2328,7 @@
 	int gridInternalEdges;
 	MEdge *medge = NULL;
 	MFace *mface = NULL;
+	int *orig_indices;
 	FaceVertWeight *qweight, *tweight;
 
 	DM_from_template(&ccgdm->dm, dm, DM_TYPE_CCGDM,
@@ -2437,6 +2438,7 @@
 
 	faceFlags = ccgdm->faceFlags = MEM_callocN(sizeof(char)*2*totface, "faceFlags");
 
+	orig_indices = (int*)ccgdm->dm.getFaceDataArray(&ccgdm->dm, CD_ORIGINDEX);
 	for(index = 0; index < totface; ++index) {
 		CCGFace *f = ccgdm->faceMap[index].face;
 		int numVerts = ccgSubSurf_getFaceNumVerts(f);
@@ -2450,6 +2452,9 @@
 		ccgdm->faceMap[index].startEdge = edgeNum;
 		ccgdm->faceMap[index].startFace = faceNum;
 
+		if(orig_indices)
+			orig_indices[faceNum] = origIndex;
+
 		/* set the face base vert */
 		*((int*)ccgSubSurf_getFaceUserData(ss, f)) = vertNum;
 





More information about the Bf-blender-cvs mailing list