Пример #1
0
        IEnumerator ComputeGenData(IntVector3 chunkPos)
        {
            cvoxelMapData.callClearMapBuffersKernel();
            yield return(new WaitForEndOfFrame());

            cvoxelMapData.callPerlinMapGenKernel(chunkPos);
            yield return(new WaitForEndOfFrame());

            /*
             * cvoxelMapData.DebugBuffs();
             *
             * cvoxelMapFormat.callFaceGenKernels();
             * yield return new WaitForEndOfFrame();
             *
             * cvoxelMapFormat.callFaceCopyKernel();
             * yield return new WaitForEndOfFrame();
             * cvoxelMapFormat.DebugBuffs();
             *
             */
            ChunkGenData c = cvoxelMapData.CopyArrays();

            c.chunkPos = chunkPos;
            //c.displays = cvoxelMapFormat.CopySolidArraysUsingCounts();

            yield return(c);
        }
Пример #2
0
        public static async void WriteAsyncDebug(ChunkGenData data, string fullPath, Action OnCompleted)
        {
            Task  t = _WriteAsync(data, fullPath);
            await t;

            OnCompleted();
        }
Пример #3
0
        public static async Task <IntVector3> WriteAsync(ChunkGenData data, string fullPath)
        {
            Task  t = _WriteAsync(data, fullPath);
            await t;

            return(data.chunkPos);
        }
Пример #4
0
 public void DebugSetSolids(ChunkGenData data)
 {
     BufferUtil.ReleaseBuffers(SolidVoxels, SolidVoxelsLOD2, SolidVoxelsLOD4);
     for (int i = 0; i < data.displays.lodArrays.Length; ++i)
     {
         DebugSetSolidAt(i, data.displays.lodArrays[i]);
     }
 }
Пример #5
0
 void UpperCallback(ChunkGenData cdata)
 {
     status = ForgeProcessStatus.FINISHED;
     foreach (var act in callbacks)
     {
         act(cdata);
     }
 }
Пример #6
0
        IEnumerator ComputeGenDataFAKE(IntVector3 chunkPos)
        {
            ChunkGenData c = FakeChunkData.StairsGenData(chunkPos, vGenConfig.ChunkSize, 5);

            yield return(new WaitForEndOfFrame());

            yield return(new WaitForSeconds(.05f));

            yield return(c);
        }
Пример #7
0
        //public bool isCompleteSet {
        //    get {
        //        foreach(var nd in CubeNeighbors6.GetDirections)
        //        {
        //            if(!ignorableDirections.Contains(nd) && !neighbors.Contains(nd)) { return false; }
        //        }
        //        if(!neighbors.ContainsCenter) { return false; }
        //        return true;
        //    }
        //}

        public void AddIfEmpty(IntVector3 globalChunkPos, ChunkGenData data)
        {
            ChunkGenData already;

            if (neighbors.Get(globalChunkPos, out already))
            {
                return;
            }
            Add(globalChunkPos, data);
        }
Пример #8
0
            public static void Write(ChunkGenData chunkGenData)
            {
                MetaData metaData = new MetaData
                {
                    LODBufferLengths         = chunkGenData.displays.getLengths(),
                    HasBeenNeighborProcessed = true
                };

                XMLOp.Serialize(metaData, SerializedChunk.GetMetaDataFullPath(chunkGenData.chunkPos));
            }
Пример #9
0
        static void DBUGFirstFew(ChunkGenData cgd)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < 10; ++i)
            {
                sb.Append(cgd[1][i].voxel);
                sb.Append(",");
            }
            Debug.Log(sb.ToString());
        }
Пример #10
0
 public void Add(IntVector3 globalChunkPos, ChunkGenData data)
 {
     if (neighbors.Set(globalChunkPos, data))
     {
         //if (OnCompleteSet != null && isCompleteSet)
         //{
         //    Debug.Log("will call On Complete: " + centerChunkData.chunkPos.ToString());
         //    OnCompleteSet(neighbors);
         //}
     }
 }
