Botcraft 1.21.4
Loading...
Searching...
No Matches
Section.cpp
Go to the documentation of this file.
4
5namespace Botcraft
6{
7 Section::Section(const bool has_sky_light)
8 {
9#if USE_GUI
10 // +2 because we also store the neighbour section blocks
11 data_blocks = std::vector<unsigned short>((CHUNK_WIDTH + 2) * (CHUNK_WIDTH + 2) * SECTION_HEIGHT);
12#else
13 data_blocks = std::vector<unsigned short>(CHUNK_WIDTH * CHUNK_WIDTH * SECTION_HEIGHT);
14#endif
15
16 block_light = std::vector<unsigned char>(CHUNK_WIDTH * CHUNK_WIDTH * SECTION_HEIGHT / 2);
17 if (has_sky_light)
18 {
19 sky_light = std::vector<unsigned char>(CHUNK_WIDTH * CHUNK_WIDTH * SECTION_HEIGHT / 2);
20 }
21 }
22
23 size_t Section::CoordsToBlockIndex(const int x, const int y, const int z)
24 {
25#if USE_GUI
26 return (y * (CHUNK_WIDTH + 2) + z + 1) * (CHUNK_WIDTH + 2) + x + 1;
27#else
28 return (y * CHUNK_WIDTH + z) * CHUNK_WIDTH + x;
29#endif
30 }
31
32 size_t Section::CoordsToLightIndex(const int x, const int y, const int z)
33 {
34 return ((y * CHUNK_WIDTH + z) * CHUNK_WIDTH + x) / 2;
35 }
36} // Botcraft
static constexpr int SECTION_HEIGHT
Definition Chunk.hpp:22
static constexpr int CHUNK_WIDTH
Definition Chunk.hpp:21
Section(const bool has_sky_light)
Definition Section.cpp:7
std::vector< unsigned char > sky_light
Definition Section.hpp:18
static size_t CoordsToLightIndex(const int x, const int y, const int z)
Definition Section.cpp:32
std::vector< unsigned short > data_blocks
Definition Section.hpp:16
std::vector< unsigned char > block_light
Definition Section.hpp:17
static size_t CoordsToBlockIndex(const int x, const int y, const int z)
Definition Section.cpp:23