[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15155] branches/apricot/source/blender: evil tri-count stats, game people want, counts tri's while drawing, but no other fast way to do this.

Campbell Barton ideasman42 at gmail.com
Sun Jun 8 03:00:17 CEST 2008


Revision: 15155
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15155
Author:   campbellbarton
Date:     2008-06-08 03:00:09 +0200 (Sun, 08 Jun 2008)

Log Message:
-----------
evil tri-count stats, game people want, counts tri's while drawing, but no other fast way to do this.

Modified Paths:
--------------
    branches/apricot/source/blender/blenkernel/BKE_global.h
    branches/apricot/source/blender/blenkernel/intern/DerivedMesh.c
    branches/apricot/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/apricot/source/blender/src/drawobject.c
    branches/apricot/source/blender/src/drawview.c
    branches/apricot/source/blender/src/header_info.c

Modified: branches/apricot/source/blender/blenkernel/BKE_global.h
===================================================================
--- branches/apricot/source/blender/blenkernel/BKE_global.h	2008-06-07 22:44:18 UTC (rev 15154)
+++ branches/apricot/source/blender/blenkernel/BKE_global.h	2008-06-08 01:00:09 UTC (rev 15155)
@@ -260,8 +260,13 @@
 /* Memory is allocated where? blender.c */
 extern Global G;
 
-#define TOTTRI_INC(isquad) G.tottri += (isquad ? 2:1)
+#define TOTTRI_INC(isquad) if (G.tottri>=1) {G.tottri += (isquad ? 2:1);}
+#define TOTTRI_ENABLE (G.tottri = abs(G.tottri))
+#define TOTTRI_DISABLE (G.tottri = -abs(G.tottri))
+#define TOTTRI_BEGIN (G.tottri = 1)
+#define TOTTRI_VALUE (abs(G.tottri)-1)
 
+
 #ifdef __cplusplus
 }
 #endif

