예제 #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);
 }