MCPcopy Create free account
hub / github.com/cuberite/cuberite / GetHeightmapAt

Method GetHeightmapAt

src/Generating/DistortedHeightmap.cpp:541–566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539
540
541int 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

Callers

nothing calls this directly

Calls 2

GetHeightAtMethod · 0.80
GenHeightMapMethod · 0.45

Tested by

no test coverage detected