Пример #11
0
        private void updateChunkGenData(ChunkGenData chunkGenData)
        {
            // DEbug
            // cvoxelFaceCopy.DebugSetSolids(chunkGenData);
            // end debug

            chunkGenData.displays = cvoxelFaceCopy.CopySolidArraysUsingCounts(); // WANT

            // write center chunk display arrays
            Debug.Log("writing at pos: " + chunkGenData.chunkPos + " : " + chunkGenData.displays.ToString());
            SerializedChunk.SerializedDisplayBuffers.WriteLODArrays(chunkGenData.displays, chunkGenData.chunkPos);
            Chunk.MetaData.Write(chunkGenData);
        }
Пример #12
0
        public ChunkGenData CopyArrays()
        {
            ChunkGenData c = new ChunkGenData();

            for (int i = 0; i < ChunkGenData.LODLevels; ++i)
            {
                c[i] = CVoxelMapFormat.BufferCountArgs.GetData <VoxelGenDataMirror>(GetLOD(i));
            }

            c.ExistsMap = CVoxelMapFormat.BufferCountArgs.GetData <uint>(ExistsMap);

            return(c);
        }
Пример #13
0
        void updateChunkCenterDisplay(CullHiddenEdgeVoxelsJob cullJob, ChunkGenData data, int lod = 0)
        {
            var  display    = new List <VoxelGeomDataMirror>(data.displays.lodArrays[lod].Length);
            uint emptyVoxel = vGenConfig.EmptyVoxel;

            for (int i = 0; i < cullJob.displayVoxels.Length; ++i)
            {
                if (cullJob.displayVoxels[i].voxel != emptyVoxel)
                {
                    display.Add(cullJob.displayVoxels[i]);
                }
            }
            data.displays.lodArrays[lod] = display.ToArray();
        }
Пример #14
0
        public static void DebugCheckGenDataHasEmpties(ChunkGenData data, string msg = "", uint EmptyVoxel = 0)
        {
            var ray      = data.lods[0];
            int gotAZero = 0;

            foreach (var vox in ray)
            {
                if (vox.voxel == EmptyVoxel)
                {
                    gotAZero++;
                }
            }

            Debug.Log(msg + " got a zero: " + gotAZero + " out of " + ray.Length);
        }
Пример #15
0
        static async Task _WriteAsync(ChunkGenData dat, string fullPath)
        {
            await new WaitForBackgroundThread();
            lock (locks.GetOrAdd(dat.chunkPos, new object()))
            {
                var paths = GenDataPaths(fullPath, ChunkGenData.LODLevels);
                for (int i = 0; i < paths.Length; ++i)
                {
                    WriteGenDataToFile(dat, paths[i], i);
                }
            }
            object o;

            locks.TryRemove(dat.chunkPos, out o);
            await new WaitForUpdate(); //Is this the way????
        }
Пример #16
0
        public static ChunkGenData Read(IntVector3 chunkPos)
        {
            var data = new ChunkGenData();

            lock (locks.GetOrAdd(chunkPos, new object()))
            {
                var paths = GenDataPaths(GenDataFullPath(chunkPos), ChunkGenData.LODLevels);
                for (int i = 0; i < paths.Length; ++i)
                {
                    data[i] = ReadGenVoxelsFromFile(paths[i]);
                }
            }
            object o;

            locks.TryRemove(chunkPos, out o);
            data.chunkPos = chunkPos;
            return(data);
        }
Пример #17
0
 static bool DBUGEqual(ChunkGenData a, ChunkGenData b)
 {
     for (int i = 0; i < ChunkGenData.LODLevels; ++i)
     {
         if (a[i].Length != b[i].Length)
         {
             return(false);
         }
         for (int j = 0; j < a[i].Length; ++j)
         {
             if (a[i][j] != b[i][j])
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #18
0
        static void WriteGenDataToFile(ChunkGenData data, string FilePath, int lodLevel)
        {
            //dbug
            if (data[lodLevel] == null)
            {
                Debug.Log("null at: " + lodLevel);
                return;
            }

            using (BinaryWriter w = new BinaryWriter(File.Open(FilePath, FileMode.Create)))
            {
                int len = data[lodLevel].Length;
                int i;
                for (i = 0; i < len; ++i)
                {
                    w.Write(data[lodLevel][i].voxel);
                }
            }
        }
Пример #19
0
 void chunkGenDataDone(ChunkGenData dat)
 {
     Busy = false;
     OnChunkGenDataDone(dat);
 }
Пример #20
0
 void OnComplete(ChunkGenData cdata)
 {
     jobs.Remove(cdata.chunkPos);
 }