[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12106] trunk/blender/source/blender: made draw shadow work as it used to ( I didnt understand at first that this was to draw the subsurfed UV faces)

Campbell Barton cbarton at metavr.com
Sat Sep 22 17:32:09 CEST 2007


Revision: 12106
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12106
Author:   campbellbarton
Date:     2007-09-22 17:32:08 +0200 (Sat, 22 Sep 2007)

Log Message:
-----------
made draw shadow work as it used to (I didnt understand at first that this was to draw the subsurfed UV faces)

this is really slow, its unuseable on suzanne subdivided twice on my computer with 2.45 and trunk, this could be sped up however it would need to be subsurf spesific.

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

Modified: trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c	2007-09-22 08:34:40 UTC (rev 12105)
+++ trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c	2007-09-22 15:32:08 UTC (rev 12106)
@@ -1874,6 +1874,37 @@
 	ccgDM_drawFacesTex_common(dm, NULL, setDrawOptions, userData);
 }
 
+static void ccgDM_drawUVEdges(DerivedMesh *dm)
+{
+
+	MFace *mf = dm->getFaceArray(dm);
+	MTFace *tf = DM_get_face_data_layer(dm, CD_MTFACE);
+	int i;
+	
+	glBegin(GL_LINES);
+	for(i = 0; i < dm->numFaceData; i++, mf++, tf++) {
+		if(!(mf->flag&ME_HIDE)) {
+			glVertex2fv(tf->uv[0]);
+			glVertex2fv(tf->uv[1]);
+
+			glVertex2fv(tf->uv[1]);
+			glVertex2fv(tf->uv[2]);
+
+			if(!mf->v4) {
+				glVertex2fv(tf->uv[2]);
+				glVertex2fv(tf->uv[0]);
+			} else {
+				glVertex2fv(tf->uv[2]);
+				glVertex2fv(tf->uv[3]);
+
+				glVertex2fv(tf->uv[3]);
+				glVertex2fv(tf->uv[0]);
+			}
+		}
+	}
+	glEnd();
+}
+
 static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors) {
 	CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
 	CCGSubSurf *ss = ccgdm->ss;
@@ -2101,7 +2132,7 @@
 	ccgdm->dm.drawFacesTex = ccgDM_drawFacesTex;
 	ccgdm->dm.drawMappedFaces = ccgDM_drawMappedFaces;
 	ccgdm->dm.drawMappedFacesTex = ccgDM_drawMappedFacesTex;
-	/* todo: drawUVEdges */
+	ccgdm->dm.drawUVEdges = ccgDM_drawUVEdges;
 
 	ccgdm->dm.drawMappedEdgesInterp = ccgDM_drawMappedEdgesInterp;
 	ccgdm->dm.drawMappedEdges = ccgDM_drawMappedEdges;

Modified: trunk/blender/source/blender/src/drawimage.c
===================================================================
--- trunk/blender/source/blender/src/drawimage.c	2007-09-22 08:34:40 UTC (rev 12105)
+++ trunk/blender/source/blender/src/drawimage.c	2007-09-22 15:32:08 UTC (rev 12106)
@@ -454,7 +454,7 @@
 	EditFace *efa;
 	
 	char col1[4], col2[4];
-	float pointsize= BIF_GetThemeValuef(TH_VERTEX_SIZE);
+	float pointsize;
  	
 	if (!G.obedit || !CustomData_has_layer(&em->fdata, CD_MTFACE))
 		return;
@@ -464,36 +464,47 @@
 	glLoadIdentity();
 	
 	
-	if(G.sima->flag & SI_DRAWTOOL || G.sima->flag & SI_DRAWSHADOW) {
+	if(G.sima->flag & SI_DRAWTOOL) {
+		/* draws the grey mesh when painting */
 		glColor3ub(112, 112, 112);
 		for (efa= em->faces.first; efa; efa= efa->next) {
 			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-			if (SIMA_FACEDRAW_CHECK(efa, tface)) {
-				efa->tmp.p = tface;
-			} else {
-				glBegin(GL_LINE_LOOP);
-				glVertex2fv(tface->uv[0]);
-				glVertex2fv(tface->uv[1]);
-				glVertex2fv(tface->uv[2]);
-				if(efa->v4) glVertex2fv(tface->uv[3]);
-				glEnd();
-				
-				efa->tmp.p = NULL;
-			}
+			glBegin(GL_LINE_LOOP);
+			glVertex2fv(tface->uv[0]);
+			glVertex2fv(tface->uv[1]);
+			glVertex2fv(tface->uv[2]);
+			if(efa->v4) glVertex2fv(tface->uv[3]);
+			glEnd();
 		}
-		if(G.sima->flag & SI_DRAWTOOL)
-			return; /* only draw shadow mesh */
+		return; /* only draw shadow mesh */
+	} else if (G.sima->flag & SI_DRAWSHADOW) {
+		/* draw shadow mesh - this is the mesh with the modifier applied */
+		DerivedMesh *finalDM, *cageDM;
 		
-	} else {
-		/* would be nice to do this within a draw loop but most below are optional, so it would involve too many checks */
-		for (efa= em->faces.first; efa; efa= efa->next) {
-			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-			if (SIMA_FACEDRAW_CHECK(efa, tface)) {		
-				efa->tmp.p = tface;
-			} else {
-				efa->tmp.p = NULL;
-			}
+		glColor3ub(112, 112, 112);
+		if (G.editMesh->derivedFinal && G.editMesh->derivedFinal->drawUVEdges) {
+			G.editMesh->derivedFinal->drawUVEdges(G.editMesh->derivedFinal);
 		}
+			
+#if 0
+		DerivedMesh *finalDM, *cageDM;
+
+		/* draw final mesh with modifiers applied */
+		cageDM = editmesh_get_derived_cage_and_final(&finalDM, CD_MASK_BAREMESH | CD_MASK_MTFACE);
+		
+		if 		(finalDM->drawUVEdges &&
+				/* When sync selection is enabled, all faces are drawn (except for hidden)
+				 * so if cage is the same as the final, theres no point in drawing the shadowmesh. */
+				!((G.sima->flag & SI_SYNC_UVSEL && cageDM==finalDM))
+		) {
+			//glColor3ub(112, 112, 112);
+			//finalDM->drawUVEdges(finalDM);
+		}
+		
+		if (cageDM != finalDM)
+			cageDM->release(cageDM);
+		finalDM->release(finalDM);
+#endif
 	}
 	
 	/* draw transparent faces */
@@ -504,13 +515,8 @@
 		glEnable(GL_BLEND);
 		
 		for (efa= em->faces.first; efa; efa= efa->next) {
-			
-//			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-//			if (SIMA_FACEDRAW_CHECK(efa, tface)) {
-			
-			/*this is a shortcut to do the same as above but a faster for drawing */
-			if ((tface=(MTFace *)efa->tmp.p)) {
-			
+			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+			if (SIMA_FACEDRAW_CHECK(efa, tface)) {
 				if( SIMA_FACESEL_CHECK(efa, tface) )
 					glColor4ubv((GLubyte *)col2);
 				else
@@ -522,8 +528,21 @@
 					glVertex2fv(tface->uv[2]);
 					if(efa->v4) glVertex2fv(tface->uv[3]);
 				glEnd();
+				efa->tmp.p = tface;
+			} else {
+				efa->tmp.p = NULL;
 			}
 		}
+	} else {
+		/* would be nice to do this within a draw loop but most below are optional, so it would involve too many checks */
+		for (efa= em->faces.first; efa; efa= efa->next) {
+			tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+			if (SIMA_FACEDRAW_CHECK(efa, tface)) {		
+				efa->tmp.p = tface;
+			} else {
+				efa->tmp.p = NULL;
+			}
+		}
 		glDisable(GL_BLEND);
 	}
 
@@ -677,6 +696,7 @@
 
     /* unselected uv's */
 	BIF_ThemeColor(TH_VERTEX);
+	pointsize = BIF_GetThemeValuef(TH_VERTEX_SIZE);
 	glPointSize(pointsize);
 
 	bglBegin(GL_POINTS);





More information about the Bf-blender-cvs mailing list