diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-08-27 17:24:28 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-01-13 03:39:28 +0100 |
commit | 04ab1a3420b46af046a898ee5510e0d9b25ed24c (patch) | |
tree | 4e9d300bb38d434305d00337535c7c4077bc57c4 /src/Section.hpp | |
parent | 2017-08-23 (diff) | |
download | AltCraft-04ab1a3420b46af046a898ee5510e0d9b25ed24c.tar AltCraft-04ab1a3420b46af046a898ee5510e0d9b25ed24c.tar.gz AltCraft-04ab1a3420b46af046a898ee5510e0d9b25ed24c.tar.bz2 AltCraft-04ab1a3420b46af046a898ee5510e0d9b25ed24c.tar.lz AltCraft-04ab1a3420b46af046a898ee5510e0d9b25ed24c.tar.xz AltCraft-04ab1a3420b46af046a898ee5510e0d9b25ed24c.tar.zst AltCraft-04ab1a3420b46af046a898ee5510e0d9b25ed24c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Section.hpp | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/src/Section.hpp b/src/Section.hpp index dfa738a..bda3584 100644 --- a/src/Section.hpp +++ b/src/Section.hpp @@ -11,47 +11,45 @@ #include "Vector.hpp" #include "Utility.hpp" -struct PackedSection { - Vector position; - - int bitsPerBlock; - - std::vector<unsigned short> palette; - - std::vector<long long> blocks; +class Section { + std::vector<long long> block; std::vector<unsigned char> light; std::vector<unsigned char> sky; - - PackedSection(Vector position, byte *dataBlocks, size_t dataBlocksLength, byte *dataLight, byte *dataSky, byte bitsPerBlock, - std::vector<unsigned short> palette); - - PackedSection() = default; -}; - -class Section { - std::vector<Block> blocks; + unsigned char bitsPerBlock; + std::vector<unsigned short> palette; Vector worldPosition; + size_t hash; + void CalculateHash(); public: + Section(Vector pos, unsigned char bitsPerBlock, std::vector<unsigned short> palette, std::vector<long long> blockData, std::vector<unsigned char> lightData, std::vector<unsigned char> skyData); - Section(PackedSection data); + Section(); ~Section(); + Section(const Section &other); + Section(Section &&other) noexcept; - Block &GetBlock(Vector pos); + Section &operator=(Section other) noexcept; - Block GetBlock(Vector pos) const; + BlockId GetBlockId(Vector pos) const; - Section &operator=(Section other) noexcept; + unsigned char GetBlockLight(Vector pos); - friend void swap(Section& lhs, Section& rhs) noexcept; + unsigned char GetBlockSkyLight(Vector pos); - Section(const Section &other); + void SetBlockId(Vector pos, BlockId value); + + void SetBlockLight(Vector pos, unsigned char value); + + void SetBlockSkyLight(Vector pos, unsigned char value); Vector GetPosition() const; size_t GetHash() const; + + friend void swap(Section& lhs, Section& rhs) noexcept; };
\ No newline at end of file |