On 2/22/07, The Watermelon <[EMAIL PROTECTED]> wrote:
3.another odd issue that kills the performance is that you cannot add all
polygons of a shape to a triangle list and draw the list instead of drawing
the polygons separately,because the shape will be very facked up if you do
so,maybe the pie's by pumpkin didnt use triangle face(which is used in
almost all rts games) when creating models...

Yeah, it looks like they screwed up polygon facing for non-terrain
polygons. Take a look at the comment in pie_DrawPoly() in
lib/ivis_opengl/piedraw.c. Backface culling is on by default, but
whenever a regular pie is drawn, it is turned off first...

The attached patch should make the code easier to understand and
optimize. (BSP_BACKFACECULL is never used. I wonder what it was meant
for.)

 - Per
Index: src/display3d.c
===================================================================
--- src/display3d.c	(revision 801)
+++ src/display3d.c	(working copy)
@@ -4812,7 +4812,7 @@
 			aVrts[2].sy = tileScreenInfo[i + 1][j + 0].water_height;
 			aVrts[2].sz = tileScreenInfo[i + 1][j + 0].z;
 		}
-		pie_DrawPoly(3, aVrts, tileTexInfo[tileNumber & TILE_NUMMASK].texPage, NULL);
+		pie_DrawTexTriangle(aVrts, tileTexInfo[tileNumber & TILE_NUMMASK].texPage, NULL);
 	}
 	else
 	{
@@ -4830,7 +4830,7 @@
 			aVrts[2].sy = tileScreenInfo[i + 1][j + 1].water_height;
 			aVrts[2].sz = tileScreenInfo[i + 1][j + 1].z;
 		}
-		pie_DrawPoly(3, aVrts, tileTexInfo[tileNumber & TILE_NUMMASK].texPage, NULL);
+		pie_DrawTexTriangle(aVrts, tileTexInfo[tileNumber & TILE_NUMMASK].texPage, NULL);
 	}
 
 	/* The second triangle */
@@ -4851,7 +4851,7 @@
 			aVrts[2].sy = tileScreenInfo[i + 1][j + 0].water_height;
 			aVrts[2].sz = tileScreenInfo[i + 1][j + 0].z;
 		}
-		pie_DrawPoly(3, aVrts, tileTexInfo[tileNumber & TILE_NUMMASK].texPage, NULL);
+		pie_DrawTexTriangle(aVrts, tileTexInfo[tileNumber & TILE_NUMMASK].texPage, NULL);
 	}
 	else
 	{
@@ -4870,7 +4870,7 @@
 			aVrts[2].sy = tileScreenInfo[i+1][j+0].water_height;
 			aVrts[2].sz = tileScreenInfo[i+1][j+0].z;
 		}
-		pie_DrawPoly(3, aVrts, tileTexInfo[tileNumber & TILE_NUMMASK].texPage, NULL);
+		pie_DrawTexTriangle(aVrts, tileTexInfo[tileNumber & TILE_NUMMASK].texPage, NULL);
 	}
 
 	/* Outline the tile if necessary */
@@ -4976,7 +4976,7 @@
 		aVrts[2].light = tileScreenInfo[i+1][j+1].wlight;
 		aVrts[2].light.byte.a = WATER_ALPHA_LEVEL;
 
-		pie_DrawPoly(3, aVrts, tileTexInfo[tileNumber & TILE_NUMMASK].texPage, &waterRealValue);//jps 15 apr99
+		pie_DrawTexTriangle(aVrts, tileTexInfo[tileNumber & TILE_NUMMASK].texPage, &waterRealValue);//jps 15 apr99
 
 		memcpy(&aVrts[1],&aVrts[2],sizeof(PIEVERTEX));
 
@@ -4987,7 +4987,7 @@
 		aVrts[2].light = tileScreenInfo[i+1][j+0].wlight;
 		aVrts[2].light.byte.a = WATER_ALPHA_LEVEL;
 
