示例#1
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var generateBURSTJob = new GenerateChunkBURSTJob
        {
            ChunkSize = ChunkMarkGenerateJS.ChunkSize,
            cbd       = GetBufferFromEntity <ChunkBufferData>()
        };
        var handle = generateBURSTJob.Schedule(this, inputDeps);

        var generateJob = new GenerateChunkJob
        {
            commandBuffer = ecbSystem.CreateCommandBuffer().ToConcurrent(),
        };

        handle = generateJob.Schedule(this, handle);
        ecbSystem.AddJobHandleForProducer(handle);
        return(handle);
    }
示例#2
0
    public void GenerateAllNewChunks(int chunkWidth, int chunkHeight)
    {
        if (newChunks.Count > 0)
        {
            NativeList <JobHandle> jobHandleList = new NativeList <JobHandle>(Allocator.Temp);
            foreach (TerrainChunk c in newChunks.Values)
            {
                //NativeHashMap<float2, bool> stateMap = new NativeHashMap<float2, bool>(chunkWidth * chunkHeight, Allocator.TempJob);
                NativeList <bool> stateList = new NativeList <bool>(chunkWidth * chunkHeight, Allocator.TempJob);
                GenerateChunkJob  chunkJob  = new GenerateChunkJob
                {
                    width       = chunkWidth,
                    height      = chunkHeight,
                    position    = c.position,
                    seed        = planetSettings.planetSeed,
                    featureSize = planetSettings.planetFeatureSize,
                    tileStates  = stateList
                };
                chunkBoolMap.Add(stateList);
                jobHandleList.Add(chunkJob.Schedule());
            }
            JobHandle.CompleteAll(jobHandleList);

            int index = 0;

            foreach (TerrainChunk c in newChunks.Values)
            {
                c.SetTileStatesFromNativeList(chunkBoolMap[index]);


                c.GenerateChunk();

                chunkBoolMap[index].Dispose();
                index++;
            }
            //CombineMeshes();

            jobHandleList.Dispose();

            chunkBoolMap.Clear();
            newChunks.Clear();
        }
    }