summaryrefslogtreecommitdiffstats
path: root/Tools/QtBiomeVisualiser/Region.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-11-23 18:12:34 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-11-23 18:12:34 +0100
commit79e5b823547a2a51d9f4e504fc24ec539e11ac34 (patch)
tree672b77f1c9a4741437b30f3289fc258d7917a2eb /Tools/QtBiomeVisualiser/Region.cpp
parentCompilation fixes (diff)
parentMerge pull request #1612 from p-mcgowan/pigsIntoZombiePigmenOnLightning (diff)
downloadcuberite-79e5b823547a2a51d9f4e504fc24ec539e11ac34.tar
cuberite-79e5b823547a2a51d9f4e504fc24ec539e11ac34.tar.gz
cuberite-79e5b823547a2a51d9f4e504fc24ec539e11ac34.tar.bz2
cuberite-79e5b823547a2a51d9f4e504fc24ec539e11ac34.tar.lz
cuberite-79e5b823547a2a51d9f4e504fc24ec539e11ac34.tar.xz
cuberite-79e5b823547a2a51d9f4e504fc24ec539e11ac34.tar.zst
cuberite-79e5b823547a2a51d9f4e504fc24ec539e11ac34.zip
Diffstat (limited to 'Tools/QtBiomeVisualiser/Region.cpp')
-rw-r--r--Tools/QtBiomeVisualiser/Region.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/Tools/QtBiomeVisualiser/Region.cpp b/Tools/QtBiomeVisualiser/Region.cpp
new file mode 100644
index 000000000..d8a0a2f76
--- /dev/null
+++ b/Tools/QtBiomeVisualiser/Region.cpp
@@ -0,0 +1,72 @@
+
+#include "Globals.h"
+#include "Region.h"
+
+
+
+
+
+Region::Region()
+{
+}
+
+
+
+
+
+Chunk & Region::getRelChunk(int a_RelChunkX, int a_RelChunkZ)
+{
+ ASSERT(a_RelChunkX >= 0);
+ ASSERT(a_RelChunkZ >= 0);
+ ASSERT(a_RelChunkX < 32);
+ ASSERT(a_RelChunkZ < 32);
+
+ return m_Chunks[a_RelChunkX + a_RelChunkZ * 32];
+}
+
+
+
+
+
+int Region::getRelBiome(int a_RelBlockX, int a_RelBlockZ)
+{
+ ASSERT(a_RelBlockX >= 0);
+ ASSERT(a_RelBlockZ >= 0);
+ ASSERT(a_RelBlockX < 512);
+ ASSERT(a_RelBlockZ < 512);
+
+ int chunkX = a_RelBlockX / 16;
+ int chunkZ = a_RelBlockZ / 16;
+ Chunk & chunk = m_Chunks[chunkX + 32 * chunkZ];
+ if (chunk.isValid())
+ {
+ return chunk.getBiome(a_RelBlockX - 16 * chunkX, a_RelBlockZ - 16 * chunkZ);
+ }
+ else
+ {
+ return biInvalidBiome;
+ }
+}
+
+
+
+
+void Region::blockToRegion(int a_BlockX, int a_BlockZ, int & a_RegionX, int & a_RegionZ)
+{
+ a_RegionX = static_cast<int>(std::floor(static_cast<float>(a_BlockX) / 512));
+ a_RegionZ = static_cast<int>(std::floor(static_cast<float>(a_BlockZ) / 512));
+}
+
+
+
+
+
+void Region::chunkToRegion(int a_ChunkX, int a_ChunkZ, int & a_RegionX, int & a_RegionZ)
+{
+ a_RegionX = static_cast<int>(std::floor(static_cast<float>(a_ChunkX) / 32));
+ a_RegionZ = static_cast<int>(std::floor(static_cast<float>(a_ChunkZ) / 32));
+}
+
+
+
+