| 539 | |
| 540 | |
| 541 | int cDistortedHeightmap::GetHeightmapAt(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Z) |
| 542 | { |
| 543 | int ChunkX = (int)floor(a_X / (NOISE_DATATYPE)16); |
| 544 | int ChunkZ = (int)floor(a_Z / (NOISE_DATATYPE)16); |
| 545 | int RelX = (int)(a_X - (NOISE_DATATYPE)ChunkX * cChunkDef::Width); |
| 546 | int RelZ = (int)(a_Z - (NOISE_DATATYPE)ChunkZ * cChunkDef::Width); |
| 547 | |
| 548 | // If we're withing the same chunk, return the pre-cached heightmap: |
| 549 | if ((ChunkX == m_CurChunkX) && (ChunkZ == m_CurChunkZ)) |
| 550 | { |
| 551 | return cChunkDef::GetHeight(m_CurChunkHeights, RelX, RelZ); |
| 552 | } |
| 553 | |
| 554 | // Ask the cache: |
| 555 | HEIGHTTYPE res = 0; |
| 556 | if (m_HeightGen.GetHeightAt(ChunkX, ChunkZ, RelX, RelZ, res)) |
| 557 | { |
| 558 | // The height was in the cache |
| 559 | return res; |
| 560 | } |
| 561 | |
| 562 | // The height is not in the cache, generate full heightmap and get it there: |
| 563 | cChunkDef::HeightMap Heightmap; |
| 564 | m_HeightGen.GenHeightMap(ChunkX, ChunkZ, Heightmap); |
| 565 | return cChunkDef::GetHeight(Heightmap, RelX, RelZ); |
| 566 | } |
| 567 | |
| 568 | |
| 569 |
nothing calls this directly
no test coverage detected