public void RemoveGenerationJob(GenerateChunkJob jobToRemove) { if (jobToRemove.Equals(activeGenerationJob)) { activeGenerationJob.Abort(); activeGenerationJob = null; hasActiveGenerationJob = false; } else if (!generationQueue.Contains(jobToRemove)) { if (jobToRemove.Equals(activeMeshJob)) { activeMeshJob.Abort(); activeMeshJob = null; hasActiveMeshJob = false; } else { meshGenerationQueue.Remove(jobToRemove.ToMeshJob()); } } else { generationQueue.Remove(jobToRemove); } }
public GenerateMeshFromChunkJob ToMeshJob() { GenerateMeshFromChunkJob meshJob = new GenerateMeshFromChunkJob(); meshJob.chunkCoordinates = chunkLocationToGenerate; return(meshJob); }
void LoadChunk(GenerateMeshFromChunkJob generatedChunk) { GameObject current = Instantiate(chunkPrefab, new Vector3(0, 0, 0), new Quaternion()); current.GetComponent <TerrainChunk>().Load(generatedChunk); loadedChunkList.Add(current.GetComponent <TerrainChunk>()); }
private void CheckActiveMeshJob() { if (activeMeshJob != null) { if (activeMeshJob.Update()) { hasActiveMeshJob = false; hasCompletedJobWaiting = true; completedJob = activeMeshJob; activeMeshJob = null; } } }
public bool Equals(GenerateMeshFromChunkJob check) { if (check == null) { return(false); } if (check.chunkCoordinates == chunkCoordinates) { return(true); } return(false); }
private void CheckActiveGenerationJob() { if (activeGenerationJob != null) { if (activeGenerationJob.Update()) { hasActiveGenerationJob = false; GenerateMeshFromChunkJob meshJob = new GenerateMeshFromChunkJob(); meshJob.chunkCoordinates = activeGenerationJob.chunkLocationToGenerate; meshJob.chunkVoxelArray = activeGenerationJob.chunkVoxelArray; AddMeshJob(meshJob); activeGenerationJob = null; } } }
private void StartNextMeshJob() { activeMeshJob = meshGenerationQueue.Dequeue(); hasActiveMeshJob = true; activeMeshJob.Start(); }
private void AddMeshJob(GenerateMeshFromChunkJob jobToAdd) { meshGenerationQueue.Enqueue(jobToAdd); }
public void Load(GenerateMeshFromChunkJob generatedChunkJob) { chunkVoxelArray = generatedChunkJob.chunkVoxelArray; chunkCoordinates = generatedChunkJob.chunkCoordinates; UpdateMesh(generatedChunkJob.generatedMesh); }