public Voxel ReadVoxel(int x, int y, int z) { int chunkX = x, chunkY = y, chunkZ = z; VoxelChunk.ConvertWorldToChunk(ref chunkX, ref chunkY, ref chunkZ); var chunk = GetChunk(chunkX, chunkY, chunkZ); if (chunk != null) { VoxelChunk.ConvertWorldToLocal(ref x, ref y, ref z); return(chunk.GetVoxel(x, y, z)); } return(new Voxel()); }
public void ReadBlock(BlockQuery block, int x, int y, int z) { int chunkX = x, chunkY = y, chunkZ = z; VoxelChunk.ConvertWorldToChunk(ref chunkX, ref chunkY, ref chunkZ); var chunk = GetChunk(chunkX, chunkY, chunkZ); Voxel voxel; if (chunk != null) { VoxelChunk.ConvertWorldToLocal(ref x, ref y, ref z); voxel = chunk.GetVoxel(x, y, z); } else { voxel = new Voxel(); } //TODO: Properly query for core voxel if current voxel.IsPointer block.Set(voxel, chunk, x, y, z); }
private void GetNextChunk(int x, int y, int z, bool createIfMissing) { int chunkX = x; int chunkY = y; int chunkZ = z; bool shouldGet = false; VoxelChunk.ConvertWorldToChunk(ref chunkX, ref chunkY, ref chunkZ); if (LastChunk != null) { Vector3i lastChunkPosition = LastChunk.ChunkPosition; if (chunkX != lastChunkPosition.x || chunkY != lastChunkPosition.y || chunkZ != lastChunkPosition.z) { shouldGet = true; } } else { shouldGet = true; } if (shouldGet) { if (createIfMissing) { LastChunk = Map.GetOrCreateChunk(chunkX, chunkY, chunkZ); } else { LastChunk = Map.GetChunk(chunkX, chunkY, chunkZ); } } }
public VoxelChunk GetOrCreateChunkFromWorldPosition(int worldX, int worldY, int worldZ) { VoxelChunk.ConvertWorldToChunk(ref worldX, ref worldY, ref worldZ); return(GetOrCreateChunk(worldX, worldY, worldZ)); }