Example #1
0
/*
   ==================
   CalcVis
   ==================
 */
void CalcVis( void ){
	int i;
	const char  *value;


	/* ydnar: rr2do2's farplane code */
	farPlaneDist = 0.0f;
	value = ValueForKey( &entities[ 0 ], "_farplanedist" );     /* proper '_' prefixed key */
	if ( value[ 0 ] == '\0' ) {
		value = ValueForKey( &entities[ 0 ], "fogclip" );       /* wolf compatibility */
	}
	if ( value[ 0 ] == '\0' ) {
		value = ValueForKey( &entities[ 0 ], "distancecull" );  /* sof2 compatibility */
	}
	if ( value[ 0 ] != '\0' ) {
		farPlaneDist = atof( value );
		if ( farPlaneDist > 0.0f ) {
			Sys_Printf( "farplane distance = %.1f\n", farPlaneDist );
		}
		else{
			farPlaneDist = 0.0f;
		}
	}



	Sys_Printf( "\n--- BasePortalVis (%d) ---\n", numportals * 2 );
	RunThreadsOnIndividual( numportals * 2, qtrue, BasePortalVis );

//	RunThreadsOnIndividual (numportals*2, qtrue, BetterPortalVis);

	SortPortals();

	if ( fastvis ) {
		CalcFastVis();
	}
	else if ( noPassageVis ) {
		CalcPortalVis();
	}
	else if ( passageVisOnly ) {
		CalcPassageVis();
	}
	else {
		CalcPassagePortalVis();
	}
	//
	// assemble the leaf vis lists by oring and compressing the portal lists
	//
	Sys_Printf( "creating leaf vis...\n" );
	for ( i = 0 ; i < portalclusters ; i++ )
		ClusterMerge( i );

	Sys_Printf( "Total visible clusters: %i\n", totalvis );
	Sys_Printf( "Average clusters visible: %i\n", totalvis / portalclusters );
}
Example #2
0
/*
==================
CalcVis
==================
*/
void CalcVis (void)
{
	int		i;
	
	RunThreadsOn (numportals*2, true, BasePortalVis);
	
	CalcPortalVis ();

//
// assemble the leaf vis lists by oring and compressing the portal lists
//
	for (i=0 ; i<portalleafs ; i++)
		LeafFlow (i);
		
	printf ("average leafs visible: %i\n", totalvis / portalleafs);
}
Example #3
0
File: vis.c Project: qbism/super8
/*
==================
CalcVis
==================
*/
void CalcVis (void)
{
    int		i;

    BasePortalVis ();

    CalcPortalVis ();

//
// assemble the leaf vis lists by oring and compressing the portal lists
//
    for (i=0 ; i<portalleafs ; i++)
        LeafFlow (i);

    printf ("average leafs visible: %i\n", totalvis / portalleafs);
    fflush(stdout);
}
Example #4
0
static void
CalcVis (void)
{
	int         i;

	BasePortalVis ();
	CalcPortalVis ();

	// assemble the leaf vis lists by oring and compressing the portal lists
	for (i = 0; i < portalclusters; i++)
		ClusterFlow (i);

	for (i = 0; i < numrealleafs; i++) {
		bsp->leafs[i + 1].visofs = clusters[leafcluster[i]].visofs;
	}
	if (options.verbosity >= 0)
		printf ("average clusters visible: %i\n", totalvis / portalclusters);
}
Example #5
0
/*
==================
CalcVis
==================
*/
void CalcVis (void)
{
	int		i;

	RunThreadsOn (numportals*2, true, BasePortalVis);

	SortPortals ();
	
	CalcPortalVis ();

//
// assemble the leaf vis lists by oring and compressing the portal lists
//
	for (i=0 ; i<portalclusters ; i++)
		ClusterMerge (i);
		
	Con_Print("Average clusters visible: %i\n", totalvis / portalclusters);
}
Example #6
0
/*
==================
CalcVis
==================
*/
void CalcVis (void)
{
	int		i;
	
    // For each portal, populate portals->mightsee (containing the leafs it might see).
    // There may be false positive in the set but no false negative
	BasePortalVis ();
	
    // At this point mightsee has been populated, let the serious things begin.
    // Note that the next method takes advantage of Multi-processor machine via multithreading.
	CalcPortalVis ();

//
// assemble the leaf vis lists by oring and compressing the portal lists
//
	for (i=0 ; i<portalleafs ; i++)
		LeafFlow (i);
		
	printf ("average leafs visible: %i\n", totalvis / portalleafs);
}
Example #7
0
/*
  ==================
  CalcVis
  ==================
*/
void
CalcVis(const bsp2_t *bsp)
{
    int i;

    if (LoadVisState()) {
        logprint("Loaded previous state. Resuming progress...\n");
    } else {
        logprint("Calculating Base Vis:\n");
        BasePortalVis();
    }

    logprint("Calculating Full Vis:\n");
    CalcPortalVis(bsp);

//
// assemble the leaf vis lists by oring and compressing the portal lists
//
    if (portalleafs == portalleafs_real) {
        for (i = 0; i < portalleafs; i++)
            LeafFlow(i, &bsp->dleafs[i + 1]);
    } else {
        leafbits_t *buffer;

        logprint("Expanding clusters...\n");
        buffer = malloc(LeafbitsSize(portalleafs));
        for (i = 0; i < portalleafs; i++) {
            memset(buffer, 0, LeafbitsSize(portalleafs));
            ClusterFlow(i, buffer);
        }
        free(buffer);
        
        // Set pointers
        for (i = 0; i < portalleafs_real; i++) {
            bsp->dleafs[i + 1].visofs = leafs[clustermap[i]].visofs;
        }
    }

    logprint("average leafs visible: %i\n", totalvis / portalleafs_real);
}
Example #8
0
/*
==================
CalcVis
==================
*/
void CalcVis (void)
{
    int		i;

    if (g_bUseMPI)
    {
        RunMPIBasePortalVis();
    }
    else
    {
        RunThreadsOnIndividual (g_numportals*2, true, BasePortalVis);
    }

    SortPortals ();

    CalcPortalVis ();

    //
    // assemble the leaf vis lists by oring the portal lists
    //
    for ( i = 0; i < portalclusters; i++ )
    {
        ClusterMerge( i );
    }

    int count = 0;
    // Now crosscheck each leaf's vis and compress
    for ( i = 0; i < portalclusters; i++ )
    {
        count += CompressAndCrosscheckClusterVis( i );
    }


    Msg ("Optimized: %d visible clusters (%.2f%%)\n", count, totalvis, count*100/totalvis);
    Msg ("Total clusters visible: %i\n", totalvis);
    Msg ("Average clusters visible: %i\n", totalvis / portalclusters);
}
Example #9
0
/*
==================
CalcVis
==================
*/
void CalcVis(void)
{
	int             i, minvis, maxvis;
	const char     *value;
	double          mu, sigma, totalvis, totalvis2;


	/* ydnar: rr2do2's farplane code */
	farPlaneDist = 0.0f;
	value = ValueForKey(&entities[0], "_farplanedist");	/* proper '_' prefixed key */
	if(value[0] == '\0')
		value = ValueForKey(&entities[0], "fogclip");	/* wolf compatibility */
	if(value[0] == '\0')
		value = ValueForKey(&entities[0], "distancecull");	/* sof2 compatibility */
	if(value[0] != '\0')
	{
		farPlaneDist = atof(value);
		if(farPlaneDist > 0.0f)
			Sys_Printf("farplane distance = %.1f\n", farPlaneDist);
		else
			farPlaneDist = 0.0f;
	}



	Sys_Printf("\n--- BasePortalVis (%d) ---\n", numportals * 2);
	RunThreadsOnIndividual(numportals * 2, qtrue, BasePortalVis);

//  RunThreadsOnIndividual (numportals*2, qtrue, BetterPortalVis);

	SortPortals();

	if(fastvis)
	{
		CalcFastVis();
	}
	else if(noPassageVis)
	{
		CalcPortalVis();
	}
	else if(passageVisOnly)
	{
		CalcPassageVis();
	}
	else
	{
		CalcPassagePortalVis();
	}
	//
	// assemble the leaf vis lists by oring and compressing the portal lists
	//
	Sys_Printf("creating leaf vis...\n");
	for(i = 0; i < portalclusters; i++)
		ClusterMerge(i);

	totalvis = 0;
	totalvis2 = 0;
	minvis = -1;
	maxvis = -1;
	for(i = 0; i < MAX_MAP_LEAFS; ++i)
		if(clustersizehistogram[i])
		{
			if(debugCluster)
				Sys_FPrintf(SYS_VRB, "%4i clusters have exactly %4i visible clusters\n", clustersizehistogram[i], i);
			/* cast is to prevent integer overflow */
			totalvis += ((double)i) * ((double)clustersizehistogram[i]);
			totalvis2 += ((double)i) * ((double)i) * ((double)clustersizehistogram[i]);

			if(minvis < 0)
				minvis = i;
			maxvis = i;
		}

	mu = totalvis / portalclusters;
	sigma = sqrt(totalvis2 / portalclusters - mu * mu);

	Sys_Printf("Total clusters: %i\n", portalclusters);
	Sys_Printf("Total visible clusters: %.0f\n", totalvis);
	Sys_Printf("Average clusters visible: %.2f (%.3f%%/total)\n", mu, mu / portalclusters * 100.0);
	Sys_Printf("  Standard deviation: %.2f (%.3f%%/total, %.3f%%/avg)\n", sigma, sigma / portalclusters * 100.0,
			   sigma / mu * 100.0);
	Sys_Printf("  Minimum: %i (%.3f%%/total, %.3f%%/avg)\n", minvis, minvis / (double)portalclusters * 100.0,
			   minvis / mu * 100.0);
	Sys_Printf("  Maximum: %i (%.3f%%/total, %.3f%%/avg)\n", maxvis, maxvis / (double)portalclusters * 100.0,
			   maxvis / mu * 100.0);
}