| 125 | |
| 126 | |
| 127 | void cStructGenTrees::GenerateSingleTree( |
| 128 | int a_ChunkX, int a_ChunkZ, int a_Seq, |
| 129 | cChunkDesc & a_ChunkDesc, |
| 130 | sSetBlockVector & a_OutsideLogs, |
| 131 | sSetBlockVector & a_OutsideOther |
| 132 | ) |
| 133 | { |
| 134 | int x = (m_Noise.IntNoise3DInt(a_ChunkX + a_ChunkZ, a_ChunkZ, a_Seq) / 19) % cChunkDef::Width; |
| 135 | int z = (m_Noise.IntNoise3DInt(a_ChunkX - a_ChunkZ, a_Seq, a_ChunkZ) / 19) % cChunkDef::Width; |
| 136 | |
| 137 | int Height = a_ChunkDesc.GetHeight(x, z); |
| 138 | |
| 139 | if ((Height <= 0) || (Height > 240)) |
| 140 | { |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | // Check the block underneath the tree: |
| 145 | BLOCKTYPE TopBlock = a_ChunkDesc.GetBlockType(x, Height, z); |
| 146 | if ((TopBlock != E_BLOCK_DIRT) && (TopBlock != E_BLOCK_GRASS) && (TopBlock != E_BLOCK_FARMLAND)) |
| 147 | { |
| 148 | return; |
| 149 | } |
| 150 | |
| 151 | sSetBlockVector TreeLogs, TreeOther; |
| 152 | GetTreeImageByBiome( |
| 153 | a_ChunkX * cChunkDef::Width + x, Height + 1, a_ChunkZ * cChunkDef::Width + z, |
| 154 | m_Noise, a_Seq, |
| 155 | a_ChunkDesc.GetBiome(x, z), |
| 156 | TreeLogs, TreeOther |
| 157 | ); |
| 158 | |
| 159 | // Check if the generated image fits the terrain. Only the logs are checked: |
| 160 | for (sSetBlockVector::const_iterator itr = TreeLogs.begin(); itr != TreeLogs.end(); ++itr) |
| 161 | { |
| 162 | if ((itr->ChunkX != a_ChunkX) || (itr->ChunkZ != a_ChunkZ)) |
| 163 | { |
| 164 | // Outside the chunk |
| 165 | continue; |
| 166 | } |
| 167 | |
| 168 | BLOCKTYPE Block = a_ChunkDesc.GetBlockType(itr->x, itr->y, itr->z); |
| 169 | switch (Block) |
| 170 | { |
| 171 | CASE_TREE_ALLOWED_BLOCKS: |
| 172 | { |
| 173 | break; |
| 174 | } |
| 175 | default: |
| 176 | { |
| 177 | // There's something in the way, abort this tree altogether |
| 178 | return; |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | ApplyTreeImage(a_ChunkX, a_ChunkZ, a_ChunkDesc, TreeOther, a_OutsideOther); |
| 184 | ApplyTreeImage(a_ChunkX, a_ChunkZ, a_ChunkDesc, TreeLogs, a_OutsideLogs); |
nothing calls this directly
no test coverage detected