Source/ThunderBeast/QuakeToonProto1/ref_gl/gl_rsurf.c
void R_MarkLeaves (void)
{
	byte	*vis;
	byte	fatvis[MAX_MAP_LEAFS/8];
	mnode_t	*node;
	int		i, c;
	mleaf_t	*leaf;
	int		cluster;

	if (r_oldviewcluster == r_viewcluster && r_oldviewcluster2 == r_viewcluster2 && !r_novis->value && r_viewcluster != -1)
		return;

	// development aid to let you run around and see exactly where
	// the pvs ends
	if (gl_lockpvs->value)
		return;

	r_visframecount++;
	r_oldviewcluster = r_viewcluster;
	r_oldviewcluster2 = r_viewcluster2;

	if (r_novis->value || r_viewcluster == -1 || !r_worldmodel->vis)
	{
		// mark everything
		for (i=0 ; i<r_worldmodel->numleafs ; i++)
			r_worldmodel->leafs[i].visframe = r_visframecount;
		for (i=0 ; i<r_worldmodel->numnodes ; i++)
			r_worldmodel->nodes[i].visframe = r_visframecount;
		return;
	}

	vis = Mod_ClusterPVS (r_viewcluster, r_worldmodel);
	// may have to combine two clusters because of solid water boundaries
	if (r_viewcluster2 != r_viewcluster)
	{
		memcpy (fatvis, vis, (r_worldmodel->numleafs+7)/8);
		vis = Mod_ClusterPVS (r_viewcluster2, r_worldmodel);
		c = (r_worldmodel->numleafs+31)/32;
		for (i=0 ; i<c ; i++)
			((int *)fatvis)[i] |= ((int *)vis)[i];
		vis = fatvis;
	}
	
	for (i=0,leaf=r_worldmodel->leafs ; i<r_worldmodel->numleafs ; i++, leaf++)
	{
		cluster = leaf->cluster;
		if (cluster == -1)
			continue;
		if (vis[cluster>>3] & (1<<(cluster&7)))
		{
			node = (mnode_t *)leaf;
			do
			{
				if (node->visframe == r_visframecount)
					break;
				node->visframe = r_visframecount;
				node = node->parent;
			} while (node);
		}
	}

#if 0
	for (i=0 ; i<r_worldmodel->vis->numclusters ; i++)
	{
		if (vis[i>>3] & (1<<(i&7)))
		{
			node = (mnode_t *)&r_worldmodel->leafs[i];	// FIXME: cluster
			do
			{
				if (node->visframe == r_visframecount)
					break;
				node->visframe = r_visframecount;
				node = node->parent;
			} while (node);
		}
	}
#endif
}
/*
===============
R_MarkLeaves

Mark the leaves and nodes that are in the PVS for the current
cluster
===============
*/
R_MarkLeaves
Mark the leaves and nodes that are in the PVS for the current
cluster
R_MarkLeaves Mark the leaves and nodes that are in the PVS for the current cluster
void R_MarkLeaves (void)
{
	byte	*vis;
	byte	fatvis[MAX_MAP_LEAFS/8];
	mnode_t	*node;
	int		i, c;
	mleaf_t	*leaf;
	int		cluster;
	if (r_oldviewcluster == r_viewcluster && r_oldviewcluster2 == r_viewcluster2 && !r_novis->value && r_viewcluster != -1)
		return;
	if (gl_lockpvs->value)
		return;
	r_visframecount++;
	r_oldviewcluster = r_viewcluster;
	r_oldviewcluster2 = r_viewcluster2;
	if (r_novis->value || r_viewcluster == -1 || !r_worldmodel->vis)
	{
		for (i=0 ; i<r_worldmodel->numleafs ; i++)
			r_worldmodel->leafs[i].visframe = r_visframecount;
		for (i=0 ; i<r_worldmodel->numnodes ; i++)
			r_worldmodel->nodes[i].visframe = r_visframecount;
		return;
	}
	vis = Mod_ClusterPVS (r_viewcluster, r_worldmodel);
	if (r_viewcluster2 != r_viewcluster)
	{
		memcpy (fatvis, vis, (r_worldmodel->numleafs+7)/8);
		vis = Mod_ClusterPVS (r_viewcluster2, r_worldmodel);
		c = (r_worldmodel->numleafs+31)/32;
		for (i=0 ; i<c ; i++)
			((int *)fatvis)[i] |= ((int *)vis)[i];
		vis = fatvis;
	}
	for (i=0,leaf=r_worldmodel->leafs ; i<r_worldmodel->numleafs ; i++, leaf++)
	{
		cluster = leaf->cluster;
		if (cluster == -1)
			continue;
		if (vis[cluster>>3] & (1<<(cluster&7)))
		{
			node = (mnode_t *)leaf;
			do
			{
				if (node->visframe == r_visframecount)
					break;
				node->visframe = r_visframecount;
				node = node->parent;
			} while (node);
		}
	}
#if 0
	for (i=0 ; i<r_worldmodel->vis->numclusters ; i++)
	{
		if (vis[i>>3] & (1<<(i&7)))
		{
			node = (mnode_t *)&r_worldmodel->leafs[i];	
			do
			{
				if (node->visframe == r_visframecount)
					break;
				node->visframe = r_visframecount;
				node = node->parent;
			} while (node);
		}
	}
#endif
}
void R_MarkLeaves ( void ) { byte * vis ; byte fatvis [ MAX_MAP_LEAFS / 8 ] ; mnode_t * node ; int i , c ; mleaf_t * leaf ; int cluster ; if ( r_oldviewcluster == r_viewcluster && r_oldviewcluster2 == r_viewcluster2 && ! r_novis -> value && r_viewcluster != -1 ) return ; if ( gl_lockpvs -> value ) return ; r_visframecount ++ ; r_oldviewcluster = r_viewcluster ; r_oldviewcluster2 = r_viewcluster2 ; if ( r_novis -> value || r_viewcluster == -1 || ! r_worldmodel -> vis ) { for ( i = 0 ; i < r_worldmodel -> numleafs ; i ++ ) r_worldmodel -> leafs [ i ] . visframe = r_visframecount ; for ( i = 0 ; i < r_worldmodel -> numnodes ; i ++ ) r_worldmodel -> nodes [ i ] . visframe = r_visframecount ; return ; } vis = Mod_ClusterPVS ( r_viewcluster , r_worldmodel ) ; if ( r_viewcluster2 != r_viewcluster ) { memcpy ( fatvis , vis , ( r_worldmodel -> numleafs + 7 ) / 8 ) ; vis = Mod_ClusterPVS ( r_viewcluster2 , r_worldmodel ) ; c = ( r_worldmodel -> numleafs + 31 ) / 32 ; for ( i = 0 ; i < c ; i ++ ) ( ( int * ) fatvis ) [ i ] |= ( ( int * ) vis ) [ i ] ; vis = fatvis ; } for ( i = 0 , leaf = r_worldmodel -> leafs ; i < r_worldmodel -> numleafs ; i ++ , leaf ++ ) { cluster = leaf -> cluster ; if ( cluster == -1 ) continue ; if ( vis [ cluster >> 3 ] & ( 1 << ( cluster & 7 ) ) ) { node = ( mnode_t * ) leaf ; do { if ( node -> visframe == r_visframecount ) break ; node -> visframe = r_visframecount ; node = node -> parent ; } while ( node ) ; } } #if 0 for ( i = 0 ; i < r_worldmodel -> vis -> numclusters ; i ++ ) { if ( vis [ i >> 3 ] & ( 1 << ( i & 7 ) ) ) { node = ( mnode_t * ) & r_worldmodel -> leafs [ i ] ; do { if ( node -> visframe == r_visframecount ) break ; node -> visframe = r_visframecount ; node = node -> parent ; } while ( node ) ; } } #endif }
R_MarkLeaves
Mark the leaves and nodes that are in the PVS for the current
cluster
R_MarkLeaves Mark the leaves and nodes that are in the PVS for the current cluster
// development aid to let you run around and see exactly where // the pvs ends // mark everything // may have to combine two clusters because of solid water boundaries // FIXME: cluster