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); }
public static async void WriteAsyncDebug(ChunkGenData data, string fullPath, Action OnCompleted) { Task t = _WriteAsync(data, fullPath); await t; OnCompleted(); }
public static async Task <IntVector3> WriteAsync(ChunkGenData data, string fullPath) { Task t = _WriteAsync(data, fullPath); await t; return(data.chunkPos); }
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]); } }
void UpperCallback(ChunkGenData cdata) { status = ForgeProcessStatus.FINISHED; foreach (var act in callbacks) { act(cdata); } }
IEnumerator ComputeGenDataFAKE(IntVector3 chunkPos) { ChunkGenData c = FakeChunkData.StairsGenData(chunkPos, vGenConfig.ChunkSize, 5); yield return(new WaitForEndOfFrame()); yield return(new WaitForSeconds(.05f)); yield return(c); }
//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); }
public static void Write(ChunkGenData chunkGenData) { MetaData metaData = new MetaData { LODBufferLengths = chunkGenData.displays.getLengths(), HasBeenNeighborProcessed = true }; XMLOp.Serialize(metaData, SerializedChunk.GetMetaDataFullPath(chunkGenData.chunkPos)); }
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()); }
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); //} } }
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); }
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); }
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(); }
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); }
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???? }
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); }
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); }
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); } } }
void chunkGenDataDone(ChunkGenData dat) { Busy = false; OnChunkGenDataDone(dat); }
void OnComplete(ChunkGenData cdata) { jobs.Remove(cdata.chunkPos); }