예제 #1
0
파일: qvis.c 프로젝트: jayschwa/quake2world
/*
 * @brief
 */
static void CalcVis(void) {
	uint32_t i;

	RunThreadsOn(map_vis.num_portals * 2, true, BaseVis);

	SortPortals();

	// fast vis just uses migh_tsee for a very loose bound
	if (fastvis) {
		for (i = 0; i < map_vis.num_portals * 2; i++) {
			map_vis.portals[i].vis = map_vis.portals[i].flood;
			map_vis.portals[i].status = stat_done;
		}
	} else {
		RunThreadsOn(map_vis.num_portals * 2, true, FinalVis);
	}

	// assemble the leaf vis lists by OR-ing and compressing the portal lists
	for (i = 0; i < map_vis.portal_clusters; i++)
		ClusterMerge(i);

	if (map_vis.portal_clusters)
		Com_Print("Average clusters visible: %i\n", visibility_count / map_vis.portal_clusters);
	else
		Com_Print("Average clusters visible: 0\n");
}
예제 #2
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 );
}
예제 #3
0
파일: qvis.c 프로젝트: raynorpat/cake
/*
==================
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);
}
예제 #4
0
파일: vvis.cpp 프로젝트: chrizonix/RCBot2
/*
==================
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);
}
예제 #5
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);
}
예제 #6
0
파일: VIS.CPP 프로젝트: 5432935/genesis3d
//=======================================================================================
//	VisAllLeafs
//=======================================================================================
geBoolean VisAllLeafs(void)
{
	int32	i;

	// Create PortalSeen array.  This is used by Vis flooding routines
	// This is deleted below...
	PortalSeen = GE_RAM_ALLOCATE_ARRAY(uint8,NumVisPortals);

	if (!PortalSeen)
		goto ExitWithError;

	// Flood all the leafs with the fast method first...
	for (i=0; i< NumVisLeafs; i++)
		FloodLeafPortalsFast(i);

	// Check for cancel request
	if (CancelRequest)
	{
		GHook.Printf("Cancel requested...\n");
		goto ExitWithError;
	}

	// Sort the portals with MightSee
	SortPortals();

	if (FullVis)
		if (!FloodPortalsSlow())
			return GE_FALSE;

	// Don't need this anymore...
	geRam_Free(PortalSeen);
	PortalSeen = NULL;

	LeafVisBits = GE_RAM_ALLOCATE_ARRAY(uint8,NumVisLeafs*NumVisLeafBytes);

	if (!LeafVisBits)
	{
		GHook.Error("VisAllLeafs:  Out of memory for LeafVisBits.\n");
		goto ExitWithError;
	}

	memset(LeafVisBits, 0, NumVisLeafs*NumVisLeafBytes);
	TotalVisibleLeafs = 0;

	PortalBits = GE_RAM_ALLOCATE_ARRAY(uint8,NumVisPortalBytes);

	if (!PortalBits)
		goto ExitWithError;

	for (i=0; i< NumVisLeafs; i++)
	{
		LeafSee = 0;
		
		if (!CollectLeafVisBits(i))
			goto ExitWithError;

		TotalVisibleLeafs += LeafSee;
	}
	geRam_Free(PortalBits);

	GHook.Printf("Total visible areas           : %5i\n", TotalVisibleLeafs);
	GHook.Printf("Average visible from each area: %5i\n", TotalVisibleLeafs / NumVisLeafs);

	return GE_TRUE;

	// ==== ERROR ====
	ExitWithError:
	{
		// Free all the global vis data
		FreeAllVisData();

		return GE_FALSE;
	}
}