#6095: OpenGL2: Use areamask and leaf cluster for PVS when VIS is missing.

This commit is contained in:
SmileTheory 2014-03-19 17:59:07 -07:00
parent 67d9ecd070
commit b099255748
3 changed files with 13 additions and 36 deletions

View file

@ -600,8 +600,6 @@ static void R_LoadVisibility( lump_t *l ) {
byte *buf; byte *buf;
len = ( s_worldData.numClusters + 63 ) & ~63; len = ( s_worldData.numClusters + 63 ) & ~63;
s_worldData.novis = ri.Hunk_Alloc( len, h_low );
Com_Memset( s_worldData.novis, 0xff, len );
len = l->filelen; len = l->filelen;
if ( !len ) { if ( !len ) {

View file

@ -1181,8 +1181,6 @@ typedef struct {
int clusterBytes; int clusterBytes;
const byte *vis; // may be passed in by CM_LoadMap to save space const byte *vis; // may be passed in by CM_LoadMap to save space
byte *novis; // clusterBytes of 0xff
char *entityString; char *entityString;
char *entityParsePoint; char *entityParsePoint;
} world_t; } world_t;

View file

@ -644,7 +644,7 @@ R_ClusterPVS
*/ */
static const byte *R_ClusterPVS (int cluster) { static const byte *R_ClusterPVS (int cluster) {
if (!tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) { if (!tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) {
return tr.world->novis; return NULL;
} }
return tr.world->vis + cluster * tr.world->clusterBytes; return tr.world->vis + cluster * tr.world->clusterBytes;
@ -698,15 +698,13 @@ static void R_MarkLeaves (void) {
for(i = 0; i < MAX_VISCOUNTS; i++) for(i = 0; i < MAX_VISCOUNTS; i++)
{ {
if(tr.visClusters[i] == cluster) // if the areamask or r_showcluster was modified, invalidate all visclusters
// this caused doors to open into undrawn areas
if (tr.refdef.areamaskModified || r_showcluster->modified)
{ {
//tr.visIndex = i; tr.visClusters[i] = -2;
break;
} }
} else if(tr.visClusters[i] == cluster)
// if r_showcluster was just turned on, remark everything
if(i != MAX_VISCOUNTS && !tr.refdef.areamaskModified && !r_showcluster->modified)// && !r_dynamicBspOcclusionCulling->modified)
{ {
if(tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer) if(tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer)
{ {
@ -715,12 +713,6 @@ static void R_MarkLeaves (void) {
tr.visIndex = i; tr.visIndex = i;
return; return;
} }
// if the areamask was modified, invalidate all visclusters
// this caused doors to open into undrawn areas
if (tr.refdef.areamaskModified)
{
memset(tr.visClusters, -2, sizeof(tr.visClusters));
} }
tr.visIndex = (tr.visIndex + 1) % MAX_VISCOUNTS; tr.visIndex = (tr.visIndex + 1) % MAX_VISCOUNTS;
@ -734,17 +726,6 @@ static void R_MarkLeaves (void) {
} }
} }
// set all nodes to visible if there is no vis
// this caused some levels to simply not render
if (r_novis->integer || !tr.world->vis || tr.visClusters[tr.visIndex] == -1) {
for (i=0 ; i<tr.world->numnodes ; i++) {
if (tr.world->nodes[i].contents != CONTENTS_SOLID) {
tr.world->nodes[i].visCounts[tr.visIndex] = tr.visCounts[tr.visIndex];
}
}
return;
}
vis = R_ClusterPVS(tr.visClusters[tr.visIndex]); vis = R_ClusterPVS(tr.visClusters[tr.visIndex]);
for (i=0,leaf=tr.world->nodes ; i<tr.world->numnodes ; i++, leaf++) { for (i=0,leaf=tr.world->nodes ; i<tr.world->numnodes ; i++, leaf++) {
@ -754,7 +735,7 @@ static void R_MarkLeaves (void) {
} }
// check general pvs // check general pvs
if ( !(vis[cluster>>3] & (1<<(cluster&7))) ) { if ( vis && !(vis[cluster>>3] & (1<<(cluster&7))) ) {
continue; continue;
} }