From 5538e347ce91d1037937248f700257d6ed69f1e6 Mon Sep 17 00:00:00 2001 From: James Canete Date: Fri, 9 Nov 2012 08:13:38 +0000 Subject: Fix bugs where some surfaces weren't merged and others were counted as merged in R_MergeLeafSurfaces(). --- src/rend2/tr_bsp.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/rend2/tr_bsp.c b/src/rend2/tr_bsp.c index 390dbe42..c21a3264 100644 --- a/src/rend2/tr_bsp.c +++ b/src/rend2/tr_bsp.c @@ -2924,6 +2924,30 @@ void R_MergeLeafSurfaces(void) } } + // 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 @@ void R_MergeLeafSurfaces(void) 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 @@ void R_MergeLeafSurfaces(void) 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 @@ void R_MergeLeafSurfaces(void) // 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 @@ void R_MergeLeafSurfaces(void) 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; -- cgit