void RenderPass() { var chunkArray = _renderQuery.CreateArchetypeChunkArray(Allocator.TempJob); var chunkIdType = GetArchetypeChunkComponentType <ChunkIdComponent>(true); var systemEntityVersionType = GetArchetypeChunkComponentType <SystemVersion>(); // var materialType = GetArchetypeChunkBufferType<BlockMaterialIdentityComponent>(true); // var subMaterialType = GetArchetypeChunkBufferType<BlockSubMaterialIdentityComponent>(true); // var blockShapeType = GetArchetypeChunkBufferType<BlockShapeComponent>(true); // var culledFaceType = GetArchetypeChunkBufferType<BlockCulledFacesComponent>(true); var materialVersionType = GetArchetypeChunkComponentType <BlockMaterialIdentityComponent.Version>(true); var subMaterialVersionType = GetArchetypeChunkComponentType <BlockSubMaterialIdentityComponent.Version>(true); var blockShapeVersionType = GetArchetypeChunkComponentType <BlockShapeComponent.Version>(true); var culledFaceVersionType = GetArchetypeChunkComponentType <BlockCulledFacesComponent.Version>(true); var chunkArchetype = GetArchetypeChunkEntityType(); Profiler.BeginSample("Process ECS Chunk"); foreach (var ecsChunk in chunkArray) { var ids = ecsChunk.GetNativeArray(chunkIdType); var systemVersions = ecsChunk.GetNativeArray(systemEntityVersionType); var materialVersions = ecsChunk.GetNativeArray(materialVersionType); var subMaterialVersions = ecsChunk.GetNativeArray(subMaterialVersionType); var blockShapeVersions = ecsChunk.GetNativeArray(blockShapeVersionType); var culledFaceVersions = ecsChunk.GetNativeArray(culledFaceVersionType); var voxelChunkEntityArray = ecsChunk.GetNativeArray(chunkArchetype); var i = 0; foreach (var voxelChunkEntity in voxelChunkEntityArray) { var version = systemVersions[i]; var currentVersion = new SystemVersion() { Material = materialVersions[i], SubMaterial = subMaterialVersions[i], BlockShape = blockShapeVersions[i], CulledFaces = culledFaceVersions[i] }; // var matVersion = // var subMatVersion = if (currentVersion.DidChange(version)) // .DidChange(materialType, version.Material) || // ecsChunk.DidChange(subMaterialType, version.SubMaterial) || // ecsChunk.DidChange(culledFaceType, version.CulledFaces) || // ecsChunk.DidChange(blockShapeType, version.BlockShape)) { var id = ids[i]; Profiler.BeginSample("Process Render Chunk"); var results = GenerateBoxelMeshes(voxelChunkEntity); Profiler.EndSample(); _frameCaches.Enqueue(new FrameCache() { Identity = id, Results = results }); systemVersions[i] = currentVersion; } i++; } } Profiler.EndSample(); chunkArray.Dispose(); //We need to process everything we couldn't while chunk array was in use ProcessFrameCache(); }