예제 #1
0
	public BackgroundWorldProcessor(bool useThreadPool) {
		if (useThreadPool) {
			int workerThreads = 0;
			int completionPortThreads = 0;
		
			ThreadPool.SetMaxThreads(400, 300);
			ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads);

			UnityEngine.Debug.Log ("workerThreads = " + workerThreads + ", completionPortThreads = " + completionPortThreads);
			
			// process batches in parallel
			sharedProcessor = new ThreadPoolBatchProcessor<Chunk>();
			// the mesh processor will have its own processor which can take a data parameter
			// this will allow us to use the same mesh processor to process different meshes on different layers simultaneously
			meshProcessor = new MeshProcessor(new ThreadPoolBatchProcessor<Chunk, BlockLayer>());
		}
		else {
			// process batches synchronously
			sharedProcessor = new BatchProcessor<Chunk>();
			
			// the mesh processor will have its own processor which can take a data parameter
			// this will allow us to use the same mesh processor to process different meshes on different layers simultaneously
			meshProcessor = new MeshProcessor(new BatchProcessor<Chunk, BlockLayer>());
		}
		
		terrainProcessor = new TerrainProcessor(sharedProcessor);
		colliderProcessor = new ColliderProcessor(sharedProcessor);
	}
예제 #2
0
    // Update is called once per frame
    void Start()
    {
        perl          = new Perlin();
        secondaryPerl = new Perlin(5);
        tp            = new TerrainProcessor(2000, 1000);

        majorData = new float[2048, 2048];
        for (int i = 0; i < 2048; i++)
        {
            for (int j = 0; j < 2048; j++)
            {
                //majorData[i, j] = (float)perl.OctavePerlin(i * 0.01d, j * 0.01d, 0.4d, 2, 0.3d);
                //majorData[i, j] += (float)perl.OctavePerlin(i * 0.002d, j * 0.002d, 0.4d, 1, 0.3d);
            }
        }
        //for (int i = 0; i < 8; i++) {
        //    for (int j = 0; j < 8; j++) {
        //        MakeChunk(100, new Vector3(i*10, 0, j*10), i, j, majorData);
        //    }
        //}

        for (int i = 0; i < 8; i++)
        {
            for (int j = 0; j < 8; j++)
            {
                MakeChunkNew(100, new Vector3(i * 2000 - 10000, -1000, j * 2000 - 10000), i, j);
            }
        }
    }
예제 #3
0
    public World(string terrainProcessorConfiguration)
    {
        Current = this;

        loadedChunks     = new HashSet <Chunk>();
        loadChunkQueue   = new Queue <Chunk>();
        unloadChunkQueue = new Queue <Chunk>();

        terrainProcessor = new TerrainProcessor(terrainProcessorConfiguration);
        terrainProcesses = new List <ITerrainProcessor>();
    }