Ejemplo n.º 1
0
        /// <summary>
        /// Starts generating the voxel data for a specified volume
        /// </summary>
        /// <param name="bounds">The volume to generate the voxel data for</param>
        /// <param name="allocator">The allocator for the new <see cref="VoxelDataVolume"/></param>
        /// <returns>The job handle and the voxel data generation job</returns>
        public override JobHandleWithData <IVoxelDataGenerationJob> GenerateVoxelData(Bounds bounds, Allocator allocator)
        {
            VoxelDataVolume voxelData = new VoxelDataVolume(bounds.size.ToInt3(), allocator);
            ProceduralTerrainVoxelDataCalculationJob job = new ProceduralTerrainVoxelDataCalculationJob
            {
                WorldPositionOffset       = bounds.min.ToInt3(),
                OutputVoxelData           = voxelData,
                ProceduralTerrainSettings = proceduralTerrainSettings
            };

            JobHandle jobHandle = job.Schedule(voxelData.Length, 256);

            JobHandleWithData <IVoxelDataGenerationJob> jobHandleWithData = new JobHandleWithData <IVoxelDataGenerationJob>();

            jobHandleWithData.JobHandle = jobHandle;
            jobHandleWithData.JobData   = job;

            return(jobHandleWithData);
        }
        /// <inheritdoc/>
        public override JobHandleWithData <IVoxelDataGenerationJob> GenerateVoxelData(int3 worldSpaceOrigin, VoxelDataVolume <byte> outputVoxelDataArray)
        {
            ProceduralTerrainVoxelDataCalculationJob job = new ProceduralTerrainVoxelDataCalculationJob
            {
                WorldPositionOffset       = worldSpaceOrigin,
                OutputVoxelData           = outputVoxelDataArray,
                ProceduralTerrainSettings = proceduralTerrainSettings
            };

            JobHandle jobHandle = job.Schedule();

            JobHandleWithData <IVoxelDataGenerationJob> jobHandleWithData = new JobHandleWithData <IVoxelDataGenerationJob>
            {
                JobHandle = jobHandle,
                JobData   = job
            };

            return(jobHandleWithData);
        }