-		pie_DrawPoly(3, aVrts, tileTexInfo[tileNumber & TILE_NUMMASK].texPage, &waterRealValue);//jps 15 apr99
+		pie_DrawTexTriangle(aVrts, tileTexInfo[tileNumber & TILE_NUMMASK].texPage, &waterRealValue);//jps 15 apr99
 
 		if( (psTile->texture & TILE_NUMMASK) != WaterTileID) {
 			drawTerrainTile(i,j, TRUE);
Index: lib/ivis_common/piedef.h
===================================================================
--- lib/ivis_common/piedef.h	(revision 799)
+++ lib/ivis_common/piedef.h	(working copy)
@@ -192,7 +192,7 @@
 extern void pie_DrawImage270( PIEIMAGE *image, PIERECT *dest );
 
 void pie_DrawTriangle( iVertex *pv );
-extern void pie_DrawPoly(SDWORD numVrts, PIEVERTEX *aVrts, SDWORD texPage, void* psEffects);
+extern void pie_DrawTexTriangle(PIEVERTEX *aVrts, SDWORD texPage, void* psEffects);
 
 extern void pie_GetResetCounts(SDWORD* pPieCount, SDWORD* pTileCount, SDWORD* pPolyCount, SDWORD* pStateCount);
 
Index: lib/ivis_opengl/bspimd.c
===================================================================
--- lib/ivis_opengl/bspimd.c	(revision 799)
+++ lib/ivis_opengl/bspimd.c	(working copy)
@@ -40,8 +40,6 @@
 
 #ifdef BSPIMD		// covers the whole file
 
-#define BSP_BACKFACECULL	// if defined we perform the backface cull in the BSP (we get this for free (!))
-
 //#define BSP_MAXDEBUG		// define this if you want max debug options (runs very slow)
 
 #include "lib/ivis_common/bspimd.h"
Index: lib/ivis_opengl/piedraw.c
===================================================================
--- lib/ivis_opengl/piedraw.c	(revision 799)
+++ lib/ivis_opengl/piedraw.c	(working copy)
@@ -958,9 +958,10 @@
 	glEnd();
 }
 
-void pie_DrawPoly(SDWORD numVrts, PIEVERTEX *aVrts, SDWORD texPage, void* psEffects)
+void pie_DrawTexTriangle(PIEVERTEX *aVrts, SDWORD texPage, void* psEffects)
 {
-	FRACT		offset = 0;
+	GLfloat	offset = 0;
+	int i;
 
 	/*	Since this is only used from within source for the terrain draw - we can backface cull the
 		polygons.
@@ -968,22 +969,29 @@
 	tileCount++;
 	pie_SetTexturePage(texPage);
 	pie_SetFogStatus(TRUE);
-	if (psEffects == NULL)//jps 15apr99 translucent water code
+	if (psEffects == NULL)
 	{
-		pie_SetRendMode(REND_GOURAUD_TEX);//jps 15apr99 old solid water code
+		/* Solid terrain */
+		pie_SetRendMode(REND_GOURAUD_TEX);
 		pie_SetColourKeyedBlack(TRUE);
 	}
-	else//jps 15apr99 translucent water code
+	else
 	{
-		pie_SetRendMode(REND_ALPHA_TEX);//jps 15apr99 old solid water code
+		/* Translucent water with animation */
+		pie_SetRendMode(REND_ALPHA_TEX);
 		pie_SetColourKeyedBlack(FALSE);
-		offset = *((float*)psEffects);
+		offset = *((GLfloat*)psEffects);
 	}
 	pie_SetBilinear(TRUE);
 
-	if (numVrts >= 3) {
-		pie_Polygon(numVrts, aVrts, offset, FALSE);
+	glBegin(GL_TRIANGLE_FAN);
+	for ( i = 0; i < 3; i++ )
+	{
+		glColor4ub( aVrts[i].light.byte.r, aVrts[i].light.byte.g, aVrts[i].light.byte.b, aVrts[i].light.byte.a );
+		glTexCoord2f( aVrts[i].tu, aVrts[i].tv + offset );
+		glVertex3f( aVrts[i].sx, aVrts[i].sy, aVrts[i].sz );
 	}
+	glEnd();
 }
 
 void pie_GetResetCounts(SDWORD* pPieCount, SDWORD* pTileCount, SDWORD* pPolyCount, SDWORD* pStateCount)
_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev

Reply via email to