[quake3-commits] r2351 - trunk/code/rend2

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Nov 9 03:13:42 EST 2012


Author: smiletheory
Date: 2012-11-09 03:13:38 -0500 (Fri, 09 Nov 2012)
New Revision: 2351

Modified:
   trunk/code/rend2/tr_bsp.c
Log:
Fix bugs where some surfaces weren't merged and others were counted as merged in R_MergeLeafSurfaces().

Modified: trunk/code/rend2/tr_bsp.c
===================================================================
--- trunk/code/rend2/tr_bsp.c	2012-11-07 00:06:51 UTC (rev 2350)
+++ trunk/code/rend2/tr_bsp.c	2012-11-09 08:13:38 UTC (rev 2351)
@@ -2924,6 +2924,30 @@
 		}
 	}
 
+	// don't add surfaces that don't merge to any others to the merged list
+	for (i = 0; i < numWorldSurfaces; i++)
+	{
+		qboolean merges = qfalse;
+
+		if (s_worldData.surfacesViewCount[i] != i)
+			continue;
+
+		for (j = 0; j < numWorldSurfaces; j++)
+		{
+			if (j == i)
+				continue;
+
+			if (s_worldData.surfacesViewCount[j] == i)
+			{
+				merges = qtrue;
+				break;
+			}
+		}
+
+		if (!merges)
+			s_worldData.surfacesViewCount[i] = -1;
+	}	
+
 	// count merged/unmerged surfaces
 	numMergedSurfaces = 0;
 	numUnmergedSurfaces = 0;
@@ -2943,6 +2967,7 @@
 	s_worldData.mergedSurfaces = ri.Hunk_Alloc(sizeof(*s_worldData.mergedSurfaces) * numMergedSurfaces, h_low);
 	s_worldData.mergedSurfacesViewCount = ri.Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesViewCount) * numMergedSurfaces, h_low);
 	s_worldData.mergedSurfacesDlightBits = ri.Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesDlightBits) * numMergedSurfaces, h_low);
+	s_worldData.mergedSurfacesPshadowBits = ri.Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesPshadowBits) * numMergedSurfaces, h_low);
 	s_worldData.numMergedSurfaces = numMergedSurfaces;
 	
 	// view surfaces are like mark surfaces, except negative ones represent merged surfaces
@@ -2981,7 +3006,7 @@
 		numSurfsToMerge = 0;
 		numTriangles = 0;
 		numVerts = 0;
-		for (j = i; j < numWorldSurfaces; j++)
+		for (j = 0; j < numWorldSurfaces; j++)
 		{
 			msurface_t *surf2;
 
@@ -3037,7 +3062,7 @@
 		// Merge surfaces (indexes) and calculate bounds
 		ClearBounds(bounds[0], bounds[1]);
 		firstIndex = numIboIndexes;
-		for (j = i; j < numWorldSurfaces; j++)
+		for (j = 0; j < numWorldSurfaces; j++)
 		{
 			msurface_t *surf2;
 
@@ -3140,7 +3165,7 @@
 		mergedSurf->shader        = surf1->shader;
 
 		// redirect view surfaces to this surf
-		for (j = i; j < numWorldSurfaces; j++)
+		for (j = 0; j < numWorldSurfaces; j++)
 		{
 			if (s_worldData.surfacesViewCount[j] != i)
 				continue;



More information about the quake3-commits mailing list