diff --git a/src/voxels/Block.hpp b/src/voxels/Block.hpp index 2d3d1577..e19c1dc6 100644 --- a/src/voxels/Block.hpp +++ b/src/voxels/Block.hpp @@ -9,7 +9,7 @@ #include "../maths/UVRegion.hpp" #include "../typedefs.hpp" -#define BLOCK_ITEM_SUFFIX ".item" +inline std::string BLOCK_ITEM_SUFFIX = ".item"; inline constexpr uint FACE_MX = 0; inline constexpr uint FACE_PX = 1; @@ -191,4 +191,4 @@ public: Block(const Block&) = delete; }; -#endif /* VOXELS_BLOCK_HPP_ */ +#endif // VOXELS_BLOCK_HPP_ diff --git a/src/voxels/voxel.hpp b/src/voxels/voxel.hpp index 9cfaf698..0e19415f 100644 --- a/src/voxels/voxel.hpp +++ b/src/voxels/voxel.hpp @@ -11,25 +11,27 @@ inline constexpr int BLOCK_DIR_UP = 0x4; inline constexpr int BLOCK_DIR_DOWN = 0x5; struct blockstate { - uint8_t rotation : 3; - uint8_t segment : 2; // planned to 0.22 - uint8_t reserved : 3; - uint8_t userbits : 8; + uint8_t rotation : 3; // block rotation index + uint8_t segment : 1; // segment block bit + uint8_t reserved : 4; // reserved bits + uint8_t userbits : 8; // bits for use in block script }; static_assert (sizeof(blockstate) == 2); +/// @brief blockstate cast to an integer (optimized out in most cases) inline constexpr blockstate_t blockstate2int(blockstate b) { return static_cast(b.rotation) | static_cast(b.segment) << 3 | - static_cast(b.reserved) << 5 | + static_cast(b.reserved) << 4 | static_cast(b.userbits) << 8; } +/// @brief integer cast to a blockstate (optimized out in most cases) inline constexpr blockstate int2blockstate(blockstate_t i) { return { static_cast(i & 0b111), - static_cast((i >> 3) & 0b11), - static_cast((i >> 5) & 0b111), + static_cast((i >> 3) & 0b1), + static_cast((i >> 4) & 0b1111), static_cast((i >> 8) & 0xFF) }; }