Пример #1
0
/*
=============
RadWorld
=============
*/
void RadWorld (void)
{
	int	i;

	MakeBackplanes ();
	MakeParents (0, -1);
	MakeTnodes (&dmodels[0]);

	// turn each face into a single patch
	MakePatches ();
	PairEdges ();

	// subdivide patches to a maximum dimension
	SubdividePatches ();

	do
	{
		// create directlights out of patches and lights
		CreateDirectLights ();

		// build initial facelights
		RunThreadsOnIndividual (numfaces, true, BuildFacelights);

		// free up the direct lights now that we have facelights
		DeleteDirectLights ();
	}
	while( numbounce != 0 && ProgressiveRefinement() );

	if (numbounce > 0)
	{
		// build transfer lists
		MakeAllScales ();

		// invert the transfers for gather vs scatter
		RunThreadsOnIndividual (num_patches, true, SwapTransfersTask);

		// spread light around
		BounceLight ();

		for( i=0; i < num_patches; i++ )
			if ( !VectorCompare( patches[i].directlight, vec3_origin ) )
				VectorSubtract( patches[i].totallight, patches[i].directlight, patches[i].totallight );
	}

	// blend bounced light into direct light and save
	PrecompLightmapOffsets();

	RunThreadsOnIndividual (numfaces, true, FinalLightFace);
}
Пример #2
0
bool CVRadDLL::DoIncrementalLight( char const *pVMFFile )
{
	char tempPath[MAX_PATH], tempFilename[MAX_PATH];
	GetTempPath( sizeof( tempPath ), tempPath );
	GetTempFileName( tempPath, "vmf_entities_", 0, tempFilename );

	FileHandle_t fp = g_pFileSystem->Open( tempFilename, "wb" );
	if( !fp )
		return false;

	g_pFileSystem->Write( pVMFFile, strlen(pVMFFile)+1, fp );
	g_pFileSystem->Close( fp );

	// Parse the new entities.
	if( !LoadEntsFromMapFile( tempFilename ) )
		return false;

	// Create lights.
	CreateDirectLights();

	// set up sky cameras
	ProcessSkyCameras();
		
	g_bInterrupt = false;
	if( RadWorld_Go() )
	{
		// Save off the last finished lighting results for the BSP.
		g_LastGoodLightData.CopyArray( pdlightdata->Base(), pdlightdata->Count() );
		if( g_pIncremental )
			g_pIncremental->GetFacesTouched( g_FacesTouched );

		return true;
	}
	else
	{
		g_iCurFace = 0;
		return false;
	}
}