Java 类net.minecraft.client.renderer.VertexBufferUploader 实例源码

项目:Backmemed    文件:ChunkRenderDispatcher.java   
public ChunkRenderDispatcher(int p_i1_1_)
{
    this.listWorkerThreads = Lists.<Thread>newArrayList();
    this.listThreadedWorkers = Lists.<ChunkRenderWorker>newArrayList();
    this.queueChunkUpdates = Queues.<ChunkCompileTaskGenerator>newPriorityBlockingQueue();
    this.worldVertexUploader = new WorldVertexBufferUploader();
    this.vertexUploader = new VertexBufferUploader();
    this.queueChunkUploads = Queues.<ChunkRenderDispatcher.PendingUpload>newPriorityQueue();
    int i = Math.max(1, (int)((double)Runtime.getRuntime().maxMemory() * 0.3D) / 10485760);
    int j = Math.max(1, MathHelper.clamp(Runtime.getRuntime().availableProcessors(), 1, i / 5));

    if (p_i1_1_ < 0)
    {
        this.countRenderBuilders = MathHelper.clamp(j, 1, i);
    }
    else
    {
        this.countRenderBuilders = p_i1_1_;
    }

    if (j > 1)
    {
        for (int k = 0; k < j; ++k)
        {
            ChunkRenderWorker chunkrenderworker = new ChunkRenderWorker(this);
            Thread thread = THREAD_FACTORY.newThread(chunkrenderworker);
            thread.start();
            this.listThreadedWorkers.add(chunkrenderworker);
            this.listWorkerThreads.add(thread);
        }
    }

    this.queueFreeRenderBuilders = Queues.<RegionRenderCacheBuilder>newArrayBlockingQueue(this.countRenderBuilders);

    for (int l = 0; l < this.countRenderBuilders; ++l)
    {
        this.queueFreeRenderBuilders.add(new RegionRenderCacheBuilder());
    }

    this.renderWorker = new ChunkRenderWorker(this, new RegionRenderCacheBuilder());
}