| 830 | |
| 831 | |
| 832 | void cDistortedHeightmap::FillColumnMesa(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelZ) |
| 833 | { |
| 834 | // Frequencies for the clay floor noise: |
| 835 | const NOISE_DATATYPE FrequencyX = 50; |
| 836 | const NOISE_DATATYPE FrequencyZ = 50; |
| 837 | |
| 838 | int Top = a_ChunkDesc.GetHeight(a_RelX, a_RelZ); |
| 839 | if (Top < m_SeaLevel) |
| 840 | { |
| 841 | // The terrain is below sealevel, handle as regular ocean: |
| 842 | FillColumnPattern(a_ChunkDesc, a_RelX, a_RelZ, patOFRedSand.Get()); |
| 843 | return; |
| 844 | } |
| 845 | |
| 846 | NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(m_CurChunkX * cChunkDef::Width + a_RelX)) / FrequencyX; |
| 847 | NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width + a_RelZ)) / FrequencyZ; |
| 848 | int ClayFloor = m_SeaLevel - 6 + (int)(4.f * m_MesaFloor.CubicNoise2D(NoiseX, NoiseY)); |
| 849 | if (ClayFloor >= Top) |
| 850 | { |
| 851 | ClayFloor = Top - 1; |
| 852 | } |
| 853 | |
| 854 | if (Top - m_SeaLevel < 5) |
| 855 | { |
| 856 | // Simple case: top is red sand, then hardened clay down to ClayFloor, then stone: |
| 857 | a_ChunkDesc.SetBlockTypeMeta(a_RelX, Top, a_RelZ, E_BLOCK_SAND, E_META_SAND_RED); |
| 858 | for (int y = Top - 1; y >= ClayFloor; y--) |
| 859 | { |
| 860 | a_ChunkDesc.SetBlockType(a_RelX, y, a_RelZ, E_BLOCK_HARDENED_CLAY); |
| 861 | } |
| 862 | for (int y = ClayFloor - 1; y > 0; y--) |
| 863 | { |
| 864 | a_ChunkDesc.SetBlockType(a_RelX, y, a_RelZ, E_BLOCK_STONE); |
| 865 | } |
| 866 | a_ChunkDesc.SetBlockType(a_RelX, 0, a_RelZ, E_BLOCK_BEDROCK); |
| 867 | return; |
| 868 | } |
| 869 | |
| 870 | // Difficult case: use the mesa pattern and watch for overhangs: |
| 871 | int NoiseArrayIdx = a_RelX + 17 * 257 * a_RelZ; |
| 872 | int PatternIdx = cChunkDef::Height - (Top - ClayFloor); // We want the block at index ClayFloor to be pattern's 256th block (first stone) |
| 873 | const sBlockInfo * Pattern = m_MesaPattern; |
| 874 | bool HasHadWater = false; |
| 875 | for (int y = Top; y > 0; y--) |
| 876 | { |
| 877 | int HeightMapHeight = (int)m_DistortedHeightmap[NoiseArrayIdx + 17 * y]; |
| 878 | if (y < HeightMapHeight) |
| 879 | { |
| 880 | // "ground" part, use the pattern: |
| 881 | a_ChunkDesc.SetBlockTypeMeta(a_RelX, y, a_RelZ, Pattern[PatternIdx].BlockType, Pattern[PatternIdx].BlockMeta); |
| 882 | PatternIdx++; |
| 883 | continue; |
| 884 | } |
| 885 | |
| 886 | if (y >= m_SeaLevel) |
| 887 | { |
| 888 | // "air" part, do nothing |
| 889 | continue; |
nothing calls this directly
no test coverage detected