private BlockNeighbourInfo GetBlockNeighbourInfo(int x, int y, int z) { BlockNeighbourInfo blockNeighbourInfo = new BlockNeighbourInfo(); blockNeighbourInfo.Front = IsInBounds(x, y, z - 1) && chunk [x, y, z - 1] > 0; blockNeighbourInfo.Back = IsInBounds(x, y, z + 1) && chunk [x, y, z + 1] > 0; blockNeighbourInfo.Left = IsInBounds(x - 1, y, z) && chunk [x - 1, y, z] > 0; blockNeighbourInfo.Right = IsInBounds(x + 1, y, z) && chunk [x + 1, y, z] > 0; blockNeighbourInfo.Top = IsInBounds(x, y + 1, z) && chunk [x, y + 1, z] > 0; blockNeighbourInfo.Bottom = IsInBounds(x, y - 1, z) && chunk [x, y - 1, z] > 0; return(blockNeighbourInfo); }
private void CreateBlock(int x, int y, int z, BlockType type) { if (type == BlockType.Air) { return; } BlockNeighbourInfo blockNeighbourInfo = GetBlockNeighbourInfo(x, y, z); Vector3 worldPosition = GetChunkSpacePosition(x, y, z); if (!blockNeighbourInfo.Front) { CreateFrontFace(worldPosition, type); } if (!blockNeighbourInfo.Back) { CreateBackFace(worldPosition, type); } if (!blockNeighbourInfo.Left) { CreateLeftFace(worldPosition, type); } if (!blockNeighbourInfo.Right) { CreateRightFace(worldPosition, type); } if (!blockNeighbourInfo.Top) { CreateTopFace(worldPosition, type); } if (!blockNeighbourInfo.Bottom) { CreateBottomFace(worldPosition, type); } }