diff options
-rw-r--r-- | src/rend2/tr_bsp.c | 31 |
1 files changed, 28 insertions, 3 deletions
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; |