Example #1
0
        async Task ProcessSet(NeighborChunkGenData neis, Action <IntVector3> OnWroteChunkData)
        {
            //TODO: trade data, etc...
            for (int i = 0; i < ChunkGenData.LODLevels; ++i)
            {
                var cullJob = await CullHidden(neis, i);

                updateChunkCenterDisplay(cullJob, neis.centerChunkData, i);
                cullJob.DisposeAll();
            }

            await localLight.CalculateLocalLight(neis);

            // write center chunk
            var wroteAtPos = neis.center;

            //
            // TODO: write chunk at some other juncture
            //
            //var wroteAtPos = await SerializedChunkGenData.WriteAsync(neis.centerChunkData, SerializedChunkGenData.GenDataFullPath(neis.center));

            // write center chunk display arrays
            SerializedChunk.SerializedDisplayBuffers.WriteLODArrays(neis.centerChunkData.displays, neis.center);

            Chunk.MetaData metaData = new Chunk.MetaData();
            metaData.LODBufferLengths         = neis.centerChunkData.displays.getLengths();
            metaData.HasBeenNeighborProcessed = true;
            XMLOp.Serialize(metaData, SerializedChunk.GetMetaDataFullPath(neis.center));

            OnWroteChunkData(wroteAtPos);
        }
Example #2
0
        CullHiddenEdgeVoxelsJob SetupCullHidden(NeighborChunkGenData neis, Allocator _alloc = Allocator.TempJob, int lodIndex = 0)
        {
            CullHiddenEdgeVoxelsJob job = new CullHiddenEdgeVoxelsJob();

            job.displayVoxels = new NativeArray <VoxelGeomDataMirror>(neis.centerChunkData.displays[lodIndex], _alloc);


            job.center = new NativeArray <VoxelGenDataMirror>(neis.centerChunkData.lods[lodIndex], _alloc);

            // TODO: neibs always get the full chunk data
            // have to rewrite some of parts of the get voxel at function
            // when lod gr than 0. have to search multiple nei cubes (we think)

            job.right   = new NativeArray <VoxelGenDataMirror>(neis.Get(NeighborDirection.Right).lods[lodIndex], _alloc);
            job.left    = new NativeArray <VoxelGenDataMirror>(neis.Get(NeighborDirection.Left).lods[lodIndex], _alloc);
            job.up      = new NativeArray <VoxelGenDataMirror>(neis.Get(NeighborDirection.Up).lods[lodIndex], _alloc);
            job.down    = new NativeArray <VoxelGenDataMirror>(neis.Get(NeighborDirection.Down).lods[lodIndex], _alloc);
            job.forward = new NativeArray <VoxelGenDataMirror>(neis.Get(NeighborDirection.Forward).lods[lodIndex], _alloc);
            job.back    = new NativeArray <VoxelGenDataMirror>(neis.Get(NeighborDirection.Back).lods[lodIndex], _alloc);

            job.chunkSize        = vGenConfig.ChunkSize;
            job.voxelsPerMapData = VGenConfig.VoxelsPerMapData;
            job.EmptyVoxel       = vGenConfig.EmptyVoxel;
            job.lodIndex         = lodIndex;

            return(job);
        }
Example #3
0
        async Task <CullHiddenEdgeVoxelsJob> CullHidden(NeighborChunkGenData neis, int lodIndex = 0)
        {
            var allo = Allocator.TempJob;
            var job  = SetupCullHidden(neis, allo, lodIndex);
            await jobCall.ScheduleParallelAwaitable(job, neis.centerChunkData.displays.lodArrays[lodIndex].Length, 1, allo);

            return(job);
        }
Example #4
0
        private async Task PostProcessSetAsync(NeighborChunkGenData neighborChunkGenData, Action <IntVector3> onWroteChunkData)
        {
            //FAKE
            //var fakeCGD = (ChunkGenData)(await ComputeGenDataFAKE(neighborChunkGenData.center));
            //neighborChunkGenData.centerChunkData = fakeCGD;

            //WANT
            await _PostProcessSet(neighborChunkGenData);

            updateChunkGenData(neighborChunkGenData.centerChunkData);
            onWroteChunkData(neighborChunkGenData.center);
        }
Example #5
0
        public async Task CalculateLocalLight(NeighborChunkGenData nei)
        {
            // yes, this is a native array or 27 nativearrays or uints
            var       job  = new VertexLocalLightJob();
            Allocator allo = Allocator.TempJob;

            //var cubeOfExists = NativeNeighbors27<NativeArray<uint>>.FromNeighbor27(nei.nieghbors, allo);  new Neighbors27<NativeArray<uint>>(nei.center), allo);
            SetUp(nei, job, 0, allo);
            await jobCall.ScheduleParallelAwaitable(job, job.display.Length, 1, allo);

            job.DisposeAll();
        }
        void SetExistsMap(NeighborChunkGenData nei)
        {
            int sizeOfExistMap = vGenConfig.SizeOfExistsMap;
            var bounds         = nei.neighbors.bounds;

            foreach (var pos in bounds.IteratorXYZ)
            {
                var rel   = bounds.RelativeOrigin(pos);
                int start = rel.ToFlatZXYIndex(new IntVector3(3));

                ExistsMap27.SetData(nei.Get(pos).ExistsMap, 0, start * sizeOfExistMap, sizeOfExistMap);
            }
        }
Example #7
0
        private void SetUp(NeighborChunkGenData nei, VertexLocalLightJob job, int lodIndex, Allocator allo)
        {
            job.locks          = new object[nei.centerChunkData.displays.getLengths()[lodIndex]];
            job.display        = new NativeArray <VoxelGeomDataMirror>(nei.centerChunkData.displays[lodIndex], allo);
            job.chunkSize      = vGenConfig.ChunkSize;
            job.SizeOfHLSLUInt = VGenConfig.SizeOfHLSLInt;

            var cubeOfExists27 = new  NativeNeighbors27 <NativeArray <uint> >(nei.center, allo);

            foreach (var pos in Cube27.NeighborsOfIncludingCenter(nei.center))
            {
                cubeOfExists27.Set(pos, new NativeArray <uint>(nei.Get(pos).ExistsMap, allo));
            }

            job.cubeOfExists = cubeOfExists27;
        }
Example #8
0
        IEnumerator _PostProcessSet(NeighborChunkGenData neighborChunkGenData)
        {
            //awkward.
            while (cvoxelNeighborFormat == null)
            {
                Debug.Log("null cvox nei format");
                yield return(new WaitForSeconds(.2f));
            }
            cvoxelNeighborFormat.SetBuffersWith(neighborChunkGenData);
            cvoxelNeighborFormat.callNeighborFormatKernels();
            yield return(new WaitForEndOfFrame());

            cvoxelFaceCopy.callFaceCopyKernel();
            yield return(new WaitForEndOfFrame());

            yield return(new object());
        }
 void SetMapVoxels(NeighborChunkGenData nei)
 {
     MapVoxels.SetData(nei.centerChunkData.lods[0]);
     MapVoxelsLOD2.SetData(nei.centerChunkData.lods[1]);
     MapVoxelsLOD4.SetData(nei.centerChunkData.lods[2]);
 }
 public void SetBuffersWith(NeighborChunkGenData nei)
 {
     SetMapVoxels(nei);
     SetExistsMap(nei);
 }