diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-02-01 07:47:22 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-02-01 07:47:22 +0100 |
commit | cd45c4009c606bceb11a1d4202204ecd0969b5ef (patch) | |
tree | e5ae5057c2ae14c5962c35cabfb72296a1e2d690 /src/World/Chunk.hpp | |
parent | 2d2671a6866864bc8fb927a63e2d6eecddff3d6a (diff) | |
download | MinedMap-cd45c4009c606bceb11a1d4202204ecd0969b5ef.tar MinedMap-cd45c4009c606bceb11a1d4202204ecd0969b5ef.zip |
Compute top non-air layer
This doesn't yet ignore non-opaque blocks.
Diffstat (limited to 'src/World/Chunk.hpp')
-rw-r--r-- | src/World/Chunk.hpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/World/Chunk.hpp b/src/World/Chunk.hpp index d063d48..22054db 100644 --- a/src/World/Chunk.hpp +++ b/src/World/Chunk.hpp @@ -27,6 +27,7 @@ #pragma once +#include "Block.hpp" #include "../Buffer.hpp" #include "../UniqueCPtr.hpp" #include "../NBT/CompoundTag.hpp" @@ -43,7 +44,18 @@ class Chunk : public std::shared_ptr<const NBT::CompoundTag> { public: static const size_t SIZE = 16; + struct Blocks { + Block blocks[SIZE][SIZE]; + }; + private: + static size_t getIndex(size_t x, size_t y, size_t z) { + if (x >= SIZE || y >= SIZE || z >= SIZE) + throw std::range_error("Chunk::getIndex(): bad coordinates"); + + return 256*y + 16*z + x; + } + size_t len; UniqueCPtr<uint8_t[]> data; @@ -56,15 +68,8 @@ private: void parseChunk(); void analyzeChunk(); - size_t getIndex(size_t x, size_t y, size_t z) { - if (x >= SIZE || y >= SIZE || z >= SIZE) - throw std::range_error("Chunk::getIndex(): bad coordinates"); - - return 256*y + 16*z + x; - } - - uint8_t getBlockAt(const std::shared_ptr<const NBT::CompoundTag> §ion, size_t x, size_t y, size_t z); - uint8_t getDataAt(const std::shared_ptr<const NBT::CompoundTag> §ion, size_t x, size_t y, size_t z); + uint8_t getBlockAt(const std::shared_ptr<const NBT::CompoundTag> §ion, size_t x, size_t y, size_t z) const; + uint8_t getDataAt(const std::shared_ptr<const NBT::CompoundTag> §ion, size_t x, size_t y, size_t z) const; public: Chunk(Buffer buffer); @@ -72,6 +77,8 @@ public: const NBT::ListTag<NBT::CompoundTag> & getSections() const { return *sections; } + + Blocks getTopLayer() const; }; } |