diff options
author | James Canete <use.less01@gmail.com> | 2012-11-09 08:13:38 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-12 21:24:47 +0000 |
commit | 5538e347ce91d1037937248f700257d6ed69f1e6 (patch) | |
tree | b332b2e84ba5fe17a00c4d91002ea1e3ab05c774 /src | |
parent | 22ac32c7a43deb902455e76446af933eba834479 (diff) |
Fix bugs where some surfaces weren't merged and others were counted as merged in R_MergeLeafSurfaces().
Diffstat (limited to 'src')
-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; |