Modified: branches/apricot/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/DerivedMesh.c	2008-06-07 22:44:18 UTC (rev 15154)
+++ branches/apricot/source/blender/blenkernel/intern/DerivedMesh.c	2008-06-08 01:00:09 UTC (rev 15155)
@@ -648,6 +648,9 @@
 			int drawSmooth = (efa->flag & ME_SMOOTH);
 			draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, i, &drawSmooth);
 			if(draw) {
+			
+				TOTTRI_INC(efa->v4);
+				
 				if (draw==2) { /* enabled with stipple */
 		  			glEnable(GL_POLYGON_STIPPLE);
 		  			glPolygonStipple(stipple_quarttone);
@@ -685,6 +688,9 @@
 			int drawSmooth = (efa->flag & ME_SMOOTH);
 			draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, i, &drawSmooth);
 			if(draw) {
+				
+				TOTTRI_INC(efa->v4);
+				
 				if (draw==2) { /* enabled with stipple */
 		  			glEnable(GL_POLYGON_STIPPLE);
 		  			glPolygonStipple(stipple_quarttone);
@@ -756,6 +762,8 @@
 
 			if(flag != 0) { /* flag 0 == the face is hidden or invisible */
 				
+				TOTTRI_INC(efa->v4);
+				
 				/* we always want smooth here since otherwise vertex colors dont interpolate */
 				if (mcol) {
 					if (flag==1) {
@@ -828,6 +836,9 @@
 				flag= 1;
 
 			if(flag != 0) { /* flag 0 == the face is hidden or invisible */
+			
+				TOTTRI_INC(efa->v4);
+			
 				/* we always want smooth here since otherwise vertex colors dont interpolate */
 				if (mcol) {
 					if (flag==1) {
@@ -955,6 +966,9 @@
 		}
 
 		if(dodraw) {
+			
+			TOTTRI_INC(efa->v4);
+			
 			glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
 			if (!drawSmooth) {
 				if(vertexCos) glNormal3fv(emdm->faceNos[i]);
@@ -1724,6 +1738,9 @@
 
 	glShadeModel(GL_FLAT);
 	while(vface) {
+		
+		TOTTRI_INC(vface->vvert3);
+		
 		glBegin(vface->vvert3?GL_QUADS:GL_TRIANGLES);
 		glNormal3fv(vface->no);
 		glVertex3fv(vdm->vertexCos ? vface->vvert0->cos : vface->vvert0->co);
@@ -1747,6 +1764,9 @@
 	vface = vdm->polygon_layer->dl.lb.first;
 
 	while(vface) {
+		
+		TOTTRI_INC(vface->vvert3);
+	
 		glBegin(vface->vvert3?GL_QUADS:GL_TRIANGLES);
 		glVertex3fv(vdm->vertexCos ? vface->vvert0->cos : vface->vvert0->co);
 		glVertex3fv(vdm->vertexCos ? vface->vvert1->cos : vface->vvert1->co);
@@ -1771,6 +1791,9 @@
 	vface = vdm->polygon_layer->dl.lb.first;
 
 	while(vface) {
+	
+		TOTTRI_INC(vface->vvert3);
+	
 		glBegin(vface->vvert3?GL_QUADS:GL_TRIANGLES);
 		glVertex3fv(vdm->vertexCos ? vface->vvert0->cos : vface->vvert0->co);
 		glVertex3fv(vdm->vertexCos ? vface->vvert1->cos : vface->vvert1->co);

Modified: branches/apricot/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/cdderivedmesh.c	2008-06-07 22:44:18 UTC (rev 15154)
+++ branches/apricot/source/blender/blenkernel/intern/cdderivedmesh.c	2008-06-08 01:00:09 UTC (rev 15155)
@@ -314,6 +314,9 @@
 			if(mface->v4) {
 				PASSVERT(mface->v4);
 			}
+			
+			TOTTRI_INC(mface->v4);
+			
 		}
 
 		if(nors) nors += 3;
@@ -380,6 +383,9 @@
 			}
 		}
 		if(col2) cp2 += 16;
+		
+		TOTTRI_INC(mface->v4);
+		
 	}
 	glEnd();
 
@@ -421,6 +427,9 @@
 		}
 		
 		if(flag != 0) { /* if the flag is 0 it means the face is hidden or invisible */
+		
+			TOTTRI_INC(mf->v4);
+		
 			if (flag==1 && mcol)
 				cp= (unsigned char*) &mcol[i*4];
 
@@ -469,6 +478,9 @@
 				if(mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
 				glVertex3fv(mvert->co);
 			}
+			
+			TOTTRI_INC(mf->v4);
+			
 			glEnd();
 		}
 		
@@ -503,7 +515,9 @@
 
 		if(!setDrawOptions || setDrawOptions(userData, orig, &drawSmooth)) {
 			unsigned char *cp = NULL;
-
+	
+			TOTTRI_INC(mf->v4);
+	
 			if(useColors && mc)
 				cp = (unsigned char *)&mc[i * 4];
 
@@ -556,6 +570,8 @@
 			}
 
 			glEnd();
+
+			TOTTRI_INC(mf->v4);
 		}
 		
 		if (nors) nors += 3;
@@ -660,6 +676,8 @@
 			PASSVERT(mface->v4, 3)
 		else
 			PASSVERT(mface->v3, 2)
+		
+		TOTTRI_INC(mface->v4);
 
 #undef PASSVERT
 	}

Modified: branches/apricot/source/blender/src/drawobject.c
===================================================================
--- branches/apricot/source/blender/src/drawobject.c	2008-06-07 22:44:18 UTC (rev 15154)
+++ branches/apricot/source/blender/src/drawobject.c	2008-06-08 01:00:09 UTC (rev 15155)
@@ -1705,7 +1705,9 @@
 	data.cols[2] = actCol;
 	data.efa_act = efa_act;
 	
+	TOTTRI_DISABLE;
 	dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, &data, 0);
+	TOTTRI_ENABLE;
 }
 
 static int draw_dm_creases__setDrawOptions(void *userData, int index)

Modified: branches/apricot/source/blender/src/drawview.c
===================================================================
--- branches/apricot/source/blender/src/drawview.c	2008-06-07 22:44:18 UTC (rev 15154)
+++ branches/apricot/source/blender/src/drawview.c	2008-06-08 01:00:09 UTC (rev 15155)
@@ -3095,6 +3095,7 @@
 	if(v3d->flag & V3D_CLIPPING)
 		view3d_set_clipping(v3d);
 	
+	TOTTRI_BEGIN;
 	/* draw set first */
 	if(G.scene->set) {
 		for(SETLOOPER(G.scene->set, base)) {
@@ -3126,12 +3127,14 @@
 			}
 		}
 	}
+	TOTTRI_DISABLE;
 
 	retopo= retopo_mesh_check() || retopo_curve_check();
 	sculptparticle= (G.f & (G_SCULPTMODE|G_PARTICLEEDIT)) && !G.obedit;
 	if(retopo)
 		view3d_update_depths(v3d);
 
+	TOTTRI_ENABLE;
 	/* draw selected and editmode */
 	for(base= G.scene->base.first; base; base= base->next) {
 		if(v3d->lay & base->lay) {
@@ -3139,6 +3142,7 @@
 				draw_object(base, 0);
 		}
 	}
+	TOTTRI_DISABLE;
 
 	if(!retopo && sculptparticle && !(obact && (obact->dtx & OB_DRAWXRAY))) {
 		if(G.f & G_SCULPTMODE)
@@ -3155,10 +3159,14 @@
 
 	if(G.scene->radio) RAD_drawall(v3d->drawtype>=OB_SOLID);
 	
+
+	TOTTRI_ENABLE;	
 	/* Transp and X-ray afterdraw stuff */
 	view3d_draw_xray(v3d);	// clears zbuffer if it is used!
 	view3d_draw_transp(v3d);
+	TOTTRI_DISABLE;	
 
+
 	if(!retopo && sculptparticle && (obact && (OBACT->dtx & OB_DRAWXRAY))) {
 		if(G.f & G_SCULPTMODE)
 			draw_sculpt_depths(v3d);

Modified: branches/apricot/source/blender/src/header_info.c
===================================================================
--- branches/apricot/source/blender/src/header_info.c	2008-06-07 22:44:18 UTC (rev 15154)
+++ branches/apricot/source/blender/src/header_info.c	2008-06-08 01:00:09 UTC (rev 15155)
@@ -2084,13 +2084,13 @@
 		s+= sprintf(s, "%s", G.editModeTitleExtra);
 		if(G.obedit->type==OB_MESH) {
 			if(G.scene->selectmode & SCE_SELECT_VERTEX)
-				s+= sprintf(s,"Ve:%d-%d | Ed:%d-%d | Fa:%d-%d",
-						G.totvertsel, G.totvert, G.totedgesel, G.totedge, G.totfacesel, G.totface);
+				s+= sprintf(s,"Ve:%d-%d | Ed:%d-%d | Fa:%d-%d | Tri:%d",
+						G.totvertsel, G.totvert, G.totedgesel, G.totedge, G.totfacesel, G.totface, TOTTRI_VALUE);
 			else if(G.scene->selectmode & SCE_SELECT_EDGE)
-				s+= sprintf(s,"Ed:%d-%d | Fa:%d-%d",
-						G.totedgesel, G.totedge, G.totfacesel, G.totface);
+				s+= sprintf(s,"Ed:%d-%d | Fa:%d-%d | Tri:%d",
+						G.totedgesel, G.totedge, G.totfacesel, G.totface, TOTTRI_VALUE);
 			else 
-				s+= sprintf(s,"Fa:%d-%d", G.totfacesel, G.totface);
+				s+= sprintf(s,"Fa:%d-%d | Tri:%d", G.totfacesel, G.totface, TOTTRI_VALUE);
 		}
 		else if(G.obedit->type==OB_ARMATURE) {
 			s+= sprintf(s,"Ve:%d-%d | Bo:%d-%d", G.totvertsel, G.totvert, G.totbonesel, G.totbone);
@@ -2106,8 +2106,8 @@
 					G.totbonesel, G.totbone, memstr);
 	}
 	else {
-		sprintf(infostr,"Ve:%d | Fa:%d | Ob:%d-%d | La:%d %s | Time:%s | ",
-			G.totvert, G.totface, G.totobj, G.totobjsel, G.totlamp, memstr, info_time_str);
+		sprintf(infostr,"Ve:%d | Fa:%d | Tri:%d | Ob:%d-%d | La:%d %s | Time:%s | ",
+			G.totvert, G.totface, TOTTRI_VALUE, G.totobj, G.totobjsel, G.totlamp, memstr, info_time_str);
 	}
 	if(ob) {
 		strcat(infostr, ob->id.name+2);





More information about the Bf-blender-cvs mailing list