예제 #1
0
            public IEnumerator ScheduleMeshingJob(Voxel[] voxels, VoxelLightBuilder.NativeLightData lightData, int3 chunkSize, SimplifyingMethod method, bool argent = false)
            {
                nativeVoxels.CopyFrom(voxels);
                switch (method)
                {
                case SimplifyingMethod.Culling:
                    ScheduleCullingJob(nativeVoxels, lightData, chunkSize);
                    break;

                case SimplifyingMethod.GreedyOnlyHeight:
                    ScheduleGreedyOnlyHeightJob(nativeVoxels, lightData, chunkSize);
                    break;

                case SimplifyingMethod.Greedy:
                    ScheduleGreedyJob(nativeVoxels, lightData, chunkSize);
                    break;

                default:
                    ScheduleGreedyJob(nativeVoxels, lightData, chunkSize);
                    break;
                }

                int frameCount = lightData.frameCount;

                yield return(new WaitUntil(() =>
                {
                    frameCount++;
                    return jobHandle.IsCompleted || frameCount >= 4 || argent;
                }));

                jobHandle.Complete();
            }
예제 #2
0
            void ScheduleGreedyJob(NativeArray <Voxel> voxels, VoxelLightBuilder.NativeLightData lightData, int3 chunkSize)
            {
                VoxelGreedyMeshingJob voxelMeshingOnlyHeightJob = new VoxelGreedyMeshingJob
                {
                    voxels    = voxels,
                    chunkSize = chunkSize,
                    vertices  = nativeVertices,
                    normals   = nativeNormals,
                    uvs       = nativeUVs,
                    indices   = nativeIndices,
                    colors    = nativeColors,
                    lightData = lightData.nativeLightData,
                    counter   = counter,
                };

                jobHandle = voxelMeshingOnlyHeightJob.Schedule();
                JobHandle.ScheduleBatchedJobs();
            }